feat: 完成前端业务闭环与后端联调
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { hasRemoteConfig } from '@/utils/runtime-config.js'
|
||||
import {
|
||||
normalizeNotificationDetail,
|
||||
normalizeNotifications
|
||||
@@ -9,17 +8,8 @@ import {
|
||||
requestStrict
|
||||
} from './request-client.js'
|
||||
|
||||
const requireRemoteNotifications = (label, operation = '读取') => {
|
||||
if (hasRemoteConfig()) return
|
||||
throw createRequestError(
|
||||
`${label}${operation}需要真实服务,当前本地预览不会伪造结果`,
|
||||
operation === '读取' ? 'REMOTE_READ_REQUIRED' : 'REMOTE_WRITE_REQUIRED'
|
||||
)
|
||||
}
|
||||
|
||||
export const notificationApi = {
|
||||
async getNotifications(requestOptions = {}) {
|
||||
requireRemoteNotifications('消息通知')
|
||||
const notificationRows = await requestStrict({
|
||||
url: '/genealogy/app/notifications',
|
||||
method: 'GET'
|
||||
@@ -31,7 +21,6 @@ export const notificationApi = {
|
||||
|
||||
async getNotificationDetail(notificationId, requestOptions = {}) {
|
||||
const normalizedNotificationId = normalizeResourcePathId(notificationId, '通知标识')
|
||||
requireRemoteNotifications('通知详情')
|
||||
const notificationDetail = await requestStrict({
|
||||
url: `/genealogy/app/notifications/${normalizedNotificationId}`,
|
||||
method: 'GET'
|
||||
@@ -42,7 +31,6 @@ export const notificationApi = {
|
||||
},
|
||||
|
||||
async getUnreadNotificationCount(requestOptions = {}) {
|
||||
requireRemoteNotifications('未读通知数量')
|
||||
const unreadCount = await requestStrict({
|
||||
url: '/genealogy/app/notifications/unread-count',
|
||||
method: 'GET'
|
||||
@@ -57,7 +45,6 @@ export const notificationApi = {
|
||||
|
||||
async markNotificationRead(notificationId, requestOptions = {}) {
|
||||
const normalizedNotificationId = normalizeResourcePathId(notificationId, '通知标识')
|
||||
requireRemoteNotifications('通知已读状态', '写入')
|
||||
await requestStrict({
|
||||
url: `/genealogy/app/notifications/${normalizedNotificationId}/read`,
|
||||
method: 'POST'
|
||||
@@ -69,7 +56,6 @@ export const notificationApi = {
|
||||
},
|
||||
|
||||
async markAllNotificationsRead(requestOptions = {}) {
|
||||
requireRemoteNotifications('全部通知已读状态', '写入')
|
||||
await requestStrict({
|
||||
url: '/genealogy/app/notifications/read-all',
|
||||
method: 'POST'
|
||||
|
||||
Reference in New Issue
Block a user