diff --git a/tenant-platform/src/api/app.ts b/tenant-platform/src/api/app.ts index fd33b6f..e095458 100644 --- a/tenant-platform/src/api/app.ts +++ b/tenant-platform/src/api/app.ts @@ -170,6 +170,11 @@ export const appApi = { } as typeof res & { data: { data: FeatureService } } }, + getServiceItem: (appKey: string, platform: string, serviceType: string) => + client.get<{ data: FeatureService }>(`/apps/${appKey}/services/item`, { + params: { platform, serviceType }, + }), + toggleService: (appKey: string, platform: string, serviceType: string, enable: boolean) => client.post<{ data: FeatureService }>(`/apps/${appKey}/services/toggle`, null, { params: { platform, serviceType, enable }, diff --git a/tenant-platform/src/views/push/PushConfigView.vue b/tenant-platform/src/views/push/PushConfigView.vue index f6d7697..7410e3b 100644 --- a/tenant-platform/src/views/push/PushConfigView.vue +++ b/tenant-platform/src/views/push/PushConfigView.vue @@ -528,17 +528,21 @@ async function loadData() { services.value = svcRes.data.data // Always default to ANDROID on load; user can switch via the platform selector selectedPlatform.value = 'ANDROID' - applySelectedPlatformConfig() + await applySelectedPlatformConfig() } finally { loading.value = false } } -function applySelectedPlatformConfig() { - const raw = services.value.find( - s => s.serviceType === 'PUSH' && s.platform === selectedPlatform.value, - )?.config - replaceState(parseConfig(raw)) +async function applySelectedPlatformConfig() { + if (!app.value) return + try { + const res = await appApi.getServiceItem(app.value.appKey, selectedPlatform.value, 'PUSH') + replaceState(parseConfig(res.data.data?.config)) + } catch { + // 该平台尚无配置,清空表单 + replaceState(parseConfig(null)) + } } function buildPayload(): PushServiceConfig {