更新最新代码

This commit is contained in:
2024-03-21 20:32:50 +08:00
parent 1ec018ca90
commit 7d756bcfa4
52 changed files with 38968 additions and 51 deletions
Generated
+1
View File
@@ -2,5 +2,6 @@
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/whitebophir" vcs="Git" />
</component>
</project>
+52
View File
@@ -0,0 +1,52 @@
<!DOCTYPE html>
<html lang="en">
<html lang="en">
<link href="https://unpkg.com/@wangeditor/editor@latest/dist/css/style.css" rel="stylesheet">
<style>
#editor—wrapper {
border: 1px solid #ccc;
z-index: 100; /* 按需定义 */
}
#toolbar-container { border-bottom: 1px solid #ccc; }
#editor-container { height: 500px; }
</style>
<head>
<meta charset="UTF-8">
<title>协同编辑器</title>
</head>
<body>
<div id="editor—wrapper">
<div id="toolbar-container"><!-- 工具栏 --></div>
<div id="editor-container"><!-- 编辑器 --></div>
</div>
</body>
</html>
<script src="https://unpkg.com/@wangeditor/editor@latest/dist/index.js"></script>
<script>
const { createEditor, createToolbar } = window.wangEditor
const editorConfig = {
placeholder: 'Type here...',
onChange(editor) {
const html = editor.getHtml()
console.log('editor content', html)
// 也可以同步到 <textarea>
}
}
const editor = createEditor({
selector: '#editor-container',
html: '<p><br></p>',
config: editorConfig,
mode: 'default', // or 'simple'
})
const toolbarConfig = {}
const toolbar = createToolbar({
editor,
selector: '#toolbar-container',
config: toolbarConfig,
mode: 'default', // or 'simple'
})
</script>
+28
View File
@@ -0,0 +1,28 @@
import asyncio
import websockets
import json
connected = set()
async def handler(websocket):
# 当新的客户端连接时,添加到连接集合
connected.add(websocket)
try:
async for message in websocket:
data = json.loads(message)
if data['type'] == 'edit':
# 广播编辑消息到所有连接的WebSocket
await broadcast(data['content'])
finally:
# 当客户端断开连接时,移除
connected.remove(websocket)
async def broadcast(message):
# 往所有客户端广播消息
for ws in connected:
await ws.send(message)
start_server = websockets.serve(handler, "localhost", 6789)
asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()
View File
+22
View File
@@ -0,0 +1,22 @@
import asyncio
import websockets
# 存储所有连接的客户端
connected_clients = set()
async def broadcast(message):
if connected_clients:
await asyncio.wait([client.send(message) for client in connected_clients])
async def handler(websocket, path):
connected_clients.add(websocket)
try:
async for message in websocket:
await broadcast(message)
finally:
connected_clients.discard(websocket)
start_server = websockets.serve(handler, "localhost", 8765)
asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()
+80
View File
@@ -0,0 +1,80 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>协同编辑器</title>
<link href="https://unpkg.com/@wangeditor/editor@latest/dist/css/style.css" rel="stylesheet">
<style>
#editor—wrapper {
border: 1px solid #ccc;
z-index: 100; /* 按需定义 */
}
#toolbar-container { border-bottom: 1px solid #ccc; }
#editor-container { height: 500px; }
</style>
</head>
<body>
<div id="editor—wrapper">
<div id="toolbar-container"><!-- 工具栏 --></div>
<div id="editor-container"><!-- 编辑器 --></div>
</div>
<textarea id="editor" placeholder="Start editing..."></textarea>
<script src="https://unpkg.com/@wangeditor/editor@latest/dist/index.js"></script>
<script>
const { createEditor, createToolbar } = window.wangEditor
document.addEventListener('DOMContentLoaded', (event) => {
const editor_content = editor.getHtml()
const ws = new WebSocket('ws://localhost:6789');
ws.onopen = function(event) {
console.log('Connection established!');
};
ws.onmessage = function(event) {
// 当接收到消息时,更新编辑器的内容
const message = JSON.parse(event.data);
editor_content.value = message; // 假设消息直接是编辑内容
console.log(editor_content.value)
};
ws.onclose = function(event) {
console.log('Connection closed!');
};
editor.oninput = function(event) {
// 当编辑器内容发生变化时,发送消息
const message = {
type: 'edit',
content: editor_content.value
};
ws.send(JSON.stringify(message));
};
});
const editorConfig = {
placeholder: 'Type here...',
onChange(editor) {
const html = editor.getHtml()
console.log('editor content', html)
// 将编辑内容发送到 WebSocket 服务器
}
}
const editor = createEditor({
selector: '#editor-container',
html: '<p><br></p>',
config: editorConfig,
mode: 'default', // or 'simple'
})
const toolbarConfig = {}
const toolbar = createToolbar({
editor,
selector: '#toolbar-container',
config: toolbarConfig,
mode: 'default', // or 'simple'
})
</script>
</body>
</html>
+49
View File
@@ -0,0 +1,49 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Collaborative Editing</title>
<style>
#editor {
width: 100%;
height: 400px;
border: 1px solid #ccc;
padding: 10px;
box-sizing: border-box;
font-family: monospace;
}
</style>
<script>
document.addEventListener('DOMContentLoaded', (event) => {
const ws = new WebSocket('ws://localhost:6789');
const editor = document.getElementById('editor');
ws.onopen = function(event) {
console.log('Connection established!');
};
ws.onmessage = function(event) {
// 当接收到消息时,更新编辑器的内容
const message = JSON.parse(event.data);
editor.value = message; // 假设消息直接是编辑内容
};
ws.onclose = function(event) {
console.log('Connection closed!');
};
editor.oninput = function(event) {
// 当编辑器内容发生变化时,发送消息
const message = {
type: 'edit',
content: editor.value
};
ws.send(JSON.stringify(message));
};
});
</script>
</head>
<body>
<textarea id="editor" placeholder="Start editing..."></textarea>
</body>
</html>
+39
View File
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>富文本协同编辑器</title>
<link rel="stylesheet" href="https://cdn.quilljs.com/1.3.6/quill.core.css">
<link rel="stylesheet" href="https://cdn.quilljs.com/1.3.6/quill.snow.css">
<script src="https://cdn.quilljs.com/1.3.6/quill.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.0/socket.io.js"></script>
</head>
<body>
<div id="editor" class="ql-container ql-snow"></div>
<script>
var quill = new Quill('#editor', {
modules: {
toolbar: [
['bold', 'italic', 'underline'],
[{'list': 'ordered'}, {'list': 'bullet'}]
]
},
theme: 'snow'
});
var socket = io('http://localhost:6789');
quill.on('text-change', function(delta, oldDelta, source) {
socket.emit('editor-change', delta);
});
socket.on('broadcast-editor-change', function(delta) {
quill.updateContents(delta);
});
</script>
</body>
</html>
+1 -1
View File
@@ -25,7 +25,7 @@ SECRET_KEY = 'django-insecure-92%z)%dv$x)-254f2ixp(ctnua4%^@=db&(ha4i-i2p2er(+^&
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
ALLOWED_HOSTS = ["*"]
# Application definition
+2
View File
@@ -15,10 +15,12 @@ urlpatterns = [
path('2_d', to_detail), # 跳转详情界面
path('s_2_d', share_to_detail), # 从分享链接跳转详细界面
path('2_share', to_share), # 到分享界面
path('2_baiban',to_baiban), # 到协作白板
path('2_echart',to_echarts), # 到图标界面
path('chat_room',to_chat_room), # 到聊天室界面
path('reng_wu',to_rengwu), # 到任务界面
path('ke_cheng',to_kecheng), # 到课程界面
path('2_write',to_write), # 到协同边界页面
path('2_star', to_star), # 到收藏界面
path('2_recycle', to_recycle), # 回收站
+1 -39
View File
@@ -2,42 +2,4 @@ CODE_SUCCESS = 0
CODE_FAILED = -1
DUPLICATE = 1
SNAPSHOT_JSON_DATA = """{
"id": "root",
"topic": "想法",
"children": [{"id": "guoan",
"topic": "guoan",
"direction": "left",
"expanded": true,
"children": [
{"id": "看法", "topic": "看法"},
{"id": "依据", "topic": "依据"},
{"id": "中立", "topic": "中立"},
{"id": "反对", "topic": "反对"}
]
},
{
"id": "组员1",
"topic": "组员1",
"direction": "right",
"expanded": true,
"children": [
{"id": "看法1", "topic": "看法"},
{"id": "依据1", "topic": "依据"},
{"id": "中立1", "topic": "中立"},
{"id": "反对1", "topic": "反对"}
]
},
{
"id": "组员2",
"topic": "组员2",
"direction": "lift",
"expanded": true,
"children": [
{"id": "看法2", "topic": "看法"},
{"id": "依据2", "topic": "依据"},
{"id": "中立2", "topic": "中立"},
{"id": "反对2", "topic": "反对"}
]
}
]}"""
SNAPSHOT_JSON_DATA = """{"id":"root","topic":"空白模板","expanded":true}"""
+15 -1
View File
@@ -7,6 +7,12 @@ def to_dashboard(request):
param = {"page": "b9b101e"}
return render(request, "html/dashboard.html", param)
def to_baiban(request):
"""
协作白板
"""
param = {"page": "share"}
return render(request, "html/baiban.html", param)
def to_share(request):
"""
@@ -25,7 +31,8 @@ def to_chat_room(request):
"""
聊天室页面
"""
param = {"page": "chat_room"}
param = {"page": "chat_room",
"username":request.user.username}
return render(request, "html/wechat_2.html", param)
def to_rengwu(request):
"""
@@ -42,6 +49,13 @@ def to_kecheng(request):
param = {"page": "chat_room"}
return render(request, "html/kecheng.html", param)
def to_write(request):
"""
协同编辑页面
"""
param = {"page": "write"}
return render(request, "html/write_2.html", param)
def to_star(request):
"""
收藏页面
+1
View File
@@ -78,6 +78,7 @@ class JsMindView(LoginRequiredJSONMixin, ListAPIView):
coop_mind_name = request.data.get('mind_name')
coop_mind_id = request.data.get('coop_mind_id')
op_type = request.data.get('op_type')
if op_type == "delete_cancel":
CooperationMind.objects.filter(id=coop_mind_id, creator_user_id=user.id).update(deleted=False)
return build_response()
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+325
View File
@@ -0,0 +1,325 @@
/*!
* Bootstrap Reboot v4.6.2 (https://getbootstrap.com/)
* Copyright 2011-2022 The Bootstrap Authors
* Copyright 2011-2022 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md)
*/
*,
*::before,
*::after {
box-sizing: border-box;
}
html {
font-family: sans-serif;
line-height: 1.15;
-webkit-text-size-adjust: 100%;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
article, aside, figcaption, figure, footer, header, hgroup, main, nav, section {
display: block;
}
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: #212529;
text-align: left;
background-color: #fff;
}
[tabindex="-1"]:focus:not(:focus-visible) {
outline: 0 !important;
}
hr {
box-sizing: content-box;
height: 0;
overflow: visible;
}
h1, h2, h3, h4, h5, h6 {
margin-top: 0;
margin-bottom: 0.5rem;
}
p {
margin-top: 0;
margin-bottom: 1rem;
}
abbr[title],
abbr[data-original-title] {
text-decoration: underline;
-webkit-text-decoration: underline dotted;
text-decoration: underline dotted;
cursor: help;
border-bottom: 0;
-webkit-text-decoration-skip-ink: none;
text-decoration-skip-ink: none;
}
address {
margin-bottom: 1rem;
font-style: normal;
line-height: inherit;
}
ol,
ul,
dl {
margin-top: 0;
margin-bottom: 1rem;
}
ol ol,
ul ul,
ol ul,
ul ol {
margin-bottom: 0;
}
dt {
font-weight: 700;
}
dd {
margin-bottom: .5rem;
margin-left: 0;
}
blockquote {
margin: 0 0 1rem;
}
b,
strong {
font-weight: bolder;
}
small {
font-size: 80%;
}
sub,
sup {
position: relative;
font-size: 75%;
line-height: 0;
vertical-align: baseline;
}
sub {
bottom: -.25em;
}
sup {
top: -.5em;
}
a {
color: #007bff;
text-decoration: none;
background-color: transparent;
}
a:hover {
color: #0056b3;
text-decoration: underline;
}
a:not([href]):not([class]) {
color: inherit;
text-decoration: none;
}
a:not([href]):not([class]):hover {
color: inherit;
text-decoration: none;
}
pre,
code,
kbd,
samp {
font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
font-size: 1em;
}
pre {
margin-top: 0;
margin-bottom: 1rem;
overflow: auto;
-ms-overflow-style: scrollbar;
}
figure {
margin: 0 0 1rem;
}
img {
vertical-align: middle;
border-style: none;
}
svg {
overflow: hidden;
vertical-align: middle;
}
table {
border-collapse: collapse;
}
caption {
padding-top: 0.75rem;
padding-bottom: 0.75rem;
color: #6c757d;
text-align: left;
caption-side: bottom;
}
th {
text-align: inherit;
text-align: -webkit-match-parent;
}
label {
display: inline-block;
margin-bottom: 0.5rem;
}
button {
border-radius: 0;
}
button:focus:not(:focus-visible) {
outline: 0;
}
input,
button,
select,
optgroup,
textarea {
margin: 0;
font-family: inherit;
font-size: inherit;
line-height: inherit;
}
button,
input {
overflow: visible;
}
button,
select {
text-transform: none;
}
[role="button"] {
cursor: pointer;
}
select {
word-wrap: normal;
}
button,
[type="button"],
[type="reset"],
[type="submit"] {
-webkit-appearance: button;
}
button:not(:disabled),
[type="button"]:not(:disabled),
[type="reset"]:not(:disabled),
[type="submit"]:not(:disabled) {
cursor: pointer;
}
button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
padding: 0;
border-style: none;
}
input[type="radio"],
input[type="checkbox"] {
box-sizing: border-box;
padding: 0;
}
textarea {
overflow: auto;
resize: vertical;
}
fieldset {
min-width: 0;
padding: 0;
margin: 0;
border: 0;
}
legend {
display: block;
width: 100%;
max-width: 100%;
padding: 0;
margin-bottom: .5rem;
font-size: 1.5rem;
line-height: inherit;
color: inherit;
white-space: normal;
}
progress {
vertical-align: baseline;
}
[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button {
height: auto;
}
[type="search"] {
outline-offset: -2px;
-webkit-appearance: none;
}
[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
::-webkit-file-upload-button {
font: inherit;
-webkit-appearance: button;
}
output {
display: inline-block;
}
summary {
display: list-item;
cursor: pointer;
}
template {
display: none;
}
[hidden] {
display: none !important;
}
/*# sourceMappingURL=bootstrap-reboot.css.map */
File diff suppressed because one or more lines are too long
+8
View File
@@ -0,0 +1,8 @@
/*!
* Bootstrap Reboot v4.6.2 (https://getbootstrap.com/)
* Copyright 2011-2022 The Bootstrap Authors
* Copyright 2011-2022 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md)
*/*,::after,::before{box-sizing:border-box}html{font-family:sans-serif;line-height:1.15;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}article,aside,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans","Liberation Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";font-size:1rem;font-weight:400;line-height:1.5;color:#212529;text-align:left;background-color:#fff}[tabindex="-1"]:focus:not(:focus-visible){outline:0!important}hr{box-sizing:content-box;height:0;overflow:visible}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5rem}p{margin-top:0;margin-bottom:1rem}abbr[data-original-title],abbr[title]{text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted;cursor:help;border-bottom:0;-webkit-text-decoration-skip-ink:none;text-decoration-skip-ink:none}address{margin-bottom:1rem;font-style:normal;line-height:inherit}dl,ol,ul{margin-top:0;margin-bottom:1rem}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-left:0}blockquote{margin:0 0 1rem}b,strong{font-weight:bolder}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}a{color:#007bff;text-decoration:none;background-color:transparent}a:hover{color:#0056b3;text-decoration:underline}a:not([href]):not([class]){color:inherit;text-decoration:none}a:not([href]):not([class]):hover{color:inherit;text-decoration:none}code,kbd,pre,samp{font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;font-size:1em}pre{margin-top:0;margin-bottom:1rem;overflow:auto;-ms-overflow-style:scrollbar}figure{margin:0 0 1rem}img{vertical-align:middle;border-style:none}svg{overflow:hidden;vertical-align:middle}table{border-collapse:collapse}caption{padding-top:.75rem;padding-bottom:.75rem;color:#6c757d;text-align:left;caption-side:bottom}th{text-align:inherit;text-align:-webkit-match-parent}label{display:inline-block;margin-bottom:.5rem}button{border-radius:0}button:focus:not(:focus-visible){outline:0}button,input,optgroup,select,textarea{margin:0;font-family:inherit;font-size:inherit;line-height:inherit}button,input{overflow:visible}button,select{text-transform:none}[role=button]{cursor:pointer}select{word-wrap:normal}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]:not(:disabled),[type=reset]:not(:disabled),[type=submit]:not(:disabled),button:not(:disabled){cursor:pointer}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{padding:0;border-style:none}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}textarea{overflow:auto;resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{display:block;width:100%;max-width:100%;padding:0;margin-bottom:.5rem;font-size:1.5rem;line-height:inherit;color:inherit;white-space:normal}progress{vertical-align:baseline}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:none}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}summary{display:list-item;cursor:pointer}template{display:none}[hidden]{display:none!important}
/*# sourceMappingURL=bootstrap-reboot.min.css.map */
File diff suppressed because one or more lines are too long
+10332
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+76
View File
@@ -0,0 +1,76 @@
.row div {
display: inline-block;
/*display: flex;*/
/*width: 30%;*/
/*box-sizing: border-box;*/
padding: 10px;
/*overflow: hidden;*/
overflow: visible;
}
.span2 {
width: 300px;
height: 1100px;
box-shadow: 0px 0px 0px #90cf5b;
border-radius: 25px;
border-style:solid;
border-color:gainsboro;
}
.span6 {
width: 1000px;
height: 1000px;
box-shadow: 0px 0px 0px #90cf5b;
border-radius: 25px;
/*border-style:solid;*/
/*border-color:greenyellow;*/
}
.span4 {
width: 300px;
height: 1000px;
box-shadow: 0px 0px 0px #90cf5b;
border-radius: 25px;
/*border-style:solid;*/
/*border-color:greenyellow;*/
}
.span10 {
width: 1400px;
height: 1100px;
box-shadow: 0px 0px 0px #90cf5b;
border-radius: 25px;
border-style:solid;
border-color:lavender;
background-color: lavender;
}
/*!* 下拉按钮 *!*/
/*.dropbtn1 {*/
/* background-color: #3498DB;*/
/* color: white;*/
/* padding: 14px;*/
/* font-size: 14px;*/
/* border: none;*/
/* cursor: pointer;*/
/*}*/
/*.dropdown1 {*/
/* !*position: relative;*!*/
/* !*display: inline-block;*!*/
/*}*/
/*.dropdown-content1 {*/
/* display: none;*/
/* !*position: absolute;*!*/
/* background-color: #f9f9f9;*/
/* overflow:hidden;*/
/* min-width: 160px;*/
/* box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);*/
/* z-index: 1000;*/
/*}*/
/*.dropdown-content1 a {*/
/* color: black;*/
/* padding: 12px 16px;*/
/* text-decoration: none;*/
/* display: block;*/
/*}*/
/*.dropdown1 a:hover {background-color: #f1f1f1}*/
/*!* 显示下拉内容的样式 *!*/
/*.show {display: block;}*/
+624
View File
@@ -0,0 +1,624 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>协作学习投入智能干预平台(学生端)</title>
<link rel="shortcut icon" href="/static/abl1b-qks1b-001.ico"/>
<link rel="stylesheet" type="text/css" href="/static/css/dashboard.css">
<link rel="stylesheet" type="text/css" href="/static/bootstrap-4.6.1-dist/css/bootstrap.css">
<!--script start-->
<script src="/static/js/jquery-1.11.3.min.js"></script>
<script src="https://cdn.staticfile.org/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
<script src="/static/bootstrap-4.6.1-dist/js/bootstrap.bundle.js"></script> <!-- bootstrap.bundle.min.js,还包含了 Popper,用于支持工具提示(tooltip)和弹出框(popover)功能,但是不包含 jQuery。-->
<script src="https://cdn.jsdelivr.net/npm/feather-icons@4.28.0/dist/feather.min.js"></script> <!-- 图标相关-->
<script src="/static/js/mind/c_m_m.js"></script>
<script>
const DefaultView = function () {
this.websocket = null
this.uuid = (new Date().getTime().toString(16) + Math.random().toString(16).substr(2)).substr(2, 16)
this.current_page_num = 1
this.default_page_size = 15
this.title_map = new Map([["main", "我的文件"], ["share", "我的分享"], ["star", "我的收藏"], ["recycle", "回收站"]]);// k-v 的形式
}
DefaultView.prototype = {
/**界面初始化*/
init_view: function () {
const uid = $('#uid').html()
// 未登录
if (!uid || isNaN(uid)) {
$('#login_register').show()
setTimeout(function () {
$('#login_register').click()
}, 500)
$('#logout_a').hide()
$('#newMindModal_btn').hide()
} else {
$('#login_register').hide()
$('#logout_a').show()
}
// 判断页面
const page_tag = this.get_page_tag()
$('#main h5').html(this.title_map.get(page_tag))
},
get_uu_id: function () {
return (new Date().getTime().toString(16) + Math.random().toString(16).substr(2)).substr(2, 16)
},
/**注销登录*/
logout_: function () {
$.ajax({
type: "post",
url: "logout",
headers: {"X-CSRFToken": $.cookie("csrftoken")},
data: {'xx': 'xx'},
dataType: "json",
success: function (data) {
common_alert(data.msg)
setTimeout(function () {
location.reload();
}, 1000)
},
async: false
});
},
/**获得源页面*/
get_page_tag: function () {
return $('#src_page').html()
},
/**获得导图*/
fetch_mind: function (current_page, page_size) {
const me = this
if (!current_page) {
current_page = me.current_page_num
}
if (!page_size) {
page_size = me.default_page_size
}
me.current_page_num = current_page
// 获得跳转源页面
const page_tag = me.get_page_tag()
$.ajax({
type: `get`,
url: `list?page=${current_page}&page_size=${page_size}&s_p=${page_tag}`,
headers: {"X-CSRFToken": $.cookie("csrftoken")},
dataType: "json",
success: function (resp) {
if (resp.code !== 0) {
return
}
// clear container-fluid
$('main .container-fluid').empty()
// 解析结果
const results = resp.results
let idx = 0
let row = $(`<div class="row"></row>`)
results.forEach(function (item) {
const uuid = me.get_uu_id()
// 添加按钮组
let sub_btn = '';
if (page_tag === 'b9b101e') {
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="window.open('2_d?id=${item.id}&s_p=b9b101e')">编辑</a>
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.del_mind(${item.id},'card_${uuid}')">删除</a>
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.share_mind(${item.id})">分享</a>`
} else if (page_tag === 'share') {
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="mind.share_cancel(${item.id})">取消分享</a>
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.fetch_share_info(${item.id})">查看分享链接</a>`
} else if (page_tag === 'star') {
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="mind.un_star(${item.id})">取消收藏</a>`
} else if (page_tag === 'recycle') {
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="mind.del_cancel(${item.id})">恢复</a>
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.del_final(${item.id})">彻底删除</a>`
}
const content = `<div class="card col-2" style="margin: 6px; margin-left: 20px;" id='card_${uuid}'>
<div class="card-body">
<div class="card-title" style="margin-bottom: 0px;font-weight:bold;text-overflow:ellipsis;white-space:nowrap;overflow: hidden;">${item.coop_mind_name}</div>
<hr style="margin: 0">
<img src="/static/pic/demo_icon.png" class="card-img-top" style="margin-top: 8px;cursor: pointer;" onclick="window.open('2_d?id=${item.id}&s_p=b9b101e')">
<div style="text-align:right;font-size: 0.8rem;margin-top: 5px;font-family: inherit;">
<div class="btn-group btn-group-sm" role="group">
<button id="btnGroupDrop1" type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">操作</button>
<div class="dropdown-menu" aria-labelledby="btnGroupDrop1">${sub_btn}</div>
</div>
</div>
</div>
</div>`
row.append(content)
})
// 如果不是3的整数倍,将剩余的添加
$('main .container-fluid').append(row)
me.init_pagination(resp.count, me.default_page_size)
// success end
},
async: false
});
},
/**显示分享链接*/
show_share_url: function (u, h) {
const url = `s_2_d?u=${u}&h=${h}`
$('#share_mind_modal .modal-body').html(`分享成功,请复制以下链接进行分享:<div>${window.location.protocol}//${window.location.host}/${url}</div>`)
$('#share_mind_modal_a').click()
},
/**分页组件*/
init_pagination: function (count, page_size) {
const container = $('#pagination_div')
/**计算页数*/
if (count <= 0) {
container.html(`<p class="text-center">无数据</p>`)
return
}
const all_page = (count <= page_size) ? 1 : (count % page_size > 0) ? Math.floor(count / page_size) + 1 : Math.floor(count / page_size)
const navigation = $(`<nav aria-label="Page navigation example"></nav>`)
const navigation_ul = $(`<ul class="pagination justify-content-center"></ul>`)
if (this.current_page_num > 1) {
navigation_ul.append(`<li class="page-item"><a class="page-link" href="javascript:void(0)" onclick="mind.fetch_mind(mind.current_page_num-1)">上一页</a></li>`)
}
for (let i = 0; i < all_page; i++) {
const ctt = $(`<li class="page-item"><a class="page-link" href="javascript:void(0)" onclick="mind.fetch_mind(${i + 1})">${i + 1}</a></li>`)
if (i + 1 === this.current_page_num) {
ctt.addClass('active')
}
navigation_ul.append(ctt)
}
if (this.current_page_num < all_page) {
navigation_ul.append(`<li class="page-item"><a class="page-link" href="javascript:void(0)" onclick="mind.fetch_mind(mind.current_page_num+1)">下一页</a></li>`)
}
navigation.append(navigation_ul)
container.empty()
container.append(navigation)
},
/**删除导图*/
del_mind: function (mind_id, card_id) {
const me = this
$.ajax({
type: "delete",
url: "delete",
headers: {"X-CSRFToken": $.cookie("csrftoken")},
data: {'coop_mind_id': mind_id, 'source': 'dashboard'},
dataType: "json",
success: function (data) {
if (data.code === 0) {
primary_alert(data.msg)
// $('#' + card_id).remove()
setTimeout(function () {
me.fetch_mind()
}, 1000)
} else {
common_alert(data.msg)
}
},
async: false
});
},
/**分享脑图*/
share_mind: function (mind_id) {
const me = this
$.ajax({
type: "post",
url: "share",
headers: {"X-CSRFToken": $.cookie("csrftoken")},
data: {'id': mind_id},
dataType: "json",
success: function (resp) {
me.show_share_url(`${resp.data.u}`, `${resp.data.h}`)
},
async: false
});
},
/**取消分享*/
share_cancel: function (mind_id) {
const me = this
$.ajax({
type: "delete",
url: "share",
headers: {"X-CSRFToken": $.cookie("csrftoken")},
data: {'id': mind_id},
dataType: "json",
success: function (resp) {
if (me.is_success_resp(resp)) {
location.reload()
} else {
common_alert(resp.msg)
}
},
async: false
});
},
/** 删除恢复*/
del_cancel: function (mind_id) {
const me = this
$.ajax({
type: "post",
url: "delete_cancel",
headers: {"X-CSRFToken": $.cookie("csrftoken")},
data: {'coop_mind_id': mind_id, 'op_type': 'delete_cancel'},
dataType: "json",
success: function (resp) {
common_alert(resp.msg)
if (me.is_success_resp(resp)) {
me.fetch_mind()
}
},
async: false
});
},
/**彻底删除*/
del_final: function (mind_id) {
const me = this
$.ajax({
type: "delete",
url: "delete",
headers: {"X-CSRFToken": $.cookie("csrftoken")},
data: {'coop_mind_id': mind_id, 'source': 'recycle'},
dataType: "json",
success: function (resp) {
common_alert(resp.msg)
if (me.is_success_resp(resp)) {
me.fetch_mind()
}
},
async: false
});
},
/** 取消收藏 */
un_star: function (mind_id) {
const me = this
$.ajax({
type: "delete",
url: "star",
headers: {"X-CSRFToken": $.cookie("csrftoken")},
data: {'coop_mind_id': mind_id},
dataType: "json",
success: function (resp) {
common_alert(resp.msg)
if (me.is_success_resp(resp)) {
me.fetch_mind()
}
},
async: false
});
},
/**获得分享信息*/
fetch_share_info: function (mind_id) {
const me = this
$.ajax({
type: "get",
url: "share",
headers: {"X-CSRFToken": $.cookie("csrftoken")},
data: {'coop_mind_id': mind_id},
dataType: "json",
success: function (resp) {
if (me.is_success_resp(resp)) {
const data = resp.data
me.show_share_url(data.share_uuid, data.share_uuid_hash)
} else {
common_alert(resp.msg)
}
},
async: false
});
},
is_success_resp(resp) {
return resp.code === 0
},
/** 清除注册时输入内容 */
clear_reg_info: function () {
$('#userName').val('');
$('#inputPassword').val('');
$('#inputPassword_').val('');
},
/**校验密码是否输入一致*/
validate_pw_eq: function (obj, inputPassword, inputPassword_) {
if (inputPassword !== inputPassword_) {
common_alert('两次密码输入不一样,请确认!')
return false
}
return true
},
/** 设置窗口名称 */
set_modal_title: function (title) {
$('#exampleModal .modal-title').html(title);
},
/************************************************************************************************/
/**初始化jquery监听*/
jq_listener_init: function () {
const me = this
/**监听modal窗口事件*/
$('#exampleModal').on('show.bs.modal', function (event) {
const ws = new WebSocket(`ws://${window.location.host}/ws/qr/?${me.uuid}`)
ws.onmessage = function (e) {
console.log('接收到websocket消息:' + e.data)
}
me.websocket = ws
});
$('#exampleModal').on('hidden.bs.modal', function (event) {
// console.log('关闭');
if (me.websocket) {
me.websocket.close()
}
});
/**点击 扫码登录 */
$('#s_login_a').click(function () {
$('.modal-body').hide();
$('.qr_login_group').show();
me.set_modal_title('登录');
})
// 点击注册控件
$('#register_a').click(function () {
$('.modal-body').hide();
$('.register_group').show();
me.set_modal_title('注册');
})
// 用户名密码登录
$('#p_login_a').click(function () {
$('.modal-body').hide();
$('.pw_login_group').show();
me.set_modal_title('登录');
})
/** 注册按钮 */
$('#register_button').click(function () {
const userName = $('#userName').val();
const inputPassword = $('#inputPassword').val();
const inputPassword_ = $('#inputPassword_').val();
if (!userName) {
common_alert('请输入用户名')
return
}
if (!inputPassword) {
common_alert('请输入密码')
return
}
// 校验输入是否一致
const validate = me.validate_pw_eq(this, inputPassword, inputPassword_)
if (validate) {
$.ajax({
type: "post",
url: "register",
data: {userName: userName, inputPassword: inputPassword},
dataType: "json",
success: function (data) {
// 注册成功
if (data.code === 0) {
me.clear_reg_info()
common_alert(data.msg, 'alert-primary')
setTimeout(function () {
$('#p_login_a').click()
}, 1500)
} else {
// 注册失败
common_alert(data.msg)
}
},
async: false
});
}
// validate end
});
/**登录按钮*/
$('#login_button').click(function () {
const userName_login = $('#userName_login').val();
const inputPassword_login = $('#inputPassword_login').val();
if (!userName_login || !inputPassword_login) {
common_alert('请输入用户名和密码')
return
}
$.ajax({
type: "post",
url: "login",
headers: {"X-CSRFToken": $.cookie("csrftoken")},
data: {username: userName_login, password: inputPassword_login},
dataType: "json",
success: function (data) {
// 登录成功
if (data.code === 0) {
common_alert(data.msg, 'alert-primary')
$('#exampleModal').modal('hide')
setTimeout(function () {
location.reload();
}, 500)
} else {
// 登录失败
common_alert(data.msg)
}
},
async: false
});
})
/**新建导图*/
$('#new_mind_btn').click(function () {
const mind_name = $('#mindName').val()
if (!mind_name) {
common_alert('请输入导图名称')
return
}
const post_data = {'mind_name': mind_name}
$.ajax({
type: "post",
url: "create",
headers: {"X-CSRFToken": $.cookie("csrftoken")},
data: post_data,
dataType: "json",
success: function (resp) {
if (resp.code === 0) {
me.fetch_mind()
$('#newMindModal').modal('hide')
if ($('#exampleCheck1').prop("checked")) {
/**新页面打开*/
setTimeout(function () {
const id = resp.data
window.open('2_d?id=' + id + `&s_p=b9b101e`)
}, 500)
}
} else {
common_alert(resp.msg)
}
},
async: false
});
})
/** 新建后打开复选框勾选事件*/
$('#exampleCheck1').change(function () {
const checked = $(this).prop("checked")
$.cookie('open_aft_create', checked, {expires: 7, path: '/'});
})
/** 创建导图modal 显示完毕后事件*/
$('#newMindModal').on('shown.bs.modal', function () {
const cookie_checked_ = $.cookie('open_aft_create')
$('#mindName').val('')
// 从cookie中获得的是字符串
if (cookie_checked_ === 'true') {
$('#exampleCheck1').attr('checked', 'checked')
} else {
$('#exampleCheck1').removeAttr('checked');
}
})
/************************************* jq_listener_init end *******************************************/
}
/** prototype end **/
}
$(function () {
const view = new DefaultView()
/**初始化*/
view.init_view()
view.jq_listener_init()
/**如果已经登录则查询列表*/
view.fetch_mind()
window.mind = view
// js end
})
</script>
<!--script end-->
</head>
<body>
<div style="display: none;">
<span id="uid">{{ user.id }}</span>
<span id="src_page">{{ page }}</span>
</div>
<!-- 页眉 start-->
<nav class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0 shadow">
<a class="navbar-brand col-md-2 col-lg-2 mr-0 px-3" href="#">协作学习投入智能干预平台(学生端)</a>
<ul class="navbar-nav px-3">
<li class="nav-item text-nowrap">
<a id="login_register" class="nav-link" href="#" data-toggle="modal" data-target="#exampleModal">登录/注册</a>
<a id="logout_a" class="nav-link" href="javascript:void(0)" onclick="mind.logout_()" style="display: none;">注销</a>
<a id="share_mind_modal_a" class="nav-link" href="#" data-toggle="modal" data-target="#share_mind_modal" style="display: none;"></a>
</li>
</ul>
</nav>
<!-- 页眉 end-->
<!--菜单 和 内容 start-->
<div class="container-fluid">
<div class="row">
<!-- 左侧菜单 start-->
<nav id="sidebarMenu" class="col-md-2 col-lg-2 d-md-block bg-light">
<div class="sidebar-sticky pt-3">
<hr/>
<ul class="nav flex-column">
<li class="nav-item">
<a class="nav-link active" href="/">
<span data-feather="file-text"></span>
协作脑图
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/2_share">
<span data-feather="share-2"></span>
协作分享
</a>
</li>
<li class="nav-item">
<a class="nav-link active" href="/2_baiban">
<span data-feather="file-text"></span>
协作白板
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/2_write">
<span data-feather="share-2"></span>
协同编辑
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/2_star">
<span data-feather="star"></span>
协作收藏
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/2_echart">
<span data-feather="star"></span>
学习分析图
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/chat_room">
<span data-feather="star"></span>
聊天室
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<span data-feather="star"></span>
任务详情
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/ke_cheng">
<span data-feather="star"></span>
课程页面
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/2_recycle">
<span data-feather="trash-2"></span>
回收站
</a>
</li>
</ul>
</div>
</nav>
<!-- 左侧菜单 end-->
<!-- 右侧内容 start-->
<main role="main" class="col-md-10 ml-sm-auto col-lg-10 px-md-4" id="main">
<iframe src="http://121.5.74.240:7101/boards/test" width="100%" height="100%"></iframe>
</main>
<!-- 右侧内容 end-->
</div>
</div>
<!--导航 和 内容 end-->
</body>
<script src="/static/js/mind/modal.js"></script>
<script>
if (window.feather) {
window.feather.replace();
}
</script>
</html>
+12
View File
@@ -553,6 +553,18 @@
协作分享
</a>
</li>
<li class="nav-item">
<a class="nav-link active" href="/2_baiban">
<span data-feather="file-text"></span>
协作白板
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/2_write">
<span data-feather="share-2"></span>
协同编辑
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/2_star">
<span data-feather="star"></span>
+206
View File
@@ -553,6 +553,18 @@
协作分享
</a>
</li>
<li class="nav-item">
<a class="nav-link active" href="/2_baiban">
<span data-feather="file-text"></span>
协作白板
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/2_write">
<span data-feather="share-2"></span>
协同编辑
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/2_star">
<span data-feather="star"></span>
@@ -596,6 +608,8 @@
<main class="col-md-10 ml-sm-auto col-lg-10 px-md-4">
<div id="main" style="width: 600px;height:400px;"></div>
<div id="app2" style="width: 600px;height:400px;"></div>
<div id="app3" style="width: 600px;height:400px;"></div>
<div id="app4" style="width: 600px;height:400px;"></div>
</main>
<!-- 右侧内容 start-->
@@ -833,6 +847,198 @@
]
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
</script>
<script type="text/javascript">
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('app3'));
option = {
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
}
},
legend: {},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: [
{
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
}
],
yAxis: [
{
type: 'value'
}
],
series: [
{
name: 'Direct',
type: 'bar',
emphasis: {
focus: 'series'
},
data: [320, 332, 301, 334, 390, 330, 320]
},
{
name: 'Email',
type: 'bar',
stack: 'Ad',
emphasis: {
focus: 'series'
},
data: [120, 132, 101, 134, 90, 230, 210]
},
{
name: 'Union Ads',
type: 'bar',
stack: 'Ad',
emphasis: {
focus: 'series'
},
data: [220, 182, 191, 234, 290, 330, 310]
},
{
name: 'Video Ads',
type: 'bar',
stack: 'Ad',
emphasis: {
focus: 'series'
},
data: [150, 232, 201, 154, 190, 330, 410]
},
{
name: 'Search Engine',
type: 'bar',
data: [862, 1018, 964, 1026, 1679, 1600, 1570],
emphasis: {
focus: 'series'
},
markLine: {
lineStyle: {
type: 'dashed'
},
data: [[{ type: 'min' }, { type: 'max' }]]
}
},
{
name: 'Baidu',
type: 'bar',
barWidth: 5,
stack: 'Search Engine',
emphasis: {
focus: 'series'
},
data: [620, 732, 701, 734, 1090, 1130, 1120]
},
{
name: 'Google',
type: 'bar',
stack: 'Search Engine',
emphasis: {
focus: 'series'
},
data: [120, 132, 101, 134, 290, 230, 220]
},
{
name: 'Bing',
type: 'bar',
stack: 'Search Engine',
emphasis: {
focus: 'series'
},
data: [60, 72, 71, 74, 190, 130, 110]
},
{
name: 'Others',
type: 'bar',
stack: 'Search Engine',
emphasis: {
focus: 'series'
},
data: [62, 82, 91, 84, 109, 110, 120]
}
]
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
</script>
<script type="text/javascript">
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('app4'));
option = {
title: {
text: 'Stacked Line'
},
tooltip: {
trigger: 'axis'
},
legend: {
data: ['Email', 'Union Ads', 'Video Ads', 'Direct', 'Search Engine']
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
toolbox: {
feature: {
saveAsImage: {}
}
},
xAxis: {
type: 'category',
boundaryGap: false,
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis: {
type: 'value'
},
series: [
{
name: 'Email',
type: 'line',
stack: 'Total',
data: [120, 132, 101, 134, 90, 230, 210]
},
{
name: 'Union Ads',
type: 'line',
stack: 'Total',
data: [220, 182, 191, 234, 290, 330, 310]
},
{
name: 'Video Ads',
type: 'line',
stack: 'Total',
data: [150, 232, 201, 154, 190, 330, 410]
},
{
name: 'Direct',
type: 'line',
stack: 'Total',
data: [320, 332, 301, 334, 390, 330, 320]
},
{
name: 'Search Engine',
type: 'line',
stack: 'Total',
data: [820, 932, 901, 934, 1290, 1330, 1320]
}
]
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
</script>
+12
View File
@@ -553,6 +553,18 @@
协作分享
</a>
</li>
<li class="nav-item">
<a class="nav-link active" href="/2_baiban">
<span data-feather="file-text"></span>
协作白板
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/2_write">
<span data-feather="share-2"></span>
协同编辑
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/2_star">
<span data-feather="star"></span>
+12
View File
@@ -553,6 +553,18 @@
协作分享
</a>
</li>
<li class="nav-item">
<a class="nav-link active" href="/2_baiban">
<span data-feather="file-text"></span>
协作白板
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/2_write">
<span data-feather="share-2"></span>
协同编辑
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/2_star">
<span data-feather="star"></span>
+10
View File
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
</body>
</html>
+118
View File
@@ -0,0 +1,118 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<!-- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">-->
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="bootstrap/css/teacher.css" rel="stylesheet">
<script src="bootstrap/js/jquery.slim.min.js"></script>
<script src="bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- <script src="bootstrap/js/jquery-3.5.1.min.js"></script>-->
<!-- <script src="bootstrap/js/bootstrap.min.js"></script>-->
<!-- <script src="bootstrap/js/teacher.js"></script>-->
</head>
<body>
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
<h3 class="text-center">
系统
</h3>
</div>
</div>
<div class="row">
<div class="span2">
<img alt="140x140" src="img/a.jpg" />
<h3>
数据可视化.
</h3>
<div>
<div class="accordion" id="accordion-714760">
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion-714760" href="#accordion-element-112009">小组 1 学习分析</a>
</div><br>
<div id="accordion-element-112009" class="accordion-body collapse in">
<div class="accordion-inner">
<h7>贡献度</h7><br><img alt="140x140" src="img/a.jpg" /><br>
<h7>话题网络</h7><br><img alt="140x140" src="img/a.jpg" /><br>
<h7>认知感知</h7><br><img alt="140x140" src="img/a.jpg" /><br>
<h7>社会感知</h7><br><img alt="140x140" src="img/a.jpg" /><br>
</div>
</div>
</div><br>
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion-714760" href="#accordion-element-549061">小组 2 学习分析</a>
</div><br>
<div id="accordion-element-549061" class="accordion-body collapse">
<div class="accordion-inner">
<h7>贡献度</h7><br><img alt="140x140" src="img/a.jpg" /><br>
<h7>话题网络</h7><br><img alt="140x140" src="img/a.jpg" /><br>
<h7>认知感知</h7><br><img alt="140x140" src="img/a.jpg" /><br>
<h7>社会感知</h7><br><img alt="140x140" src="img/a.jpg" /><br>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="span10">
<div class="span6">
<h3>
任务详情&任务分工
</h3>
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown" aria-expanded="false">
Dropdown button
</button>
<div class="dropdown-menu" >
<a class="dropdown-item" href="#">任务详情</a>
<a class="dropdown-item" href="#">任务分工</a>
</div>
</div><br>
<div>
这里填充任务详情和任务分工
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</div>
<ul class="nav">
<li class="nav-item">
<a class="nav-link active" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled">Disabled</a>
</li>
</ul>
</div>
<div class="span4">
<div>
第n小组分工情况
</div>
<h3>
聊天框
</h3>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
+23 -4
View File
@@ -553,6 +553,18 @@
协作分享
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/2_write">
<span data-feather="share-2"></span>
协同编辑
</a>
</li>
<li class="nav-item">
<a class="nav-link active" href="/2_baiban">
<span data-feather="file-text"></span>
协作白板
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/2_star">
<span data-feather="star"></span>
@@ -594,8 +606,11 @@
</nav>
<!-- 左侧菜单 end-->
<main class="col-md-10 ml-sm-auto col-lg-10 px-md-4">
<div style="width: 800px;height: 600px;margin: 30px auto;text-align: center">
<h1>课程A小组A聊天室</h1>
<div id = "username" class={{ username }}>
</div>
<div style="width: 800px;height: 600px;margin: 30px auto;text-align: center">
<h1>websocket聊天室</h1>
<div style="width: 800px;border: 1px solid gray;height: 300px;">
<div style="width: 200px;height: 300px;float: left;text-align: left;">
<p><span>当前在线:</span><span id="user_num">0</span></p>
@@ -621,9 +636,13 @@
<script src="/static/js/mind/modal.js"></script>
<script src="/static/js/echarts.js"></script>
<script type="text/javascript">
// 存储用户名到全局变量,握手成功后发送给服务器
var uname = "guoan";
var ws = new WebSocket("ws://127.0.0.1:4321");
{#var uname = prompt('请输入用户名', 'user' + uuid(8, 16));#}
var uname = document.getElementById('username').className
console.log(uname)
var ws = new WebSocket("ws://121.5.74.240:7101/");
var ws = new WebSocket("ws://121.5.74.240:7101/");
ws.onopen = function() {
var data = "系统消息:建立连接成功";
listMsg(data);
+7 -1
View File
@@ -14,6 +14,10 @@
</head>
<body>
<div class="username">
{{ username }}
</div>
<div style="width: 800px;height: 600px;margin: 30px auto;text-align: center">
<h1>websocket聊天室</h1>
<div style="width: 800px;border: 1px solid gray;height: 300px;">
@@ -35,8 +39,10 @@
</html>
<script type="text/javascript">
// 存储用户名到全局变量,握手成功后发送给服务器
var uname = prompt('请输入用户名', 'user' + uuid(8, 16));
{#var uname = prompt('请输入用户名', 'user' + uuid(8, 16));#}
var uname = document.getElementsByClassName('username');
var ws = new WebSocket("ws://127.0.0.1:4321");
ws.onopen = function() {
var data = "系统消息:建立连接成功";
+658
View File
@@ -0,0 +1,658 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>协作学习投入智能干预平台(学生端)</title>
<style>
#editor {
width: 100%;
height: 400px;
border: 1px solid #ccc;
padding: 10px;
box-sizing: border-box;
font-family: monospace;
}
</style>
<link rel="shortcut icon" href="/static/abl1b-qks1b-001.ico"/>
<link rel="stylesheet" type="text/css" href="/static/css/dashboard.css">
<link rel="stylesheet" type="text/css" href="/static/bootstrap-4.6.1-dist/css/bootstrap.css">
<!--script start-->
<script src="/static/js/jquery-1.11.3.min.js"></script>
<script src="https://cdn.staticfile.org/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
<script src="/static/bootstrap-4.6.1-dist/js/bootstrap.bundle.js"></script> <!-- bootstrap.bundle.min.js,还包含了 Popper,用于支持工具提示(tooltip)和弹出框(popover)功能,但是不包含 jQuery。-->
<script src="https://cdn.jsdelivr.net/npm/feather-icons@4.28.0/dist/feather.min.js"></script> <!-- 图标相关-->
<script src="/static/js/mind/c_m_m.js"></script>
<script>
const DefaultView = function () {
this.websocket = null
this.uuid = (new Date().getTime().toString(16) + Math.random().toString(16).substr(2)).substr(2, 16)
this.current_page_num = 1
this.default_page_size = 15
this.title_map = new Map([["main", "我的文件"], ["share", "我的分享"], ["star", "我的收藏"], ["recycle", "回收站"]]);// k-v 的形式
}
DefaultView.prototype = {
/**界面初始化*/
init_view: function () {
const uid = $('#uid').html()
// 未登录
if (!uid || isNaN(uid)) {
$('#login_register').show()
setTimeout(function () {
$('#login_register').click()
}, 500)
$('#logout_a').hide()
$('#newMindModal_btn').hide()
} else {
$('#login_register').hide()
$('#logout_a').show()
}
// 判断页面
const page_tag = this.get_page_tag()
$('#main h5').html(this.title_map.get(page_tag))
},
get_uu_id: function () {
return (new Date().getTime().toString(16) + Math.random().toString(16).substr(2)).substr(2, 16)
},
/**注销登录*/
logout_: function () {
$.ajax({
type: "post",
url: "logout",
headers: {"X-CSRFToken": $.cookie("csrftoken")},
data: {'xx': 'xx'},
dataType: "json",
success: function (data) {
common_alert(data.msg)
setTimeout(function () {
location.reload();
}, 1000)
},
async: false
});
},
/**获得源页面*/
get_page_tag: function () {
return $('#src_page').html()
},
/**获得导图*/
fetch_mind: function (current_page, page_size) {
const me = this
if (!current_page) {
current_page = me.current_page_num
}
if (!page_size) {
page_size = me.default_page_size
}
me.current_page_num = current_page
// 获得跳转源页面
const page_tag = me.get_page_tag()
$.ajax({
type: `get`,
url: `list?page=${current_page}&page_size=${page_size}&s_p=${page_tag}`,
headers: {"X-CSRFToken": $.cookie("csrftoken")},
dataType: "json",
success: function (resp) {
if (resp.code !== 0) {
return
}
// clear container-fluid
$('main .container-fluid').empty()
// 解析结果
const results = resp.results
let idx = 0
let row = $(`<div class="row"></row>`)
results.forEach(function (item) {
const uuid = me.get_uu_id()
// 添加按钮组
let sub_btn = '';
if (page_tag === 'b9b101e') {
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="window.open('2_d?id=${item.id}&s_p=b9b101e')">编辑</a>
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.del_mind(${item.id},'card_${uuid}')">删除</a>
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.share_mind(${item.id})">分享</a>`
} else if (page_tag === 'share') {
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="mind.share_cancel(${item.id})">取消分享</a>
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.fetch_share_info(${item.id})">查看分享链接</a>`
} else if (page_tag === 'star') {
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="mind.un_star(${item.id})">取消收藏</a>`
} else if (page_tag === 'recycle') {
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="mind.del_cancel(${item.id})">恢复</a>
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.del_final(${item.id})">彻底删除</a>`
}
const content = `<div class="card col-2" style="margin: 6px; margin-left: 20px;" id='card_${uuid}'>
<div class="card-body">
<div class="card-title" style="margin-bottom: 0px;font-weight:bold;text-overflow:ellipsis;white-space:nowrap;overflow: hidden;">${item.coop_mind_name}</div>
<hr style="margin: 0">
<img src="/static/pic/demo_icon.png" class="card-img-top" style="margin-top: 8px;cursor: pointer;" onclick="window.open('2_d?id=${item.id}&s_p=b9b101e')">
<div style="text-align:right;font-size: 0.8rem;margin-top: 5px;font-family: inherit;">
<div class="btn-group btn-group-sm" role="group">
<button id="btnGroupDrop1" type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">操作</button>
<div class="dropdown-menu" aria-labelledby="btnGroupDrop1">${sub_btn}</div>
</div>
</div>
</div>
</div>`
row.append(content)
})
// 如果不是3的整数倍,将剩余的添加
$('main .container-fluid').append(row)
me.init_pagination(resp.count, me.default_page_size)
// success end
},
async: false
});
},
/**显示分享链接*/
show_share_url: function (u, h) {
const url = `s_2_d?u=${u}&h=${h}`
$('#share_mind_modal .modal-body').html(`分享成功,请复制以下链接进行分享:<div>${window.location.protocol}//${window.location.host}/${url}</div>`)
$('#share_mind_modal_a').click()
},
/**分页组件*/
init_pagination: function (count, page_size) {
const container = $('#pagination_div')
/**计算页数*/
if (count <= 0) {
container.html(`<p class="text-center">无数据</p>`)
return
}
const all_page = (count <= page_size) ? 1 : (count % page_size > 0) ? Math.floor(count / page_size) + 1 : Math.floor(count / page_size)
const navigation = $(`<nav aria-label="Page navigation example"></nav>`)
const navigation_ul = $(`<ul class="pagination justify-content-center"></ul>`)
if (this.current_page_num > 1) {
navigation_ul.append(`<li class="page-item"><a class="page-link" href="javascript:void(0)" onclick="mind.fetch_mind(mind.current_page_num-1)">上一页</a></li>`)
}
for (let i = 0; i < all_page; i++) {
const ctt = $(`<li class="page-item"><a class="page-link" href="javascript:void(0)" onclick="mind.fetch_mind(${i + 1})">${i + 1}</a></li>`)
if (i + 1 === this.current_page_num) {
ctt.addClass('active')
}
navigation_ul.append(ctt)
}
if (this.current_page_num < all_page) {
navigation_ul.append(`<li class="page-item"><a class="page-link" href="javascript:void(0)" onclick="mind.fetch_mind(mind.current_page_num+1)">下一页</a></li>`)
}
navigation.append(navigation_ul)
container.empty()
container.append(navigation)
},
/**删除导图*/
del_mind: function (mind_id, card_id) {
const me = this
$.ajax({
type: "delete",
url: "delete",
headers: {"X-CSRFToken": $.cookie("csrftoken")},
data: {'coop_mind_id': mind_id, 'source': 'dashboard'},
dataType: "json",
success: function (data) {
if (data.code === 0) {
primary_alert(data.msg)
// $('#' + card_id).remove()
setTimeout(function () {
me.fetch_mind()
}, 1000)
} else {
common_alert(data.msg)
}
},
async: false
});
},
/**分享脑图*/
share_mind: function (mind_id) {
const me = this
$.ajax({
type: "post",
url: "share",
headers: {"X-CSRFToken": $.cookie("csrftoken")},
data: {'id': mind_id},
dataType: "json",
success: function (resp) {
me.show_share_url(`${resp.data.u}`, `${resp.data.h}`)
},
async: false
});
},
/**取消分享*/
share_cancel: function (mind_id) {
const me = this
$.ajax({
type: "delete",
url: "share",
headers: {"X-CSRFToken": $.cookie("csrftoken")},
data: {'id': mind_id},
dataType: "json",
success: function (resp) {
if (me.is_success_resp(resp)) {
location.reload()
} else {
common_alert(resp.msg)
}
},
async: false
});
},
/** 删除恢复*/
del_cancel: function (mind_id) {
const me = this
$.ajax({
type: "post",
url: "delete_cancel",
headers: {"X-CSRFToken": $.cookie("csrftoken")},
data: {'coop_mind_id': mind_id, 'op_type': 'delete_cancel'},
dataType: "json",
success: function (resp) {
common_alert(resp.msg)
if (me.is_success_resp(resp)) {
me.fetch_mind()
}
},
async: false
});
},
/**彻底删除*/
del_final: function (mind_id) {
const me = this
$.ajax({
type: "delete",
url: "delete",
headers: {"X-CSRFToken": $.cookie("csrftoken")},
data: {'coop_mind_id': mind_id, 'source': 'recycle'},
dataType: "json",
success: function (resp) {
common_alert(resp.msg)
if (me.is_success_resp(resp)) {
me.fetch_mind()
}
},
async: false
});
},
/** 取消收藏 */
un_star: function (mind_id) {
const me = this
$.ajax({
type: "delete",
url: "star",
headers: {"X-CSRFToken": $.cookie("csrftoken")},
data: {'coop_mind_id': mind_id},
dataType: "json",
success: function (resp) {
common_alert(resp.msg)
if (me.is_success_resp(resp)) {
me.fetch_mind()
}
},
async: false
});
},
/**获得分享信息*/
fetch_share_info: function (mind_id) {
const me = this
$.ajax({
type: "get",
url: "share",
headers: {"X-CSRFToken": $.cookie("csrftoken")},
data: {'coop_mind_id': mind_id},
dataType: "json",
success: function (resp) {
if (me.is_success_resp(resp)) {
const data = resp.data
me.show_share_url(data.share_uuid, data.share_uuid_hash)
} else {
common_alert(resp.msg)
}
},
async: false
});
},
is_success_resp(resp) {
return resp.code === 0
},
/** 清除注册时输入内容 */
clear_reg_info: function () {
$('#userName').val('');
$('#inputPassword').val('');
$('#inputPassword_').val('');
},
/**校验密码是否输入一致*/
validate_pw_eq: function (obj, inputPassword, inputPassword_) {
if (inputPassword !== inputPassword_) {
common_alert('两次密码输入不一样,请确认!')
return false
}
return true
},
/** 设置窗口名称 */
set_modal_title: function (title) {
$('#exampleModal .modal-title').html(title);
},
/************************************************************************************************/
/**初始化jquery监听*/
jq_listener_init: function () {
const me = this
/**监听modal窗口事件*/
$('#exampleModal').on('show.bs.modal', function (event) {
const ws = new WebSocket(`ws://${window.location.host}/ws/qr/?${me.uuid}`)
ws.onmessage = function (e) {
console.log('接收到websocket消息:' + e.data)
}
me.websocket = ws
});
$('#exampleModal').on('hidden.bs.modal', function (event) {
// console.log('关闭');
if (me.websocket) {
me.websocket.close()
}
});
/**点击 扫码登录 */
$('#s_login_a').click(function () {
$('.modal-body').hide();
$('.qr_login_group').show();
me.set_modal_title('登录');
})
// 点击注册控件
$('#register_a').click(function () {
$('.modal-body').hide();
$('.register_group').show();
me.set_modal_title('注册');
})
// 用户名密码登录
$('#p_login_a').click(function () {
$('.modal-body').hide();
$('.pw_login_group').show();
me.set_modal_title('登录');
})
/** 注册按钮 */
$('#register_button').click(function () {
const userName = $('#userName').val();
const inputPassword = $('#inputPassword').val();
const inputPassword_ = $('#inputPassword_').val();
if (!userName) {
common_alert('请输入用户名')
return
}
if (!inputPassword) {
common_alert('请输入密码')
return
}
// 校验输入是否一致
const validate = me.validate_pw_eq(this, inputPassword, inputPassword_)
if (validate) {
$.ajax({
type: "post",
url: "register",
data: {userName: userName, inputPassword: inputPassword},
dataType: "json",
success: function (data) {
// 注册成功
if (data.code === 0) {
me.clear_reg_info()
common_alert(data.msg, 'alert-primary')
setTimeout(function () {
$('#p_login_a').click()
}, 1500)
} else {
// 注册失败
common_alert(data.msg)
}
},
async: false
});
}
// validate end
});
/**登录按钮*/
$('#login_button').click(function () {
const userName_login = $('#userName_login').val();
const inputPassword_login = $('#inputPassword_login').val();
if (!userName_login || !inputPassword_login) {
common_alert('请输入用户名和密码')
return
}
$.ajax({
type: "post",
url: "login",
headers: {"X-CSRFToken": $.cookie("csrftoken")},
data: {username: userName_login, password: inputPassword_login},
dataType: "json",
success: function (data) {
// 登录成功
if (data.code === 0) {
common_alert(data.msg, 'alert-primary')
$('#exampleModal').modal('hide')
setTimeout(function () {
location.reload();
}, 500)
} else {
// 登录失败
common_alert(data.msg)
}
},
async: false
});
})
/**新建导图*/
$('#new_mind_btn').click(function () {
const mind_name = $('#mindName').val()
if (!mind_name) {
common_alert('请输入导图名称')
return
}
const post_data = {'mind_name': mind_name}
$.ajax({
type: "post",
url: "create",
headers: {"X-CSRFToken": $.cookie("csrftoken")},
data: post_data,
dataType: "json",
success: function (resp) {
if (resp.code === 0) {
me.fetch_mind()
$('#newMindModal').modal('hide')
if ($('#exampleCheck1').prop("checked")) {
/**新页面打开*/
setTimeout(function () {
const id = resp.data
window.open('2_d?id=' + id + `&s_p=b9b101e`)
}, 500)
}
} else {
common_alert(resp.msg)
}
},
async: false
});
})
/** 新建后打开复选框勾选事件*/
$('#exampleCheck1').change(function () {
const checked = $(this).prop("checked")
$.cookie('open_aft_create', checked, {expires: 7, path: '/'});
})
/** 创建导图modal 显示完毕后事件*/
$('#newMindModal').on('shown.bs.modal', function () {
const cookie_checked_ = $.cookie('open_aft_create')
$('#mindName').val('')
// 从cookie中获得的是字符串
if (cookie_checked_ === 'true') {
$('#exampleCheck1').attr('checked', 'checked')
} else {
$('#exampleCheck1').removeAttr('checked');
}
})
/************************************* jq_listener_init end *******************************************/
}
/** prototype end **/
}
$(function () {
const view = new DefaultView()
/**初始化*/
view.init_view()
view.jq_listener_init()
/**如果已经登录则查询列表*/
view.fetch_mind()
window.mind = view
// js end
})
</script>
<!--script end-->
</head>
<body>
<div style="display: none;">
<span id="uid">{{ user.id }}</span>
<span id="src_page">{{ page }}</span>
</div>
<!-- 页眉 start-->
<nav class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0 shadow">
<a class="navbar-brand col-md-2 col-lg-2 mr-0 px-3" href="#">协作学习投入智能干预平台(学生端)</a>
<ul class="navbar-nav px-3">
<li class="nav-item text-nowrap">
<a id="login_register" class="nav-link" href="#" data-toggle="modal" data-target="#exampleModal">登录/注册</a>
<a id="logout_a" class="nav-link" href="javascript:void(0)" onclick="mind.logout_()" style="display: none;">注销</a>
<a id="share_mind_modal_a" class="nav-link" href="#" data-toggle="modal" data-target="#share_mind_modal" style="display: none;"></a>
</li>
</ul>
</nav>
<!-- 页眉 end-->
<!--菜单 和 内容 start-->
<div class="container-fluid">
<div class="row">
<!-- 左侧菜单 start-->
<nav id="sidebarMenu" class="col-md-2 col-lg-2 d-md-block bg-light">
<div class="sidebar-sticky pt-3">
<hr/>
<ul class="nav flex-column">
<li class="nav-item">
<a class="nav-link active" href="/">
<span data-feather="file-text"></span>
协作脑图
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/2_share">
<span data-feather="share-2"></span>
协作分享
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/2_write">
<span data-feather="share-2"></span>
协同编辑
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/2_star">
<span data-feather="star"></span>
协作收藏
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/2_echart">
<span data-feather="star"></span>
学习分析图
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/chat_room">
<span data-feather="star"></span>
聊天室
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/reng_wu">
<span data-feather="star"></span>
任务详情
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/ke_cheng">
<span data-feather="star"></span>
课程页面
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/2_recycle">
<span data-feather="trash-2"></span>
回收站
</a>
</li>
</ul>
</div>
</nav>
<!-- 左侧菜单 end-->
<main class="col-md-10 ml-sm-auto col-lg-10 px-md-4">
<textarea id="editor" placeholder="Start editing..."></textarea>
</main>
<!-- 右侧内容 start-->
<!-- 右侧内容 end-->
</div>
</div>
<!--导航 和 内容 end-->
</body>
<script src="/static/js/mind/modal.js"></script>
<script src="/static/js/echarts.js"></script>
<script>
document.addEventListener('DOMContentLoaded', (event) => {
const ws = new WebSocket('ws://localhost:6789');
const editor = document.getElementById('editor');
ws.onopen = function(event) {
console.log('Connection established!');
};
ws.onmessage = function(event) {
// 当接收到消息时,更新编辑器的内容
const message = JSON.parse(event.data);
editor.value = message; // 假设消息直接是编辑内容
};
ws.onclose = function(event) {
console.log('Connection closed!');
};
editor.oninput = function(event) {
// 当编辑器内容发生变化时,发送消息
const message = {
type: 'edit',
content: editor.value
};
ws.send(JSON.stringify(message));
};
});
</script>
<script>
if (window.feather) {
window.feather.replace();
}
</script>
</html>
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+4356
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+10872
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+25
View File
@@ -0,0 +1,25 @@
function myFunction() {
document.getElementById("myDropdown").classList.toggle("show");
}
// 函数来显示任务详情
function showDetails() {
document.getElementById("taskDetails").style.display = "block";
document.getElementById("taskDivision").style.display = "none";
}
// 函数来显示任务分工
function showDivision() {
document.getElementById("taskDivision").style.display = "block";
document.getElementById("taskDetails").style.display = "none";
}
// 点击下拉以外的地方隐藏下拉菜单
window.onclick = function(event) {
if (!event.target.matches('.dropbtn1')) {
var dropdowns = document.getElementsByClassName("dropdown-content1");
for (var i = 0; i < dropdowns.length; i++) {
var openDropdown = dropdowns[i];
if (openDropdown.classList.contains('show')) {
openDropdown.classList.remove('show');
}
}
}
}
+25
View File
@@ -0,0 +1,25 @@
from zhipuai import ZhipuAI
def gml_chat(prompt):
client = ZhipuAI(api_key="92a0e4868cda21d22fe6fd0f4c0bf6fb.oZ4IE9PPDOhsLKPp")
response = client.chat.completions.create(
model="glm-3-turbo",
messages=[
{
"role": "user",
"content": prompt
}
],
top_p=0.7,
temperature=0.95,
max_tokens=1024,
stream=True,
)
content = ""
for trunk in response:
# print(trunk.choices[0].delta)
content = content + trunk.choices[0].delta.content
print(trunk)
return content
gml_chat("我刚才告诉你我的名字了")
+9
View File
@@ -0,0 +1,9 @@
import re
str = "这是一段测试字符串,@机器人,请回答。"
pattern = r"@机器人"
matches = re.findall(pattern, str)
print(len(matches))
result = re.sub(pattern, "", str)
print(result)
+25
View File
@@ -0,0 +1,25 @@
import time
from zhipuai import ZhipuAI
client = ZhipuAI(api_key="92a0e4868cda21d22fe6fd0f4c0bf6fb.oZ4IE9PPDOhsLKPp") # 请填写您自己的APIKey
response = client.chat.asyncCompletions.create(
model="glm-4", # 填写需要调用的模型名称
messages=[
{
"role": "user",
"content": "请你作为童话故事大王,写一篇短篇童话故事,故事的主题是要永远保持一颗善良的心,要能够激发儿童的学习兴趣和想象力,同时也能够帮助儿童更好地理解和接受故事中所蕴含的道理和价值观。"
}
],
)
task_id = response.id
task_status = ''
get_cnt = 0
while task_status != 'SUCCESS' and task_status != 'FAILED' and get_cnt <= 40:
result_response = client.chat.asyncCompletions.retrieve_completion_result(id=task_id)
print(result_response)
task_status = result_response.task_status
time.sleep(2)
get_cnt += 1
+57 -5
View File
@@ -5,6 +5,35 @@
import asyncio
import json
import websockets
import re
from zhipuai import ZhipuAI
async def gml_chat(messages):
client = ZhipuAI(api_key="92a0e4868cda21d22fe6fd0f4c0bf6fb.oZ4IE9PPDOhsLKPp")
response = client.chat.completions.create(
model="glm-3-turbo",
# messages=[
# {
# "role": "user",
# "content": prompt
# }
# ],
messages = messages,
top_p=0.7,
temperature=0.95,
max_tokens=1024,
stream=True,
)
content = ""
for trunk in response:
# print(trunk.choices[0].delta)
content = content + trunk.choices[0].delta.content
robot_message = json.dumps(
{"type": "user", "content": content, "from": "机器人"})
await asyncio.wait([user.send(robot_message) for user in USERS.values()])
return content
# print(gml_chat("你好"))
# 名字:websockets
USERS = {}
@@ -14,6 +43,7 @@ async def chat(websocket, path):
async for message in websocket:
data = json.loads(message)
print("---------------------")
print(data)
print(data['content'])
message = ''
# 用户发信息
@@ -22,27 +52,49 @@ async def chat(websocket, path):
for k, v in USERS.items():
if v == websocket:
name = k
if len(USERS) != 0: # asyncio.wait doesn't accept an empty list
message = json.dumps(
{"type": "user", "content": data["content"], "from": name})
pattern = r"@机器人"
matches = re.findall(pattern, data['content'])
if len(USERS) != 0:
if len(matches):
question_rebot = re.sub(pattern, "", data['content'])
# robot_reply = await gml_chat(question_rebot) # 获取机器人的回复
message = json.dumps(
{"type": "user", "content": data["content"], "from": name})
await asyncio.wait([user.send(message) for user in USERS.values()])
robot_reply = await gml_chat(question_rebot) # 获取机器人的回复
# await asyncio.wait([user.send(message) for user in USERS.values()])
# robot_message = json.dumps(
# {"type": "user", "content": robot_reply, "from": "机器人"})
# # await asyncio.wait([user.send(robot_message) for user in USERS.values()])
else:
message = json.dumps(
{"type": "user", "content": data["content"], "from": name})
await asyncio.wait([user.send(message) for user in USERS.values()])
# if len(USERS) != 0: # asyncio.wait doesn't accept an empty list
# message = json.dumps(
# {"type": "user", "content": data["content"], "from": name})
#用户登录
elif data["type"] == 'login':
USERS[data["content"]] = websocket
if len(USERS) != 0: # asyncio.wait doesn't accept an empty list
message = json.dumps(
{"type": "login", "content": data["content"], "user_list": list(USERS.keys())})
await asyncio.wait([user.send(message) for user in USERS.values()])
#用户退出
elif data["type"] == 'logout':
del USERS[data["content"]]
if len(USERS) != 0: # asyncio.wait doesn't accept an empty list
message = json.dumps(
{"type": "logout", "content": data["content"], "user_list": list(USERS.keys())})
await asyncio.wait([user.send(message) for user in USERS.values()])
# 群发
await asyncio.wait([user.send(message) for user in USERS.values()])
# await asyncio.wait([user.send(message) for user in USERS.values()])
start_server = websockets.serve(chat, "127.0.0.1", 4321)
start_server = websockets.serve(chat, "0.0.0.0", 4321)
asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()