From 3737434945cf8d0dda016ade3d27cfb6cc10506b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zhukeda-=E6=9C=B1=E7=A7=91=E8=BE=BE?= Date: Tue, 27 Aug 2024 09:58:23 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=A2=9E=E5=8A=A0=E8=AE=A4?= =?UTF-8?q?=E8=AF=81=E6=96=87=E6=9C=AC=E8=8E=B7=E5=8F=96=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E7=9A=84=E9=94=99=E8=AF=AF=E6=8D=95=E8=8E=B7=E9=80=BB=E8=BE=91?= =?UTF-8?q?=20#=20Reviewed,=20transaction=20id:=2016534?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resource/setting/hooks/useTextGetter.ts | 48 +++++++++++-------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/src/dashboard-front/src/views/resource/setting/hooks/useTextGetter.ts b/src/dashboard-front/src/views/resource/setting/hooks/useTextGetter.ts index 9a1cdca7b..82f779875 100644 --- a/src/dashboard-front/src/views/resource/setting/hooks/useTextGetter.ts +++ b/src/dashboard-front/src/views/resource/setting/hooks/useTextGetter.ts @@ -6,35 +6,43 @@ export default function useTextGetter() { if (!authConfig) return '--'; let auth; - if (typeof authConfig === 'string') { - auth = JSON.parse(authConfig); - } else { - auth = authConfig; - } - const tmpArr: string[] = []; + try { + if (typeof authConfig === 'string') { + auth = JSON.parse(authConfig); + } else { + auth = authConfig; + } + const tmpArr: string[] = []; - if (auth?.app_verified_required) { - tmpArr.push(`${t('蓝鲸应用认证')}`); - } - if (auth?.auth_verified_required) { - tmpArr.push(`${t('用户认证')}`); + if (auth?.app_verified_required) { + tmpArr.push(`${t('蓝鲸应用认证')}`); + } + if (auth?.auth_verified_required) { + tmpArr.push(`${t('用户认证')}`); + } + return tmpArr.join(', ') || '--'; + } catch { + return '--'; } - return tmpArr.join(', ') || '--'; }; const getPermRequiredText = (authConfig: string | object | null | undefined) => { if (!authConfig) return '--'; let auth; - if (typeof authConfig === 'string') { - auth = JSON.parse(authConfig); - } else { - auth = authConfig; - } - if (auth?.resource_perm_required) { - return `${t('是')}`; + try { + if (typeof authConfig === 'string') { + auth = JSON.parse(authConfig); + } else { + auth = authConfig; + } + if (auth?.resource_perm_required) { + return `${t('是')}`; + } + return `${t('否')}`; + } catch { + return '--'; } - return `${t('否')}`; }; const getPublicSettingText = (is_public: boolean | null | undefined) => {