From ed006f2f6fb7bfcd6ae1d0b2e1413b94b7f4bb13 Mon Sep 17 00:00:00 2001 From: orange Date: Wed, 1 Feb 2023 14:32:27 +0800 Subject: [PATCH 1/2] refactor(i18n): add confirm and cancel text to messageBox --- src/composables/config/useDeleteDriver.ts | 7 ++++++- src/composables/config/useGroupList.ts | 18 +++++++++++++++--- src/composables/config/usePlugin.ts | 7 ++++++- src/composables/config/useSubscription.ts | 5 ++++- src/composables/config/useTagList.ts | 16 +++++++++++++--- src/i18n/common.ts | 8 ++++++++ 6 files changed, 52 insertions(+), 9 deletions(-) diff --git a/src/composables/config/useDeleteDriver.ts b/src/composables/config/useDeleteDriver.ts index bb62c041..09705471 100644 --- a/src/composables/config/useDeleteDriver.ts +++ b/src/composables/config/useDeleteDriver.ts @@ -7,7 +7,12 @@ export default () => { const { t } = useI18n() const delDriver = async ({ name }: DriverItemInList) => { try { - await EmqxMessageBox({ title: t('common.operateConfirm'), message: t('common.confirmDelete'), type: 'warning' }) + await EmqxMessageBox({ + title: t('common.operateConfirm'), + message: t('common.confirmDelete'), + type: 'warning', + confirmButtonText: t('common.confirmButtonText'), + }) await deleteDriver(name) EmqxMessage.success(t('common.operateSuccessfully')) return Promise.resolve() diff --git a/src/composables/config/useGroupList.ts b/src/composables/config/useGroupList.ts index 036edab9..3bbb049d 100644 --- a/src/composables/config/useGroupList.ts +++ b/src/composables/config/useGroupList.ts @@ -53,7 +53,11 @@ export default () => { } const delGroup = async ({ name }: GroupDataInTable) => { - await EmqxMessageBox({ title: t('common.operateConfirm'), message: t('common.confirmDelete') }) + await EmqxMessageBox({ + title: t('common.operateConfirm'), + message: t('common.confirmDelete'), + confirmButtonText: t('common.confirmButtonText'), + }) await deleteGroup(node.value, name) EmqxMessage.success(t('common.operateSuccessfully')) getGroupList() @@ -66,12 +70,20 @@ export default () => { } const batchDeleteGroup = async () => { - await EmqxMessageBox({ title: t('common.operateConfirm'), message: t('common.confirmDelete') }) + await EmqxMessageBox({ + title: t('common.operateConfirm'), + message: t('common.confirmDelete'), + confirmButtonText: t('common.confirmButtonText'), + }) delGroupList(groupCheckedList.value) } const clearGroup = async () => { - await EmqxMessageBox({ title: t('common.operateConfirm'), message: t('common.confirmClear') }) + await EmqxMessageBox({ + title: t('common.operateConfirm'), + message: t('common.confirmClear'), + confirmButtonText: t('common.confirmButtonText'), + }) delGroupList(groupList.value) } diff --git a/src/composables/config/usePlugin.ts b/src/composables/config/usePlugin.ts index 6a47ae6a..a200f183 100644 --- a/src/composables/config/usePlugin.ts +++ b/src/composables/config/usePlugin.ts @@ -131,7 +131,12 @@ export const useDeletePlugin = () => { const { t } = useI18n() const delPlugin = async ({ name }: CreatedPlugin) => { try { - await EmqxMessageBox({ title: t('common.operateConfirm'), message: t('common.confirmDelete'), type: 'warning' }) + await EmqxMessageBox({ + title: t('common.operateConfirm'), + message: t('common.confirmDelete'), + type: 'warning', + confirmButtonText: t('common.confirmButtonText'), + }) await deletePlugin(name) EmqxMessage.success(t('common.operateSuccessfully')) return Promise.resolve() diff --git a/src/composables/config/useSubscription.ts b/src/composables/config/useSubscription.ts index 6ecb73a5..3b944b3e 100644 --- a/src/composables/config/useSubscription.ts +++ b/src/composables/config/useSubscription.ts @@ -51,7 +51,10 @@ export const useSubscriptionList = () => { const unsubscribe = async (confirmText: string, data: SubscriptionData | Array) => { try { - await EmqxMessageBox.confirm(confirmText, t('common.operateConfirm')) + await EmqxMessageBox.confirm(confirmText, t('common.operateConfirm'), { + confirmButtonText: t('common.confirmButtonText'), + cancelButtonText: t('common.cancelButtonText'), + }) if (Array.isArray(data)) { const requestList = data.map((groupItem: SubscriptionData) => deleteSubscription(groupItem)) await Promise.all(requestList) diff --git a/src/composables/config/useTagList.ts b/src/composables/config/useTagList.ts index a53c692b..036546d1 100644 --- a/src/composables/config/useTagList.ts +++ b/src/composables/config/useTagList.ts @@ -105,13 +105,19 @@ export default () => { } const delTag = async (item: TagDataInTable) => { - await EmqxMessageBox.confirm(t('common.confirmDelete'), t('common.operateConfirm')) + await EmqxMessageBox.confirm(t('common.confirmDelete'), t('common.operateConfirm'), { + confirmButtonText: t('common.confirmButtonText'), + cancelButtonText: t('common.cancelButtonText'), + }) const delList = OmitArrayFields([item], ['checked']) deleteTagList(delList) } const batchDeleteTag = async () => { - await EmqxMessageBox.confirm(t('common.confirmDelete'), t('common.operateConfirm')) + await EmqxMessageBox.confirm(t('common.confirmDelete'), t('common.operateConfirm'), { + confirmButtonText: t('common.confirmButtonText'), + cancelButtonText: t('common.cancelButtonText'), + }) deleteTagList(tagCheckedList.value) } @@ -121,7 +127,11 @@ export default () => { } const clearTag = async () => { - await EmqxMessageBox({ title: t('common.operateConfirm'), message: t('common.confirmClear') }) + await EmqxMessageBox({ + title: t('common.operateConfirm'), + message: t('common.confirmClear'), + confirmButtonText: t('common.confirmButtonText'), + }) deleteTagList(totalData.value) } diff --git a/src/i18n/common.ts b/src/i18n/common.ts index 1a8ff70b..3e9f80f7 100644 --- a/src/i18n/common.ts +++ b/src/i18n/common.ts @@ -219,6 +219,14 @@ export default { zh: '确认', en: 'Confirm', }, + confirmButtonText: { + zh: '确认', + en: 'OK', + }, + cancelButtonText: { + zh: '取消', + en: 'Cancel', + }, back: { zh: '返回', en: 'Back', From f51f1dc687a20dfb78ff3d138f11e150f75c1f13 Mon Sep 17 00:00:00 2001 From: orange Date: Wed, 1 Feb 2023 14:43:00 +0800 Subject: [PATCH 2/2] refactor(i18n): add empty text to table --- src/views/admin/Log.vue | 2 +- src/views/config/northDriver/Group.vue | 2 +- src/views/config/southDriver/Group.vue | 2 +- src/views/config/southDriver/Tag.vue | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/views/admin/Log.vue b/src/views/admin/Log.vue index 376005b5..c39ea46a 100644 --- a/src/views/admin/Log.vue +++ b/src/views/admin/Log.vue @@ -23,7 +23,7 @@ {{ $t('common.submit') }}
- +