diff --git a/server/urls.py b/server/urls.py index 5cb4d54..261113c 100644 --- a/server/urls.py +++ b/server/urls.py @@ -24,6 +24,7 @@ urlpatterns = [ path('s_d', JsMindShareView.as_view()), # 获得导图详情 path('delete', JsMindView.as_view()), # 删除思维导图 path('share', JsMindShareView.as_view()), # 分享思维导图,查询等 + path('star', JsMindStarView.as_view()), # 收藏思维导图 # --------------------------------------------------- path('register', MindUserView.as_view()), # 用户注册 diff --git a/server/util/constant_util.py b/server/util/constant_util.py index 8932dc8..5d7d238 100644 --- a/server/util/constant_util.py +++ b/server/util/constant_util.py @@ -2,47 +2,43 @@ CODE_SUCCESS = 0 CODE_FAILED = -1 DUPLICATE = 1 -snapshot_json_data = """{ - "id": "root", - "topic": "MindMap", - "children": [ - { - "id": "easy", - "topic": "Easy", - "direction": "left", - "expanded": false, - "children": [ - {"id": "easy1", "topic": "Easy to show"}, - {"id": "easy2", "topic": "Easy to edit"}, - {"id": "easy3", "topic": "Easy to store"}, - {"id": "easy4", "topic": "Easy to embed"} - ] - }, - { - "id": "open", - "topic": "Open Source", - "direction": "left", - "expanded": false, - "children": [ - {"id": "open1", "topic": "on GitHub"}, - {"id": "open2", "topic": "BSD License"} - ] - }, - { - "id": "powerful", - "topic": "Powerful", - "direction": "right", - "expanded": false, - "children": [ - {"id": "powerful1", "topic": "Base on Javascript"}, - {"id": "powerful2", "topic": "Base on HTML5"}, - {"id": "powerful3", "topic": "Depends on you"} - ] - }, - { - "id": "other", - "topic": "多人协作", - "direction": "right" - } - ] -}""" +SNAPSHOT_JSON_DATA = """{ + "id": "root", + "topic": "MindMap", + "children": [{"id": "easy", + "topic": "Easy", + "direction": "left", + "expanded": false, + "children": [ + {"id": "easy1", "topic": "Easy to show"}, + {"id": "easy2", "topic": "Easy to edit"}, + {"id": "easy3", "topic": "Easy to store"}, + {"id": "easy4", "topic": "Easy to embed"} + ] + }, + { + "id": "open", + "topic": "Open Source", + "direction": "left", + "expanded": false, + "children": [ + {"id": "open1", "topic": "on GitHub"}, + {"id": "open2", "topic": "BSD License"} + ] + }, + { + "id": "powerful", + "topic": "Powerful", + "direction": "right", + "expanded": false, + "children": [ + {"id": "powerful1", "topic": "Base on Javascript"}, + {"id": "powerful2", "topic": "Base on HTML5"}, + {"id": "powerful3", "topic": "Depends on you"} + ] + }, + { + "id": "other", + "topic": "多人协作", + "direction": "right" + }]}""" diff --git a/server/views/mind_map.py b/server/views/mind_map.py index f5080d5..b5d4ada 100644 --- a/server/views/mind_map.py +++ b/server/views/mind_map.py @@ -62,7 +62,7 @@ class JsMindView(LoginRequiredJSONMixin, ListAPIView): """ coop_mind_name = request.data.get('mind_name') user = request.user - snapshot_data = snapshot_json_data + snapshot_data = SNAPSHOT_JSON_DATA data_format = 'node_tree' mind = CooperationMind(coop_mind_name=coop_mind_name, client_uuid='', mind_log_id=-1, creator_user_id=user.id, snapshot_data=snapshot_data, data_format=data_format) mind.save() @@ -190,3 +190,12 @@ class JsMindShareView(LoginRequiredJSONMixin, ListAPIView): return build_response(code=CODE_FAILED, msg='用户未登录') res = CooperationMindShare.objects.filter(coop_mind_id=id, operator_user_id=user.id).delete() return build_response(msg="操作成功", data=res[0]) + + +class JsMindStarView(LoginRequiredJSONMixin, ListAPIView): + """ + 收藏 + """ + + def get(self, request, *args, **kwargs): + pass diff --git a/static/html/detail.html b/static/html/detail.html index afd28d1..a21892c 100644 --- a/static/html/detail.html +++ b/static/html/detail.html @@ -95,7 +95,7 @@ this.jm.coop.clear_timer() } }, - show_mind: function (name, data_format, data) { + show_mind: function (name, data_format, data_resp) { // options const options = { container: 'jsmind_container', @@ -134,8 +134,8 @@ // eslint-disable-next-line new-cap let jsMind = window.jsMind this.jm = new jsMind(options) - if (data) { - mind.data = data + if (data_resp) { + mind.data = data_resp } this.jm.show(mind) }, @@ -156,7 +156,7 @@