From f989960353deb9474bc84c0761b4a4a4a576592c Mon Sep 17 00:00:00 2001 From: wosiwq Date: Mon, 25 Dec 2023 17:18:28 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=A8=20feat(codemirror):=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E9=98=B2=E6=8A=96=EF=BC=8C=E6=B7=BB=E5=8A=A0=E6=8A=A5?= =?UTF-8?q?=E9=94=99=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改触发handleFormattedBilichatChange的方式,添加防抖,并在页面中展示报错原因 --- src/views/BaseView.vue | 46 +++++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/src/views/BaseView.vue b/src/views/BaseView.vue index 53332e5..9edbaa4 100644 --- a/src/views/BaseView.vue +++ b/src/views/BaseView.vue @@ -26,7 +26,7 @@

配置文件

+
{{ error }}
保存修改 @@ -248,7 +249,7 @@ import type { } from '@/types' import { json } from '@codemirror/lang-json' import { oneDark } from '@codemirror/theme-one-dark' -import { useDark } from '@vueuse/core' +import { useDark, useDebounceFn } from '@vueuse/core' import axios from 'axios' import QrcodeVue from 'qrcode.vue' import { Codemirror } from 'vue-codemirror' @@ -264,6 +265,7 @@ const formDiv: Ref = ref() const inputUid = ref() const qrcodeUrl = ref() const authCode = ref() +const error = ref() const timer = ref() const bilichat = ref() @@ -348,14 +350,17 @@ onMounted(() => { }) }) -const handleFormattedBilichatChange = () => { +const handleFormattedBilichatChange = useDebounceFn((val: string) => { try { - bilichat.value = JSON.parse(formattedBilichat.value as string) as BiliChat + bilichat.value = JSON.parse(val) as BiliChat + error.value = undefined + formattedBilichat.value = JSON.stringify(bilichat.value, null, 2) } catch (e) { ElMessage.error('JSON格式错误') - formattedBilichat.value = JSON.stringify(bilichat.value, null, 2) + error.value = 'JSON格式错误:' + e + // formattedBilichat.value = JSON.stringify(bilichat.value, null, 2) } -} +}, 1000) const saveChange = () => { const loading = ElLoading.service({ @@ -519,4 +524,31 @@ const getButtonColor = () => { return 'rgb(59 130 246 / var(--un-bg-opacity))' } - + From c23a452996a2e058d4af9f086b3e5f142e3041a0 Mon Sep 17 00:00:00 2001 From: wosiwq Date: Mon, 25 Dec 2023 17:19:44 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=9A=80=20feat(release):=20=E5=8D=87?= =?UTF-8?q?=E7=BA=A7=E7=89=88=E6=9C=AC=E5=88=B01.0.3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index f7cff17..3d3e45d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bilichat", - "version": "1.0.2", + "version": "1.0.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "bilichat", - "version": "1.0.2", + "version": "1.0.3", "dependencies": { "@codemirror/lang-json": "^6.0.1", "@codemirror/theme-one-dark": "^6.1.2", diff --git a/package.json b/package.json index c592fc2..5e1020f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bilichat", - "version": "1.0.2", + "version": "1.0.3", "private": true, "type": "module", "scripts": {