完善配置审计与数据库迁移安全链路
This commit is contained in:
1 parent
84440d8761
commit
3af1fc4147
117 files changed
+4703
-1110
No files matched your search
@@ -34,7 +34,7 @@ const useGlobalStatusStore = defineStore("useGlobalStatusStore", {
|
||||
|
||||
this.authLoading = true;
|
||||
try {
|
||||
const response = await http.post("/api/user/info", {});
|
||||
const response = await http.post("/api/v1/user/info", {});
|
||||
if (response.errorNo === 0 && response.data) {
|
||||
this.setUser(response.data, false);
|
||||
this.authChecked = true;
|
||||
|
||||
+22
-3
@@ -27,6 +27,21 @@ http.interceptors.request.use((config) => {
|
||||
Promise.reject(error));
|
||||
|
||||
//响应拦截器
|
||||
function attachApiErrorDetails(error) {
|
||||
const payload = error?.response?.data
|
||||
const details = payload?.data
|
||||
|
||||
if (payload && typeof payload === 'object') {
|
||||
error.apiErrorCode = typeof details?.code === 'string' ? details.code : ''
|
||||
error.apiRequestId = typeof details?.requestId === 'string' ? details.requestId : ''
|
||||
error.apiErrorFields = details?.fields && typeof details.fields === 'object' ? details.fields : {}
|
||||
if (typeof payload.errorMsg === 'string' && payload.errorMsg.trim()) {
|
||||
error.message = payload.errorMsg
|
||||
}
|
||||
}
|
||||
|
||||
return error
|
||||
}
|
||||
http.interceptors.response.use(async (response) => {
|
||||
//响应成功
|
||||
if (response.data.errorNo === 403) {
|
||||
@@ -95,9 +110,13 @@ http.interceptors.response.use(async (response) => {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
message = '请求失败';
|
||||
}
|
||||
return Promise.reject(error);
|
||||
const enrichedError = attachApiErrorDetails(error)
|
||||
if (message && !enrichedError.response?.data?.errorMsg) {
|
||||
enrichedError.message = message
|
||||
}
|
||||
return Promise.reject(enrichedError)
|
||||
}
|
||||
return Promise.reject(error);
|
||||
return Promise.reject(attachApiErrorDetails(error));
|
||||
});
|
||||
|
||||
export {http};
|
||||
export {http};
|
||||
@@ -0,0 +1,11 @@
|
||||
export const PASSWORD_MIN_BYTES = 8
|
||||
export const PASSWORD_MAX_BYTES = 12
|
||||
|
||||
export function getPasswordByteLength(value) {
|
||||
return new TextEncoder().encode(value || "").length
|
||||
}
|
||||
|
||||
export function isValidPasswordLength(value) {
|
||||
const length = getPasswordByteLength(value)
|
||||
return length >= PASSWORD_MIN_BYTES && length <= PASSWORD_MAX_BYTES
|
||||
}
|
||||
@@ -169,7 +169,7 @@ export function usePage() {
|
||||
|
||||
let text = editorRef.value.getText()
|
||||
|
||||
http.post("/api/email/send", {
|
||||
http.post("/api/v1/email/send", {
|
||||
from: {name: ruleForm.nickName, email: ruleForm.sender + "@" + ruleForm.pick域名},
|
||||
to: objectTos,
|
||||
cc: objectCcs,
|
||||
|
||||
@@ -31,7 +31,7 @@ export function usePage() {
|
||||
|
||||
const showCC = ref(false)
|
||||
|
||||
http.post("/api/email/detail", {id: parseInt(route.params.id)}).then(res => {
|
||||
http.post("/api/v1/email/detail", {id: parseInt(route.params.id)}).then(res => {
|
||||
detailData.value = res.data || {}
|
||||
detailData.value.attachments = res.data.attachments || [];
|
||||
|
||||
@@ -88,7 +88,7 @@ export function usePage() {
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}).then(() => {
|
||||
http.post("/api/email/del", {ids: [id], forcedDel}).then(res => {
|
||||
http.post("/api/v1/email/del", {ids: [id], forcedDel}).then(res => {
|
||||
if (res.errorNo === 0) {
|
||||
ElMessage.success('删除成功');
|
||||
router.push({name: 'list'});
|
||||
|
||||
@@ -6,6 +6,8 @@ import { useRouter } from "vue-router"
|
||||
|
||||
import { http } from "@/utils/axios"
|
||||
|
||||
import { isValidPasswordLength } from "@/utils/password"
|
||||
|
||||
import { useGlobalStatusStore } from "@/stores/useGlobalStatusStore"
|
||||
|
||||
export function usePage() {
|
||||
@@ -27,14 +29,14 @@ export function usePage() {
|
||||
ElMessage.warning("两次输入的新密码不一致")
|
||||
return
|
||||
}
|
||||
if (new TextEncoder().encode(form.newPassword).length < 8) {
|
||||
ElMessage.warning("新密码长度至少为 8 个字节")
|
||||
if (!isValidPasswordLength(form.newPassword)) {
|
||||
ElMessage.warning("新密码长度必须为 8 到 12 个字节")
|
||||
return
|
||||
}
|
||||
|
||||
loading.value = true
|
||||
try {
|
||||
const response = await http.post("/api/settings/modify_password", {
|
||||
const response = await http.post("/api/v1/settings/modify_password", {
|
||||
current_password: form.currentPassword,
|
||||
password: form.newPassword
|
||||
})
|
||||
@@ -54,7 +56,7 @@ export function usePage() {
|
||||
|
||||
const logout = async () => {
|
||||
try {
|
||||
await http.post("/api/logout", {})
|
||||
await http.post("/api/v1/logout", {})
|
||||
} finally {
|
||||
globalStatus.clear()
|
||||
await router.replace({ name: "login" })
|
||||
|
||||
@@ -47,14 +47,14 @@ export function usePage() {
|
||||
const totalPage = ref(0)
|
||||
|
||||
const updateList = function () {
|
||||
http.post("/api/email/list", {tag: tag, page_size: 15}).then(res => {
|
||||
http.post("/api/v1/email/list", {tag: tag, page_size: 15}).then(res => {
|
||||
data.value = res.data.list || []
|
||||
totalPage.value = res.data.total_page || 0
|
||||
})
|
||||
}
|
||||
|
||||
const updateGroupList = function () {
|
||||
http.post("/api/group/list").then(res => {
|
||||
http.post("/api/v1/group/list").then(res => {
|
||||
groupList.value = res.data || []
|
||||
})
|
||||
}
|
||||
@@ -100,7 +100,7 @@ export function usePage() {
|
||||
return;
|
||||
}
|
||||
let ids = rows.map(e => e.id);
|
||||
http.post("/api/email/read", {"ids": ids}).then(res => {
|
||||
http.post("/api/v1/email/read", {"ids": ids}).then(res => {
|
||||
if (res.errorNo === 0) {
|
||||
updateList()
|
||||
ElMessage.success('Marked as read');
|
||||
@@ -121,7 +121,7 @@ export function usePage() {
|
||||
ElMessageBox.confirm(lang.move_email_confirm, '警告', {
|
||||
confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning'
|
||||
}).then(() => {
|
||||
http.post("/api/email/move", {"group_id": group_id, "group_name": group_name, "ids": ids}).then(res => {
|
||||
http.post("/api/v1/email/move", {"group_id": group_id, "group_name": group_name, "ids": ids}).then(res => {
|
||||
if (res.errorNo === 0) {
|
||||
updateList()
|
||||
ElMessage.success('移动完成')
|
||||
@@ -144,7 +144,7 @@ export function usePage() {
|
||||
ElMessageBox.confirm(lang.del_email_confirm, '警告', {
|
||||
confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning'
|
||||
}).then(() => {
|
||||
http.post("/api/email/del", {"ids": ids, "forcedDel": groupTag.status === 3}).then(res => {
|
||||
http.post("/api/v1/email/del", {"ids": ids, "forcedDel": groupTag.status === 3}).then(res => {
|
||||
if (res.errorNo === 0) {
|
||||
updateList()
|
||||
ElMessage.success('删除成功')
|
||||
@@ -160,7 +160,7 @@ export function usePage() {
|
||||
}
|
||||
|
||||
const pageChange = function (p) {
|
||||
http.post("/api/email/list", {tag: tag, page_size: 15, current_page: p}).then(res => {
|
||||
http.post("/api/v1/email/list", {tag: tag, page_size: 15, current_page: p}).then(res => {
|
||||
data.value = res.data.list || []
|
||||
})
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ export function usePage() {
|
||||
}
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await http.post("/api/login", form)
|
||||
const res = await http.post("/api/v1/login", form)
|
||||
if (res.errorNo !== 0) {
|
||||
ElMessage.error(res.errorMsg)
|
||||
return
|
||||
|
||||
@@ -69,7 +69,7 @@ export function usePage() {
|
||||
loading.value = true
|
||||
errorMessage.value = ""
|
||||
try {
|
||||
const response = await http.post("/api/security/login/verify", {
|
||||
const response = await http.post("/api/v1/security/login/verify", {
|
||||
id: pending.value.challengeId,
|
||||
account: pending.value.account,
|
||||
code: code.value.trim()
|
||||
@@ -96,7 +96,7 @@ export function usePage() {
|
||||
resending.value = true
|
||||
errorMessage.value = ""
|
||||
try {
|
||||
const response = await http.post("/api/security/login/resend", {
|
||||
const response = await http.post("/api/v1/security/login/resend", {
|
||||
id: pending.value.challengeId,
|
||||
account: pending.value.account
|
||||
})
|
||||
@@ -126,7 +126,7 @@ export function usePage() {
|
||||
webAuthnLoading.value = true
|
||||
errorMessage.value = ""
|
||||
try {
|
||||
const begin = await http.post("/api/security/webauthn/login/begin", {
|
||||
const begin = await http.post("/api/v1/security/webauthn/login/begin", {
|
||||
challenge_id: pending.value.challengeId,
|
||||
account: pending.value.account
|
||||
})
|
||||
@@ -136,7 +136,7 @@ export function usePage() {
|
||||
const credential = await navigator.credentials.get({
|
||||
publicKey: normalizeRequestOptions(begin.data.options)
|
||||
})
|
||||
const finish = await http.post("/api/security/webauthn/login/finish", {
|
||||
const finish = await http.post("/api/v1/security/webauthn/login/finish", {
|
||||
challenge_id: pending.value.challengeId,
|
||||
account: pending.value.account,
|
||||
session_id: begin.data.session_id,
|
||||
|
||||
@@ -4,6 +4,8 @@ import { ElMessage } from 'element-plus'
|
||||
|
||||
import { http } from '@/utils/axios'
|
||||
|
||||
import { isValidPasswordLength } from '@/utils/password'
|
||||
|
||||
export function usePage() {
|
||||
const loading = ref(false)
|
||||
|
||||
@@ -61,7 +63,7 @@ export function usePage() {
|
||||
verificationState.value = ''
|
||||
sendingCode.value = true
|
||||
try {
|
||||
const result = await http.post('/api/security/recovery/begin', {
|
||||
const result = await http.post('/api/v1/security/recovery/begin', {
|
||||
identifier: recovery.identifier,
|
||||
email: recovery.email
|
||||
})
|
||||
@@ -84,9 +86,8 @@ export function usePage() {
|
||||
ElMessage.warning('两次输入的新密码不一致')
|
||||
return false
|
||||
}
|
||||
const passwordLength = new TextEncoder().encode(recovery.newPassword).length
|
||||
if (passwordLength < 8 || passwordLength > 256) {
|
||||
ElMessage.warning('新密码长度必须为 8-256 个字节')
|
||||
if (!isValidPasswordLength(recovery.newPassword)) {
|
||||
ElMessage.warning('新密码长度必须为 8 到 12 个字节')
|
||||
return false
|
||||
}
|
||||
return true
|
||||
@@ -128,7 +129,7 @@ export function usePage() {
|
||||
answer: recovery.answer,
|
||||
recovery_code: recovery.recoveryCode
|
||||
}
|
||||
const result = await http.post('/api/security/recovery/verify', payload)
|
||||
const result = await http.post('/api/v1/security/recovery/verify', payload)
|
||||
if (result.errorNo !== 0 || !result.data?.ticket) throw new Error('验证失败')
|
||||
verificationTicket.value = result.data.ticket
|
||||
return result.data.ticket
|
||||
@@ -141,7 +142,7 @@ export function usePage() {
|
||||
verificationState.value = ''
|
||||
try {
|
||||
const ticket = await verifyRecovery()
|
||||
const result = await http.post('/api/security/recovery/complete', {
|
||||
const result = await http.post('/api/v1/security/recovery/complete', {
|
||||
ticket,
|
||||
new_password: recovery.newPassword
|
||||
})
|
||||
|
||||
+122
-248
@@ -1,295 +1,169 @@
|
||||
.recovery-content {
|
||||
width: 100%;
|
||||
max-width: 760px;
|
||||
max-width: 720px;
|
||||
min-width: 0;
|
||||
margin: auto;
|
||||
padding: clamp(28px, 4vw, 48px);
|
||||
margin: 0 auto;
|
||||
padding: clamp(24px, 4vw, 44px);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.reset-boundary {
|
||||
margin-top: 18px;
|
||||
}
|
||||
|
||||
.security-notice,
|
||||
.steps-card,
|
||||
.channel-card {
|
||||
min-width: 0;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid var(--pm-border-color);
|
||||
border-radius: 14px;
|
||||
background: rgba(247, 250, 255, 0.9);
|
||||
box-shadow: 0 4px 14px rgba(31, 41, 55, 0.04);
|
||||
}
|
||||
|
||||
.security-notice {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
margin-bottom: 18px;
|
||||
padding: 12px 14px;
|
||||
box-sizing: border-box;
|
||||
color: var(--pm-text-secondary);
|
||||
background: rgba(247, 250, 255, 0.88);
|
||||
border: 1px solid var(--pm-border-color);
|
||||
border-radius: 12px;
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
gap: 14px;
|
||||
align-items: flex-start;
|
||||
padding: 18px;
|
||||
border-color: rgba(245, 158, 11, 0.32);
|
||||
background: rgba(255, 251, 235, 0.92);
|
||||
}
|
||||
|
||||
.security-notice strong {
|
||||
.notice-icon {
|
||||
display: inline-flex;
|
||||
flex: 0 0 auto;
|
||||
color: var(--pm-text-primary);
|
||||
white-space: nowrap;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border-radius: 50%;
|
||||
color: #ffffff;
|
||||
background: #d97706;
|
||||
font-size: 17px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.security-notice span {
|
||||
min-width: 0;
|
||||
.security-notice h2,
|
||||
.steps-card h3 {
|
||||
margin: 0;
|
||||
color: var(--pm-text-primary);
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.security-notice h2 {
|
||||
font-size: 19px;
|
||||
}
|
||||
|
||||
.security-notice p,
|
||||
.channel-card p {
|
||||
margin: 8px 0 0;
|
||||
color: var(--pm-text-secondary);
|
||||
font-size: 14px;
|
||||
line-height: 1.7;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.method-switcher {
|
||||
.steps-card,
|
||||
.channel-card {
|
||||
margin-top: 16px;
|
||||
padding: 18px;
|
||||
}
|
||||
|
||||
.steps-card h3 {
|
||||
font-size: 17px;
|
||||
}
|
||||
|
||||
.steps-card ol {
|
||||
margin: 12px 0 0;
|
||||
padding-left: 24px;
|
||||
color: var(--pm-text-secondary);
|
||||
font-size: 14px;
|
||||
line-height: 1.8;
|
||||
}
|
||||
|
||||
.steps-card li + li {
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
code {
|
||||
padding: 2px 6px;
|
||||
border-radius: 6px;
|
||||
color: var(--pm-primary-color);
|
||||
background: rgba(37, 99, 235, 0.1);
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
font-size: 0.94em;
|
||||
}
|
||||
|
||||
.channel-heading {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
min-width: 0;
|
||||
margin-bottom: 18px;
|
||||
padding: 10px 14px;
|
||||
box-sizing: border-box;
|
||||
background: rgba(247, 250, 255, 0.88);
|
||||
border: 1px solid var(--pm-border-color);
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 4px 14px rgba(31, 41, 55, 0.04);
|
||||
}
|
||||
|
||||
.method-copy {
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
.method-label {
|
||||
color: var(--pm-text-secondary);
|
||||
font-size: 13px;
|
||||
line-height: 1.35;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.method-copy strong {
|
||||
.channel-heading strong {
|
||||
color: var(--pm-text-primary);
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
line-height: 1.35;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.switch-button {
|
||||
flex: 0 1 auto;
|
||||
max-width: 48%;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.verification-panel {
|
||||
min-width: 0;
|
||||
margin-bottom: 18px;
|
||||
padding: 16px;
|
||||
box-sizing: border-box;
|
||||
background: rgba(247, 250, 255, 0.88);
|
||||
border: 1px solid var(--pm-border-color);
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 4px 14px rgba(31, 41, 55, 0.04);
|
||||
}
|
||||
|
||||
.verification-panel h2 {
|
||||
margin: 0 0 6px;
|
||||
color: var(--pm-text-primary);
|
||||
font-size: 17px;
|
||||
line-height: 1.35;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.verification-panel p {
|
||||
margin: 0 0 14px;
|
||||
color: var(--pm-text-secondary);
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.verification-panel :deep(.el-form-item) {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.verification-panel :deep(.el-form-item__label),
|
||||
.password-form :deep(.el-form-item__label) {
|
||||
max-width: 100%;
|
||||
padding-bottom: 4px;
|
||||
color: var(--pm-text-primary);
|
||||
font-weight: 500;
|
||||
line-height: 1.35;
|
||||
white-space: normal;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.verification-panel :deep(.el-input__wrapper),
|
||||
.password-form :deep(.el-input__wrapper) {
|
||||
min-height: 44px;
|
||||
background-color: var(--pm-surface-muted);
|
||||
border: 1px solid transparent;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 0 0 1px var(--pm-border-color) inset !important;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.verification-panel :deep(.el-input__wrapper:hover),
|
||||
.verification-panel :deep(.el-input__wrapper.is-focus),
|
||||
.password-form :deep(.el-input__wrapper:hover),
|
||||
.password-form :deep(.el-input__wrapper.is-focus) {
|
||||
border-color: var(--pm-primary-color);
|
||||
background-color: var(--pm-bg-secondary);
|
||||
}
|
||||
|
||||
.recovery-action-btn,
|
||||
.switch-button {
|
||||
min-height: 44px;
|
||||
padding: 0 14px;
|
||||
border-radius: 14px;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
line-height: 1.35;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.recovery-action-btn {
|
||||
box-shadow: 0 10px 24px rgba(37, 99, 235, 0.2);
|
||||
}
|
||||
|
||||
.recovery-action-btn:hover {
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 14px 28px rgba(37, 99, 235, 0.26);
|
||||
}
|
||||
|
||||
.secondary-action-btn {
|
||||
color: var(--pm-text-primary);
|
||||
border-color: var(--pm-border-color);
|
||||
background: rgba(240, 246, 255, 0.9);
|
||||
box-shadow: 0 4px 14px rgba(31, 41, 55, 0.04);
|
||||
}
|
||||
|
||||
.secondary-action-btn:hover,
|
||||
.secondary-action-btn:focus-visible {
|
||||
color: var(--pm-primary-color);
|
||||
border-color: rgba(37, 99, 235, 0.36);
|
||||
background: rgba(37, 99, 235, 0.07);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.email-verification-row {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) minmax(128px, auto);
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.email-verification-row > * {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.email-verification-row :deep(.el-button) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.verification-state {
|
||||
display: block;
|
||||
min-width: 0;
|
||||
margin-top: 10px;
|
||||
color: var(--pm-text-secondary);
|
||||
font-size: 13px;
|
||||
line-height: 1.45;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.password-form :deep(.el-form-item) {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.actions {
|
||||
.channel-hint {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-top: 18px;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px 16px;
|
||||
margin-top: 12px;
|
||||
color: var(--pm-text-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.back-button {
|
||||
display: block;
|
||||
margin: 18px auto 0;
|
||||
display: flex;
|
||||
width: 100%;
|
||||
margin-top: 20px;
|
||||
min-height: 44px;
|
||||
border-radius: 12px;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
@media (max-width: 760px) {
|
||||
.recovery-content {
|
||||
max-width: none;
|
||||
padding: 18px 16px 22px;
|
||||
padding: 18px 16px 24px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 560px) {
|
||||
.security-notice {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.security-notice strong {
|
||||
display: block;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.method-switcher {
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.switch-button {
|
||||
max-width: 48%;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.email-verification-row {
|
||||
grid-template-columns: minmax(0, 1fr) minmax(118px, auto);
|
||||
}
|
||||
|
||||
.actions,
|
||||
.actions .el-button,
|
||||
.back-button {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 380px) {
|
||||
@media (max-width: 480px) {
|
||||
.recovery-content {
|
||||
padding: 16px 12px 20px;
|
||||
}
|
||||
|
||||
.security-notice,
|
||||
.method-switcher,
|
||||
.verification-panel {
|
||||
padding: 10px;
|
||||
.steps-card,
|
||||
.channel-card {
|
||||
padding: 14px;
|
||||
}
|
||||
|
||||
.method-switcher {
|
||||
align-items: stretch;
|
||||
.security-notice {
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.security-notice h2 {
|
||||
font-size: 17px;
|
||||
}
|
||||
|
||||
.security-notice p,
|
||||
.channel-card p,
|
||||
.steps-card ol {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.channel-heading {
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
.switch-button {
|
||||
width: 100%;
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
.email-verification-row {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.method-label,
|
||||
.verification-panel p,
|
||||
.verification-state {
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.method-copy strong,
|
||||
.verification-panel h2 {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.recovery-action-btn,
|
||||
.switch-button {
|
||||
min-height: 38px;
|
||||
padding-right: 10px;
|
||||
padding-left: 10px;
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,139 +1,12 @@
|
||||
import { computed, reactive, ref } from 'vue'
|
||||
|
||||
import { ElMessage } from 'element-plus'
|
||||
|
||||
import { http } from '@/utils/axios'
|
||||
|
||||
import { normalizeRequestOptions, serializeCredential, webAuthnSupported } from '@/utils/webauthn'
|
||||
import { ref } from 'vue'
|
||||
|
||||
export function usePage() {
|
||||
const loading = ref(false)
|
||||
|
||||
const verificationTicket = ref('')
|
||||
|
||||
const verificationState = ref('')
|
||||
|
||||
const securityKeySupported = webAuthnSupported()
|
||||
|
||||
const recovery = reactive({
|
||||
method: 'webauthn',
|
||||
email: '',
|
||||
code: '',
|
||||
challengeId: '',
|
||||
newPassword: '',
|
||||
confirmPassword: ''
|
||||
})
|
||||
|
||||
const verified = computed(() => verificationTicket.value !== '')
|
||||
|
||||
const clearVerification = () => {
|
||||
recovery.code = ''
|
||||
recovery.challengeId = ''
|
||||
verificationTicket.value = ''
|
||||
verificationState.value = ''
|
||||
}
|
||||
|
||||
const switchRecoveryMethod = () => {
|
||||
recovery.method = recovery.method === 'webauthn' ? 'email' : 'webauthn'
|
||||
recovery.email = ''
|
||||
clearVerification()
|
||||
}
|
||||
|
||||
const verifySecurityKey = async () => {
|
||||
if (!securityKeySupported) {
|
||||
ElMessage.warning('当前浏览器或访问环境不支持安全密钥')
|
||||
return
|
||||
}
|
||||
clearVerification()
|
||||
loading.value = true
|
||||
try {
|
||||
const begin = await http.post('/api/security/recovery/webauthn/begin', { identifier: 'super_admin' })
|
||||
if (begin.errorNo !== 0 || !begin.data?.options) throw new Error('安全密钥验证暂不可用')
|
||||
const credential = await navigator.credentials.get({ publicKey: normalizeRequestOptions(begin.data.options) })
|
||||
const result = await http.post('/api/security/recovery/webauthn/verify', {
|
||||
identifier: 'super_admin',
|
||||
session_id: begin.data.session_id,
|
||||
credential: serializeCredential(credential)
|
||||
})
|
||||
if (result.errorNo !== 0 || !result.data?.ticket) throw new Error('安全密钥验证失败')
|
||||
verificationTicket.value = result.data.ticket
|
||||
verificationState.value = '安全密钥验证成功'
|
||||
} catch (error) {
|
||||
if (error?.name !== 'NotAllowedError') {
|
||||
verificationState.value = '安全密钥验证未完成'
|
||||
ElMessage.error(error?.message || '安全密钥验证失败')
|
||||
}
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const requestRecoveryCode = async () => {
|
||||
if (!recovery.email) {
|
||||
ElMessage.warning('请填写外部安全邮箱')
|
||||
return
|
||||
}
|
||||
clearVerification()
|
||||
loading.value = true
|
||||
try {
|
||||
const result = await http.post('/api/security/recovery/begin', { identifier: 'super_admin', email: recovery.email })
|
||||
if (result.errorNo === 0 && result.data?.id) recovery.challengeId = result.data.id
|
||||
verificationState.value = '如果邮箱有效,验证码将发送到该邮箱'
|
||||
} catch (_) {
|
||||
verificationState.value = '如果邮箱有效,验证码将发送到该邮箱'
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const validatePassword = () => {
|
||||
if (!recovery.newPassword || !recovery.confirmPassword) {
|
||||
ElMessage.warning('请填写两次新密码')
|
||||
return false
|
||||
}
|
||||
if (recovery.newPassword !== recovery.confirmPassword) {
|
||||
ElMessage.warning('两次输入的新密码不一致')
|
||||
return false
|
||||
}
|
||||
if (new TextEncoder().encode(recovery.newPassword).length < 8) {
|
||||
ElMessage.warning('新密码至少需要 8 个字节')
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
const completeRecovery = () => {
|
||||
if (!verified.value) {
|
||||
ElMessage.warning('请先完成当前验证方式')
|
||||
return
|
||||
}
|
||||
if (!validatePassword()) return
|
||||
ElMessage.warning('请通过部署端 smail-admin 本机安全通道完成正式重置')
|
||||
}
|
||||
|
||||
|
||||
const goLogin = () => window.location.assign('/#/login')
|
||||
|
||||
return {
|
||||
computed,
|
||||
reactive,
|
||||
ref,
|
||||
ElMessage,
|
||||
http,
|
||||
normalizeRequestOptions,
|
||||
serializeCredential,
|
||||
webAuthnSupported,
|
||||
loading,
|
||||
verificationTicket,
|
||||
verificationState,
|
||||
securityKeySupported,
|
||||
recovery,
|
||||
verified,
|
||||
clearVerification,
|
||||
switchRecoveryMethod,
|
||||
verifySecurityKey,
|
||||
requestRecoveryCode,
|
||||
validatePassword,
|
||||
completeRecovery,
|
||||
goLogin
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
<template>
|
||||
<template>
|
||||
<AuthLayout
|
||||
brand-caption="超级管理员密码重置"
|
||||
intro-title="重置超级管理员密码"
|
||||
intro-description="此页面仅用于系统中唯一的超级管理员,不适用于管理员或普通用户。"
|
||||
intro-description="超级管理员密码不支持通过网页恢复,只能由部署端本机安全通道完成。"
|
||||
>
|
||||
<template #intro-extra>
|
||||
<el-alert
|
||||
title="正式重置必须由部署端 smail-admin 本机安全通道授权。"
|
||||
title="为避免远程接管风险,网页端不会收集或验证超级管理员重置凭据。"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
show-icon
|
||||
@@ -14,123 +14,44 @@
|
||||
/>
|
||||
</template>
|
||||
|
||||
<section class="recovery-content">
|
||||
<section class="recovery-content" aria-labelledby="recovery-title">
|
||||
<div class="security-notice">
|
||||
<strong>安全密钥不需要输入</strong>
|
||||
<span>
|
||||
点击验证按钮后,按照浏览器提示触碰硬件安全密钥,或使用系统安全凭据完成验证。
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="method-switcher">
|
||||
<div class="method-copy">
|
||||
<span class="method-label">当前验证方式</span>
|
||||
<strong>
|
||||
{{ recovery.method === 'webauthn' ? 'WebAuthn 安全密钥' : '外部邮箱验证码' }}
|
||||
</strong>
|
||||
<span class="notice-icon" aria-hidden="true">!</span>
|
||||
<div>
|
||||
<h2 id="recovery-title">请使用本机部署端工具</h2>
|
||||
<p>
|
||||
超级管理员重置必须在部署服务器本机发起,并由部署管理员进行交互式确认。
|
||||
普通登录页、忘记密码页和其他 Web API 均不能开启或完成该流程。
|
||||
</p>
|
||||
</div>
|
||||
<el-button
|
||||
plain
|
||||
type="primary"
|
||||
class="switch-button secondary-action-btn"
|
||||
:disabled="loading"
|
||||
@click="switchRecoveryMethod"
|
||||
>
|
||||
切换验证方式
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="recovery.method === 'webauthn'"
|
||||
class="verification-panel"
|
||||
>
|
||||
<h2>使用安全密钥验证</h2>
|
||||
<p>支持 USB、NFC、蓝牙安全密钥以及当前设备的系统凭据。</p>
|
||||
<el-button
|
||||
type="primary"
|
||||
class="recovery-action-btn"
|
||||
:loading="loading"
|
||||
:disabled="!securityKeySupported"
|
||||
@click="verifySecurityKey"
|
||||
>
|
||||
{{ securityKeySupported ? '验证安全密钥' : '当前环境不支持安全密钥' }}
|
||||
</el-button>
|
||||
<span v-if="verificationState" class="verification-state">
|
||||
{{ verificationState }}
|
||||
</span>
|
||||
<div class="steps-card">
|
||||
<h3>操作步骤</h3>
|
||||
<ol>
|
||||
<li>登录部署服务器本机终端,确认当前服务版本和运行状态。</li>
|
||||
<li>通过受保护的本机管理通道启动 <code>smail-admin</code>。</li>
|
||||
<li>按终端提示完成身份确认和新密码输入,密码不会回显或写入日志。</li>
|
||||
<li>重置成功后,使用新密码重新登录,并重新配置需要的安全凭据。</li>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
<div v-else class="verification-panel">
|
||||
<h2>使用外部邮箱验证码</h2>
|
||||
<p>验证码只发送到已经验证的超级管理员安全邮箱。</p>
|
||||
<el-form label-position="top">
|
||||
<el-form-item label="外部安全邮箱">
|
||||
<el-input
|
||||
v-model="recovery.email"
|
||||
type="email"
|
||||
autocomplete="email"
|
||||
placeholder="请输入外部安全邮箱"
|
||||
/>
|
||||
</el-form-item>
|
||||
<div class="email-verification-row">
|
||||
<el-input
|
||||
v-model="recovery.code"
|
||||
inputmode="numeric"
|
||||
maxlength="12"
|
||||
autocomplete="one-time-code"
|
||||
placeholder="请输入邮箱验证码"
|
||||
/>
|
||||
<el-button
|
||||
type="primary"
|
||||
class="recovery-action-btn"
|
||||
:loading="loading"
|
||||
@click="requestRecoveryCode"
|
||||
>
|
||||
发送验证码
|
||||
</el-button>
|
||||
</div>
|
||||
<span v-if="verificationState" class="verification-state">
|
||||
{{ verificationState }}
|
||||
</span>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<el-form
|
||||
class="password-form"
|
||||
label-position="top"
|
||||
@submit.prevent="completeRecovery"
|
||||
>
|
||||
<el-form-item label="新密码">
|
||||
<el-input
|
||||
v-model="recovery.newPassword"
|
||||
type="password"
|
||||
show-password
|
||||
autocomplete="new-password"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="确认新密码">
|
||||
<el-input
|
||||
v-model="recovery.confirmPassword"
|
||||
type="password"
|
||||
show-password
|
||||
autocomplete="new-password"
|
||||
/>
|
||||
</el-form-item>
|
||||
<div class="actions">
|
||||
<el-button
|
||||
type="primary"
|
||||
class="recovery-action-btn"
|
||||
:loading="loading"
|
||||
:disabled="!verified"
|
||||
native-type="submit"
|
||||
>
|
||||
验证并重置密码
|
||||
</el-button>
|
||||
<div class="channel-card">
|
||||
<div class="channel-heading">
|
||||
<span>专用安全通道</span>
|
||||
<strong>smail-admin</strong>
|
||||
</div>
|
||||
</el-form>
|
||||
<p>
|
||||
该工具只通过本机 IPC 与 Smail 主服务通信,不读取数据库密码,不监听网络端口,
|
||||
也不能执行任意命令或访问任意文件。
|
||||
</p>
|
||||
<div class="channel-hint">
|
||||
<span>Linux:Unix Domain Socket</span>
|
||||
<span>Windows:Named Pipe</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
class="back-button"
|
||||
@click="goLogin"
|
||||
@@ -145,18 +66,7 @@
|
||||
import AuthLayout from '@/views/components/AuthLayout/AuthLayout.vue'
|
||||
import { usePage } from './Recovery.js'
|
||||
|
||||
const {
|
||||
recovery,
|
||||
switchRecoveryMethod,
|
||||
loading,
|
||||
securityKeySupported,
|
||||
verifySecurityKey,
|
||||
verificationState,
|
||||
requestRecoveryCode,
|
||||
completeRecovery,
|
||||
verified,
|
||||
goLogin
|
||||
} = usePage()
|
||||
const { goLogin } = usePage()
|
||||
</script>
|
||||
|
||||
<style scoped src="./Recovery.css"></style>
|
||||
<style scoped src="./Recovery.css"></style>
|
||||
+11
-11
@@ -92,7 +92,7 @@ export function usePage() {
|
||||
return
|
||||
}
|
||||
|
||||
http.post("/api/setup", {
|
||||
http.post("/api/v1/setup", {
|
||||
"action": "set",
|
||||
"step": "password",
|
||||
"account": adminSettings.account,
|
||||
@@ -110,7 +110,7 @@ export function usePage() {
|
||||
}
|
||||
|
||||
const getPassword = () => {
|
||||
http.post("/api/setup", {"action": "get", "step": "password"}).then((res) => {
|
||||
http.post("/api/v1/setup", {"action": "get", "step": "password"}).then((res) => {
|
||||
if (res.errorNo !== 0) {
|
||||
ElMessage.error(res.errorMsg)
|
||||
} else {
|
||||
@@ -126,7 +126,7 @@ export function usePage() {
|
||||
}
|
||||
|
||||
const getDbConfig = () => {
|
||||
http.post("/api/setup", {"action": "get", "step": "database"}).then((res) => {
|
||||
http.post("/api/v1/setup", {"action": "get", "step": "database"}).then((res) => {
|
||||
if (res.errorNo !== 0) {
|
||||
ElMessage.error(res.errorMsg)
|
||||
} else {
|
||||
@@ -143,7 +143,7 @@ export function usePage() {
|
||||
}
|
||||
|
||||
const getDomainConfig = () => {
|
||||
http.post("/api/setup", {"action": "get", "step": "domain"}).then((res) => {
|
||||
http.post("/api/v1/setup", {"action": "get", "step": "domain"}).then((res) => {
|
||||
if (res.errorNo !== 0) {
|
||||
ElMessage.error(res.errorMsg)
|
||||
} else {
|
||||
@@ -196,7 +196,7 @@ export function usePage() {
|
||||
"db_name": dbSettings.name
|
||||
}
|
||||
|
||||
http.post("/api/setup", payload).then((res) => {
|
||||
http.post("/api/v1/setup", payload).then((res) => {
|
||||
if (res.errorNo !== 0) {
|
||||
ElMessage.error(res.errorMsg || lang.db_init_failed)
|
||||
return
|
||||
@@ -229,7 +229,7 @@ export function usePage() {
|
||||
}
|
||||
|
||||
const getDNSConfig = () => {
|
||||
http.post("/api/setup", {"action": "get", "step": "dns"}).then((res) => {
|
||||
http.post("/api/v1/setup", {"action": "get", "step": "dns"}).then((res) => {
|
||||
if (res.errorNo !== 0) {
|
||||
ElMessage.error(res.errorMsg)
|
||||
} else {
|
||||
@@ -270,7 +270,7 @@ export function usePage() {
|
||||
}
|
||||
|
||||
const getSSLConfig = () => {
|
||||
http.post("/api/setup", {"action": "get", "step": "ssl"}).then((res) => {
|
||||
http.post("/api/v1/setup", {"action": "get", "step": "ssl"}).then((res) => {
|
||||
if (res.errorNo !== 0) {
|
||||
ElMessage.error(res.errorMsg)
|
||||
} else {
|
||||
@@ -295,7 +295,7 @@ export function usePage() {
|
||||
}
|
||||
|
||||
|
||||
http.post("/api/setup", {
|
||||
http.post("/api/v1/setup", {
|
||||
"action": "set",
|
||||
"step": "ssl",
|
||||
"ssl_type": sslType,
|
||||
@@ -318,7 +318,7 @@ export function usePage() {
|
||||
}
|
||||
|
||||
const checkStatus = () => {
|
||||
http.post("/api/setup", {"action": "get", "step": "ssl"}).then((res) => {
|
||||
http.post("/api/v1/setup", {"action": "get", "step": "ssl"}).then((res) => {
|
||||
if (res.errorNo === 0 && res.data.ready) {
|
||||
if (sslSettings.type === "1") {
|
||||
window.location.href = "http://" + domainSettings.web_domain;
|
||||
@@ -334,7 +334,7 @@ export function usePage() {
|
||||
}
|
||||
|
||||
const setDomainConfig = () => {
|
||||
http.post("/api/setup", {
|
||||
http.post("/api/v1/setup", {
|
||||
"action": "set",
|
||||
"step": "domain",
|
||||
"web_domain": domainSettings.web_domain,
|
||||
@@ -351,7 +351,7 @@ export function usePage() {
|
||||
}
|
||||
|
||||
const getSSLDNSParams = () => {
|
||||
http.post("/api/setup", {"action": "getParams", "step": "ssl"}).then((res) => {
|
||||
http.post("/api/v1/setup", {"action": "getParams", "step": "ssl"}).then((res) => {
|
||||
if (res.errorNo !== 0) {
|
||||
ElMessage.error(res.errorMsg)
|
||||
} else {
|
||||
|
||||
@@ -11,13 +11,13 @@ import { Folder, Delete, Plus } from "@element-plus/icons-vue";
|
||||
export function usePage() {
|
||||
const data = reactive([]);
|
||||
|
||||
http.get("/api/group").then((res) => {
|
||||
http.get("/api/v1/group").then((res) => {
|
||||
data.push(...res.data);
|
||||
});
|
||||
|
||||
const del = function (node, dataObj) {
|
||||
if (dataObj.id !== -1) {
|
||||
http.post("/api/group/del", { id: dataObj.id }).then((res) => {
|
||||
http.post("/api/v1/group/del", { id: dataObj.id }).then((res) => {
|
||||
if (res.errorNo !== 0) {
|
||||
ElMessage({ message: res.errorMsg, type: "error" });
|
||||
} else {
|
||||
@@ -64,12 +64,12 @@ export function usePage() {
|
||||
|
||||
const onInputBlur = function (item) {
|
||||
if (item.label !== "") {
|
||||
http.post("/api/group/add", { name: item.label, parent_id: item.parent_id })
|
||||
http.post("/api/v1/group/add", { name: item.label, parent_id: item.parent_id })
|
||||
.then((res) => {
|
||||
if (res.errorNo !== 0) {
|
||||
ElMessage({ message: res.errorMsg, type: "error" });
|
||||
} else {
|
||||
http.get("/api/group").then((res) => {
|
||||
http.get("/api/v1/group").then((res) => {
|
||||
data.splice(0, data.length);
|
||||
data.push(...res.data);
|
||||
});
|
||||
|
||||
@@ -33,7 +33,7 @@ export function usePage() {
|
||||
activeGroup.value = newVal;
|
||||
});
|
||||
|
||||
http.get("/api/group").then((res) => {
|
||||
http.get("/api/v1/group").then((res) => {
|
||||
if (res.data) {
|
||||
// Attempting to flatten the tree for a simpler premium menu or keep it, el-tree is less beautiful.
|
||||
// For now we assume res.data is an array of items. If it's a tree, we flatten it.
|
||||
|
||||
@@ -1,77 +1,46 @@
|
||||
import {onBeforeUnmount, onMounted, reactive, ref} from 'vue'
|
||||
import { computed, reactive, ref } from 'vue'
|
||||
|
||||
import {http} from "@/utils/axios";
|
||||
import { http } from '@/utils/axios'
|
||||
|
||||
import lang from '../../../i18n/i18n';
|
||||
import lang from '../../../i18n/i18n'
|
||||
|
||||
export function usePage() {
|
||||
const pluginList = reactive({})
|
||||
|
||||
const pluginFrames = ref([])
|
||||
|
||||
function normalizePluginPayload(payload) {
|
||||
if (!payload || Object.getPrototypeOf(payload) !== Object.prototype) {
|
||||
return null
|
||||
|
||||
const pluginLogicalID = name => {
|
||||
const aliases = {
|
||||
SpamBlock: 'spam_block',
|
||||
WechatPush: 'wechat_push',
|
||||
TelegramPush: 'telegram_push'
|
||||
}
|
||||
const entries = Object.entries(payload)
|
||||
if (entries.length > 20) {
|
||||
return null
|
||||
}
|
||||
const normalized = {}
|
||||
for (const [key, value] of entries) {
|
||||
if (!/^[a-zA-Z0-9_-]{1,64}$/.test(key) || typeof value !== 'string' || value.length > 4096) {
|
||||
return null
|
||||
}
|
||||
normalized[key] = value
|
||||
}
|
||||
return normalized
|
||||
return aliases[name] || name
|
||||
}
|
||||
|
||||
function isKnownPluginFrame(source, plugin) {
|
||||
return pluginFrames.value.some((frame) => frame?.dataset?.plugin === plugin && frame.contentWindow === source)
|
||||
}
|
||||
|
||||
function handlePluginMessage(event) {
|
||||
const message = event.data
|
||||
if (!message || message.type !== 'smail-plugin-settings-save' || typeof message.plugin !== 'string') {
|
||||
return
|
||||
}
|
||||
if (!Object.prototype.hasOwnProperty.call(pluginList, message.plugin) || !isKnownPluginFrame(event.source, message.plugin)) {
|
||||
return
|
||||
}
|
||||
const payload = normalizePluginPayload(message.payload)
|
||||
if (!payload) {
|
||||
return
|
||||
}
|
||||
http.post(`/api/plugin/settings/${encodeURIComponent(message.plugin)}/save`, payload)
|
||||
.then(() => event.source.postMessage({type: 'smail-plugin-settings-result', plugin: message.plugin, ok: true}, '*'))
|
||||
.catch(() => event.source.postMessage({type: 'smail-plugin-settings-result', plugin: message.plugin, ok: false}, '*'))
|
||||
}
|
||||
|
||||
onMounted(() => window.addEventListener('message', handlePluginMessage))
|
||||
|
||||
onBeforeUnmount(() => window.removeEventListener('message', handlePluginMessage))
|
||||
|
||||
http.get('/api/plugin/list').then(res => {
|
||||
if (res.data != null && res.data.length > 0) {
|
||||
for (let i = 0; i < res.data.length; i++) {
|
||||
let name = res.data[i];
|
||||
pluginList[name] = "/api/plugin/settings/" + encodeURIComponent(name) + "/index.html";
|
||||
|
||||
const pluginEntries = computed(() => Object.entries(pluginList).map(([name, src]) => ({
|
||||
name,
|
||||
src,
|
||||
logicalID: pluginLogicalID(name)
|
||||
})))
|
||||
|
||||
http.get('/api/v1/plugin/list').then(response => {
|
||||
if (Array.isArray(response.data) && response.data.length > 0) {
|
||||
for (const name of response.data) {
|
||||
if (typeof name !== 'string' || !/^[a-zA-Z0-9_-]{1,64}$/.test(name)) {
|
||||
continue
|
||||
}
|
||||
pluginList[name] = `/api/v1/plugin/settings/${encodeURIComponent(name)}/index.html`
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return {
|
||||
onBeforeUnmount,
|
||||
onMounted,
|
||||
reactive,
|
||||
ref,
|
||||
reactive,
|
||||
http,
|
||||
lang,
|
||||
pluginList,
|
||||
pluginFrames,
|
||||
normalizePluginPayload,
|
||||
isKnownPluginFrame,
|
||||
handlePluginMessage
|
||||
pluginEntries,
|
||||
pluginFrames
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="settings-card">
|
||||
<div class="settings-card">
|
||||
<div class="settings-header">
|
||||
<h3>{{ lang.extensions }}</h3>
|
||||
<p class="settings-desc">{{ lang.extensions_desc }}</p>
|
||||
@@ -7,12 +7,20 @@
|
||||
|
||||
<div class="plugin-container">
|
||||
<el-tabs class="custom-tabs">
|
||||
<el-tab-pane v-for="(src, name) in pluginList" :key="src" :label="name">
|
||||
<div class="iframe-wrapper">
|
||||
<iframe :src="src" sandbox="allow-scripts" referrerpolicy="no-referrer" ref="pluginFrames" :data-plugin="name" :title="name"></iframe>
|
||||
<el-tab-pane v-for="entry in pluginEntries" :key="entry.src" :label="entry.name">
|
||||
<SpamBlockSettings v-if="entry.logicalID === 'spam_block'" />
|
||||
<div v-else class="iframe-wrapper">
|
||||
<iframe
|
||||
:src="entry.src"
|
||||
sandbox="allow-scripts"
|
||||
referrerpolicy="no-referrer"
|
||||
ref="pluginFrames"
|
||||
:data-plugin="entry.name"
|
||||
:title="entry.name"
|
||||
/>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane v-if="Object.keys(pluginList).length === 0" :label="lang.no_plugins">
|
||||
<el-tab-pane v-if="pluginEntries.length === 0" :label="lang.no_plugins">
|
||||
<div class="empty-state">
|
||||
<el-empty :description="lang.no_plugins_installed" :image-size="120" />
|
||||
</div>
|
||||
@@ -24,11 +32,12 @@
|
||||
|
||||
<script setup>
|
||||
import { usePage } from './PluginSettings.js'
|
||||
import SpamBlockSettings from './SpamBlockSettings.vue'
|
||||
|
||||
const {
|
||||
lang,
|
||||
pluginList
|
||||
pluginEntries
|
||||
} = usePage()
|
||||
</script>
|
||||
|
||||
<style scoped src="./PluginSettings.css"></style>
|
||||
<style scoped src="./PluginSettings.css"></style>
|
||||
@@ -0,0 +1,104 @@
|
||||
.spam-block-settings {
|
||||
min-height: 400px;
|
||||
padding: 24px;
|
||||
color: var(--pm-text-primary);
|
||||
background: var(--pm-bg-secondary);
|
||||
}
|
||||
|
||||
.plugin-heading {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.plugin-heading h4 {
|
||||
margin: 6px 0 8px;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.plugin-heading p,
|
||||
.spam-help {
|
||||
margin: 0;
|
||||
color: var(--pm-text-secondary);
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.plugin-eyebrow {
|
||||
color: var(--pm-primary-color);
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
letter-spacing: .08em;
|
||||
}
|
||||
|
||||
.spam-alert {
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.spam-form {
|
||||
max-width: 760px;
|
||||
margin-top: 24px;
|
||||
}
|
||||
|
||||
.spam-form-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.spam-form-grid :deep(.el-input-number) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.spam-help {
|
||||
margin-top: -4px;
|
||||
}
|
||||
|
||||
.spam-confirmation {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.spam-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.spam-result {
|
||||
display: grid;
|
||||
gap: 7px;
|
||||
margin-top: 20px;
|
||||
padding: 14px;
|
||||
border-radius: var(--pm-radius-sm);
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.spam-result.is-success {
|
||||
color: #166534;
|
||||
background: #f0fdf4;
|
||||
}
|
||||
|
||||
.spam-result.is-error {
|
||||
color: #991b1b;
|
||||
background: #fef2f2;
|
||||
}
|
||||
|
||||
.spam-result ul {
|
||||
margin: 0;
|
||||
padding-left: 18px;
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.spam-block-settings {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.spam-form-grid {
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { http } from '@/utils/axios'
|
||||
import { useGlobalStatusStore } from '@/stores/useGlobalStatusStore'
|
||||
|
||||
const defaultSettings = {
|
||||
url: '',
|
||||
timeout: 3000,
|
||||
threshold: 20
|
||||
}
|
||||
|
||||
const isObject = value => value && typeof value === 'object' && !Array.isArray(value)
|
||||
|
||||
export function useSpamBlockSettings() {
|
||||
const globalStatus = useGlobalStatusStore()
|
||||
const loading = ref(false)
|
||||
const working = ref('')
|
||||
const errorMessage = ref('')
|
||||
const confirmed = ref(false)
|
||||
const savedGeneration = ref(0)
|
||||
const activeGeneration = ref(0)
|
||||
const validationResult = ref(null)
|
||||
const pluginsPayload = ref(null)
|
||||
const settings = reactive({ ...defaultSettings })
|
||||
|
||||
const canWrite = () => globalStatus.hasCapability('config.write_global')
|
||||
|
||||
const notifyResponseError = (response, fallback) => {
|
||||
if (!response || response.errorNo !== 0) {
|
||||
throw new Error(response?.errorMsg || fallback)
|
||||
}
|
||||
}
|
||||
|
||||
const applySettings = value => {
|
||||
const source = isObject(value) ? value : {}
|
||||
settings.url = typeof source.url === 'string' ? source.url : defaultSettings.url
|
||||
settings.timeout = Number.isFinite(Number(source.timeout)) ? Number(source.timeout) : defaultSettings.timeout
|
||||
settings.threshold = Number.isFinite(Number(source.threshold)) ? Number(source.threshold) : defaultSettings.threshold
|
||||
}
|
||||
|
||||
const load = async () => {
|
||||
loading.value = true
|
||||
errorMessage.value = ''
|
||||
try {
|
||||
const [statusResponse, pluginsResponse] = await Promise.all([
|
||||
http.get('/api/v1/config/status'),
|
||||
http.get('/api/v1/config/plugins')
|
||||
])
|
||||
notifyResponseError(statusResponse, '配置状态读取失败')
|
||||
notifyResponseError(pluginsResponse, '插件配置读取失败')
|
||||
activeGeneration.value = Number(statusResponse.data?.activeGeneration || 0)
|
||||
pluginsPayload.value = pluginsResponse.data || null
|
||||
applySettings(pluginsPayload.value?.plugins?.spam_block?.settings)
|
||||
} catch (error) {
|
||||
errorMessage.value = error.message || '垃圾邮件插件配置读取失败'
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const buildPayload = () => {
|
||||
if (!isObject(pluginsPayload.value) || !isObject(pluginsPayload.value.plugins)) {
|
||||
throw new Error('插件配置格式无效')
|
||||
}
|
||||
const payload = JSON.parse(JSON.stringify(pluginsPayload.value))
|
||||
Object.values(payload.plugins).forEach(plugin => {
|
||||
if (isObject(plugin)) {
|
||||
delete plugin.secretStatus
|
||||
}
|
||||
})
|
||||
if (!isObject(payload.plugins.spam_block)) {
|
||||
throw new Error('垃圾邮件插件未安装或配置不存在')
|
||||
}
|
||||
payload.plugins.spam_block.settings = {
|
||||
url: settings.url.trim(),
|
||||
timeout: Number(settings.timeout),
|
||||
threshold: Number(settings.threshold)
|
||||
}
|
||||
return payload
|
||||
}
|
||||
|
||||
const buildRequest = () => ({
|
||||
expectedGeneration: activeGeneration.value,
|
||||
payload: buildPayload(),
|
||||
confirmation: {
|
||||
confirmed: confirmed.value,
|
||||
method: 'recent_auth'
|
||||
}
|
||||
})
|
||||
|
||||
const validate = async () => {
|
||||
working.value = 'validate'
|
||||
try {
|
||||
const response = await http.post('/api/v1/config/plugins/validate', buildRequest())
|
||||
notifyResponseError(response, '插件配置验证失败')
|
||||
validationResult.value = response.data || null
|
||||
ElMessage[validationResult.value?.valid ? 'success' : 'warning'](
|
||||
validationResult.value?.valid ? '垃圾邮件插件配置验证通过' : '垃圾邮件插件配置验证未通过'
|
||||
)
|
||||
} catch (error) {
|
||||
ElMessage.error(error.message || '插件配置验证失败')
|
||||
} finally {
|
||||
working.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
const save = async () => {
|
||||
working.value = 'save'
|
||||
try {
|
||||
const response = await http.put('/api/v1/config/plugins', buildRequest())
|
||||
notifyResponseError(response, '插件配置保存失败')
|
||||
savedGeneration.value = Number(response.data?.generation || 0)
|
||||
validationResult.value = { valid: true, generation: savedGeneration.value, issues: [] }
|
||||
ElMessage.success(`垃圾邮件插件配置已保存,代次 ${savedGeneration.value} 等待应用`)
|
||||
} catch (error) {
|
||||
ElMessage.error(error.message || '插件配置保存失败')
|
||||
} finally {
|
||||
working.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
const apply = async () => {
|
||||
if (!savedGeneration.value) return
|
||||
working.value = 'apply'
|
||||
try {
|
||||
const response = await http.post('/api/v1/config/plugins/apply', { generation: savedGeneration.value })
|
||||
notifyResponseError(response, '插件配置应用失败')
|
||||
savedGeneration.value = 0
|
||||
await load()
|
||||
ElMessage.success('垃圾邮件插件配置已应用')
|
||||
} catch (error) {
|
||||
ElMessage.error(error.message || '垃圾邮件插件配置应用失败')
|
||||
} finally {
|
||||
working.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(load)
|
||||
|
||||
return {
|
||||
loading,
|
||||
working,
|
||||
errorMessage,
|
||||
confirmed,
|
||||
savedGeneration,
|
||||
validationResult,
|
||||
settings,
|
||||
canWrite,
|
||||
load,
|
||||
validate,
|
||||
save,
|
||||
apply
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
<template>
|
||||
<section class="spam-block-settings" v-loading="loading">
|
||||
<div class="plugin-heading">
|
||||
<div>
|
||||
<span class="plugin-eyebrow">安全插件</span>
|
||||
<h4>垃圾邮件拦截</h4>
|
||||
<p>配置模型接口和识别阈值,配置会通过统一配置管理器校验后再应用。</p>
|
||||
</div>
|
||||
<el-button size="small" plain :loading="loading" @click="load">刷新</el-button>
|
||||
</div>
|
||||
|
||||
<el-alert
|
||||
v-if="!canWrite()"
|
||||
title="当前账号仅能查看配置,保存和应用操作已禁用。"
|
||||
type="info"
|
||||
:closable="false"
|
||||
show-icon
|
||||
/>
|
||||
<el-alert
|
||||
v-if="errorMessage"
|
||||
class="spam-alert"
|
||||
:title="errorMessage"
|
||||
type="error"
|
||||
:closable="false"
|
||||
show-icon
|
||||
/>
|
||||
|
||||
<el-form label-position="top" class="spam-form">
|
||||
<el-form-item label="模型 API 接口地址">
|
||||
<el-input
|
||||
v-model="settings.url"
|
||||
:disabled="!canWrite()"
|
||||
placeholder="例如:https://model.example.com/v1/predict"
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
<div class="spam-form-grid">
|
||||
<el-form-item label="请求超时时间(毫秒)">
|
||||
<el-input-number
|
||||
v-model="settings.timeout"
|
||||
:disabled="!canWrite()"
|
||||
:min="100"
|
||||
:max="120000"
|
||||
:step="100"
|
||||
controls-position="right"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="识别阈值">
|
||||
<el-input-number
|
||||
v-model="settings.threshold"
|
||||
:disabled="!canWrite()"
|
||||
:min="0"
|
||||
:max="100"
|
||||
:step="0.01"
|
||||
:precision="2"
|
||||
controls-position="right"
|
||||
/>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<p class="spam-help">阈值越低,过滤越严格,也更容易产生误判;请根据模型返回结果逐步调整。</p>
|
||||
|
||||
<el-checkbox v-if="canWrite()" v-model="confirmed" class="spam-confirmation">
|
||||
我已确认这是受控变更,并允许使用最近认证完成高风险配置操作
|
||||
</el-checkbox>
|
||||
<div class="spam-actions">
|
||||
<el-button :loading="working === 'validate'" :disabled="!canWrite()" @click="validate">只验证</el-button>
|
||||
<el-button type="primary" :loading="working === 'save'" :disabled="!canWrite()" @click="save">保存候选配置</el-button>
|
||||
<el-button type="success" plain :loading="working === 'apply'" :disabled="!canWrite() || !savedGeneration" @click="apply">
|
||||
应用{{ savedGeneration ? `代次 ${savedGeneration}` : '' }}
|
||||
</el-button>
|
||||
</div>
|
||||
<div v-if="validationResult" class="spam-result" :class="validationResult.valid ? 'is-success' : 'is-error'">
|
||||
<strong>{{ validationResult.valid ? '验证通过' : '验证未通过' }}</strong>
|
||||
<span v-if="validationResult.generation">候选代次:{{ validationResult.generation }}</span>
|
||||
<ul v-if="validationResult.issues?.length">
|
||||
<li v-for="issue in validationResult.issues" :key="`${issue.code}-${issue.message}`">{{ issue.code }}:{{ issue.message }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
</el-form>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { useSpamBlockSettings } from './SpamBlockSettings.js'
|
||||
|
||||
const {
|
||||
loading,
|
||||
working,
|
||||
errorMessage,
|
||||
confirmed,
|
||||
savedGeneration,
|
||||
validationResult,
|
||||
settings,
|
||||
canWrite,
|
||||
load,
|
||||
validate,
|
||||
save,
|
||||
apply
|
||||
} = useSpamBlockSettings()
|
||||
</script>
|
||||
|
||||
<style scoped src="./SpamBlockSettings.css"></style>
|
||||
@@ -85,7 +85,7 @@ const generateRecoveryCodes = async () => {
|
||||
}
|
||||
loading.value = true
|
||||
try {
|
||||
const response = await http.post("/api/security/credentials/recovery-codes/generate", { count: 10 })
|
||||
const response = await http.post("/api/v1/security/credentials/recovery-codes/generate", { count: 10 })
|
||||
if (response.errorNo !== 0 || !Array.isArray(response.data?.codes)) {
|
||||
throw new Error(response.errorMsg || "离线恢复码生成失败")
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ export function usePage() {
|
||||
}
|
||||
|
||||
const init = function () {
|
||||
http.post("/api/rule/get").then((res) => {
|
||||
http.post("/api/v1/rule/get").then((res) => {
|
||||
data.value = res.data || []
|
||||
})
|
||||
}
|
||||
@@ -41,7 +41,7 @@ export function usePage() {
|
||||
})
|
||||
|
||||
const reflushGroupInfos = function () {
|
||||
http.get('/api/group/list').then(res => {
|
||||
http.get('/api/v1/group/list').then(res => {
|
||||
if (res.data != null) {
|
||||
groupData.list = res.data
|
||||
for (let i = 0; i < groupData.list.length; i++) {
|
||||
@@ -63,7 +63,7 @@ export function usePage() {
|
||||
})
|
||||
|
||||
const delRule = function (id) {
|
||||
http.post("/api/rule/del", {"id": id}).then((res) => {
|
||||
http.post("/api/v1/rule/del", {"id": id}).then((res) => {
|
||||
ElNotification({
|
||||
title: res.errorNo === 0 ? lang.succ : lang.fail,
|
||||
message: res.data,
|
||||
@@ -92,9 +92,9 @@ export function usePage() {
|
||||
}
|
||||
|
||||
const submitRule = function () {
|
||||
let api = "/api/rule/add"
|
||||
let api = "/api/v1/rule/add"
|
||||
if (addRuleForm.id > 0) {
|
||||
api = "/api/rule/update"
|
||||
api = "/api/v1/rule/update"
|
||||
}
|
||||
|
||||
addRuleForm.sort = parseInt(addRuleForm.sort)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
|
||||
import { ElMessageBox, ElNotification } from 'element-plus'
|
||||
|
||||
@@ -39,7 +39,7 @@ export function usePage() {
|
||||
if (!supported) return
|
||||
credentialsLoading.value = true
|
||||
try {
|
||||
const res = await http.get('/api/security/webauthn/credentials')
|
||||
const res = await http.get('/api/v1/security/webauthn/credentials')
|
||||
if (res.errorNo !== 0) throw new Error(res.errorMsg || '加载安全密钥失败')
|
||||
credentials.value = Array.isArray(res.data) ? res.data : []
|
||||
} catch (error) {
|
||||
@@ -53,11 +53,11 @@ export function usePage() {
|
||||
securityLoading.value = true
|
||||
try {
|
||||
const requests = [
|
||||
http.get('/api/security/credentials/question'),
|
||||
http.get('/api/security/external-email/list'),
|
||||
http.get('/api/v1/security/credentials/question'),
|
||||
http.get('/api/v1/security/external-email/list'),
|
||||
]
|
||||
if (!isSuperAdmin.value) {
|
||||
requests.push(http.get('/api/security/credentials/recovery-codes'))
|
||||
requests.push(http.get('/api/v1/security/credentials/recovery-codes'))
|
||||
}
|
||||
const [question, external, recovery] = await Promise.all(requests)
|
||||
if (question.errorNo === 0 && question.data) {
|
||||
@@ -82,10 +82,10 @@ export function usePage() {
|
||||
confirmButtonText: '确定', cancelButtonText: '取消', inputPlaceholder: '例如:工作电脑',
|
||||
inputValidator: value => String(value || '').trim().length > 0 || '请输入密钥名称',
|
||||
})
|
||||
const begin = await http.post('/api/security/webauthn/registration/begin', {})
|
||||
const begin = await http.post('/api/v1/security/webauthn/registration/begin', {})
|
||||
if (begin.errorNo !== 0) throw new Error(begin.errorMsg || '无法开始安全密钥注册')
|
||||
const credential = await navigator.credentials.create({ publicKey: normalizeCreationOptions(begin.data.options) })
|
||||
const finish = await http.post('/api/security/webauthn/registration/finish', {
|
||||
const finish = await http.post('/api/v1/security/webauthn/registration/finish', {
|
||||
session_id: begin.data.session_id,
|
||||
display_name: String(prompt.value).trim(),
|
||||
credential: serializeCredential(credential),
|
||||
@@ -106,7 +106,7 @@ export function usePage() {
|
||||
confirmButtonText: '确定', cancelButtonText: '取消', inputValue: item.display_name,
|
||||
inputValidator: value => String(value || '').trim().length > 0 || '请输入密钥名称',
|
||||
})
|
||||
const res = await http.post('/api/security/webauthn/credentials/rename', { id: item.id, display_name: String(prompt.value).trim() })
|
||||
const res = await http.post('/api/v1/security/webauthn/credentials/rename', { id: item.id, display_name: String(prompt.value).trim() })
|
||||
if (res.errorNo !== 0) throw new Error(res.errorMsg || '密钥重命名失败')
|
||||
notify('密钥重命名成功', 'success')
|
||||
await loadCredentials()
|
||||
@@ -120,7 +120,7 @@ export function usePage() {
|
||||
await ElMessageBox.confirm(`确定要撤销密钥“${item.display_name}”吗?撤销后将不能用于登录`, '撤销安全密钥', {
|
||||
confirmButtonText: '确定撤销', cancelButtonText: '取消', type: 'warning',
|
||||
})
|
||||
const res = await http.post('/api/security/webauthn/credentials/revoke', { id: item.id })
|
||||
const res = await http.post('/api/v1/security/webauthn/credentials/revoke', { id: item.id })
|
||||
if (res.errorNo !== 0) throw new Error(res.errorMsg || '撤销安全密钥失败')
|
||||
notify('安全密钥已撤销', 'success')
|
||||
await loadCredentials()
|
||||
@@ -134,7 +134,7 @@ export function usePage() {
|
||||
notify('请填写密保问题和答案')
|
||||
return
|
||||
}
|
||||
const res = await http.post('/api/security/credentials/question', questionForm)
|
||||
const res = await http.post('/api/v1/security/credentials/question', questionForm)
|
||||
if (res.errorNo !== 0) {
|
||||
notify(res.errorMsg || '密保问题设置失败')
|
||||
return
|
||||
@@ -148,7 +148,7 @@ export function usePage() {
|
||||
const generateRecoveryCodes = async () => {
|
||||
try {
|
||||
await ElMessageBox.confirm('生成新恢复码会撤销当前仍有效的恢复码,请确认已准备好安全保存。', '生成离线恢复码', { type: 'warning' })
|
||||
const res = await http.post('/api/security/credentials/recovery-codes/generate', { count: 10 })
|
||||
const res = await http.post('/api/v1/security/credentials/recovery-codes/generate', { count: 10 })
|
||||
if (res.errorNo !== 0 || !Array.isArray(res.data?.codes)) throw new Error(res.errorMsg || '离线恢复码生成失败')
|
||||
generatedCodes.value = res.data.codes
|
||||
recoveryConfigured.value = true
|
||||
@@ -161,7 +161,7 @@ export function usePage() {
|
||||
const revokeRecoveryCodes = async () => {
|
||||
try {
|
||||
await ElMessageBox.confirm('撤销后现有离线恢复码将立即失效,是否继续?', '撤销离线恢复码', { type: 'warning' })
|
||||
const res = await http.post('/api/security/credentials/recovery-codes/revoke', {})
|
||||
const res = await http.post('/api/v1/security/credentials/recovery-codes/revoke', {})
|
||||
if (res.errorNo !== 0) throw new Error(res.errorMsg || '撤销恢复码失败')
|
||||
recoveryConfigured.value = false
|
||||
generatedCodes.value = []
|
||||
@@ -178,7 +178,7 @@ export function usePage() {
|
||||
}
|
||||
externalLoading.value = true
|
||||
try {
|
||||
const res = await http.post('/api/security/external-email/bind', { email: bindForm.email.trim(), type: bindForm.type })
|
||||
const res = await http.post('/api/v1/security/external-email/bind', { email: bindForm.email.trim(), type: bindForm.type })
|
||||
if (res.errorNo !== 0) throw new Error(res.errorMsg || '外部邮箱绑定失败')
|
||||
bindForm.challengeId = res.data.challenge_id
|
||||
bindForm.bindingId = res.data.id
|
||||
@@ -186,7 +186,7 @@ export function usePage() {
|
||||
confirmButtonText: '验证', cancelButtonText: '取消', inputPlaceholder: '请输入验证码',
|
||||
})
|
||||
bindForm.code = String(prompt.value).trim()
|
||||
const verified = await http.post('/api/security/external-email/verify', {
|
||||
const verified = await http.post('/api/v1/security/external-email/verify', {
|
||||
id: bindForm.challengeId, binding_id: bindForm.bindingId, email: bindForm.email.trim(), code: bindForm.code,
|
||||
})
|
||||
if (verified.errorNo !== 0) throw new Error(verified.errorMsg || '外部邮箱验证失败')
|
||||
@@ -205,7 +205,7 @@ export function usePage() {
|
||||
const disableExternalEmail = async item => {
|
||||
try {
|
||||
await ElMessageBox.confirm(`确定停用 ${item.email} 吗?停用后不能用于登录验证和恢复。`, '停用外部邮箱', { type: 'warning' })
|
||||
const res = await http.post('/api/security/external-email/disable', { id: item.id })
|
||||
const res = await http.post('/api/v1/security/external-email/disable', { id: item.id })
|
||||
if (res.errorNo !== 0) throw new Error(res.errorMsg || '外部邮箱停用失败')
|
||||
await loadSecurityData()
|
||||
notify('外部邮箱已停用', 'success')
|
||||
@@ -215,7 +215,7 @@ export function usePage() {
|
||||
}
|
||||
|
||||
const formatTime = value => value ? new Date(value).toLocaleString('zh-CN', { hour12: false }) : '-'
|
||||
const logout = () => http.post('/api/logout', {}).then(() => location.reload())
|
||||
const logout = () => http.post('/api/v1/logout', {}).then(() => location.reload())
|
||||
|
||||
const submit = async () => {
|
||||
if (!ruleForm.current_pwd || !ruleForm.new_pwd) return
|
||||
@@ -223,7 +223,7 @@ export function usePage() {
|
||||
notify(lang.err_pwd_diff)
|
||||
return
|
||||
}
|
||||
const res = await http.post('/api/settings/modify_password', { current_password: ruleForm.current_pwd, password: ruleForm.new_pwd })
|
||||
const res = await http.post('/api/v1/settings/modify_password', { current_password: ruleForm.current_pwd, password: ruleForm.new_pwd })
|
||||
notify(res.errorNo === 0 ? '密码修改成功' : res.errorMsg, res.errorNo === 0 ? 'success' : 'error')
|
||||
if (res.errorNo === 0) Object.assign(ruleForm, { current_pwd: '', new_pwd: '', new_pwd2: '' })
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ export function usePage() {
|
||||
const title = ref(lang.editUser)
|
||||
|
||||
const reflushList = function () {
|
||||
http.post('/api/user/list', {"current_page": currentPage.value, "page_size": 10}).then(res => {
|
||||
http.post('/api/v1/user/list', {"current_page": currentPage.value, "page_size": 10}).then(res => {
|
||||
userList.length = 0
|
||||
totalPage.value = res.data.total_page
|
||||
if (res.data["list"]) {
|
||||
@@ -69,7 +69,7 @@ export function usePage() {
|
||||
newData["password"] = editUserInfo.password
|
||||
}
|
||||
|
||||
http.post('/api/user/edit', newData).then(res => {
|
||||
http.post('/api/v1/user/edit', newData).then(res => {
|
||||
ElNotification({
|
||||
title: res.errorNo === 0 ? lang.succ : lang.fail,
|
||||
message: res.errorNo === 0 ? "" : res.data,
|
||||
@@ -88,7 +88,7 @@ export function usePage() {
|
||||
"password": editUserInfo.password
|
||||
}
|
||||
|
||||
http.post('/api/user/create', newData).then(res => {
|
||||
http.post('/api/v1/user/create', newData).then(res => {
|
||||
ElNotification({
|
||||
title: res.errorNo === 0 ? lang.succ : lang.fail,
|
||||
message: res.errorNo === 0 ? "" : res.data,
|
||||
|
||||
Reference in new issue
Block a user