From bbe75b1910ee7c9ca8f789eaa1ee4dcc45c98e2b Mon Sep 17 00:00:00 2001 From: ZiuChen <457353192@qq.com> Date: Mon, 19 Sep 2022 16:50:48 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AF=B9=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E6=8C=89=E9=92=AE=E7=9A=84=E8=BE=B9=E7=95=8C?= =?UTF-8?q?=E6=9D=A1=E4=BB=B6=E8=BF=9B=E8=A1=8C=E7=BA=A6=E6=9D=9F=20?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=87=AA=E5=AE=9A=E4=B9=89=E6=9D=A1=E6=95=B0?= =?UTF-8?q?=E4=B8=8E=E6=97=A5=E6=9C=9F=E5=8F=AF=E9=80=89=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/Setting.vue | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/views/Setting.vue b/src/views/Setting.vue index 1f9ea15..28d5fd6 100644 --- a/src/views/Setting.vue +++ b/src/views/Setting.vue @@ -19,14 +19,14 @@
最大历史条数 - +
最长保存时间 - +
@@ -46,7 +46,7 @@ ...custom.map(({ id, title, icon }) => ({ id, title, icon })) ]" :key="id" - :label="icon + title" + :label="icon + ' ' + title" :value="id" /> @@ -102,6 +102,7 @@ const handlePathBtnClick = (param) => { if (files.length > 0) { path.value = files[0].path } + ElMessage.info('修改成功 不要忘记点击保存按钮') } } else if (param === 'open') { utools.shellShowItemInFolder(path.value) @@ -109,6 +110,7 @@ const handlePathBtnClick = (param) => { } const handleSaveBtnClick = () => { + // 校验格式 if (path.value === '') { ElMessage.error('数据库路径不能为空') return @@ -116,12 +118,23 @@ const handleSaveBtnClick = () => { ElMessage.error('数据库路径不正确') return } + if (stringCustom.value === '') { + // 如果将全部清空 则默认为空数组 + stringCustom.value = '[]' + } + if (!/^\[.*\]$/.test(stringCustom.value)) { + ElMessage.error('自定义功能格式不正确') + return + } try { custom.value = JSON.parse(stringCustom.value) } catch (error) { custom.value = operation.custom - ElMessage.error('格式错误') + stringCustom.value = JSON.stringify(custom.value) + ElMessage.error('自定义功能格式不正确') + return } + // 执行保存到utools本地数据库 utools.dbStorage.setItem( 'setting', JSON.parse(