fix(push-config): 移除平台切换开关和服务状态,修复凭据保存不生效问题

- 删除"配置平台"切换 UI(Android/iOS/鸿蒙分段选择器)和推送服务开关
- 删除"服务状态"显示(页面可达即已开通,显示"未开通"逻辑有误)
- 修复厂商凭据保存:前端直接将 PushServiceConfig 作为 body,
  服务端 FeatureServiceConfigRequest 期望 pushConfig 字段包裹,
  导致 req.pushConfig() 始终为 null,vendors 从未实际写入。
  改为发送 { pushConfig: payload } 使服务端正确解析。
- loadData 改为优先选取已启用的 PUSH 服务平台

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
这个提交包含在:
XuqmGroup 2026-06-25 17:53:09 +08:00
父节点 963bd67bf7
当前提交 af552ad58e

查看文件

@ -10,17 +10,7 @@
<el-text class="mono">{{ app.appKey }}</el-text>
<el-button link @click="copy(app.appKey)"><el-icon><CopyDocument /></el-icon></el-button>
</el-descriptions-item>
<el-descriptions-item label="服务状态">
<el-tag :type="pushEnabled ? 'success' : 'info'">{{ pushEnabled ? '已开通' : '未开通' }}</el-tag>
</el-descriptions-item>
<el-descriptions-item label="配置平台">
<el-segmented v-model="selectedPlatform" :options="platformOptions" @change="applySelectedPlatformConfig" />
</el-descriptions-item>
</el-descriptions>
<div class="push-switch-row">
<el-switch :model-value="pushEnabled" @change="(val: boolean) => onTogglePushService(val)" />
<span class="hint">关闭后推送注册与推送发送都不会再向该应用开放</span>
</div>
</el-card>
<el-alert
@ -199,10 +189,10 @@
</template>
<script setup lang="ts">
import { computed, onBeforeUnmount, onMounted, reactive, ref } from 'vue'
import { onBeforeUnmount, onMounted, reactive, ref } from 'vue'
import { useRoute } from 'vue-router'
import { CopyDocument } from '@element-plus/icons-vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { ElMessage } from 'element-plus'
import {
appApi,
type App,
@ -262,12 +252,6 @@ const saving = ref(false)
const isMobile = ref(window.innerWidth < 768)
const selectedPlatform = ref<'ANDROID' | 'IOS' | 'HARMONY'>('ANDROID')
const platformOptions = [
{ label: 'Android', value: 'ANDROID' },
{ label: 'iOS', value: 'IOS' },
{ label: '鸿蒙', value: 'HARMONY' },
]
const vendorOptions: Array<{ label: string; value: PushVendorKey }> = [
{ label: '华为', value: 'huawei' },
{ label: '小米', value: 'xiaomi' },
@ -389,10 +373,6 @@ const vendorDefs: VendorDef[] = [
},
]
const pushEnabled = computed(() => services.value.some(
s => s.serviceType === 'PUSH' && s.platform === selectedPlatform.value && s.enabled,
))
function updateViewport() {
isMobile.value = window.innerWidth < 768
}
@ -516,9 +496,10 @@ async function loadData() {
])
app.value = appRes.data.data
services.value = svcRes.data.data
const firstPushService = services.value.find(s => s.serviceType === 'PUSH')
if (firstPushService && !services.value.some(s => s.serviceType === 'PUSH' && s.platform === selectedPlatform.value)) {
selectedPlatform.value = firstPushService.platform
const activePushService = services.value.find(s => s.serviceType === 'PUSH' && s.enabled)
?? services.value.find(s => s.serviceType === 'PUSH')
if (activePushService) {
selectedPlatform.value = activePushService.platform as 'ANDROID' | 'IOS' | 'HARMONY'
}
applySelectedPlatformConfig()
} finally {
@ -551,7 +532,7 @@ async function saveConfig() {
},
profiles: pushConfig.profiles.map(profile => normalizeProfile(profile)),
}
await appApi.updateServiceConfig(app.value.appKey, selectedPlatform.value, 'PUSH', payload)
await appApi.updateServiceConfig(app.value.appKey, selectedPlatform.value, 'PUSH', { pushConfig: payload })
ElMessage.success('推送配置已保存')
await loadData()
} catch {
@ -569,22 +550,6 @@ function removeProfile(index: number) {
pushConfig.profiles.splice(index, 1)
}
async function onTogglePushService(enable: boolean) {
if (enable) {
ElMessage.info('请通过服务开通流程启用推送服务')
return
}
await ElMessageBox.confirm('确认关闭离线推送服务?', '关闭服务', {
type: 'warning',
confirmButtonText: '确认关闭',
cancelButtonText: '取消',
})
if (!app.value) return
await appApi.toggleService(app.value.appKey, selectedPlatform.value, 'PUSH', false)
ElMessage.success('已关闭')
await loadData()
}
function reloadConfig() {
return loadData()
}
@ -614,14 +579,6 @@ onBeforeUnmount(() => window.removeEventListener('resize', updateViewport))
overflow-x: auto;
}
.push-switch-row {
margin-top: 12px;
display: flex;
gap: 8px;
flex-wrap: wrap;
align-items: center;
}
.vendor-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
@ -671,11 +628,6 @@ onBeforeUnmount(() => window.removeEventListener('resize', updateViewport))
grid-template-columns: 1fr;
}
.push-switch-row {
flex-direction: column;
align-items: flex-start;
}
.toolbar :deep(.el-button),
.profiles-actions :deep(.el-button) {
width: 100%;