diff --git a/src/layout/components/lay-notice/data.ts b/src/layout/components/lay-notice/data.ts index ec0213a..36de185 100644 --- a/src/layout/components/lay-notice/data.ts +++ b/src/layout/components/lay-notice/data.ts @@ -34,10 +34,12 @@ export const getAllMessageList = async () => { .filter(message => message.messageType === 'notifications') .map(message => ({ cover: message.cover, - description: message.summary, title: message.title, datetime: message.createTime, + description: message.summary, type: '1', + status: message.statusType, + extra: message.extra, })) as ListItem[]; // 消息 @@ -49,6 +51,8 @@ export const getAllMessageList = async () => { title: message.title, datetime: message.createTime, type: '2', + status: message.statusType, + extra: message.extra, })) as ListItem[]; // 系统消息 @@ -60,6 +64,8 @@ export const getAllMessageList = async () => { title: message.title, datetime: message.createTime, type: '3', + status: message.statusType, + extra: message.extra, })) as ListItem[]; noticesData.value = [ diff --git a/src/layout/components/lay-notice/index.vue b/src/layout/components/lay-notice/index.vue index e2d0866..ba9a443 100644 --- a/src/layout/components/lay-notice/index.vue +++ b/src/layout/components/lay-notice/index.vue @@ -4,23 +4,33 @@ import { computed, onMounted, ref } from 'vue'; import { getAllMessageList, noticesData } from './data'; import NoticeList from './components/NoticeList.vue'; import BellIcon from '@iconify-icons/ep/bell'; +import { useIntervalFn } from '@vueuse/core'; const { t } = useI18n(); -const noticesNum = ref(0); // 通知消息数据 +const noticesNum = ref(0); const notices = ref(noticesData); // 选择的消息栏目 const activeKey = ref(noticesData.value[0]?.key); - const getLabel = computed(() => item => item.name + (item.list.length > 0 ? `(${item.list.length})` : '')); -onMounted(async () => { +/** 计算消息数量 */ +const computedNoticesNum = async () => { // 获取所有的消息 await getAllMessageList(); + // 请求成功后将原本条数置为0 + noticesNum.value = 0; // 整合消息一共多少条 notices.value.map(v => (noticesNum.value += v.list.length)); // 默认选中的消息类别 activeKey.value = noticesData.value[0]?.key; + // 定时刷新 +}; + +onMounted(() => { + computedNoticesNum(); + // 定时刷新消息内容 + useIntervalFn(() => computedNoticesNum(), 1000 * 30); }); diff --git a/src/layout/components/lay-panel/index.vue b/src/layout/components/lay-panel/index.vue index fb4fb20..b533fac 100644 --- a/src/layout/components/lay-panel/index.vue +++ b/src/layout/components/lay-panel/index.vue @@ -1,149 +1,139 @@ - diff --git a/src/views/messageManagement/messageEditing/message-editor-from.vue b/src/views/messageManagement/messageEditing/message-editor-from.vue index 3098105..48866a9 100644 --- a/src/views/messageManagement/messageEditing/message-editor-from.vue +++ b/src/views/messageManagement/messageEditing/message-editor-from.vue @@ -1,36 +1,24 @@