import i18next from 'i18next'; // Preserve settings unknown to this version of the channel form. export function mergeChannelSettings(raw, edits, channelType, mode) { const saved = raw ? JSON.parse(raw) : {}; if (!saved || Array.isArray(saved) || typeof saved !== 'object') { throw new Error(i18next.t('渠道 setting 必须是 JSON 对象')); } const next = { ...saved, ...edits }; if (channelType === 62) { const normalized = mode === undefined || mode === '' ? 'legacy' : mode; if (!['legacy', 'omit'].includes(normalized)) { throw new Error(i18next.t('百度真人 Header 模式必须是 legacy 或 omit')); } next.baidu_liveness_header_mode = normalized; } return JSON.stringify(next); }