2026-04-24 16:16:54 +08:00
|
|
|
import axios from 'axios'
|
|
|
|
|
|
|
|
|
|
const updateClient = axios.create({
|
2026-04-27 17:18:56 +08:00
|
|
|
baseURL: 'https://dev.xuqinmin.com',
|
2026-04-24 16:16:54 +08:00
|
|
|
timeout: 30000,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
updateClient.interceptors.request.use((config) => {
|
|
|
|
|
const token = localStorage.getItem('token')
|
|
|
|
|
if (token) config.headers.Authorization = `Bearer ${token}`
|
|
|
|
|
return config
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
export interface AppVersion {
|
|
|
|
|
id: string
|
|
|
|
|
appId: string
|
|
|
|
|
platform: 'ANDROID' | 'IOS'
|
|
|
|
|
versionName: string
|
|
|
|
|
versionCode: number
|
|
|
|
|
downloadUrl?: string
|
|
|
|
|
changeLog?: string
|
|
|
|
|
forceUpdate: boolean
|
|
|
|
|
publishStatus: 'DRAFT' | 'PUBLISHED' | 'DEPRECATED'
|
|
|
|
|
grayEnabled: boolean
|
|
|
|
|
grayPercent: number
|
|
|
|
|
appStoreUrl?: string
|
|
|
|
|
marketUrl?: string
|
|
|
|
|
createdAt: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface RnBundle {
|
|
|
|
|
id: string
|
|
|
|
|
appId: string
|
|
|
|
|
moduleId: string
|
|
|
|
|
platform: 'ANDROID' | 'IOS'
|
|
|
|
|
version: string
|
|
|
|
|
md5: string
|
|
|
|
|
minCommonVersion?: string
|
|
|
|
|
note?: string
|
|
|
|
|
publishStatus: 'DRAFT' | 'PUBLISHED' | 'DEPRECATED'
|
|
|
|
|
grayEnabled: boolean
|
|
|
|
|
grayPercent: number
|
|
|
|
|
createdAt: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const updateAdminApi = {
|
|
|
|
|
listAppVersions(appId: string, platform: 'ANDROID' | 'IOS') {
|
|
|
|
|
return updateClient.get<{ data: AppVersion[] }>('/api/v1/updates/app/list', {
|
|
|
|
|
params: { appId, platform },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
publishAppVersion(id: string) {
|
|
|
|
|
return updateClient.post(`/api/v1/updates/app/${id}/publish`)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
unpublishAppVersion(id: string) {
|
|
|
|
|
return updateClient.post(`/api/v1/updates/app/${id}/unpublish`)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
grayAppVersion(id: string, enabled: boolean, percent: number) {
|
|
|
|
|
return updateClient.post(`/api/v1/updates/app/${id}/gray`, { enabled, percent })
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
uploadAppVersion(formData: FormData) {
|
|
|
|
|
return updateClient.post<{ data: AppVersion }>('/api/v1/updates/app/upload', formData, {
|
|
|
|
|
headers: { 'Content-Type': 'multipart/form-data' },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
listRnBundles(appId: string, moduleId?: string, platform?: string) {
|
|
|
|
|
return updateClient.get<{ data: RnBundle[] }>('/api/v1/rn/list', {
|
|
|
|
|
params: { appId, ...(moduleId && { moduleId }), ...(platform && { platform }) },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
publishRnBundle(id: string) {
|
|
|
|
|
return updateClient.post(`/api/v1/rn/${id}/publish`)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
unpublishRnBundle(id: string) {
|
|
|
|
|
return updateClient.post(`/api/v1/rn/${id}/unpublish`)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
grayRnBundle(id: string, enabled: boolean, percent: number) {
|
|
|
|
|
return updateClient.post(`/api/v1/rn/${id}/gray`, { enabled, percent })
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
uploadRnBundle(formData: FormData) {
|
|
|
|
|
return updateClient.post<{ data: RnBundle }>('/api/v1/rn/upload', formData, {
|
|
|
|
|
headers: { 'Content-Type': 'multipart/form-data' },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
}
|