diff --git a/packages/frontend/src/components/StyleCustomizer.vue b/packages/frontend/src/components/StyleCustomizer.vue
index 74c9dbc..4b34e8a 100644
--- a/packages/frontend/src/components/StyleCustomizer.vue
+++ b/packages/frontend/src/components/StyleCustomizer.vue
@@ -369,12 +369,22 @@ const handleAddNewTheme = () => {
};
-// 开始编辑现有主题
+// 开始编辑主题 (用户主题或基于预设创建副本)
const handleEditTheme = (theme: TerminalTheme) => {
- if (theme.isPreset) return; // 不允许编辑预设
saveThemeError.value = null; // 清除旧错误
- // 深拷贝以避免直接修改列表中的对象
- editingTheme.value = JSON.parse(JSON.stringify(theme));
+ if (theme.isPreset) {
+ // 基于预设创建副本
+ const themeCopy = JSON.parse(JSON.stringify(theme));
+ themeCopy._id = undefined; // 清除 ID,表示是新建
+ themeCopy.name = `${theme.name} (${t('styleCustomizer.copySuffix', '副本')})`; // 添加后缀,需要添加翻译 '副本'
+ themeCopy.isPreset = false; // 副本不再是预设
+ editingTheme.value = themeCopy;
+ console.log('创建预设主题副本进行编辑:', editingTheme.value);
+ } else {
+ // 编辑用户自己的主题
+ editingTheme.value = JSON.parse(JSON.stringify(theme));
+ console.log('编辑用户主题:', editingTheme.value);
+ }
isEditingTheme.value = true;
};
@@ -662,7 +672,7 @@ const formatXtermLabel = (key: keyof ITheme): string => {
{{ theme.name }} {{ theme.isPreset ? `(${t('styleCustomizer.preset')})` : '' }}
-
+
diff --git a/packages/frontend/src/locales/en.json b/packages/frontend/src/locales/en.json
index c6a2f21..684b2b1 100644
--- a/packages/frontend/src/locales/en.json
+++ b/packages/frontend/src/locales/en.json
@@ -86,7 +86,9 @@
"uiThemeJsonEditorTitle": "UI Theme JSON Editor",
"uiThemeJsonEditorDesc": "Directly edit the UI theme configuration using JSON. Changes here will reflect in the color pickers above after blurring the textarea.",
"errorInvalidJsonObject": "Invalid input. Please provide a valid JSON object.",
- "errorInvalidJsonConfig": "Invalid JSON configuration"
+ "errorInvalidJsonConfig": "Invalid JSON configuration",
+ "editAsCopy": "Edit as Copy",
+ "copySuffix": "Copy"
},
"login": {
"title": "User Login",
diff --git a/packages/frontend/src/locales/zh.json b/packages/frontend/src/locales/zh.json
index 909ffe8..257180a 100644
--- a/packages/frontend/src/locales/zh.json
+++ b/packages/frontend/src/locales/zh.json
@@ -86,7 +86,9 @@
"uiThemeJsonEditorTitle": "界面主题 JSON 编辑器",
"uiThemeJsonEditorDesc": "直接使用 JSON 编辑界面主题配置。在此处更改并在文本区域失焦后,上面的颜色选择器将同步更新。",
"errorInvalidJsonObject": "输入无效。请输入一个有效的 JSON 对象。",
- "errorInvalidJsonConfig": "无效的 JSON 配置"
+ "errorInvalidJsonConfig": "无效的 JSON 配置",
+ "editAsCopy": "编辑副本",
+ "copySuffix": "副本"
},
"login": {
"title": "用户登录",