From 86a62c3b9dce1b15eb4ecf93b117f323d1dcfc5f Mon Sep 17 00:00:00 2001 From: Ryan SU <1137661202@qq.com> Date: Fri, 13 Jan 2023 08:32:14 +0800 Subject: [PATCH] perf: optimize await logic --- src/locales/lang/en/common.ts | 1 + src/locales/lang/zh-CN/common.ts | 1 + .../dashboard/workbench/components/data.ts | 2 +- src/views/sys/api/index.vue | 6 +- src/views/sys/dictionary/detail.vue | 6 +- src/views/sys/dictionary/index.vue | 2 +- src/views/sys/menu/MenuDrawer.vue | 32 +++++----- src/views/sys/menu/index.vue | 2 +- src/views/sys/oauth/callback.vue | 2 +- src/views/sys/role/RoleDrawer.vue | 60 +++++++++---------- src/views/sys/role/index.vue | 4 +- src/views/sys/token/index.vue | 6 +- src/views/sys/user/index.vue | 6 +- 13 files changed, 63 insertions(+), 67 deletions(-) diff --git a/src/locales/lang/en/common.ts b/src/locales/lang/en/common.ts index bdf09a4b..d8ee4b9c 100644 --- a/src/locales/lang/en/common.ts +++ b/src/locales/lang/en/common.ts @@ -63,5 +63,6 @@ export default { changeStatusFailed: 'Change status failed', targetNotExist: 'Target does not exist', notAllowDelete: 'Disallow deletion of this object', + notAllowDeleteAdminData: "Disallow deletion of administrator's data", notAllowChangeStatus: 'Disallow modification of status', }; diff --git a/src/locales/lang/zh-CN/common.ts b/src/locales/lang/zh-CN/common.ts index 57892c7a..ccc81024 100644 --- a/src/locales/lang/zh-CN/common.ts +++ b/src/locales/lang/zh-CN/common.ts @@ -63,5 +63,6 @@ export default { changeStatusFailed: '状态修改失败', targetNotExist: '目标不存在', notAllowDelete: '禁止删除该数据', + notAllowDeleteAdminData: "禁止删除管理员数据", notAllowChangeStatus: '禁止改变目标状态', }; diff --git a/src/views/dashboard/workbench/components/data.ts b/src/views/dashboard/workbench/components/data.ts index 798e0942..df6bd506 100644 --- a/src/views/dashboard/workbench/components/data.ts +++ b/src/views/dashboard/workbench/components/data.ts @@ -52,5 +52,5 @@ export const navItems: NavItem[] = [ export const systemInfoData = [ ['sys.sys.Name', 'Simple Admin'], - ['sys.sys.version', 'V 0.1.6'], + ['sys.sys.version', 'V 0.2.1'], ]; diff --git a/src/views/sys/api/index.vue b/src/views/sys/api/index.vue index b9f666a0..0e29bb33 100644 --- a/src/views/sys/api/index.vue +++ b/src/views/sys/api/index.vue @@ -89,11 +89,11 @@ description: t(result.msg), duration: 3, }); - reload(); + await reload(); } - function handleSuccess() { - reload(); + async function handleSuccess() { + await reload(); } return { diff --git a/src/views/sys/dictionary/detail.vue b/src/views/sys/dictionary/detail.vue index eba77ca1..be97f36c 100644 --- a/src/views/sys/dictionary/detail.vue +++ b/src/views/sys/dictionary/detail.vue @@ -102,11 +102,11 @@ description: t(result.msg), duration: 3, }); - reload(); + await reload(); } - function handleSuccess() { - reload(); + async function handleSuccess() { + await reload(); } return { diff --git a/src/views/sys/dictionary/index.vue b/src/views/sys/dictionary/index.vue index 1ddba4a7..baf592ae 100644 --- a/src/views/sys/dictionary/index.vue +++ b/src/views/sys/dictionary/index.vue @@ -84,7 +84,7 @@ async function handleDelete(record: Recordable) { const result = await deleteDictionary({ id: record.id }, 'modal'); message.success(t(result.msg), 2); - reload(); + await reload(); } function handleSuccess() { diff --git a/src/views/sys/menu/MenuDrawer.vue b/src/views/sys/menu/MenuDrawer.vue index bf2ac5b4..e736900c 100644 --- a/src/views/sys/menu/MenuDrawer.vue +++ b/src/views/sys/menu/MenuDrawer.vue @@ -134,7 +134,7 @@ const modalVisible = ref(false); const paramFormTitle = ref(''); // form model for menu parameters creating and updating - const formdata = reactive({ + const formData = reactive({ id: 0, menuId: 0, dataType: 'string', @@ -145,10 +145,10 @@ function handleOpenParamForm() { modalVisible.value = false; - formdata.id = 0; - formdata.key = ''; - formdata.value = ''; - formdata.dataType = 'string'; + formData.id = 0; + formData.key = ''; + formData.value = ''; + formData.dataType = 'string'; paramFormVisible.value = true; } @@ -156,16 +156,16 @@ const result = await getMenuParamListByMenuId({ id: menuId.value }); dataSource.value = result.data.data; paramFormTitle.value = t('sys.menu.addMenuParam'); - formdata.menuId = menuId.value; + formData.menuId = menuId.value; modalVisible.value = true; } // menu parameters operations function handleEdit(record: Recordable) { - formdata.id = record.id; - formdata.key = record.key; - formdata.value = record.value; - formdata.dataType = record.dataType; + formData.id = record.id; + formData.key = record.key; + formData.value = record.value; + formData.dataType = record.dataType; paramFormTitle.value = t('sys.menu.editMenuParam'); paramFormVisible.value = true; } @@ -177,11 +177,11 @@ async function handleParamSubmit() { const result = await createOrUpdateMenuParam({ - id: formdata.id, - menuId: formdata.menuId, - dataType: formdata.dataType, - value: formdata.value, - key: formdata.key, + id: formData.id, + menuId: formData.menuId, + dataType: formData.dataType, + value: formData.value, + key: formData.key, }); if (result.code === 0) { paramFormVisible.value = false; @@ -331,7 +331,7 @@ handleOpenModal, modalVisible, dataSource, - formdata, + formData, paramFormVisible, handleOpenParamForm, paramFormTitle, diff --git a/src/views/sys/menu/index.vue b/src/views/sys/menu/index.vue index 00895104..30f1fcbe 100644 --- a/src/views/sys/menu/index.vue +++ b/src/views/sys/menu/index.vue @@ -92,7 +92,7 @@ description: t(result.msg), duration: 3, }); - reload(); + await reload(); } function handleSuccess() { diff --git a/src/views/sys/oauth/callback.vue b/src/views/sys/oauth/callback.vue index ebf0beaa..47c1587f 100644 --- a/src/views/sys/oauth/callback.vue +++ b/src/views/sys/oauth/callback.vue @@ -29,7 +29,7 @@ const userStore = useUserStore(); // save token userStore.setToken(token); - userStore.afterLoginAction(false); + await userStore.afterLoginAction(false); go(PageEnum.BASE_HOME); } catch (e) { message.error(t('sys.oauth.createAccount'), 5); diff --git a/src/views/sys/role/RoleDrawer.vue b/src/views/sys/role/RoleDrawer.vue index b35b3a13..16680990 100644 --- a/src/views/sys/role/RoleDrawer.vue +++ b/src/views/sys/role/RoleDrawer.vue @@ -45,36 +45,36 @@