| | |
| | | </el-dialog> |
| | | </div> |
| | | <div class="notice" v-if="!isSharePage"> |
| | | <el-badge :value="`${state.announcementList.length}`"> |
| | | <el-badge :value="`${state.announcementList.length}`" :hidden="announcementIsRead || state.announcementList?.length === 0"> |
| | | <el-button link size="small" icon="ele-Message" class="set-notice" @click="handleAnnouncementClick">系统公告</el-button> |
| | | </el-badge> |
| | | <div class="notice_box notice_box_show" v-show="state.isShowAnnouncement" ref="noticeRef"> |
| | |
| | | import { storeToRefs } from 'pinia'; |
| | | import pinia from '/@/stores'; |
| | | import { useThemeConfig } from '/@/stores/themeConfig'; |
| | | import { Local } from '/@/utils/storage'; |
| | | import { userInfoKey } from '/@/utils/request'; |
| | | const props = defineProps(['sidebarIsShow']); |
| | | let state = reactive({ |
| | | isShowAnnouncement: false, |
| | |
| | | announcementContent: '', |
| | | announcementTime: '', |
| | | }); |
| | | //#region ====================== 公告是否看过 ====================== |
| | | const userInfo = ref(Local.get(userInfoKey)); |
| | | const readKey = `announcementIsRead_${userInfo.value?.id}`; |
| | | const getIsRead = () => { |
| | | if (!userInfo.value?.id) return false; |
| | | const isRead = Local.get(readKey) ?? false; |
| | | return isRead; |
| | | }; |
| | | |
| | | const setRead = (isRead: boolean) => { |
| | | if (!userInfo.value?.id) return; |
| | | announcementIsRead.value = isRead; |
| | | Local.set(readKey, isRead); |
| | | }; |
| | | const announcementIsRead = ref(getIsRead()); |
| | | |
| | | //#endregion |
| | | const noticeRef = ref(null); |
| | | const getSystemNotify = async () => { |
| | | const res = await systemNotifyList(); |
| | |
| | | |
| | | const handleAnnouncementClick = () => { |
| | | state.isShowAnnouncement = !state.isShowAnnouncement; |
| | | if (!announcementIsRead.value && state.isShowAnnouncement) { |
| | | setRead(true); |
| | | } |
| | | }; |
| | | |
| | | const goBack = () => { |