update
This commit is contained in:
+4
-1
@@ -1,14 +1,17 @@
|
|||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
from server.views import *
|
from server.views import *
|
||||||
|
from server.view_test import *
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', to_list), # 跳转列表界面
|
path('', to_list), # 跳转列表界面
|
||||||
path('detail', to_detail), # 跳转详情界面
|
path('detail', to_detail), # 跳转详情界面
|
||||||
path('modal', to_modal), #
|
|
||||||
path('dashboard', to_dashboard), #
|
path('dashboard', to_dashboard), #
|
||||||
|
|
||||||
path('create', JsMindView.as_view()), # 创建思维导图
|
path('create', JsMindView.as_view()), # 创建思维导图
|
||||||
path('delete', JsMindView.as_view()), # 删除思维导图
|
path('delete', JsMindView.as_view()), # 删除思维导图
|
||||||
path('list', JsMindView.as_view()), # 查询思维导图
|
path('list', JsMindView.as_view()), # 查询思维导图
|
||||||
path(r'jsmind_op', JsMindLogView.as_view()), # 更新快照,get日志
|
path(r'jsmind_op', JsMindLogView.as_view()), # 更新快照,get日志
|
||||||
|
|
||||||
|
path('test', test), #
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
from django.http import HttpResponse
|
||||||
|
from server.lib.qr_context import get_context
|
||||||
|
|
||||||
|
|
||||||
|
def test(request):
|
||||||
|
uid = request.GET.get('uid')
|
||||||
|
print(uid)
|
||||||
|
qrContext = get_context()
|
||||||
|
consumer = qrContext.get(uid)
|
||||||
|
print(consumer)
|
||||||
|
consumer.sed_text('ppp')
|
||||||
|
return HttpResponse('success')
|
||||||
@@ -20,13 +20,6 @@ def to_dashboard(request):
|
|||||||
return render(request, "html/dashboard.html")
|
return render(request, "html/dashboard.html")
|
||||||
|
|
||||||
|
|
||||||
def to_modal(request):
|
|
||||||
"""
|
|
||||||
界面
|
|
||||||
"""
|
|
||||||
return render(request, "html/modal.html")
|
|
||||||
|
|
||||||
|
|
||||||
def to_list(request):
|
def to_list(request):
|
||||||
"""
|
"""
|
||||||
列表界面
|
列表界面
|
||||||
|
|||||||
@@ -14,7 +14,9 @@ class QrConsumer(WebsocketConsumer):
|
|||||||
|
|
||||||
def connect(self):
|
def connect(self):
|
||||||
self.room_group_name = 'qr%s' % bytes.decode(self.scope['query_string'])
|
self.room_group_name = 'qr%s' % bytes.decode(self.scope['query_string'])
|
||||||
# print(self.room_group_name)
|
self.channel_name = 'qr_cn%s' % bytes.decode(self.scope['query_string'])
|
||||||
|
print(self.room_group_name)
|
||||||
|
print(self.channel_name)
|
||||||
|
|
||||||
# Join room group
|
# Join room group
|
||||||
async_to_sync(self.channel_layer.group_add)(
|
async_to_sync(self.channel_layer.group_add)(
|
||||||
@@ -22,6 +24,7 @@ class QrConsumer(WebsocketConsumer):
|
|||||||
self.channel_name
|
self.channel_name
|
||||||
)
|
)
|
||||||
self.accept()
|
self.accept()
|
||||||
|
self.send(text_data=self.channel_name)
|
||||||
qrContext.add(self.channel_name, self)
|
qrContext.add(self.channel_name, self)
|
||||||
|
|
||||||
def disconnect(self, close_code):
|
def disconnect(self, close_code):
|
||||||
@@ -34,7 +37,7 @@ class QrConsumer(WebsocketConsumer):
|
|||||||
print('close')
|
print('close')
|
||||||
|
|
||||||
# Receive message from WebSocket
|
# Receive message from WebSocket
|
||||||
def receive(self, text_data):
|
def receive(self, text_data=None, bytes_data=None):
|
||||||
# Send message to room group
|
# Send message to room group
|
||||||
async_to_sync(self.channel_layer.group_send)(
|
async_to_sync(self.channel_layer.group_send)(
|
||||||
self.room_group_name,
|
self.room_group_name,
|
||||||
@@ -51,3 +54,6 @@ class QrConsumer(WebsocketConsumer):
|
|||||||
|
|
||||||
# Send message to WebSocket
|
# Send message to WebSocket
|
||||||
self.send(text_data=message)
|
self.send(text_data=message)
|
||||||
|
|
||||||
|
def sed_text(self, text):
|
||||||
|
self.send(text_data=text)
|
||||||
|
|||||||
@@ -25,6 +25,9 @@
|
|||||||
console.log(qr_websocket)
|
console.log(qr_websocket)
|
||||||
console.log('打开');
|
console.log('打开');
|
||||||
const ws = new WebSocket(`ws://${window.location.host}/ws/qr/?${qr_websocket.uuid}`)
|
const ws = new WebSocket(`ws://${window.location.host}/ws/qr/?${qr_websocket.uuid}`)
|
||||||
|
ws.onmessage = function (e) {
|
||||||
|
console.log(e.data)
|
||||||
|
}
|
||||||
qr_websocket.websocket = ws
|
qr_websocket.websocket = ws
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user