From f1f4cf6e187b29a26a657c3aa5f424d02f8f4856 Mon Sep 17 00:00:00 2001 From: YokiiroBW Date: Sun, 5 Jul 2026 14:59:43 +0800 Subject: [PATCH] feat: add settings snapshot rollback workbench --- frontend/shared/api/endpoints.ts | 2 + frontend/shared/types/settings.ts | 14 +++++ frontend/standalone-web/src/App.vue | 51 +++++++++++++++++++ .../{index-qwpM8MfX.js => index-BTVLk-aV.js} | 10 ++-- pages/imagestudio/index.html | 2 +- web/assets/index-B4u_EVSo.css | 1 + web/assets/index-BULwMWcy.css | 1 - web/assets/index-D3ylcAeI.js | 17 ------- web/assets/index-D8LANsZc.js | 17 +++++++ web/index.html | 4 +- 10 files changed, 93 insertions(+), 26 deletions(-) rename pages/imagestudio/assets/{index-qwpM8MfX.js => index-BTVLk-aV.js} (85%) create mode 100644 web/assets/index-B4u_EVSo.css delete mode 100644 web/assets/index-BULwMWcy.css delete mode 100644 web/assets/index-D3ylcAeI.js create mode 100644 web/assets/index-D8LANsZc.js diff --git a/frontend/shared/api/endpoints.ts b/frontend/shared/api/endpoints.ts index b2f4007..56b48f1 100644 --- a/frontend/shared/api/endpoints.ts +++ b/frontend/shared/api/endpoints.ts @@ -40,6 +40,8 @@ export const endpoints = { settingsReload: "settings/reload", settingsExport: "settings/export", settingsImport: "settings/import", + settingsSnapshots: "settings/snapshots", + settingsRollback: "settings/rollback", storageStatus: "storage/status", mediaSign: "media/sign", materialCategories: "material-categories", diff --git a/frontend/shared/types/settings.ts b/frontend/shared/types/settings.ts index 7f6d93f..ac888ab 100644 --- a/frontend/shared/types/settings.ts +++ b/frontend/shared/types/settings.ts @@ -48,3 +48,17 @@ export interface ImportSettingsResult { saved: boolean config: Record } + +export interface SettingsSnapshot { + snapshot_id: string + reason: string + actor_id?: string | null + config: Record + created_at: string +} + +export interface RollbackSettingsResult { + rolled_back: boolean + snapshot_id: string + config: Record +} diff --git a/frontend/standalone-web/src/App.vue b/frontend/standalone-web/src/App.vue index e88c90b..ba4cf78 100644 --- a/frontend/standalone-web/src/App.vue +++ b/frontend/standalone-web/src/App.vue @@ -18,8 +18,10 @@ import type { ExportSettingsResult, ImportSettingsResult, ReloadSettingsResult, + RollbackSettingsResult, SaveSettingsResult, SettingsSchema, + SettingsSnapshot, ValidateSettingsResult, } from "../../shared/types/settings" import type { MediaSignResult, StorageStatus } from "../../shared/types/storage" @@ -201,6 +203,10 @@ const text = { importSettings: "\u5bfc\u5165\u8bbe\u7f6e", importDone: "\u8bbe\u7f6e\u5df2\u5bfc\u5165", importDraftInvalid: "\u5bfc\u5165 JSON \u683c\u5f0f\u65e0\u6548", + snapshots: "\u914d\u7f6e\u5feb\u7167", + loadSnapshots: "\u52a0\u8f7d\u5feb\u7167", + rollback: "\u56de\u6eda", + rollbackDone: "\u914d\u7f6e\u5df2\u56de\u6eda", settingsEditor: "\u914d\u7f6e\u7f16\u8f91", settingsDraftInvalid: "\u914d\u7f6e JSON \u683c\u5f0f\u65e0\u6548", settingsSaved: "\u8bbe\u7f6e\u5df2\u4fdd\u5b58", @@ -249,6 +255,7 @@ const logs = ref({ generation: [], workflows: [], errors: [], integra const signedMedia = ref(null) const settingsDraft = ref("") const settingsImportDraft = ref("") +const settingsSnapshots = ref([]) const settingsValidation = ref(null) const settingsDiff = ref(null) const profileDraft = ref({ @@ -1172,6 +1179,32 @@ function importSettingsDraft() { ) } +function loadSettingsSnapshots() { + return runOperation( + text.loadSnapshots, + async () => { + settingsSnapshots.value = await getJson(endpoints.settingsSnapshots, { limit: 20 }) + return settingsSnapshots.value + }, + false, + ) +} + +function rollbackSettingsSnapshot(snapshotId: string) { + return runOperation( + text.rollback, + async () => { + const result = await postJson(endpoints.settingsRollback, { snapshot_id: snapshotId }) + currentSettings.value = { config_path: currentSettings.value?.config_path ?? "***PATH***", config: result.config } + resetSettingsDraft(result.config) + await loadSettingsSnapshots() + lastOperation.value = text.rollbackDone + return result + }, + false, + ) +} + function signFirstMaterial() { const uri = materials.value?.items.find((item) => item.image_uri?.startsWith("storage://"))?.image_uri if (!uri) { @@ -2218,6 +2251,7 @@ function storageRootBytes(uriPrefix: string) { +
@@ -2241,6 +2275,23 @@ function storageRootBytes(uriPrefix: string) {