// 装配:注册「增强设置」分区(settings.section)与其英文字典。 function registerSettingsSection(ctx) { if (ctx.slots !== undefined && typeof ctx.slots.inject === 'function') { if (ctx.locale !== undefined && typeof ctx.locale.register === 'function') { ctx.effect(function () { return ctx.locale.register(SETTINGS_NS, { zh: SETTINGS_ZH, en: SETTINGS_EN }) }, 'dsh-zh: settings dictionaries') } const t = (ctx.locale !== undefined && typeof ctx.locale.bind === 'function') ? ctx.locale.bind(SETTINGS_NS) : function (key) { return SETTINGS_ZH[key] || key } ctx.slots.inject('settings.section', function () { return ctx.slots.register({ name: 'settings.section', id: 'dsh-zh-enhance', order: 50, label: function () { return t('nav') }, locale: SETTINGS_NS, }, function () { return React.createElement(ZhSettingsSection, { t: t }) }) }) } } // 装配:绑定「中文优先提示」开关到主机插件行 config(DSH 0.1.7 起经 // configForms 按入口 id 取 ConfigForm,快照/订阅/set 面与旧 settingsScope // 同构;默认关闭)。用可选注入而不是 exports.inject:configForms 缺失时仅该 // 开关不可用,中文补全等核心功能不受影响。 // 写入不再是逐键即时:设置页把所有改动攒在草稿里,点「保存」时用一次 // mutate 原子提交(见 settings-section.ts 的草稿层)。 function bindPromptScope(ctx) { if (typeof ctx.inject === 'function') { ctx.inject(['configForms'], function (configCtx) { const configForms = configCtx === null ? null : configCtx.get('configForms') if (configForms === undefined || configForms === null || typeof configForms.get !== 'function') return const scope = configForms.get(PROMPT_SETTINGS_NS) zhPromptStore._set(scope) configCtx.effect(function () { return function () { if (zhPromptStore.getSnapshot() !== null && zhPromptStore.getSnapshot().scope === scope) zhPromptStore._set(null) } }, 'dsh-zh: prompt settings scope') }) } }