1.优化谷歌验证器-前端不显示验证器按钮

This commit is contained in:
2026-06-24 16:49:34 +08:00
parent 21def75ef1
commit ceb4386440
4 changed files with 41 additions and 6 deletions

View File

@@ -9,7 +9,6 @@
/>
<!-- 表格 -->
<!-- 要使用`el-table`组件原有的属性直接加在Table标签上即可 -->
<Table />
<!-- 表单 -->
@@ -36,6 +35,18 @@ defineOptions({
const { t } = useI18n()
const adminInfo = useAdminInfo()
/** 超管或拥有 resetTotp 权限,且不能操作自己 */
const canManageTotp = (row: TableRow) => {
if (row.id == adminInfo.id) {
return false
}
return adminInfo.super
}
const isTotpBound = (row: TableRow) => {
return row.totp_bound === true || row.totp_bound === 1 || row.totp_bound === '1'
}
const optButtons: OptButton[] = [
{
render: 'confirmButton',
@@ -52,15 +63,25 @@ const optButtons: OptButton[] = [
title: t('auth.admin.Reset authenticator confirm'),
},
disabledTip: false,
display: (row: TableRow) => {
return adminInfo.super && row.id != adminInfo.id && !!row.totp_bound
},
display: (row: TableRow) => canManageTotp(row) && isTotpBound(row),
click: (row: TableRow) => {
resetTotp(row.id).then(() => {
baTable.onTableHeaderAction('refresh', {})
})
},
},
{
render: 'tipButton',
name: 'bindTip',
title: 'auth.admin.Pending bind tip',
text: '',
type: 'info',
icon: 'fa fa-shield',
class: 'table-row-bind-tip',
disabledTip: false,
display: (row: TableRow) => canManageTotp(row) && !isTotpBound(row),
disabled: () => true,
},
...defaultOptButtons(['edit', 'delete']).map((btn) => {
if (btn.name === 'delete') {
return {
@@ -115,7 +136,7 @@ const baTable = new baTableClass(
{
label: t('Operate'),
align: 'center',
width: '140',
width: '170',
render: 'buttons',
buttons: optButtons,
operator: false,