diff --git a/client/src/api/notification.ts b/client/src/api/notification.ts index d4542f4..f8d9f51 100644 --- a/client/src/api/notification.ts +++ b/client/src/api/notification.ts @@ -9,6 +9,12 @@ export interface Notification { is_read: number created_at: string group_id?: number | null + is_pinned?: number + is_urgent?: number + publish_at?: string | null + expire_at?: string | null + image_url?: string + link_url?: string } /** 通知列表响应 */ @@ -19,11 +25,30 @@ export interface NotificationList { pageSize: number } +/** 发布公告参数 */ +export interface PublishParams { + title: string + content?: string + type?: 'system' | 'group' | 'personal' + group_id?: number + is_pinned?: boolean + is_urgent?: boolean + publish_at?: string + expire_at?: string + image_url?: string + link_url?: string +} + /** 获取通知列表 */ export function getNotifications(params?: { type?: string; page?: number; pageSize?: number }) { return request({ url: '/notifications', data: params }) } +/** 获取置顶/强提醒公告 */ +export function getPinnedNotifications() { + return request({ url: '/notifications/pinned' }) +} + /** 获取未读数量 */ export function getUnreadCount() { return request<{ count: number }>({ url: '/notifications/unread-count' }) @@ -39,7 +64,17 @@ export function markAllRead() { return request({ url: '/notifications/read-all', method: 'PUT' }) } -/** 发布系统公告(管理员) */ -export function publishNotification(data: { title: string; content?: string }) { - return request({ url: '/notifications', method: 'POST', data }) +/** 发布公告 */ +export function publishNotification(data: PublishParams) { + return request<{ id: number }>({ url: '/notifications', method: 'POST', data }) +} + +/** 编辑公告 */ +export function updateNotification(id: number, data: Partial) { + return request({ url: `/notifications/${id}`, method: 'PUT', data }) +} + +/** 删除公告 */ +export function deleteNotification(id: number) { + return request({ url: `/notifications/${id}`, method: 'DELETE' }) } diff --git a/client/src/components/Numpad/Numpad.vue b/client/src/components/Numpad/Numpad.vue index 937cac6..588397d 100644 --- a/client/src/components/Numpad/Numpad.vue +++ b/client/src/components/Numpad/Numpad.vue @@ -52,7 +52,7 @@ function onKeyTap(key: string) { if (key === '.') { if (current.includes('.')) return - if (!current) { emitValue('0.'); return } + if (!current || current === '0') { emitValue('0.'); return } } let next: string diff --git a/client/src/pages/add/index.vue b/client/src/pages/add/index.vue index def4e9d..37aed76 100644 --- a/client/src/pages/add/index.vue +++ b/client/src/pages/add/index.vue @@ -149,11 +149,13 @@ onMounted(async () => { if (currentCategories.value.length > 0 && !selectedCat.value) { selectedCat.value = currentCategories.value[0].id } + initialLoaded.value = true }) // 返回页面时刷新分类(可能新增了分类) +const initialLoaded = ref(false) onShow(() => { - catStore.fetchCategories() + if (initialLoaded.value) catStore.fetchCategories() }) function onDateChange(e: any) { diff --git a/client/src/pages/admin/index.vue b/client/src/pages/admin/index.vue index 8f6c264..6f4a4b9 100644 --- a/client/src/pages/admin/index.vue +++ b/client/src/pages/admin/index.vue @@ -70,6 +70,74 @@ + + + + + + 发布公告 + + × + + + + + 标题 * + + + + 内容 +