Skip to content

Commit 39e5608

Browse files
committed
AI 配置项
1 parent 2b2a166 commit 39e5608

7 files changed

Lines changed: 1032 additions & 349 deletions

File tree

app/src/boot/onGetConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export const onGetConfig = (isStart: boolean, app: App) => {
7070
/// #if !MOBILE
7171
// 临时:启动后直接打开设置
7272
window.setTimeout(() => {
73-
openSetting(app);
73+
openSetting(app, "ai");
7474
}, 0);
7575
/// #endif
7676
} catch (e) {

app/src/config/ai.ts

Lines changed: 0 additions & 265 deletions
This file was deleted.

app/src/config/setting/builder.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ type ControlSpecBase = {
4343
desc?: string;
4444
save?: SaveFn;
4545
afterMount?: (root: HTMLElement) => void | Promise<void>;
46+
/** 省略时按控件 id 从 config 读取;嵌套 / 派生项需显式传入 */
47+
readConfig?: () => unknown;
4648
};
4749
type SwitchSpec = ControlSpecBase;
4850
type NumberSpec = ControlSpecBase & {
@@ -250,7 +252,9 @@ class SettingGroupBuilder<TId extends string> {
250252
}
251253

252254
switch(id: string, spec: SwitchSpec) {
253-
return this.registerFullItem(id, spec, controlBoolean(id));
255+
return this.registerFullItem(id, spec, controlBoolean(id, {
256+
readConfig: spec.readConfig as (() => boolean) | undefined,
257+
}));
254258
}
255259

256260
number(id: string, spec: NumberSpec) {
@@ -259,6 +263,7 @@ class SettingGroupBuilder<TId extends string> {
259263
max: spec.max,
260264
step: spec.step,
261265
unit: spec.unit,
266+
readConfig: spec.readConfig as (() => number) | undefined,
262267
}));
263268
}
264269

@@ -267,6 +272,7 @@ class SettingGroupBuilder<TId extends string> {
267272
min: spec.min,
268273
max: spec.max,
269274
step: spec.step,
275+
readConfig: spec.readConfig as (() => number) | undefined,
270276
}));
271277
}
272278

@@ -278,11 +284,16 @@ class SettingGroupBuilder<TId extends string> {
278284
}
279285

280286
text(id: string, spec: TextSpec) {
281-
return this.registerFullItem(id, spec, controlString(id));
287+
return this.registerFullItem(id, spec, controlString(id, {
288+
readConfig: spec.readConfig as (() => string) | undefined,
289+
}));
282290
}
283291

284292
textBlock(id: string, spec: TextBlockSpec) {
285-
return this.registerFullItem(id, spec, controlTextBlock(id, {mode: spec.mode}));
293+
return this.registerFullItem(id, spec, controlTextBlock(id, {
294+
mode: spec.mode,
295+
readConfig: spec.readConfig as (() => string) | undefined,
296+
}));
286297
}
287298

288299
textPair(spec: TextPairSpec) {

0 commit comments

Comments
 (0)