fix: 系统公告弹窗前端
This commit is contained in:
@@ -1,9 +1,37 @@
|
||||
<script setup lang="ts">
|
||||
import SystemAnnouncementDialog from '@/components/SystemAnnouncementDialog/index.vue';
|
||||
import { getMockSystemAnnouncements } from '@/data/mockAnnouncementData.ts';
|
||||
import { useAnnouncementStore } from '@/stores';
|
||||
|
||||
const announcementStore = useAnnouncementStore();
|
||||
|
||||
// 应用加载时检查是否需要显示公告弹窗
|
||||
onMounted(async () => {
|
||||
// 检查是否应该显示弹窗
|
||||
if (announcementStore.shouldShowDialog) {
|
||||
try {
|
||||
// 获取公告数据
|
||||
// const res = await getSystemAnnouncements();
|
||||
// 使用模拟数据进行测试
|
||||
const res = await getMockSystemAnnouncements();
|
||||
if (res.data) {
|
||||
announcementStore.setAnnouncementData(res.data);
|
||||
// 显示弹窗
|
||||
announcementStore.openDialog();
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
console.error('获取系统公告失败:', error);
|
||||
// 静默失败,不影响用户体验
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<router-view />
|
||||
<!-- 系统公告弹窗 -->
|
||||
<SystemAnnouncementDialog />
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
|
||||
Reference in New Issue
Block a user