From 862281ba6566b7b623e4ec4db70b6ee32c630920 Mon Sep 17 00:00:00 2001 From: Kinplemelon Date: Sat, 7 May 2022 12:30:01 +0800 Subject: [PATCH] refactor(global): use switch to show and control enable status --- src/i18n/Base.js | 4 +++ src/views/APIKey/APIKey.vue | 14 +++++---- src/views/Auth/Authn.vue | 24 ++++++++------ src/views/Auth/Authz.vue | 26 +++++++++------ src/views/Auth/components/TableDropdown.vue | 8 ++--- src/views/Exhook/Exhook.vue | 24 ++++++++------ src/views/Listener/Listener.vue | 35 ++++++++------------- src/views/RuleEngine/Bridge/DataBridge.vue | 20 ++++++------ src/views/RuleEngine/IoT/IoT.vue | 20 ++++++------ 9 files changed, 94 insertions(+), 81 deletions(-) diff --git a/src/i18n/Base.js b/src/i18n/Base.js index 5fb4e8da7..40a28a041 100644 --- a/src/i18n/Base.js +++ b/src/i18n/Base.js @@ -395,4 +395,8 @@ export default { zh: '以 -----BEGIN RSA PRIVATE KEY----- 开头', en: 'Begins with -----BEGIN RSA PRIVATE KEY-----', }, + isEnabled: { + zh: '是否启用', + en: 'Enable', + }, } diff --git a/src/views/APIKey/APIKey.vue b/src/views/APIKey/APIKey.vue index ca04717cc..ee2a4cf17 100644 --- a/src/views/APIKey/APIKey.vue +++ b/src/views/APIKey/APIKey.vue @@ -25,15 +25,17 @@ + + + @@ -84,17 +86,17 @@ const toggleKeyItemEnable = async (itemData: APIKey) => { try { const { name, enable, expired_at, desc } = itemData const body: { enable: boolean; desc: string; expired_at?: string } = { - enable: !enable, + enable, desc, } if (expired_at) { body.expired_at = expired_at } await updateAPIKey(name, body) - ElMessage.success(t(`Base.${!enable ? 'enableSuccess' : 'disabledSuccess'}`)) - getList() + ElMessage.success(t(`Base.${enable ? 'enableSuccess' : 'disabledSuccess'}`)) } catch (error) { console.error(error) + itemData.enable = !itemData.enable } } diff --git a/src/views/Auth/Authn.vue b/src/views/Auth/Authn.vue index 3be67f468..a2b0de44d 100644 --- a/src/views/Auth/Authn.vue +++ b/src/views/Auth/Authn.vue @@ -39,18 +39,22 @@ prop="metrics.metrics.rate" :min-width="148" /> + + + - +