mirror of
https://github.com/hansjone/dsh-ops-cron.git
synced 2026-10-12 03:50:44 +08:00
Adapt settings client for DSH 0.2.0 configForms without breaking boot.
Soft-inject configForms/settingsScope and mark Config fields volatile so desktop 0.2.0 no longer waits forever on the removed settingsScope service. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
a41a2b53c9
commit
fcc8f75560
6 changed files with 117 additions and 44 deletions
|
|
@ -158,7 +158,9 @@ window.__ModuleLoader__.load({
|
|||
|
||||
const name = 'dsh-ops-cron'
|
||||
const NS = 'dsh-ops-cron'
|
||||
const inject = ['slots', 'locale', 'settingsScope']
|
||||
// Hard-inject only services present on both DSH ≤0.1.5 and ≥0.1.7.
|
||||
// Do NOT hard-inject settingsScope: DSH ≥0.1.7 / 0.2.0 removed it (configForms).
|
||||
const inject = ['slots', 'locale']
|
||||
const API = '/dsh-ops-cron'
|
||||
|
||||
function readCookie(name) {
|
||||
|
|
@ -2222,19 +2224,43 @@ body>.dsh-ct-main{position:fixed;top:0;right:0;bottom:0;left:var(--dsh-ct-sideba
|
|||
}
|
||||
}, 'dsh-ops-cron: locale')
|
||||
|
||||
const scope = ctx.settingsScope.bind({ namespace: NS })
|
||||
const form = createForm(scope)
|
||||
ctx.slots.inject('settings.plugin.item', () => ctx.slots.register({
|
||||
name: 'settings.plugin.item',
|
||||
key: NS,
|
||||
locale: LOCALE_NS,
|
||||
inject: () => ({
|
||||
hooks: { card: form.store },
|
||||
edit: (field, value) => form.edit(field, value),
|
||||
save: () => { form.save() },
|
||||
discard: () => form.discard(),
|
||||
}),
|
||||
}, SettingsCard))
|
||||
// Soft-mount Plugins card: configForms (DSH ≥0.1.7 / 0.2.0) or settingsScope (≤0.1.5).
|
||||
let settingsMounted = false
|
||||
const mountSettingsCard = (scope) => {
|
||||
if (settingsMounted || !scope) return
|
||||
settingsMounted = true
|
||||
const form = createForm(scope)
|
||||
ctx.slots.inject('settings.plugin.item', () => ctx.slots.register({
|
||||
name: 'settings.plugin.item',
|
||||
key: NS,
|
||||
locale: LOCALE_NS,
|
||||
inject: () => ({
|
||||
hooks: { card: form.store },
|
||||
edit: (field, value) => form.edit(field, value),
|
||||
save: () => { form.save() },
|
||||
discard: () => form.discard(),
|
||||
}),
|
||||
}, SettingsCard))
|
||||
}
|
||||
ctx.inject(['configForms'], (formsCtx) => {
|
||||
const forms = formsCtx.configForms || formsCtx.get?.('configForms')
|
||||
if (!forms || typeof forms.get !== 'function') {
|
||||
formsCtx.logger?.warn?.('[dsh-ops-cron] configForms present but .get missing')
|
||||
return
|
||||
}
|
||||
formsCtx.logger?.info?.('[dsh-ops-cron] settings card via configForms')
|
||||
mountSettingsCard(forms.get(NS))
|
||||
})
|
||||
ctx.inject(['settingsScope'], (scopeCtx) => {
|
||||
if (settingsMounted) return
|
||||
const binder = scopeCtx.settingsScope || scopeCtx.get?.('settingsScope')
|
||||
if (!binder || typeof binder.bind !== 'function') {
|
||||
scopeCtx.logger?.warn?.('[dsh-ops-cron] settingsScope present but .bind missing')
|
||||
return
|
||||
}
|
||||
scopeCtx.logger?.info?.('[dsh-ops-cron] settings card via settingsScope')
|
||||
mountSettingsCard(binder.bind({ namespace: NS }))
|
||||
})
|
||||
|
||||
const faces = {
|
||||
sessions: undefined,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue