优化分页条数修改/在弹窗下不运行某些任务

This commit is contained in:
GoEdgeLab
2021-10-16 12:45:56 +08:00
parent 17ba8a1836
commit 0d3ae67c7f

View File

@@ -1,25 +1,27 @@
Tea.context(function () { Tea.context(function () {
this.moreOptionsVisible = false this.moreOptionsVisible = false
this.globalMessageBadge = 0 this.globalMessageBadge = 0
if (typeof this.leftMenuItemIsDisabled == "undefined") { if (typeof this.leftMenuItemIsDisabled == "undefined") {
this.leftMenuItemIsDisabled = false this.leftMenuItemIsDisabled = false
} }
this.$delay(function () { this.$delay(function () {
if (this.$refs.focus != null) { if (this.$refs.focus != null) {
this.$refs.focus.focus() this.$refs.focus.focus()
} }
// 检查消息 if (!window.IS_POPUP) {
this.checkMessages() // 检查消息
this.checkMessages()
// 检查集群节点同步 // 检查集群节点同步
this.loadNodeTasks(); this.loadNodeTasks();
// 检查DNS同步 // 检查DNS同步
this.loadDNSTasks() this.loadDNSTasks()
}) }
})
/** /**
* 切换模板 * 切换模板
@@ -32,186 +34,192 @@ Tea.context(function () {
}) })
} }
/** /**
* 左侧子菜单 * 左侧子菜单
*/ */
this.showSubMenu = function (menu) { this.showSubMenu = function (menu) {
if (menu.alwaysActive) { if (menu.alwaysActive) {
return return
} }
if (this.teaSubMenus.menus != null && this.teaSubMenus.menus.length > 0) { if (this.teaSubMenus.menus != null && this.teaSubMenus.menus.length > 0) {
this.teaSubMenus.menus.$each(function (k, v) { this.teaSubMenus.menus.$each(function (k, v) {
if (menu.id == v.id) { if (menu.id == v.id) {
return return
} }
v.isActive = false v.isActive = false
}) })
} }
menu.isActive = !menu.isActive menu.isActive = !menu.isActive
}; };
/** /**
* 检查消息 * 检查消息
*/ */
this.checkMessages = function () { this.checkMessages = function () {
this.$post("/messages/badge") this.$post("/messages/badge")
.params({}) .params({})
.success(function (resp) { .success(function (resp) {
this.globalMessageBadge = resp.data.count this.globalMessageBadge = resp.data.count
}) })
.done(function () { .done(function () {
let delay = 6000 let delay = 6000
if (this.globalMessageBadge > 0) { if (this.globalMessageBadge > 0) {
delay = 30000 delay = 30000
} }
this.$delay(function () { this.$delay(function () {
this.checkMessages() this.checkMessages()
}, delay) }, delay)
}) })
} }
this.checkMessagesOnce = function () { this.checkMessagesOnce = function () {
this.$post("/messages/badge") this.$post("/messages/badge")
.params({}) .params({})
.success(function (resp) { .success(function (resp) {
this.globalMessageBadge = resp.data.count this.globalMessageBadge = resp.data.count
}) })
} }
this.showMessages = function () { this.showMessages = function () {
teaweb.popup("/messages", { teaweb.popup("/messages", {
height: "24em", height: "24em",
width: "50em" width: "50em"
}) })
} }
/** /**
* 底部伸展框 * 底部伸展框
*/ */
this.showQQGroupQrcode = function () { this.showQQGroupQrcode = function () {
teaweb.popup("/about/qq", { teaweb.popup("/about/qq", {
width: "21em", width: "21em",
height: "24em" height: "24em"
}) })
} }
/** /**
* 弹窗中默认成功回调 * 弹窗中默认成功回调
*/ */
if (window.IS_POPUP === true) { if (window.IS_POPUP === true) {
this.success = window.NotifyPopup this.success = window.NotifyPopup
} }
/** /**
* 节点同步任务 * 节点同步任务
*/ */
this.doingNodeTasks = { this.doingNodeTasks = {
isDoing: false, isDoing: false,
hasError: false, hasError: false,
isUpdated: false isUpdated: false
} }
this.loadNodeTasks = function () { this.loadNodeTasks = function () {
if (!Tea.Vue.teaCheckNodeTasks) { if (!Tea.Vue.teaCheckNodeTasks) {
return return
} }
this.$post("/clusters/tasks/check") this.$post("/clusters/tasks/check")
.success(function (resp) { .success(function (resp) {
this.doingNodeTasks.isDoing = resp.data.isDoing this.doingNodeTasks.isDoing = resp.data.isDoing
this.doingNodeTasks.hasError = resp.data.hasError this.doingNodeTasks.hasError = resp.data.hasError
this.doingNodeTasks.isUpdated = true this.doingNodeTasks.isUpdated = true
}) })
.done(function () { .done(function () {
this.$delay(function () { this.$delay(function () {
this.loadNodeTasks() this.loadNodeTasks()
}, 3000) }, 3000)
}) })
} }
this.showNodeTasks = function () { this.showNodeTasks = function () {
teaweb.popup("/clusters/tasks/listPopup", { teaweb.popup("/clusters/tasks/listPopup", {
height: "24em", height: "24em",
width: "50em" width: "50em"
}) })
} }
/** /**
* DNS同步任务 * DNS同步任务
*/ */
this.doingDNSTasks = { this.doingDNSTasks = {
isDoing: false, isDoing: false,
hasError: false, hasError: false,
isUpdated: false isUpdated: false
} }
this.loadDNSTasks = function () { this.loadDNSTasks = function () {
if (!Tea.Vue.teaCheckDNSTasks) { if (!Tea.Vue.teaCheckDNSTasks) {
return return
} }
this.$post("/dns/tasks/check") this.$post("/dns/tasks/check")
.success(function (resp) { .success(function (resp) {
this.doingDNSTasks.isDoing = resp.data.isDoing this.doingDNSTasks.isDoing = resp.data.isDoing
this.doingDNSTasks.hasError = resp.data.hasError this.doingDNSTasks.hasError = resp.data.hasError
this.doingDNSTasks.isUpdated = true this.doingDNSTasks.isUpdated = true
}) })
.done(function () { .done(function () {
this.$delay(function () { this.$delay(function () {
this.loadDNSTasks() this.loadDNSTasks()
}, 3000) }, 3000)
}) })
} }
this.showDNSTasks = function () { this.showDNSTasks = function () {
teaweb.popup("/dns/tasks/listPopup", { teaweb.popup("/dns/tasks/listPopup", {
height: "24em", height: "24em",
width: "50em" width: "50em"
}) })
} }
}); });
window.NotifySuccess = function (message, url, params) { window.NotifySuccess = function (message, url, params) {
if (typeof (url) == "string" && url.length > 0) { if (typeof (url) == "string" && url.length > 0) {
if (url[0] != "/") { if (url[0] != "/") {
url = Tea.url(url, params); url = Tea.url(url, params);
} }
} }
return function () { return function () {
teaweb.success(message, function () { teaweb.success(message, function () {
window.location = url; window.location = url;
}); });
}; };
}; };
window.NotifyReloadSuccess = function (message) { window.NotifyReloadSuccess = function (message) {
return function () { return function () {
teaweb.success(message, function () { teaweb.success(message, function () {
window.location.reload() window.location.reload()
}) })
} }
} }
window.NotifyDelete = function (message, url, params) { window.NotifyDelete = function (message, url, params) {
teaweb.confirm(message, function () { teaweb.confirm(message, function () {
Tea.Vue.$post(url) Tea.Vue.$post(url)
.params(params) .params(params)
.refresh(); .refresh();
}); });
}; };
window.NotifyPopup = function (resp) { window.NotifyPopup = function (resp) {
window.parent.teaweb.popupFinish(resp); window.parent.teaweb.popupFinish(resp);
}; };
window.ChangePageSize = function (size) { window.ChangePageSize = function (size) {
let url = window.location.toString(); let url = window.location.toString();
if (url.indexOf("pageSize") > 0) { url = url.replace(/page=\d+/g, "page=1")
url = url.replace(/pageSize=\d+/g, "pageSize=" + size); if (url.indexOf("pageSize") > 0) {
} else { url = url.replace(/pageSize=\d+/g, "pageSize=" + size)
if (url.indexOf("?") > 0) { } else {
url += "&pageSize=" + size; if (url.indexOf("?") > 0) {
} else { let anchorIndex = url.indexOf("#")
url += "?pageSize=" + size; if (anchorIndex < 0) {
} url += "&pageSize=" + size;
} } else {
window.location = url; url = url.substring(0, anchorIndex) + "&pageSize=" + size + url.substr(anchorIndex);
}
} else {
url += "?pageSize=" + size;
}
}
window.location = url;
}; };