ensureColumn("sites", "app_icon_filename", "TEXT");
ensureColumn("sites", "app_color_scheme", "TEXT DEFAULT 'blue'");
ensureColumn("domains", "color", "TEXT");
+ensureColumn("domain_templates", "abbr", "TEXT");
ensureColumn("menu_items", "source_key", "TEXT");
ensureColumn("sites", "template_id", "INTEGER");
ensureColumn("sites", "template_applied_at", "TEXT");
const name = body.name != null ? body.name.toString().trim() : row.name;
const domain_id = body.domain_id != null ? Number(body.domain_id) : row.domain_id;
const description = body.description != null ? body.description : row.description;
- const status = body.status != null ? (body.status === "unavailable" ? "unavailable" : "available") : row.status;
+ const abbr = body.abbr != null ? body.abbr.toString().trim() : row.abbr;
+ const status = body.status != null ? (["available", "editing", "unavailable"].includes(body.status) ? body.status : "available") : row.status;
const version = body.version != null ? body.version.toString() : row.version;
const creator = body.creator != null ? body.creator.toString() : row.creator;
const supplement = body.supplement != null ? body.supplement : row.supplement;
const style_id = body.style_id !== undefined ? (body.style_id != null ? Number(body.style_id) : null) : row.style_id;
if (!name) return respondError(res, 400, "模板名称不能为空");
- db.prepare("UPDATE domain_templates SET domain_id=?,name=?,description=?,status=?,version=?,creator=?,supplement=?,style_id=? WHERE id=?").run(domain_id, name, description, status, version, creator, supplement, style_id, id);
+ db.prepare("UPDATE domain_templates SET domain_id=?,name=?,abbr=?,description=?,status=?,version=?,creator=?,supplement=?,style_id=? WHERE id=?").run(domain_id, name, abbr, description, status, version, creator, supplement, style_id, id);
if (body.device_template_ids !== undefined) {
db.prepare("DELETE FROM device_template_domain_templates WHERE domain_template_id=?").run(id);
for (const devId of Array.isArray(body.device_template_ids) ? body.device_template_ids : []) {