update
This commit is contained in:
@@ -369,12 +369,22 @@ const handleAddNewTheme = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// 开始编辑现有主题
|
// 开始编辑主题 (用户主题或基于预设创建副本)
|
||||||
const handleEditTheme = (theme: TerminalTheme) => {
|
const handleEditTheme = (theme: TerminalTheme) => {
|
||||||
if (theme.isPreset) return; // 不允许编辑预设
|
|
||||||
saveThemeError.value = null; // 清除旧错误
|
saveThemeError.value = null; // 清除旧错误
|
||||||
// 深拷贝以避免直接修改列表中的对象
|
if (theme.isPreset) {
|
||||||
editingTheme.value = JSON.parse(JSON.stringify(theme));
|
// 基于预设创建副本
|
||||||
|
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;
|
isEditingTheme.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -662,7 +672,7 @@ const formatXtermLabel = (key: keyof ITheme): string => {
|
|||||||
<li v-for="theme in availableTerminalThemes" :key="theme._id" :class="{ 'preset-theme': theme.isPreset }">
|
<li v-for="theme in availableTerminalThemes" :key="theme._id" :class="{ 'preset-theme': theme.isPreset }">
|
||||||
<span>{{ theme.name }} {{ theme.isPreset ? `(${t('styleCustomizer.preset')})` : '' }}</span>
|
<span>{{ theme.name }} {{ theme.isPreset ? `(${t('styleCustomizer.preset')})` : '' }}</span>
|
||||||
<div class="theme-actions">
|
<div class="theme-actions">
|
||||||
<button @click="handleEditTheme(theme)" :disabled="theme.isPreset">{{ t('common.edit') }}</button>
|
<button @click="handleEditTheme(theme)">{{ theme.isPreset ? t('styleCustomizer.editAsCopy', '编辑副本') : t('common.edit') }}</button> <!-- 移除 disabled,修改文本,需要添加翻译 '编辑副本' -->
|
||||||
<button @click="handleDeleteTheme(theme)" :disabled="theme.isPreset" class="button-danger">{{ t('common.delete') }}</button>
|
<button @click="handleDeleteTheme(theme)" :disabled="theme.isPreset" class="button-danger">{{ t('common.delete') }}</button>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -86,7 +86,9 @@
|
|||||||
"uiThemeJsonEditorTitle": "UI Theme JSON Editor",
|
"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.",
|
"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.",
|
"errorInvalidJsonObject": "Invalid input. Please provide a valid JSON object.",
|
||||||
"errorInvalidJsonConfig": "Invalid JSON configuration"
|
"errorInvalidJsonConfig": "Invalid JSON configuration",
|
||||||
|
"editAsCopy": "Edit as Copy",
|
||||||
|
"copySuffix": "Copy"
|
||||||
},
|
},
|
||||||
"login": {
|
"login": {
|
||||||
"title": "User Login",
|
"title": "User Login",
|
||||||
|
|||||||
@@ -86,7 +86,9 @@
|
|||||||
"uiThemeJsonEditorTitle": "界面主题 JSON 编辑器",
|
"uiThemeJsonEditorTitle": "界面主题 JSON 编辑器",
|
||||||
"uiThemeJsonEditorDesc": "直接使用 JSON 编辑界面主题配置。在此处更改并在文本区域失焦后,上面的颜色选择器将同步更新。",
|
"uiThemeJsonEditorDesc": "直接使用 JSON 编辑界面主题配置。在此处更改并在文本区域失焦后,上面的颜色选择器将同步更新。",
|
||||||
"errorInvalidJsonObject": "输入无效。请输入一个有效的 JSON 对象。",
|
"errorInvalidJsonObject": "输入无效。请输入一个有效的 JSON 对象。",
|
||||||
"errorInvalidJsonConfig": "无效的 JSON 配置"
|
"errorInvalidJsonConfig": "无效的 JSON 配置",
|
||||||
|
"editAsCopy": "编辑副本",
|
||||||
|
"copySuffix": "副本"
|
||||||
},
|
},
|
||||||
"login": {
|
"login": {
|
||||||
"title": "用户登录",
|
"title": "用户登录",
|
||||||
|
|||||||
Reference in New Issue
Block a user