packageName 字段由租户在推送配置页维护,对应 Xiaomi MiPush restricted_package_name,服务端凭此正确路由推送。 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
159 行
4.5 KiB
TypeScript
159 行
4.5 KiB
TypeScript
import client from './client'
|
|
|
|
export interface App {
|
|
id: string
|
|
tenantId: string
|
|
packageName: string
|
|
name: string
|
|
description?: string
|
|
iconUrl?: string
|
|
appKey: string
|
|
appSecret: string
|
|
createdAt: string
|
|
}
|
|
|
|
export interface CreateAppRequest {
|
|
packageName: string
|
|
name: string
|
|
description?: string
|
|
iconUrl?: string
|
|
}
|
|
|
|
export interface FeatureService {
|
|
id: string
|
|
appId: string
|
|
platform: 'ANDROID' | 'IOS' | 'HARMONY'
|
|
serviceType: 'IM' | 'PUSH' | 'UPDATE'
|
|
enabled: boolean
|
|
config?: string | null
|
|
createdAt: string
|
|
}
|
|
|
|
export interface ImServiceConfig {
|
|
allowStrangerMessage: boolean
|
|
allowFriendRequest: boolean
|
|
friendRequestMode: 'REQUIRE_CONFIRM' | 'DIRECT_ACCEPT' | 'DISALLOW'
|
|
allowGroupJoinRequest: boolean
|
|
blacklistSendSuccess: boolean
|
|
messageRecallMinutes: number
|
|
historyRetentionDays: number
|
|
conversationPullLimit: number
|
|
multiClientConversationDeleteSync: boolean
|
|
multiDeviceLoginMode?: 'MULTI_DEVICE_FREE' | 'SAME_PLATFORM_ONE' | 'SINGLE_DEVICE'
|
|
}
|
|
|
|
export interface UpdateServiceConfig {
|
|
defaultStoreTargets?: string[]
|
|
defaultPublishMode?: 'MANUAL' | 'NOW' | 'SCHEDULED' | 'AUTO_REVIEW'
|
|
defaultPublishImmediately?: boolean
|
|
defaultScheduledPublishAt?: string
|
|
defaultAutoPublishAfterReview?: boolean
|
|
defaultWebhookUrl?: string
|
|
defaultForceUpdate?: boolean
|
|
defaultGrayEnabled?: boolean
|
|
defaultGrayPercent?: number
|
|
defaultPackageName?: string
|
|
defaultAppStoreUrl?: string
|
|
defaultMarketUrl?: string
|
|
}
|
|
|
|
export interface PushVendorConfig {
|
|
appId?: string
|
|
appKey?: string
|
|
appSecret?: string
|
|
packageName?: string
|
|
masterSecret?: string
|
|
clientId?: string
|
|
clientSecret?: string
|
|
teamId?: string
|
|
keyId?: string
|
|
bundleId?: string
|
|
keyPath?: string
|
|
sandbox?: boolean
|
|
serviceAccountJson?: string
|
|
}
|
|
|
|
export interface PushServiceConfig {
|
|
huawei?: PushVendorConfig
|
|
xiaomi?: PushVendorConfig
|
|
oppo?: PushVendorConfig
|
|
vivo?: PushVendorConfig
|
|
honor?: PushVendorConfig
|
|
harmony?: PushVendorConfig
|
|
apns?: PushVendorConfig
|
|
fcm?: PushVendorConfig
|
|
channels?: PushNotificationChannelConfig[]
|
|
routing?: Record<string, PushNotificationRouteConfig>
|
|
}
|
|
|
|
export interface PushNotificationChannelConfig {
|
|
key: string
|
|
channelId: string
|
|
version: number
|
|
name: string
|
|
description?: string
|
|
importance: 'MIN' | 'LOW' | 'DEFAULT' | 'HIGH' | 'MAX'
|
|
sound: boolean
|
|
vibration: boolean
|
|
badge: boolean
|
|
}
|
|
|
|
export interface PushNotificationRouteConfig {
|
|
channel: string
|
|
category: string
|
|
priority: 'LOW' | 'DEFAULT' | 'HIGH'
|
|
}
|
|
|
|
export const appApi = {
|
|
list: () => client.get<{ data: App[] }>('/apps'),
|
|
|
|
get: (id: string) => client.get<{ data: App }>(`/apps/${id}`),
|
|
|
|
create: (data: CreateAppRequest) => client.post<{ data: App }>('/apps', data),
|
|
|
|
update: (id: string, data: CreateAppRequest) => client.put<{ data: App }>(`/apps/${id}`, data),
|
|
|
|
delete: (id: string) => client.delete(`/apps/${id}`),
|
|
|
|
getServices: (appId: string) =>
|
|
client.get<{ data: FeatureService[] }>(`/apps/${appId}/services`),
|
|
|
|
getService: async (appId: string, platform: string, serviceType: string) => {
|
|
const res = await client.get<{ data: FeatureService[] }>(`/apps/${appId}/services`)
|
|
const service = res.data.data.find(item => item.platform === platform && item.serviceType === serviceType)
|
|
if (!service) {
|
|
throw new Error('服务不存在')
|
|
}
|
|
return {
|
|
...res,
|
|
data: { data: service },
|
|
} as typeof res & { data: { data: FeatureService } }
|
|
},
|
|
|
|
toggleService: (appId: string, platform: string, serviceType: string, enable: boolean) =>
|
|
client.post<{ data: FeatureService }>(`/apps/${appId}/services/toggle`, null, {
|
|
params: { platform, serviceType, enable },
|
|
}),
|
|
|
|
updateServiceConfig: (
|
|
appId: string,
|
|
platform: string,
|
|
serviceType: string,
|
|
config: Partial<ImServiceConfig> & Partial<UpdateServiceConfig> & Partial<PushServiceConfig> | Record<string, unknown>,
|
|
) =>
|
|
client.put<{ data: FeatureService }>(`/apps/${appId}/services/config`, config, {
|
|
params: { platform, serviceType },
|
|
}),
|
|
|
|
requestSecretVerify: (appId: string, purpose: 'REVEAL_SECRET' | 'RESET_SECRET') =>
|
|
client.post<{ data: null }>(`/apps/${appId}/request-secret-verify`, null, {
|
|
params: { purpose },
|
|
}),
|
|
|
|
revealSecret: (appId: string, code: string) =>
|
|
client.post<{ data: { appSecret: string } }>(`/apps/${appId}/reveal-secret`, { code }),
|
|
|
|
resetSecret: (appId: string, code: string) =>
|
|
client.post<{ data: { appSecret: string } }>(`/apps/${appId}/reset-secret`, { code }),
|
|
}
|