Skip to content

Commit

Permalink
refactor: 增加认证文本获取方法的错误捕获逻辑
Browse files Browse the repository at this point in the history
# Reviewed, transaction id: 16534
  • Loading branch information
Carlmac committed Aug 27, 2024
1 parent 1c8726e commit 3737434
Showing 1 changed file with 28 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit 3737434

Please sign in to comment.