XuqmGroup-Web/tenant-platform/src/api/app.ts

207 行
5.8 KiB
TypeScript

2026-04-21 22:07:29 +08:00
import client from './client'
export interface App {
id: string
tenantId: string
packageName: string
iosBundleId?: string
harmonyBundleName?: string
2026-04-21 22:07:29 +08:00
name: string
description?: string
iconUrl?: string
appKey: string
appSecret: string
createdAt: string
}
export interface CreateAppRequest {
packageName: string
iosBundleId?: string
harmonyBundleName?: string
2026-04-21 22:07:29 +08:00
name: string
description?: string
iconUrl?: string
}
export interface FeatureService {
id: string
2026-05-07 19:39:47 +08:00
appKey: string
2026-04-21 22:07:29 +08:00
platform: 'ANDROID' | 'IOS' | 'HARMONY'
2026-05-15 21:00:24 +08:00
serviceType: 'IM' | 'PUSH' | 'UPDATE' | 'LICENSE'
2026-04-21 22:07:29 +08:00
enabled: boolean
config?: string | null
2026-04-21 22:07:29 +08:00
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 type PushVendorKey = 'huawei' | 'xiaomi' | 'oppo' | 'vivo' | 'honor' | 'harmony' | 'apns'
export type PushImportance = 'MIN' | 'LOW' | 'DEFAULT' | 'HIGH' | 'MAX'
export type PushPriority = 'LOW' | 'DEFAULT' | 'HIGH'
export type PushInterruptionLevel = '' | 'passive' | 'active' | 'time-sensitive' | 'critical'
export interface XiaomiPushVendorConfig {
appId?: string
appKey?: string
appSecret?: string
}
export interface HuaweiPushVendorConfig {
appId?: string
appSecret?: string
}
export interface OppoPushVendorConfig {
appId?: string
appKey?: string
masterSecret?: string
}
export interface VivoPushVendorConfig {
appId?: string
appKey?: string
appSecret?: string
}
export interface HonorPushVendorConfig {
appId?: string
clientId?: string
clientSecret?: string
}
export interface HarmonyPushVendorConfig {
appId?: string
appSecret?: string
}
export interface ApnsPushVendorConfig {
teamId?: string
keyId?: string
bundleId?: string
privateKey?: string
sandbox?: boolean
}
export interface PushVendorsConfig {
huawei?: HuaweiPushVendorConfig
xiaomi?: XiaomiPushVendorConfig
oppo?: OppoPushVendorConfig
vivo?: VivoPushVendorConfig
honor?: HonorPushVendorConfig
harmony?: HarmonyPushVendorConfig
apns?: ApnsPushVendorConfig
}
export interface PushProfileConfig {
profileKey: string
vendor: PushVendorKey
routeType: string
enabled: boolean
channelId?: string
category?: string
importance?: PushImportance
priority?: PushPriority
threadIdentifier?: string
interruptionLevel?: PushInterruptionLevel
badge?: boolean
sound?: boolean
vibration?: boolean
notifyType?: number
version?: number
remark?: string
}
export interface PushServiceConfig {
schemaVersion?: number
updatedAt?: string
vendors?: PushVendorsConfig
profiles?: PushProfileConfig[]
}
2026-04-21 22:07:29 +08:00
export const appApi = {
list: () => client.get<{ data: App[] }>('/apps'),
get: (appKey: string) => client.get<{ data: App }>(`/apps/${appKey}`),
2026-04-21 22:07:29 +08:00
create: (data: CreateAppRequest) => client.post<{ data: App }>('/apps', data),
update: (appKey: string, data: CreateAppRequest) => client.put<{ data: App }>(`/apps/${appKey}`, data),
2026-04-21 22:07:29 +08:00
delete: (appKey: string) => client.delete(`/apps/${appKey}`),
2026-04-21 22:07:29 +08:00
2026-05-07 19:39:47 +08:00
getServices: (appKey: string) =>
client.get<{ data: FeatureService[] }>(`/apps/${appKey}/services`),
2026-04-21 22:07:29 +08:00
2026-05-07 19:39:47 +08:00
getService: async (appKey: string, platform: string, serviceType: string) => {
const res = await client.get<{ data: FeatureService[] }>(`/apps/${appKey}/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 } }
},
2026-05-07 19:39:47 +08:00
toggleService: (appKey: string, platform: string, serviceType: string, enable: boolean) =>
client.post<{ data: FeatureService }>(`/apps/${appKey}/services/toggle`, null, {
2026-04-21 22:07:29 +08:00
params: { platform, serviceType, enable },
}),
updateServiceConfig: (
2026-05-07 19:39:47 +08:00
appKey: string,
platform: string,
serviceType: string,
config: Partial<ImServiceConfig> & Partial<UpdateServiceConfig> & Partial<PushServiceConfig> | Record<string, unknown>,
) =>
2026-05-07 19:39:47 +08:00
client.put<{ data: FeatureService }>(`/apps/${appKey}/services/config`, config, {
params: { platform, serviceType },
}),
2026-05-07 19:39:47 +08:00
requestSecretVerify: (appKey: string, purpose: 'REVEAL_SECRET' | 'RESET_SECRET') =>
client.post<{ data: null }>(`/apps/${appKey}/request-secret-verify`, null, {
params: { purpose },
}),
2026-05-07 19:39:47 +08:00
revealSecret: (appKey: string, code: string) =>
client.post<{ data: { appSecret: string } }>(`/apps/${appKey}/reveal-secret`, { code }),
2026-05-07 19:39:47 +08:00
resetSecret: (appKey: string, code: string) =>
client.post<{ data: { appSecret: string } }>(`/apps/${appKey}/reset-secret`, { code }),
2026-05-15 21:00:24 +08:00
downloadLicenseFile: (appKey: string) =>
client.get<Blob>(`/apps/${appKey}/license-file`, { responseType: 'blob' }),
requestActivation: (appKey: string, serviceType: 'IM' | 'PUSH' | 'UPDATE' | 'LICENSE', reason: string) =>
client.post<{ data: null }>(`/apps/${appKey}/services/request-activation`, null, {
params: { platform: 'ANDROID', serviceType, applyReason: reason },
}),
2026-04-21 22:07:29 +08:00
}