54 行
1.4 KiB
TypeScript
54 行
1.4 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
|
||
|
|
secretKey: string
|
||
|
|
createdAt: string
|
||
|
|
}
|
||
|
|
|
||
|
|
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`),
|
||
|
|
|
||
|
|
toggleService: (appId: string, platform: string, serviceType: string, enable: boolean) =>
|
||
|
|
client.post<{ data: FeatureService }>(`/apps/${appId}/services/toggle`, null, {
|
||
|
|
params: { platform, serviceType, enable },
|
||
|
|
}),
|
||
|
|
|
||
|
|
regenerateKey: (appId: string, serviceId: string) =>
|
||
|
|
client.post<{ data: FeatureService }>(`/apps/${appId}/services/${serviceId}/regenerate-key`),
|
||
|
|
}
|