update
This commit is contained in:
+74
-51
@@ -22,7 +22,23 @@
|
|||||||
uuid: (new Date().getTime().toString(16) + Math.random().toString(16).substr(2)).substr(2, 16)
|
uuid: (new Date().getTime().toString(16) + Math.random().toString(16).substr(2)).substr(2, 16)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**界面初始化*/
|
||||||
|
function view_init() {
|
||||||
|
const uid = $('#uid').html()
|
||||||
|
// 未登录
|
||||||
|
if (!uid || isNaN(uid)) {
|
||||||
|
$('#login_register').show()
|
||||||
|
$('#logout_a').hide()
|
||||||
|
} else {
|
||||||
|
$('#login_register').hide()
|
||||||
|
$('#logout_a').show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
|
/**界面初始化*/
|
||||||
|
view_init()
|
||||||
|
|
||||||
// 监听modal窗口事件
|
// 监听modal窗口事件
|
||||||
$('#exampleModal').on('show.bs.modal', function (event) {
|
$('#exampleModal').on('show.bs.modal', function (event) {
|
||||||
// console.log(qr_websocket)
|
// console.log(qr_websocket)
|
||||||
@@ -152,8 +168,11 @@
|
|||||||
if (data.code === 0) {
|
if (data.code === 0) {
|
||||||
login_alert(data.msg, 'alert-primary')
|
login_alert(data.msg, 'alert-primary')
|
||||||
$('#exampleModal').modal('hide')
|
$('#exampleModal').modal('hide')
|
||||||
$('#login_register').remove()
|
// $('#login_register').hide()
|
||||||
fetch_mind()
|
// fetch_mind()
|
||||||
|
setTimeout(function () {
|
||||||
|
location.reload();
|
||||||
|
}, 500)
|
||||||
} else {
|
} else {
|
||||||
// 登录失败
|
// 登录失败
|
||||||
login_alert(data.msg)
|
login_alert(data.msg)
|
||||||
@@ -163,6 +182,58 @@
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
/**新建导图*/
|
||||||
|
$('#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) {
|
||||||
|
fetch_mind()
|
||||||
|
$('#newMindModal').modal('hide')
|
||||||
|
// 新页面打开
|
||||||
|
setTimeout(function () {
|
||||||
|
const id = resp.data
|
||||||
|
window.open('detail?id=' + id)
|
||||||
|
}, 500)
|
||||||
|
},
|
||||||
|
async: false
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
/**如果已经登录则查询列表*/
|
||||||
|
fetch_mind()
|
||||||
|
// js end
|
||||||
|
})
|
||||||
|
|
||||||
|
/**注销登录*/
|
||||||
|
function logout_() {
|
||||||
|
$.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
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**获得导图*/
|
/**获得导图*/
|
||||||
function fetch_mind(page, page_size) {
|
function fetch_mind(page, page_size) {
|
||||||
if (!page) {
|
if (!page) {
|
||||||
@@ -215,59 +286,11 @@
|
|||||||
async: false
|
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) {
|
|
||||||
fetch_mind()
|
|
||||||
$('#newMindModal').modal('hide')
|
|
||||||
// 新页面打开
|
|
||||||
setTimeout(function () {
|
|
||||||
const id = resp.data
|
|
||||||
window.open('detail?id=' + id)
|
|
||||||
}, 500)
|
|
||||||
},
|
|
||||||
async: false
|
|
||||||
});
|
|
||||||
})
|
|
||||||
|
|
||||||
/**如果已经登录则查询列表*/
|
|
||||||
fetch_mind()
|
|
||||||
// js end
|
|
||||||
})
|
|
||||||
|
|
||||||
/**注销登录*/
|
|
||||||
function logout_() {
|
|
||||||
$.ajax({
|
|
||||||
type: "post",
|
|
||||||
url: "login",
|
|
||||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
|
||||||
data: {'username': 'userName_login'},
|
|
||||||
dataType: "json",
|
|
||||||
success: function (data) {
|
|
||||||
common_alert_(data.msg)
|
|
||||||
},
|
|
||||||
async: false
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
<!--script end-->
|
<!--script end-->
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<span id="uid" style="display: none;">{{ user.id }}</span>
|
||||||
<!-- 页眉 start-->
|
<!-- 页眉 start-->
|
||||||
<nav class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0 shadow">
|
<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>
|
<a class="navbar-brand col-md-2 col-lg-2 mr-0 px-3" href="#">协作思维导图</a>
|
||||||
|
|||||||
Reference in New Issue
Block a user