diff --git a/frontend/components.d.ts b/frontend/components.d.ts index f86d08a..afebaeb 100644 --- a/frontend/components.d.ts +++ b/frontend/components.d.ts @@ -54,6 +54,7 @@ declare module 'vue' { ElInput: typeof import('element-plus/es')['ElInput'] ElLink: typeof import('element-plus/es')['ElLink'] ElOption: typeof import('element-plus/es')['ElOption'] + ElPagination: typeof import('element-plus/es')['ElPagination'] ElPopover: typeof import('element-plus/es')['ElPopover'] ElProgress: typeof import('element-plus/es')['ElProgress'] ElRow: typeof import('element-plus/es')['ElRow'] diff --git a/frontend/src/components/taskbar/MessageCenterPop.vue b/frontend/src/components/taskbar/MessageCenterPop.vue index 7f9f442..2197b33 100644 --- a/frontend/src/components/taskbar/MessageCenterPop.vue +++ b/frontend/src/components/taskbar/MessageCenterPop.vue @@ -3,44 +3,60 @@
- 共{{ notifyGroup.length }}条提醒 - × + 共{{ store.page.total }}条通知
-
-
+
+
{{ notify.title }}
-
- {{ notify.content }} -
+ + +
+ +
+
+

发布时间: {{ newsDetail.showtime }}

+
+
\ No newline at end of file diff --git a/frontend/src/stores/notify.ts b/frontend/src/stores/notify.ts new file mode 100644 index 0000000..a1643f5 --- /dev/null +++ b/frontend/src/stores/notify.ts @@ -0,0 +1,40 @@ +import { defineStore } from "pinia"; +import { ref } from "vue"; +import { getSystemConfig,fetchGet } from "@/system/config"; +export const useNotifyStore = defineStore('notifyStore', () => { + const config = getSystemConfig(); + const notifyList:any = ref([]); + const page = ref({ + current: 1, + size: 10, + total: 0, + pages: 0, + }) + async function getList(){ + if(config.userType == 'person'){ + return + } + const complition = await fetchGet(config.userInfo.url + '/news/list?page=' + page.value.current + '&limit='+ page.value.size) + if(!complition.ok){ + return; + } + const data = await complition.json(); + if(data.success){ + page.value.total = data.data.total; + notifyList.value = data.data.list; + page.value.pages = Math.ceil(page.value.total / page.value.size) + } + + } + const pageClick = async (pageNum: any) => { + //console.log(pageNum) + page.value.current = pageNum + await getList() + } + return { + notifyList, + getList, + page, + pageClick + } +}) \ No newline at end of file diff --git a/frontend/src/system/notification/Notification.ts b/frontend/src/system/notification/Notification.ts index 6c0c6da..6aa21b3 100644 --- a/frontend/src/system/notification/Notification.ts +++ b/frontend/src/system/notification/Notification.ts @@ -20,27 +20,27 @@ export class Notify { this.close(); }, option.timeout || 5000); - // // 检查浏览器是否支持通知 - // if ('Notification' in window) { - // // 请求通知权限 - // Notification.requestPermission().then(function (permission) { - // if (permission === 'granted') { - // // 创建通知 - // const notification = new Notification(option.title, { - // body: option.content, - // }); + // 检查浏览器是否支持通知 + if ('Notification' in window) { + // 请求通知权限 + Notification.requestPermission().then(function (permission) { + if (permission === 'granted') { + // 创建通知 + const notification = new Notification(option.title, { + body: option.content, + }); - // // 点击通知时触发的事件 - // notification.onclick = function () { - // // console.log('通知被点击了'); - // }; - // } else { - // // console.warn('用户拒绝了通知权限'); - // } - // }); - // } else { - // // console.error('浏览器不支持通知'); - // } + // 点击通知时触发的事件 + notification.onclick = function () { + // console.log('通知被点击了'); + }; + } else { + // console.warn('用户拒绝了通知权限'); + } + }); + } else { + // console.error('浏览器不支持通知'); + } } close() { const sys = useSystem();