From 0d3ae67c7fe107974e156458bc543952a54a6351 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Sat, 16 Oct 2021 12:45:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=88=86=E9=A1=B5=E6=9D=A1?= =?UTF-8?q?=E6=95=B0=E4=BF=AE=E6=94=B9/=E5=9C=A8=E5=BC=B9=E7=AA=97?= =?UTF-8?q?=E4=B8=8B=E4=B8=8D=E8=BF=90=E8=A1=8C=E6=9F=90=E4=BA=9B=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/views/@default/@layout.js | 352 +++++++++++++++++----------------- 1 file changed, 180 insertions(+), 172 deletions(-) diff --git a/web/views/@default/@layout.js b/web/views/@default/@layout.js index e3f2ba8f..c0fa397b 100644 --- a/web/views/@default/@layout.js +++ b/web/views/@default/@layout.js @@ -1,25 +1,27 @@ Tea.context(function () { - this.moreOptionsVisible = false - this.globalMessageBadge = 0 + this.moreOptionsVisible = false + this.globalMessageBadge = 0 - if (typeof this.leftMenuItemIsDisabled == "undefined") { - this.leftMenuItemIsDisabled = false - } + if (typeof this.leftMenuItemIsDisabled == "undefined") { + this.leftMenuItemIsDisabled = false + } - this.$delay(function () { - if (this.$refs.focus != null) { - this.$refs.focus.focus() - } + this.$delay(function () { + if (this.$refs.focus != null) { + this.$refs.focus.focus() + } - // 检查消息 - this.checkMessages() + if (!window.IS_POPUP) { + // 检查消息 + this.checkMessages() - // 检查集群节点同步 - this.loadNodeTasks(); + // 检查集群节点同步 + this.loadNodeTasks(); - // 检查DNS同步 - this.loadDNSTasks() - }) + // 检查DNS同步 + this.loadDNSTasks() + } + }) /** * 切换模板 @@ -32,186 +34,192 @@ Tea.context(function () { }) } - /** - * 左侧子菜单 - */ - this.showSubMenu = function (menu) { - if (menu.alwaysActive) { - return - } - if (this.teaSubMenus.menus != null && this.teaSubMenus.menus.length > 0) { - this.teaSubMenus.menus.$each(function (k, v) { - if (menu.id == v.id) { - return - } - v.isActive = false - }) - } - menu.isActive = !menu.isActive - }; + /** + * 左侧子菜单 + */ + this.showSubMenu = function (menu) { + if (menu.alwaysActive) { + return + } + if (this.teaSubMenus.menus != null && this.teaSubMenus.menus.length > 0) { + this.teaSubMenus.menus.$each(function (k, v) { + if (menu.id == v.id) { + return + } + v.isActive = false + }) + } + menu.isActive = !menu.isActive + }; - /** - * 检查消息 - */ - this.checkMessages = function () { - this.$post("/messages/badge") - .params({}) - .success(function (resp) { - this.globalMessageBadge = resp.data.count - }) - .done(function () { - let delay = 6000 - if (this.globalMessageBadge > 0) { - delay = 30000 - } - this.$delay(function () { - this.checkMessages() - }, delay) - }) - } + /** + * 检查消息 + */ + this.checkMessages = function () { + this.$post("/messages/badge") + .params({}) + .success(function (resp) { + this.globalMessageBadge = resp.data.count + }) + .done(function () { + let delay = 6000 + if (this.globalMessageBadge > 0) { + delay = 30000 + } + this.$delay(function () { + this.checkMessages() + }, delay) + }) + } - this.checkMessagesOnce = function () { - this.$post("/messages/badge") - .params({}) - .success(function (resp) { - this.globalMessageBadge = resp.data.count - }) - } + this.checkMessagesOnce = function () { + this.$post("/messages/badge") + .params({}) + .success(function (resp) { + this.globalMessageBadge = resp.data.count + }) + } - this.showMessages = function () { - teaweb.popup("/messages", { - height: "24em", - width: "50em" - }) - } + this.showMessages = function () { + teaweb.popup("/messages", { + height: "24em", + width: "50em" + }) + } - /** - * 底部伸展框 - */ - this.showQQGroupQrcode = function () { - teaweb.popup("/about/qq", { - width: "21em", - height: "24em" - }) - } + /** + * 底部伸展框 + */ + this.showQQGroupQrcode = function () { + teaweb.popup("/about/qq", { + width: "21em", + height: "24em" + }) + } - /** - * 弹窗中默认成功回调 - */ - if (window.IS_POPUP === true) { - this.success = window.NotifyPopup - } + /** + * 弹窗中默认成功回调 + */ + if (window.IS_POPUP === true) { + this.success = window.NotifyPopup + } - /** - * 节点同步任务 - */ - this.doingNodeTasks = { - isDoing: false, - hasError: false, - isUpdated: false - } + /** + * 节点同步任务 + */ + this.doingNodeTasks = { + isDoing: false, + hasError: false, + isUpdated: false + } - this.loadNodeTasks = function () { - if (!Tea.Vue.teaCheckNodeTasks) { - return - } - this.$post("/clusters/tasks/check") - .success(function (resp) { - this.doingNodeTasks.isDoing = resp.data.isDoing - this.doingNodeTasks.hasError = resp.data.hasError - this.doingNodeTasks.isUpdated = true - }) - .done(function () { - this.$delay(function () { - this.loadNodeTasks() - }, 3000) - }) - } + this.loadNodeTasks = function () { + if (!Tea.Vue.teaCheckNodeTasks) { + return + } + this.$post("/clusters/tasks/check") + .success(function (resp) { + this.doingNodeTasks.isDoing = resp.data.isDoing + this.doingNodeTasks.hasError = resp.data.hasError + this.doingNodeTasks.isUpdated = true + }) + .done(function () { + this.$delay(function () { + this.loadNodeTasks() + }, 3000) + }) + } - this.showNodeTasks = function () { - teaweb.popup("/clusters/tasks/listPopup", { - height: "24em", - width: "50em" - }) - } + this.showNodeTasks = function () { + teaweb.popup("/clusters/tasks/listPopup", { + height: "24em", + width: "50em" + }) + } - /** - * DNS同步任务 - */ - this.doingDNSTasks = { - isDoing: false, - hasError: false, - isUpdated: false - } + /** + * DNS同步任务 + */ + this.doingDNSTasks = { + isDoing: false, + hasError: false, + isUpdated: false + } - this.loadDNSTasks = function () { - if (!Tea.Vue.teaCheckDNSTasks) { - return - } - this.$post("/dns/tasks/check") - .success(function (resp) { - this.doingDNSTasks.isDoing = resp.data.isDoing - this.doingDNSTasks.hasError = resp.data.hasError - this.doingDNSTasks.isUpdated = true - }) - .done(function () { - this.$delay(function () { - this.loadDNSTasks() - }, 3000) - }) - } + this.loadDNSTasks = function () { + if (!Tea.Vue.teaCheckDNSTasks) { + return + } + this.$post("/dns/tasks/check") + .success(function (resp) { + this.doingDNSTasks.isDoing = resp.data.isDoing + this.doingDNSTasks.hasError = resp.data.hasError + this.doingDNSTasks.isUpdated = true + }) + .done(function () { + this.$delay(function () { + this.loadDNSTasks() + }, 3000) + }) + } - this.showDNSTasks = function () { - teaweb.popup("/dns/tasks/listPopup", { - height: "24em", - width: "50em" - }) - } + this.showDNSTasks = function () { + teaweb.popup("/dns/tasks/listPopup", { + height: "24em", + width: "50em" + }) + } }); window.NotifySuccess = function (message, url, params) { - if (typeof (url) == "string" && url.length > 0) { - if (url[0] != "/") { - url = Tea.url(url, params); - } - } - return function () { - teaweb.success(message, function () { - window.location = url; - }); - }; + if (typeof (url) == "string" && url.length > 0) { + if (url[0] != "/") { + url = Tea.url(url, params); + } + } + return function () { + teaweb.success(message, function () { + window.location = url; + }); + }; }; window.NotifyReloadSuccess = function (message) { - return function () { - teaweb.success(message, function () { - window.location.reload() - }) - } + return function () { + teaweb.success(message, function () { + window.location.reload() + }) + } } window.NotifyDelete = function (message, url, params) { - teaweb.confirm(message, function () { - Tea.Vue.$post(url) - .params(params) - .refresh(); - }); + teaweb.confirm(message, function () { + Tea.Vue.$post(url) + .params(params) + .refresh(); + }); }; window.NotifyPopup = function (resp) { - window.parent.teaweb.popupFinish(resp); + window.parent.teaweb.popupFinish(resp); }; window.ChangePageSize = function (size) { - let url = window.location.toString(); - if (url.indexOf("pageSize") > 0) { - url = url.replace(/pageSize=\d+/g, "pageSize=" + size); - } else { - if (url.indexOf("?") > 0) { - url += "&pageSize=" + size; - } else { - url += "?pageSize=" + size; - } - } - window.location = url; + let url = window.location.toString(); + url = url.replace(/page=\d+/g, "page=1") + if (url.indexOf("pageSize") > 0) { + url = url.replace(/pageSize=\d+/g, "pageSize=" + size) + } else { + if (url.indexOf("?") > 0) { + let anchorIndex = url.indexOf("#") + if (anchorIndex < 0) { + url += "&pageSize=" + size; + } else { + url = url.substring(0, anchorIndex) + "&pageSize=" + size + url.substr(anchorIndex); + } + } else { + url += "?pageSize=" + size; + } + } + window.location = url; }; \ No newline at end of file