refactor(common-config): consolidate hasContent methods into adapters

- Add hasContent method to CommonConfigAdapter interface
- Move isSubset utility to configMerge.ts for reuse
- Export preserveCodexConfigFormat from adapters for hook use
- Add hasContentByAppType dispatcher for unified content detection
- Remove dead code from providerConfigUtils (hasCommonConfigSnippet,
  hasTomlCommonConfigSnippet, hasGeminiCommonConfigSnippet)
This commit is contained in:
YoVinchen
2026-01-31 15:23:49 +08:00
parent 580b32dd67
commit d66f196378
6 changed files with 196 additions and 173 deletions
+20
View File
@@ -62,6 +62,26 @@ export const deepEqual = (a: unknown, b: unknown): boolean => {
return false;
};
/**
* 检查 source 是否是 target 的子集
* 即 source 中的所有键值对都存在于 target 中
*/
export const isSubset = (target: unknown, source: unknown): boolean => {
if (isPlainObject(source)) {
if (!isPlainObject(target)) return false;
return Object.entries(source).every(([key, value]) =>
isSubset(target[key], value),
);
}
if (Array.isArray(source)) {
if (!Array.isArray(target) || target.length !== source.length) return false;
return source.every((item, index) => isSubset(target[index], item));
}
return target === source;
};
// ============================================================================
// 配置合并函数
// ============================================================================