feat(runtime): 即梦本机运行时 - 接入安全生成闭环与桌面本机渠道
Refs #225 Co-authored-by: zkhyww <127009345+zkhyww@users.noreply.github.com>
This commit is contained in:
19
web/src/services/generation-consumer-dedupe.ts
Normal file
19
web/src/services/generation-consumer-dedupe.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
export type GenerationEffectStamped = {
|
||||
generationEffectKeys?: string[];
|
||||
};
|
||||
|
||||
export function generationEffectApplied(target: GenerationEffectStamped, effectKey: string | undefined): boolean {
|
||||
return Boolean(effectKey && target.generationEffectKeys?.includes(effectKey));
|
||||
}
|
||||
|
||||
export function applyGenerationConsumerEffect<T extends GenerationEffectStamped>(target: T, effectKey: string, apply: (current: T) => T): { value: T; applied: boolean } {
|
||||
if (generationEffectApplied(target, effectKey)) return { value: target, applied: false };
|
||||
const value = apply(target);
|
||||
return {
|
||||
value: {
|
||||
...value,
|
||||
generationEffectKeys: [...new Set([...(value.generationEffectKeys || []), effectKey])],
|
||||
},
|
||||
applied: true,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user