From 6c2ddd295599f85d0aeae1b734fc828d60aebd77 Mon Sep 17 00:00:00 2001 From: chenyang Date: Sun, 10 Jul 2022 14:31:13 +0800 Subject: [PATCH] update --- server/models.py | 6 +++--- server/views/mind_map.py | 4 ++-- static/html/dashboard.html | 15 +++++++++++---- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/server/models.py b/server/models.py index 227cb84..066cd40 100644 --- a/server/models.py +++ b/server/models.py @@ -37,7 +37,7 @@ class CooperationMindLog(AbstractModel): """ 操作日志表 """ - coop_mind_id = models.BigIntegerField(verbose_name='脑图ID', null=False, blank=False) + coop_mind = models.ForeignKey(to="CooperationMind", to_field="id", verbose_name="脑图ID", on_delete=models.CASCADE) log_uuid = models.CharField(verbose_name='操作UUID', max_length=64, null=False, blank=False) log_content = models.CharField(verbose_name='操作内容', max_length=1024, null=False, blank=False) operator_user_id = models.BigIntegerField(verbose_name='操作人', null=True) @@ -59,7 +59,7 @@ class CooperationMindShare(AbstractModel): """ 分享记录表 """ - coop_mind_id = models.BigIntegerField(verbose_name='脑图ID', null=False, blank=False) + coop_mind = models.ForeignKey(to="CooperationMind", to_field="id", verbose_name="脑图ID", on_delete=models.CASCADE) coop_mind_name = models.CharField(verbose_name='脑图名称', max_length=128, null=False, blank=False) share_uuid = models.CharField(verbose_name='分享uuid', max_length=128, null=False, blank=False) share_uuid_hash = models.BigIntegerField(verbose_name='分享uuid_hash', null=False, blank=False) @@ -80,7 +80,7 @@ class CooperationMindStar(AbstractModel): 收藏记录表 """ user_id = models.BigIntegerField(verbose_name='收藏人', null=False) - coop_mind_id = models.BigIntegerField(verbose_name='脑图ID', null=False, blank=False) + coop_mind = models.ForeignKey(to="CooperationMind", to_field="id", verbose_name="脑图ID", on_delete=models.CASCADE) coop_mind_name = models.CharField(verbose_name='脑图名称', max_length=128, null=False, blank=False) class Meta: diff --git a/server/views/mind_map.py b/server/views/mind_map.py index 2078178..17cda07 100644 --- a/server/views/mind_map.py +++ b/server/views/mind_map.py @@ -49,7 +49,7 @@ class JsMindView(LoginRequiredJSONMixin, ListAPIView): self.queryset = CooperationMind.objects.filter(creator_user_id=user.id, deleted=0).values('id', 'coop_mind_name', "client_uuid", "data_format") elif 'share' == src_page: share = CooperationMindShare.objects.filter(coop_mind_id=OuterRef('id')) - self.queryset = CooperationMind.objects.annotate(share_new=Exists(share), ).filter(share_new=1) + self.queryset = CooperationMind.objects.annotate(share_new=Exists(share), ).filter(share_new=1).values('id', 'coop_mind_name', "client_uuid", "data_format") else: # 不返回数据 self.queryset = CooperationMind.objects.filter(creator_user_id=-100).values('id', 'coop_mind_name', "client_uuid", "data_format") @@ -123,7 +123,7 @@ class JsMindShareView(LoginRequiredJSONMixin, ListAPIView): def get(self, request, *args, **kwargs): """ - 通过链接即uuid获得分享的导图,默认有uuid就能进入界面查看 + 通过链接即uuid、hash获得分享的导图详情 """ share_uuid_hash = request.GET.get('h') share_uuid = request.GET.get('u') diff --git a/static/html/dashboard.html b/static/html/dashboard.html index a46df2c..423fb7e 100644 --- a/static/html/dashboard.html +++ b/static/html/dashboard.html @@ -112,7 +112,8 @@ 删除 分享` } else if (src_page === 'share') { - sub_btn = `取消分享` + sub_btn = `取消分享 + 查看分享链接` } const content = `
@@ -139,9 +140,17 @@ async: false }); }, + /**显示分享链接*/ + show_share_url: function (u, h) { + const url = `s_2_d?u=${u}&h=${h}` + $('#share_mind_modal .modal-body').html(`分享成功,请复制以下链接进行分享:
${window.location.protocol}//${window.location.host}/${url}
`) + $('#share_mind_modal_a').click() + }, /**分页组件*/ init_pagination: function (count, page_size) { /**计算页数*/ + if (count <= 0) return + const all_page = (count <= page_size) ? 1 : (count % page_size > 0) ? Math.floor(count / page_size) + 1 : Math.floor(count / page_size) const container = $('#pagination_div') const navigation = $(``) @@ -197,9 +206,7 @@ data: {'id': mind_id}, dataType: "json", success: function (resp) { - const url = `s_2_d?u=${resp.data.u}&h=${resp.data.h}` - $('#share_mind_modal .modal-body').html(`分享成功,请复制以下链接进行分享:
${window.location.protocol}//${window.location.host}/${url}
`) - $('#share_mind_modal_a').click() + me.show_share_url(`${resp.data.u}`, `${resp.data.h}`) }, async: false });