From e56e321d5bfa64cc2f786b258af9713ec1222cbb Mon Sep 17 00:00:00 2001 From: chenyang Date: Fri, 8 Jul 2022 16:04:32 +0800 Subject: [PATCH] update --- server/urls.py | 1 + server/views/jump.py | 7 +++++++ server/views/mind_map.py | 2 +- static/html/dashboard.html | 4 +++- static/html/detail.html | 14 +++++++++++--- 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/server/urls.py b/server/urls.py index c799da9..c316b13 100644 --- a/server/urls.py +++ b/server/urls.py @@ -19,6 +19,7 @@ urlpatterns = [ path('list', JsMindView.as_view()), # 查询思维导图 path('delete', JsMindView.as_view()), # 删除思维导图 path('share', JsMindShareView.as_view()), # 分享思维导图 + path('jp', to_share), # 跳转 path('4cbcb74630898f41fd0a', JsMindShareView.as_view()), # 通过分享链接查看 path(r'jsmind_op', JsMindLogView.as_view()), # 更新快照,get日志 diff --git a/server/views/jump.py b/server/views/jump.py index 5877d95..b284831 100644 --- a/server/views/jump.py +++ b/server/views/jump.py @@ -21,3 +21,10 @@ def to_detail(request): """ param = {'id': request.GET.get('id')} return render(request, "html/detail.html", param) + + +def to_share(request): + """ + """ + param = {'h': request.GET.get('h'), 'u': request.GET.get('u')} + return render(request, "html/detail.html", param) diff --git a/server/views/mind_map.py b/server/views/mind_map.py index 805a1d4..d08eba7 100644 --- a/server/views/mind_map.py +++ b/server/views/mind_map.py @@ -143,4 +143,4 @@ class JsMindShareView(LoginRequiredJSONMixin, APIView): return build_response(data={"u": uuid_str, "h": share_uuid_hash}) # 重复分享 - return build_response(code=DUPLICATE, data=share.share_uuid) + return build_response(code=DUPLICATE, data={"u": share.share_uuid, "h": share.share_uuid_hash}) diff --git a/static/html/dashboard.html b/static/html/dashboard.html index 2a4061e..efa401e 100644 --- a/static/html/dashboard.html +++ b/static/html/dashboard.html @@ -177,7 +177,9 @@ dataType: "json", success: function (resp) { console.log(resp) - console.log(`${window.location.protocol}//${window.location.host}/4cbcb74630898f41fd0a?u=${resp.data.u}&h=${resp.data.h}`) + console.log() + const url = `jp?u=${resp.data.u}&h=${resp.data.h}` + window.open(url) }, async: false }); diff --git a/static/html/detail.html b/static/html/detail.html index 473a59c..2f2b712 100644 --- a/static/html/detail.html +++ b/static/html/detail.html @@ -44,9 +44,13 @@ }, loadMind: function () { // 打开已有脑图1、查询数据,组装option 2、实例化jm、show - let id = {{ id }}; - const me = this - $.get('list?id=' + id, function (resp) { + let id = `{{ id }}`; + let u = `{{ u }}`; + let h = `{{ h }}`; + const me = this; + const from_share = id.length === 0; + const url = from_share ? `4cbcb74630898f41fd0a?u=${u}&h=${h}` : 'list?id=' + id; + $.get(url, function (resp) { // reset me.close_coop_timer_if_necessary() @@ -59,6 +63,10 @@ const data_format = resp_data.data_format const coop_mind_name = resp.data.coop_mind_name + if (from_share) { + me.coop_mind_id = resp_data.id + } + // node_tree 和 node_array 需要被转成对象,freemind 不需要 snapshot_data = (data_format === 'node_tree' || data_format === 'node_array') ? JSON.parse(snapshot_data) : snapshot_data me.show_mind(coop_mind_name, data_format, snapshot_data)