feat: redesign the web console with Vue and isolated account workspaces

This commit is contained in:
AttilaNet
2026-11-11 09:35:54 +08:00
parent 99aff423d8
commit ff6a828f58
46 changed files with 4549 additions and 748 deletions
+16 -4
View File
@@ -29,7 +29,7 @@ export function control(field, {get, set, onError = () => {}}) {
} else if (['boolean', 'bool', 'checkbox'].includes(type)) {
root = el('input', {type: 'checkbox', 'aria-label': label});
root.addEventListener('change', () => commit(root.checked));
sync = () => { root.checked = Boolean(value()); };
sync = () => { if (document.activeElement !== root) root.checked = Boolean(value()); };
} else if (['select', 'enum'].includes(type)) {
root = el('select', {'aria-label': label});
let optionsSignature;
@@ -58,7 +58,10 @@ export function control(field, {get, set, onError = () => {}}) {
root.append(el('label', {}, check, option.label));
return {check, option};
});
sync = () => items.forEach(({check, option}) => { check.checked = (value() || []).includes(option.value); });
sync = () => {
const selected = value() || [];
items.forEach(({check, option}) => { if (document.activeElement !== check) check.checked = selected.includes(option.value); });
};
} else if (['id_counts', 'counts', 'reserves'].includes(type)) {
root = el('div', {class: 'counts-editor', role: 'group', 'aria-label': label});
const lines = el('div', {class: 'counts-lines'});
@@ -123,7 +126,15 @@ export function control(field, {get, set, onError = () => {}}) {
}
root.dataset.configPath = pathKey(path);
root.title = field.help || field.description || label;
root.disabled = Boolean(field.disabled || field.readonly);
const syncValue = sync;
sync = () => {
if (!root.contains(document.activeElement)) {
const disabled = Boolean(field.disabled || field.readonly);
if (root.matches('input,select,button,textarea')) root.disabled = disabled;
else root.querySelectorAll('input,select,button,textarea').forEach(input => { input.disabled = disabled; });
}
syncValue();
};
sync();
return {root, sync, field};
}
@@ -172,8 +183,9 @@ export class PolicyForm {
this.signature = signature;
}
this.host.hidden = !fields.length;
const latestByPath = new Map(fields.map(field => [pathKey(field.path), field]));
this.controls.forEach(entry => {
const latest = fields.find(field => pathKey(field.path) === pathKey(entry.field.path));
const latest = latestByPath.get(pathKey(entry.field.path));
if (latest) Object.assign(entry.field, latest);
entry.sync();
entry.row.dataset.dirty = String(Boolean(this.context.dirty?.(entry.field.path)));