优化消息弹窗交互

This commit is contained in:
GoEdgeLab
2021-09-18 11:02:23 +08:00
parent c5debefa8e
commit cde964fe82
2 changed files with 46 additions and 36 deletions

View File

@@ -1,41 +1,51 @@
Vue.component("message-row", { Vue.component("message-row", {
props: ["v-message"], props: ["v-message", "v-can-close"],
data: function () { data: function () {
let paramsJSON = this.vMessage.params let paramsJSON = this.vMessage.params
let params = null let params = null
if (paramsJSON != null && paramsJSON.length > 0) { if (paramsJSON != null && paramsJSON.length > 0) {
params = JSON.parse(paramsJSON) params = JSON.parse(paramsJSON)
} }
return { return {
message: this.vMessage, message: this.vMessage,
params: params params: params,
} isClosing: false
}, }
methods: { },
viewCert: function (certId) { methods: {
teaweb.popup("/servers/certs/certPopup?certId=" + certId, { viewCert: function (certId) {
height: "28em", teaweb.popup("/servers/certs/certPopup?certId=" + certId, {
width: "48em" height: "28em",
}) width: "48em"
}, })
readMessage: function (messageId) { },
Tea.action("/messages/readPage") readMessage: function (messageId) {
.params({"messageIds": [messageId]}) let that = this
.post()
.success(function () {
// 刷新父级页面Badge
if (window.parent.Tea != null && window.parent.Tea.Vue != null) {
window.parent.Tea.Vue.checkMessagesOnce()
}
// 刷新当前页面 Tea.action("/messages/readPage")
teaweb.reload() .params({"messageIds": [messageId]})
}) .post()
} .success(function () {
}, // 刷新父级页面Badge
template: `<div> if (window.parent.Tea != null && window.parent.Tea.Vue != null) {
<table class="ui table selectable"> window.parent.Tea.Vue.checkMessagesOnce()
}
// 刷新当前页面
if (that.vCanClose && typeof (NotifyPopup) != "undefined") {
that.isClosing = true
setTimeout(function () {
NotifyPopup({})
}, 1000)
} else {
teaweb.reload()
}
})
}
},
template: `<div>
<table class="ui table selectable" v-if="!isClosing">
<tr :class="{error: message.level == 'error', positive: message.level == 'success', warning: message.level == 'warning'}"> <tr :class="{error: message.level == 'error', positive: message.level == 'success', warning: message.level == 'warning'}">
<td style="position: relative"> <td style="position: relative">
<strong>{{message.datetime}}</strong> <strong>{{message.datetime}}</strong>

View File

@@ -8,6 +8,6 @@
<p class="comment" v-if="messages.length == 0">暂时还没有消息。</p> <p class="comment" v-if="messages.length == 0">暂时还没有消息。</p>
<message-row v-for="message in messages" :v-message="message" :key="message.id"></message-row> <message-row v-for="message in messages" :v-message="message" :key="message.id" :v-can-close="messages.length == 1"></message-row>
<div class="page" v-html="page"></div> <div class="page" v-html="page"></div>