From b43f879c23a609f1f97e9cb6a0515bb94e9bed67 Mon Sep 17 00:00:00 2001 From: YangFong Date: Wed, 21 Aug 2024 08:22:28 +0800 Subject: [PATCH] feat: optimize custom css (#335) --- src/components/CodemirrorEditor/CssEditor.vue | 53 ++++++++++++++++--- src/stores/index.js | 9 ++++ 2 files changed, 54 insertions(+), 8 deletions(-) diff --git a/src/components/CodemirrorEditor/CssEditor.vue b/src/components/CodemirrorEditor/CssEditor.vue index 1cdf761..06e1f52 100644 --- a/src/components/CodemirrorEditor/CssEditor.vue +++ b/src/components/CodemirrorEditor/CssEditor.vue @@ -5,15 +5,38 @@ import { useStore } from '@/stores' const store = useStore() +function editTabName() { + ElMessageBox.prompt(`请输入新的方案名称`, `编辑方案名称`, { + confirmButtonText: `确认`, + cancelButtonText: `取消`, + inputValue: store.cssContentConfig.active, + inputErrorMessage: `不能与现有方案重名`, + inputValidator: store.validatorTabName, + }) + .then(({ value }) => { + if (!(`${value}`).trim()) { + ElMessage.error(`修改失败,方案名不可为空`) + return + } + store.renameTab(value) + ElMessage.success(`修改成功~`) + }) +} + function handleTabsEdit(targetName, action) { if (action === `add`) { ElMessageBox.prompt(`请输入方案名称`, `新建自定义 CSS`, { confirmButtonText: `确认`, cancelButtonText: `取消`, + inputValue: `方案${store.cssContentConfig.tabs.length + 1}`, inputErrorMessage: `不能与现有方案重名`, inputValidator: store.validatorTabName, }) .then(({ value }) => { + if (!(`${value}`).trim()) { + ElMessage.error(`新建失败,方案名不可为空`) + return + } store.addCssContentTab(value) ElMessage.success(`新建成功~`) }) @@ -36,7 +59,7 @@ function handleTabsEdit(targetName, action) { }) } - store.cssContentConfig.active = activeName + store.tabChanged(activeName) store.cssContentConfig.tabs = tabs.filter(tab => tab.name !== targetName) } } @@ -47,7 +70,8 @@ function handleTabsEdit(targetName, action) { + > + +