From 5bf6e5f1dcac18c192060344ccb2afcb6dbd42dc Mon Sep 17 00:00:00 2001 From: qwqcode Date: Mon, 4 Mar 2024 21:04:38 +0800 Subject: [PATCH] fix(exception): missing `message` field after refactoring exception data structure --- docs/swagger/docs.go | 14 +++++++++++++- docs/swagger/swagger.json | 14 +++++++++++++- docs/swagger/swagger.yaml | 11 ++++++++++- ui/artalk-sidebar/src/components/PageEditor.vue | 6 +++--- ui/artalk-sidebar/src/components/SiteCreate.vue | 2 +- ui/artalk-sidebar/src/components/SiteEditor.vue | 2 +- ui/artalk-sidebar/src/pages/users.vue | 4 ++-- ui/artalk/src/api/v2.ts | 4 ++-- ui/artalk/src/plugins/editor/submit.ts | 2 +- ui/artalk/src/plugins/editor/upload.ts | 2 +- ui/artalk/src/plugins/list/with-editor.ts | 2 +- 11 files changed, 48 insertions(+), 15 deletions(-) diff --git a/docs/swagger/docs.go b/docs/swagger/docs.go index 026fc341a..2335dafd4 100644 --- a/docs/swagger/docs.go +++ b/docs/swagger/docs.go @@ -2504,7 +2504,7 @@ const docTemplate = `{ { "type": "object", "properties": { - " data": { + "data": { "type": "object", "properties": { "need_name_select": { @@ -3219,6 +3219,7 @@ const docTemplate = `{ "is_collapsed", "is_pending", "is_pinned", + "is_verified", "link", "nick", "page_key", @@ -3268,6 +3269,9 @@ const docTemplate = `{ "is_pinned": { "type": "boolean" }, + "is_verified": { + "type": "boolean" + }, "link": { "type": "string" }, @@ -3978,6 +3982,7 @@ const docTemplate = `{ "is_collapsed", "is_pending", "is_pinned", + "is_verified", "link", "nick", "page_key", @@ -4027,6 +4032,9 @@ const docTemplate = `{ "is_pinned": { "type": "boolean" }, + "is_verified": { + "type": "boolean" + }, "link": { "type": "string" }, @@ -4128,6 +4136,7 @@ const docTemplate = `{ "is_collapsed", "is_pending", "is_pinned", + "is_verified", "link", "nick", "page_key", @@ -4177,6 +4186,9 @@ const docTemplate = `{ "is_pinned": { "type": "boolean" }, + "is_verified": { + "type": "boolean" + }, "link": { "type": "string" }, diff --git a/docs/swagger/swagger.json b/docs/swagger/swagger.json index 8a9320c3c..41da5458e 100644 --- a/docs/swagger/swagger.json +++ b/docs/swagger/swagger.json @@ -2497,7 +2497,7 @@ { "type": "object", "properties": { - " data": { + "data": { "type": "object", "properties": { "need_name_select": { @@ -3212,6 +3212,7 @@ "is_collapsed", "is_pending", "is_pinned", + "is_verified", "link", "nick", "page_key", @@ -3261,6 +3262,9 @@ "is_pinned": { "type": "boolean" }, + "is_verified": { + "type": "boolean" + }, "link": { "type": "string" }, @@ -3971,6 +3975,7 @@ "is_collapsed", "is_pending", "is_pinned", + "is_verified", "link", "nick", "page_key", @@ -4020,6 +4025,9 @@ "is_pinned": { "type": "boolean" }, + "is_verified": { + "type": "boolean" + }, "link": { "type": "string" }, @@ -4121,6 +4129,7 @@ "is_collapsed", "is_pending", "is_pinned", + "is_verified", "link", "nick", "page_key", @@ -4170,6 +4179,9 @@ "is_pinned": { "type": "boolean" }, + "is_verified": { + "type": "boolean" + }, "link": { "type": "string" }, diff --git a/docs/swagger/swagger.yaml b/docs/swagger/swagger.yaml index 5baa71bec..1898d1bdb 100644 --- a/docs/swagger/swagger.yaml +++ b/docs/swagger/swagger.yaml @@ -63,6 +63,8 @@ definitions: type: boolean is_pinned: type: boolean + is_verified: + type: boolean link: type: string nick: @@ -98,6 +100,7 @@ definitions: - is_collapsed - is_pending - is_pinned + - is_verified - link - nick - page_key @@ -611,6 +614,8 @@ definitions: type: boolean is_pinned: type: boolean + is_verified: + type: boolean link: type: string nick: @@ -646,6 +651,7 @@ definitions: - is_collapsed - is_pending - is_pinned + - is_verified - link - nick - page_key @@ -716,6 +722,8 @@ definitions: type: boolean is_pinned: type: boolean + is_verified: + type: boolean link: type: string nick: @@ -751,6 +759,7 @@ definitions: - is_collapsed - is_pending - is_pinned + - is_verified - link - nick - page_key @@ -2568,7 +2577,7 @@ paths: allOf: - $ref: '#/definitions/handler.Map' - properties: - ' data': + data: properties: need_name_select: items: diff --git a/ui/artalk-sidebar/src/components/PageEditor.vue b/ui/artalk-sidebar/src/components/PageEditor.vue index 0d7983a16..fc5d16246 100644 --- a/ui/artalk-sidebar/src/components/PageEditor.vue +++ b/ui/artalk-sidebar/src/components/PageEditor.vue @@ -32,7 +32,7 @@ async function editAdminOnly() { try { p = (await artalk!.ctx.getApi().pages.updatePage(page.value.id, { ...page.value, admin_only: !page.value.admin_only })).data } catch (err: any) { - alert(`修改失败:${err.msg || '未知错误'}`) + alert(`修改失败:${err.message || '未知错误'}`) console.log(err) return } finally { isLoading.value = false } @@ -45,7 +45,7 @@ async function sync() { try { p = (await artalk!.ctx.getApi().pages.fetchPage(page.value.id)).data } catch (err: any) { - alert(`同步失败:${err.msg || '未知错误'}`) + alert(`同步失败:${err.message || '未知错误'}`) console.log(err) return } finally { isLoading.value = false } @@ -80,7 +80,7 @@ async function onFieldEditorYes(val: string) { try { p = (await artalk!.ctx.getApi().pages.updatePage(page.value.id, { ...page.value, [editFieldKey.value as any]: val })).data } catch (err: any) { - alert(`修改失败:${err.msg || '未知错误'}`) + alert(`修改失败:${err.message || '未知错误'}`) console.error(err) return false } finally { isLoading.value = false } diff --git a/ui/artalk-sidebar/src/components/SiteCreate.vue b/ui/artalk-sidebar/src/components/SiteCreate.vue index fe942fa61..9f7d21545 100644 --- a/ui/artalk-sidebar/src/components/SiteCreate.vue +++ b/ui/artalk-sidebar/src/components/SiteCreate.vue @@ -38,7 +38,7 @@ async function submit() { urls: siteUrls })).data } catch (err: any) { - window.alert(`创建失败:${err.msg || ''}`) + window.alert(`创建失败:${err.message || ''}`) console.error(err) return } finally { isLoading.value = false } diff --git a/ui/artalk-sidebar/src/components/SiteEditor.vue b/ui/artalk-sidebar/src/components/SiteEditor.vue index ac4e13a66..5d7bfde99 100644 --- a/ui/artalk-sidebar/src/components/SiteEditor.vue +++ b/ui/artalk-sidebar/src/components/SiteEditor.vue @@ -66,7 +66,7 @@ async function onFieldEditorYes(val: string) { if (Array.isArray(site.value[editFieldKey.value])) finalVal = val.split(',').map((v) => v.trim()).filter((v) => !!v) s = (await artalk!.ctx.getApi().sites.updateSite(site.value.id, { ...site.value, [editFieldKey.value]: finalVal })).data } catch (err: any) { - alert(`修改失败:${err.msg || '未知错误'}`) + alert(`修改失败:${err.message || '未知错误'}`) console.error(err) return false } finally { isLoading.value = false } diff --git a/ui/artalk-sidebar/src/pages/users.vue b/ui/artalk-sidebar/src/pages/users.vue index 5da658d48..124c6a260 100644 --- a/ui/artalk-sidebar/src/pages/users.vue +++ b/ui/artalk-sidebar/src/pages/users.vue @@ -111,8 +111,8 @@ function delUser(user: ArtalkType.UserDataForAdmin) { alert('用户已从数据库删除,请手动编辑配置文件并删除用户') } }) - .catch((e) => { - alert('删除失败:'+e.msg) + .catch((e: ArtalkType.FetchError) => { + alert('删除失败:'+e.message) }) } } diff --git a/ui/artalk/src/api/v2.ts b/ui/artalk/src/api/v2.ts index 9542c0447..736d1a1f8 100644 --- a/ui/artalk/src/api/v2.ts +++ b/ui/artalk/src/api/v2.ts @@ -1955,7 +1955,7 @@ export class Api extends HttpClient extends HttpClient { - ctx.editorShowNotify(`${$t('editFail')}: ${err.msg || String(err)}`, 'e') + ctx.editorShowNotify(`${$t('editFail')}: ${err.message || String(err)}`, 'e') }) .finally(() => { ctx.editorHideLoading()