update
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
# jsmindmutli
|
||||
|
||||
#### Description
|
||||
多人协作思维导图python后台版本
|
||||
|
||||
#### Software Architecture
|
||||
Software architecture description
|
||||
|
||||
#### Installation
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### Instructions
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### Contribution
|
||||
|
||||
1. Fork the repository
|
||||
2. Create Feat_xxx branch
|
||||
3. Commit your code
|
||||
4. Create Pull Request
|
||||
|
||||
|
||||
#### Gitee Feature
|
||||
|
||||
1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
|
||||
2. Gitee blog [blog.gitee.com](https://blog.gitee.com)
|
||||
3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
|
||||
4. The most valuable open source project [GVP](https://gitee.com/gvp)
|
||||
5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
|
||||
6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
|
||||
@@ -0,0 +1,31 @@
|
||||
from server.models import CooperationMindLog
|
||||
import ast
|
||||
|
||||
|
||||
class CooperationMindLogLib(object):
|
||||
"""
|
||||
操作日志
|
||||
"""
|
||||
|
||||
def save_log(self, json_msg):
|
||||
"""
|
||||
保存操作日志
|
||||
"""
|
||||
if self.should_handle(json_msg):
|
||||
# 避免json解析失败
|
||||
json_msg = json_msg.replace(',null]', ']')
|
||||
json_msg_dict = ast.literal_eval(json_msg)
|
||||
|
||||
log = CooperationMindLog(
|
||||
coop_mind_id=json_msg_dict.get('coop_mind_id'),
|
||||
log_uuid=json_msg_dict.get('log_uuid'),
|
||||
log_content=json_msg,
|
||||
client_id=json_msg_dict.get('client_id')
|
||||
)
|
||||
log.save()
|
||||
json_msg_dict.update({'log_id': log.id})
|
||||
return json_msg_dict
|
||||
return None
|
||||
|
||||
def should_handle(self, json_msg):
|
||||
return 'coop_mind_id' in json_msg and 'select_node' not in json_msg
|
||||
+1
-2
@@ -37,9 +37,8 @@ class CooperationMindLog(AbstractModel):
|
||||
"""
|
||||
coop_mind_id = models.BigIntegerField(verbose_name='脑图ID', null=False, blank=False)
|
||||
log_uuid = models.CharField(verbose_name='操作UUID', max_length=64, null=False, blank=False)
|
||||
log_event = models.CharField(verbose_name='操作事件', max_length=32, null=False, blank=False)
|
||||
log_content = models.CharField(verbose_name='操作内容', max_length=1024, null=False, blank=False)
|
||||
operator = models.BigIntegerField(verbose_name='操作人', null=False)
|
||||
operator = models.BigIntegerField(verbose_name='操作人', null=True)
|
||||
operator_ip = models.CharField(verbose_name='操作人IP', null=False, max_length=32)
|
||||
client_id = models.CharField(verbose_name='客户端ID', max_length=64, null=False, blank=False)
|
||||
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
from asgiref.sync import async_to_sync
|
||||
from channels.generic.websocket import WebsocketConsumer
|
||||
from server.lib.coope_mind_lib import CooperationMindLogLib
|
||||
import json
|
||||
|
||||
|
||||
class ChatConsumer(WebsocketConsumer):
|
||||
log_lib = CooperationMindLogLib()
|
||||
|
||||
def connect(self):
|
||||
self.room_group_name = 'chat%s' % bytes.decode(self.scope['query_string'])
|
||||
print(self.room_group_name)
|
||||
@@ -25,12 +29,13 @@ class ChatConsumer(WebsocketConsumer):
|
||||
def receive(self, text_data):
|
||||
# Send message to room group
|
||||
print(text_data)
|
||||
log_dict = self.log_lib.save_log(text_data)
|
||||
async_to_sync(self.channel_layer.group_send)(
|
||||
self.room_group_name,
|
||||
{
|
||||
# chat_message 方法
|
||||
'type': 'chat_message',
|
||||
'message': text_data
|
||||
'message': text_data if log_dict is None else json.dumps(log_dict)
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
coop_mind_id: null,
|
||||
// 上一次操作日志ID
|
||||
coop_mind_log_last_id: 0,
|
||||
// 默认操作日志ID
|
||||
// 默认操作日志IDh
|
||||
coop_mind_log_id: 0,
|
||||
// 定时备份数据
|
||||
timer_push_task: null,
|
||||
@@ -76,7 +76,7 @@
|
||||
}
|
||||
ws.onmessage = function (e) {
|
||||
//当客户端收到服务端发来的消息时,触发onmessage事件,参数e.data包含server传递过来的数据
|
||||
me._oper_jsmind_with_ws_message(e.data)
|
||||
me._handle_jsmind_with_ws_message(e.data)
|
||||
}
|
||||
ws.onclose = function (e) {
|
||||
//当客户端收到服务端发送的关闭连接请求时,触发onclose事件
|
||||
@@ -117,8 +117,14 @@
|
||||
return {'client_id': this.client_id, 'log_uuid': Jm.util.uuid.newid(), 'coop_mind_id': this.coop_mind_id}
|
||||
},
|
||||
// 调用jsmind接口
|
||||
_oper_jsmind_with_ws_message: function (message) {
|
||||
_handle_jsmind_with_ws_message: function (message) {
|
||||
const msg_json = JSON.parse(message)
|
||||
const client_id = msg_json.client_id
|
||||
if (client_id === this.client_id) {
|
||||
console.log('self msg')
|
||||
} else {
|
||||
|
||||
}
|
||||
},
|
||||
/**
|
||||
* body:
|
||||
@@ -153,7 +159,7 @@
|
||||
},
|
||||
// 发送ws消息
|
||||
_send_ws_message: function (msg) {
|
||||
if (this.web_socket) {
|
||||
if (this.web_socket != null) {
|
||||
this.web_socket.send(msg)
|
||||
} else {
|
||||
console.error('web_socket is not ready!')
|
||||
|
||||
@@ -2986,6 +2986,10 @@
|
||||
var nodeid = this._newid();
|
||||
var node = _jm.add_node(selected_node, nodeid, 'New Node');
|
||||
if (!!node) {
|
||||
let evt = e || event;
|
||||
evt.stopPropagation();
|
||||
evt.preventDefault();
|
||||
|
||||
_jm.select_node(nodeid);
|
||||
_jm.begin_edit(nodeid);
|
||||
}
|
||||
@@ -2997,6 +3001,10 @@
|
||||
var nodeid = this._newid();
|
||||
var node = _jm.insert_node_after(selected_node, nodeid, 'New Node');
|
||||
if (!!node) {
|
||||
const evt = e || event;
|
||||
evt.stopPropagation();
|
||||
evt.preventDefault();
|
||||
|
||||
_jm.select_node(nodeid);
|
||||
_jm.begin_edit(nodeid);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user