修复 kuaishou-lewan 多账号健康检查与平台配置展示
恢复 health 任务对全部账号的合并监控,补齐 React 后台多账号 UI 与账号选择,并将用户可见文案统一为 kuaishou-lewan。
This commit is contained in:
@@ -170,21 +170,63 @@ function mapScheduledJobCloudtentaclesAccounts(
|
||||
cloudtentaclesAccountMap: Map<string, JsonObject>,
|
||||
) {
|
||||
const accounts = Array.isArray(rawAccounts) ? rawAccounts : []
|
||||
return accounts.map((item) => {
|
||||
const source = isPlainObject(item) ? item : {}
|
||||
const sourceKey = String(source.sourceKey || source.key || '').trim()
|
||||
const option = cloudtentaclesAccountMap.get(sourceKey) || {}
|
||||
const configuredMap = new Map(
|
||||
accounts
|
||||
.map((item) => {
|
||||
const source = isPlainObject(item) ? item : {}
|
||||
const sourceKey = String(source.sourceKey || source.key || '').trim()
|
||||
if (!sourceKey) {
|
||||
return null
|
||||
}
|
||||
|
||||
const option = cloudtentaclesAccountMap.get(sourceKey) || {}
|
||||
return [
|
||||
sourceKey,
|
||||
{
|
||||
sourceKey,
|
||||
label: String(source.label || option.label || sourceKey).trim(),
|
||||
enabled: source.enabled !== false,
|
||||
assetThreshold: normalizeNonNegativeNumber(
|
||||
source.assetThreshold ?? source.threshold,
|
||||
defaultAssetThreshold,
|
||||
),
|
||||
},
|
||||
] as const
|
||||
})
|
||||
.filter(Boolean) as Array<readonly [string, {
|
||||
sourceKey: string
|
||||
label: string
|
||||
enabled: boolean
|
||||
assetThreshold: number
|
||||
}]>,
|
||||
)
|
||||
|
||||
// 读配置时合并全部 kuaishou-lewan 账号,避免前端/任务只看到历史 default。
|
||||
const merged = Array.from(cloudtentaclesAccountMap.values()).map((option) => {
|
||||
const sourceKey = String(option.sourceKey || '').trim()
|
||||
const configured = configuredMap.get(sourceKey)
|
||||
return {
|
||||
sourceKey,
|
||||
label: String(source.label || option.label || sourceKey).trim(),
|
||||
enabled: source.enabled !== false,
|
||||
label: String(configured?.label || option.label || sourceKey).trim(),
|
||||
enabled: configured
|
||||
? configured.enabled !== false
|
||||
: option.enabled !== false,
|
||||
assetThreshold: normalizeNonNegativeNumber(
|
||||
source.assetThreshold ?? source.threshold,
|
||||
configured?.assetThreshold,
|
||||
defaultAssetThreshold,
|
||||
),
|
||||
}
|
||||
}).filter((item) => item.sourceKey)
|
||||
|
||||
const mergedKeys = new Set(merged.map((item) => item.sourceKey))
|
||||
for (const [sourceKey, configured] of configuredMap.entries()) {
|
||||
if (mergedKeys.has(sourceKey)) {
|
||||
continue
|
||||
}
|
||||
merged.push(configured)
|
||||
}
|
||||
|
||||
return merged
|
||||
}
|
||||
|
||||
function normalizeNonNegativeNumber(value: unknown, fallback: number) {
|
||||
|
||||
Reference in New Issue
Block a user