import { state as appState } from "/assets/js/state.js"; import { tr } from "/assets/js/i18n.js"; import { pluginText } from "/assets/js/shared.js"; import { field } from "./schema.js"; import { markChanged } from "./config.js"; export function renderDevice(values) { return `
${Object.entries(values) .map(([key, raw]) => { const automatic = !raw || raw.toLowerCase() === "auto", value = automatic ? appState.deviceIdentity[key === "identifier" ? "id" : "name"] || appState.deviceIdentity.hostname || "" : raw; return field("device", key, value).replace( 'data-section="device"', `data-device-auto="${automatic}" data-section="device"`, ); }) .join( "", )}

${pluginText("默认值跟随本机主机名;修改后点击保存到当前机器。", "Defaults follow the device hostname. Save to the current host to apply changes.")}

`; } export function resetDeviceDefaults() { document.querySelectorAll('[data-section="device"]').forEach((el) => { el.value = appState.deviceIdentity.hostname || ""; el.dataset.deviceAuto = "true"; }); markChanged(); }