Files
EdgeAdmin/web/views/@default/@layout.js

119 lines
2.3 KiB
JavaScript
Raw Normal View History

2020-07-22 22:19:39 +08:00
Tea.context(function () {
this.moreOptionsVisible = false
2020-10-20 20:18:12 +08:00
this.globalMessageBadge = 0
2020-07-22 22:19:39 +08:00
2020-09-23 18:43:38 +08:00
if (typeof this.leftMenuItemIsDisabled == "undefined") {
this.leftMenuItemIsDisabled = false
}
2020-07-22 22:19:39 +08:00
this.$delay(function () {
if (this.$refs.focus != null) {
this.$refs.focus.focus()
2020-07-22 22:19:39 +08:00
}
2020-08-21 12:32:16 +08:00
2020-10-20 20:18:12 +08:00
// 检查消息
this.checkMessages()
})
2020-07-22 22:19:39 +08:00
/**
* 左侧子菜单
*/
this.showSubMenu = function (menu) {
if (menu.alwaysActive) {
return
2020-07-22 22:19:39 +08:00
}
if (this.teaSubMenus.menus != null && this.teaSubMenus.menus.length > 0) {
this.teaSubMenus.menus.$each(function (k, v) {
if (menu.id == v.id) {
return
2020-07-22 22:19:39 +08:00
}
v.isActive = false
})
2020-07-22 22:19:39 +08:00
}
menu.isActive = !menu.isActive
2020-07-22 22:19:39 +08:00
};
2020-08-21 12:32:16 +08:00
2020-10-20 20:18:12 +08:00
/**
* 检查消息
*/
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)
})
}
2020-08-21 12:32:16 +08:00
/**
* 底部伸展框
*/
this.showQQGroupQrcode = function () {
teaweb.popup("/about/qq", {
width: "21em",
height: "24em"
})
}
2020-11-24 17:36:42 +08:00
/**
* 弹窗中默认成功回调
*/
if (window.IS_POPUP === true) {
this.success = window.NotifyPopup
}
2020-07-22 22:19:39 +08:00
});
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;
});
};
};
2020-09-06 16:19:34 +08:00
window.NotifyReloadSuccess = function (message) {
return function () {
teaweb.success(message, function () {
window.location.reload()
})
}
}
2020-07-22 22:19:39 +08:00
window.NotifyDelete = function (message, url, params) {
teaweb.confirm(message, function () {
Tea.Vue.$post(url)
.params(params)
.refresh();
});
};
window.NotifyPopup = function (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;
};