fix: 系统公告与尊享额度明细

This commit is contained in:
Gsh
2025-11-12 23:08:52 +08:00
parent eecdf442fb
commit d21f61646a
15 changed files with 2739 additions and 1628 deletions

View File

@@ -1,28 +1,58 @@
<script setup lang="ts">
import type { AnnouncementLogDto } from '@/api';
import { getSystemAnnouncements } from '@/api';
import SystemAnnouncementDialog from '@/components/SystemAnnouncementDialog/index.vue';
import { getMockSystemAnnouncements } from '@/data/mockAnnouncementData.ts';
import { useAnnouncementStore } from '@/stores';
const announcementStore = useAnnouncementStore();
// 模拟数据(当后端接口未就绪时使用)
const mockData: AnnouncementLogDto[] = [
{
title: 'v2.3.0',
content: [
'重大更新',
'1优化整体',
'2: 还有谁',
],
imageUrl: 'https://ccnetcore.com/prod-api/wwwroot/logo.png',
startTime: '2025-11-10 14:58:58',
endTime: null,
type: 'System',
},
{
title: 'KFC翻牌活动',
content: [
'666',
'777',
'2: 还有谁',
],
imageUrl: 'https://ccnetcore.com/prod-api/wwwroot/logo.png',
startTime: '2025-11-10 14:58:58',
endTime: '2025-11-15 14:59:49',
type: 'Activity',
},
];
// 应用加载时检查是否需要显示公告弹窗
onMounted(async () => {
console.log('announcementStore.shouldShowDialog--', announcementStore.shouldShowDialog);
// 检查是否应该显示弹窗
if (announcementStore.shouldShowDialog) {
try {
// 获取公告数据
// const res = await getSystemAnnouncements();
// 使用模拟数据进行测试
const res = await getMockSystemAnnouncements();
if (res.data) {
const res = await getSystemAnnouncements();
if (res && res.data && Array.isArray(res.data) && res.data.length > 0) {
announcementStore.setAnnouncementData(res.data);
// 显示弹窗
announcementStore.openDialog();
}
}
catch (error) {
console.error('获取系统公告失败:', error);
// 静默失败,不影响用户体验
console.error('获取系统公告失败,使用模拟数据:', error);
// 使用模拟数据作为降级方案
announcementStore.setAnnouncementData(mockData);
announcementStore.openDialog();
}
}
});