按实际安全设置状态重复提醒并仅关闭当前登录提示
Security Checks / security (push) Waiting to run

This commit is contained in:
xuans committed 2026-09-18 23:32:06 +08:00
1 parent 4e2f69ae60
commit 914bdc67e2
11 files changed
+208 -71

No files matched your search

@@ -22,7 +22,7 @@ export function usePage() {
options.push({ value: 'password', label: lang.modify_pwd })
options.push({ value: 'question', label: '密保问题' })
if (!isSuperAdmin.value) {
options.push({ value: 'recovery', label: '离线恢复码' })
options.push({ value: 'recovery', label: '安全码' })
}
options.push({ value: 'external-email', label: '外部安全邮箱' })
options.push({ value: 'totp', label: '手机动态码' })
@@ -84,7 +84,7 @@
<el-divider v-if="selectedSection === 'recovery'" class="settings-divider" />
<section v-if="selectedSection === 'recovery' && !isSuperAdmin" class="security-section">
<div class="settings-header security-key-header">
<div><h3>离线恢复码</h3><p class="settings-desc">恢复码只在生成时显示一次,请保存到安全位置。</p></div>
<div><h3>安全码</h3><p class="settings-desc">安全码只在生成时显示一次,请妥善保存。</p></div>
<div class="section-actions"><el-button type="primary" @click="generateRecoveryCodes">生成新恢复码</el-button><el-button v-if="recoveryConfigured" type="danger" plain @click="revokeRecoveryCodes">撤销</el-button></div>
</div>
<el-alert v-if="recoveryConfigured" title="当前已配置有效离线恢复码" type="success" :closable="false" show-icon />
@@ -10,16 +10,16 @@ export function usePage() {
&& globalStatus.userInfos.showSecuritySetupPrompt === true
&& !globalStatus.userInfos.must_change_password)
const isSuperAdmin = computed(() => globalStatus.role === 'super_admin')
const options = computed(() => [
{ key: 'question', title: '密保问题', description: '设置只有自己知道的答案,避免使用容易猜到的个人信息。' },
{ key: 'external-email', title: '外部安全邮箱', description: '绑定可正常接收验证码的外部邮箱,并完成验证。' },
{
key: 'webauthn', title: '安全密钥',
description: globalStatus.userInfos.webAuthnEnabled === true
? '使用支持 WebAuthn 的设备或浏览器注册安全密钥。'
: '服务器尚未启用,需由部署管理员配置 WebAuthn 后才能注册。'
const options = computed(() => {
const items = []
if (!isSuperAdmin.value && !globalStatus.userInfos.recoveryCodesConfigured) {
items.push({ key: 'recovery', title: '安全码', description: '生成安全码并妥善保存。' })
}
])
if (!globalStatus.userInfos.externalEmailConfigured) {
items.push({ key: 'external-email', title: '外部邮箱', description: '绑定邮箱并完成验证。' })
}
return items
})
const acknowledge = async section => {
if (saving.value) return
@@ -8,7 +8,7 @@
:show-close="false"
class="security-setup-dialog"
>
<p class="setup-description">欢迎使用 Smail!首次登录请了解并设置以下安全选项,确认后不再自动弹出此引导。</p>
<p class="setup-description">{{ isSuperAdmin ? '请绑定外部邮箱。未完成前,每次登录都会提醒。' : '请设置安全码并绑定外部邮箱。未完成前,每次登录都会提醒。' }}</p>
<div class="setup-options">
<section v-for="item in options" :key="item.key" class="setup-option">
<div>
@@ -18,24 +18,10 @@
<el-button :disabled="saving" @click="acknowledge(item.key)">前往设置</el-button>
</section>
</div>
<el-alert
v-if="isSuperAdmin"
title="超级管理员密码仍只能通过部署端受保护的本机通道重置,上述选项不会开放网页密码恢复。"
type="info"
:closable="false"
show-icon
/>
<el-alert
v-else
title="普通账号还可在安全设置中生成离线恢复码。恢复码只显示一次,请妥善保存。"
type="info"
:closable="false"
show-icon
/>
<el-alert v-if="error" :title="error" type="error" :closable="false" show-icon />
<template #footer>
<el-button :loading="saving" @click="acknowledge()">我已了解,稍后设置</el-button>
<el-button type="primary" :loading="saving" @click="acknowledge('question')">开始设置</el-button>
<el-button :loading="saving" @click="acknowledge()">我知道了</el-button>
<el-button type="primary" :loading="saving" @click="acknowledge(options[0]?.key)">去设置</el-button>
</template>
</el-dialog>
</template>