2023-11-28 20:33:38 +08:00
|
|
|
<template>
|
2024-07-08 16:26:03 +08:00
|
|
|
<div id="app">
|
|
|
|
|
<router-view />
|
|
|
|
|
<theme-picker />
|
2024-07-09 08:26:07 +08:00
|
|
|
|
|
|
|
|
<!-- <Notice :noticeDialog="noticeDialog"></Notice> -->
|
2024-07-08 16:26:03 +08:00
|
|
|
</div>
|
2023-11-28 20:33:38 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2024-07-08 16:26:03 +08:00
|
|
|
import ThemePicker from '@/components/ThemePicker'
|
|
|
|
|
import { getHomeNoticeApi, setQueryNoticeApi } from '@/api/system/notice.js'
|
2024-07-09 08:26:07 +08:00
|
|
|
import Notice from '@/components/Notice'
|
2023-11-28 20:33:38 +08:00
|
|
|
|
|
|
|
|
export default {
|
2024-07-08 16:26:03 +08:00
|
|
|
name: 'App',
|
2024-07-09 08:26:07 +08:00
|
|
|
components: { ThemePicker, Notice },
|
2023-11-28 20:33:38 +08:00
|
|
|
metaInfo() {
|
|
|
|
|
return {
|
2024-07-08 16:26:03 +08:00
|
|
|
title:
|
|
|
|
|
this.$store.state.settings.dynamicTitle &&
|
|
|
|
|
this.$store.state.settings.title,
|
|
|
|
|
titleTemplate: (title) => {
|
|
|
|
|
return title
|
|
|
|
|
? `${title} - ${process.env.VUE_APP_TITLE}`
|
|
|
|
|
: process.env.VUE_APP_TITLE
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
notifyPromise: Promise.resolve(),
|
|
|
|
|
whiteList: [
|
|
|
|
|
'/login',
|
|
|
|
|
'/register',
|
|
|
|
|
'/auth/sendCode',
|
|
|
|
|
'/qrCode/qrCodePage',
|
|
|
|
|
],
|
|
|
|
|
isWindowRefresh: false,
|
2024-07-09 08:26:07 +08:00
|
|
|
noticeDialog: {
|
|
|
|
|
outerTitle: '重要通知',
|
|
|
|
|
outerWidth: '70%',
|
|
|
|
|
outerVisible: false,
|
|
|
|
|
},
|
2023-11-28 20:33:38 +08:00
|
|
|
}
|
2024-07-08 16:26:03 +08:00
|
|
|
},
|
|
|
|
|
mounted() {
|
|
|
|
|
// window.addEventListener('beforeunload', this.handleBeforeUnload)
|
|
|
|
|
// if (this.isWindowRefresh) {
|
|
|
|
|
// this.getHomeNoticeFun()
|
|
|
|
|
// }
|
2024-07-09 08:26:07 +08:00
|
|
|
// this.noticeDialog.outerVisible = true
|
2024-07-08 16:26:03 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
updated() {
|
|
|
|
|
// if (!this.isWindowRefresh) {
|
|
|
|
|
// this.getHomeNoticeFun()
|
|
|
|
|
// }
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
|
async getHomeNoticeFun() {
|
|
|
|
|
const urlHref = window.location.href
|
|
|
|
|
const isWhite = this.whiteList.some((e) => urlHref.indexOf(e) > 1)
|
|
|
|
|
|
|
|
|
|
if (isWhite) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
const res = await getHomeNoticeApi()
|
|
|
|
|
if (res.code == 200) {
|
|
|
|
|
res.data.forEach((item) => {
|
|
|
|
|
this.notifyPromise = this.notifyPromise.then(() => {
|
|
|
|
|
this.$notify({
|
|
|
|
|
title: `通知公告`,
|
|
|
|
|
dangerouslyUseHTMLString: true,
|
|
|
|
|
message: `${item.noticeContent}`,
|
|
|
|
|
duration: 0,
|
|
|
|
|
onClose: async () => {
|
|
|
|
|
const params = {
|
|
|
|
|
noticeId: item.noticeId,
|
|
|
|
|
userId: sessionStorage.getItem('userId'),
|
|
|
|
|
}
|
|
|
|
|
const res = await setQueryNoticeApi(params)
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
2023-11-28 20:33:38 +08:00
|
|
|
</script>
|
2024-07-08 16:26:03 +08:00
|
|
|
<style scoped >
|
2023-11-28 20:33:38 +08:00
|
|
|
#app .theme-picker {
|
2024-07-08 16:26:03 +08:00
|
|
|
display: none;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
.el-notification {
|
|
|
|
|
width: 440px;
|
|
|
|
|
}
|
|
|
|
|
.el-notification__title {
|
|
|
|
|
font-size: 18px;
|
|
|
|
|
}
|
|
|
|
|
.el-notification__content {
|
|
|
|
|
margin: 15px 0;
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
line-height: 1.5;
|
2023-11-28 20:33:38 +08:00
|
|
|
}
|
|
|
|
|
</style>
|