diff --git a/src/api/system/notice.ts b/src/api/system/notice.ts index e6ba17f..a403bd8 100644 --- a/src/api/system/notice.ts +++ b/src/api/system/notice.ts @@ -1,5 +1,5 @@ import request from '@/utils/request' -import type { NoticeQueryParams, SysNotice, AjaxResult, TableDataInfo } from '@/types' +import type { NoticeQueryParams, SysNotice, SysNoticeTopResult, AjaxResult, TableDataInfo } from '@/types' // 查询公告列表 export function listNotice(query: NoticeQueryParams): Promise> { @@ -43,3 +43,29 @@ export function delNotice(noticeId: number | number[]): Promise { method: 'delete' }) } + +// 首页顶部公告列表(带已读状态) +export function listNoticeTop(): Promise { + return request({ + url: '/system/notice/listTop', + method: 'get' + }) +} + +// 标记公告已读 +export function markNoticeRead(noticeId: number): Promise { + return request({ + url: '/system/notice/markRead', + method: 'post', + params: { noticeId } + }) +} + +// 批量标记已读 +export function markNoticeReadAll(ids: string): Promise { + return request({ + url: '/system/notice/markReadAll', + method: 'post', + params: { ids } + }) +} diff --git a/src/assets/icons/svg/bell.svg b/src/assets/icons/svg/bell.svg new file mode 100644 index 0000000..a7320a0 --- /dev/null +++ b/src/assets/icons/svg/bell.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/layout/components/HeaderNotice/index.vue b/src/layout/components/HeaderNotice/index.vue new file mode 100644 index 0000000..82921b3 --- /dev/null +++ b/src/layout/components/HeaderNotice/index.vue @@ -0,0 +1,242 @@ + + + + + + + diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue index e98307d..2ce4a13 100644 --- a/src/layout/components/Navbar.vue +++ b/src/layout/components/Navbar.vue @@ -32,6 +32,10 @@ + + + + @@ -72,6 +76,7 @@ import RuoYiDoc from '@/components/RuoYi/Doc/index.vue' import useAppStore from '@/store/modules/app' import useUserStore from '@/store/modules/user' import useSettingsStore from '@/store/modules/settings' +import HeaderNotice from './HeaderNotice' const appStore = useAppStore() const userStore = useUserStore() @@ -204,11 +209,6 @@ async function toggleTheme(event?: MouseEvent): Promise { margin-left: 8px; } - .errLog-container { - display: inline-block; - vertical-align: top; - } - .right-menu { height: 100%; line-height: 50px; diff --git a/src/types/api/system/notice.ts b/src/types/api/system/notice.ts index 6506356..4d27877 100644 --- a/src/types/api/system/notice.ts +++ b/src/types/api/system/notice.ts @@ -1,4 +1,4 @@ -import type { PageDomain, BaseEntity } from "../common"; +import type { PageDomain, BaseEntity, AjaxResult } from "../common"; /** 通知公告分页查询参数 */ export interface NoticeQueryParams extends PageDomain { @@ -22,4 +22,10 @@ export interface SysNotice extends BaseEntity { noticeContent?: string; /** 状态(0正常 1停用) */ status?: '0' | '1'; + /** 是否已读 */ + isRead: boolean; +} + +export interface SysNoticeTopResult extends AjaxResult { + unreadCount: number }