From c703fa3730e9f5dcf487ede4e288c2b0d8206269 Mon Sep 17 00:00:00 2001 From: Lufaneng Date: Tue, 28 Apr 2026 16:23:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=98=AF=E5=90=A6=E5=BC=80?= =?UTF-8?q?=E5=90=AF=E5=AF=86=E7=A0=81=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components.d.ts | 1 + src/views/SystemSettings/index.vue | 46 ++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/src/components.d.ts b/src/components.d.ts index dee0f14..5d0f239 100644 --- a/src/components.d.ts +++ b/src/components.d.ts @@ -27,6 +27,7 @@ declare module 'vue' { ElScrollbar: typeof import('element-plus/es')['ElScrollbar'] ElSelect: typeof import('element-plus/es')['ElSelect'] ElSlider: typeof import('element-plus/es')['ElSlider'] + ElSwitch: typeof import('element-plus/es')['ElSwitch'] ElTable: typeof import('element-plus/es')['ElTable'] ElTableColumn: typeof import('element-plus/es')['ElTableColumn'] ElTimePicker: typeof import('element-plus/es')['ElTimePicker'] diff --git a/src/views/SystemSettings/index.vue b/src/views/SystemSettings/index.vue index 1fb4a91..9f6c9a4 100644 --- a/src/views/SystemSettings/index.vue +++ b/src/views/SystemSettings/index.vue @@ -67,6 +67,12 @@
修改操作密码
+
+
+
启用密码保护
+ +
+
原密码
@@ -208,6 +214,45 @@ const changePassword = async () => { } } +// ─── 密码保护开关 ───────────────────────────────── +const passwordEnabled = ref(false) + +const getPasswordStatus = async () => { + try { + const res = await RPC.post('/m9z/password/status', {}) + passwordEnabled.value = res?.enabled || false + } catch (e) { + // 错误由 rpc.js 处理 + } +} + +const handlePasswordEnableChange = async (val) => { + const actionText = val ? '开启' : '关闭' + try { + await ElMessageBox.confirm( + `确认要${actionText}密码保护功能吗?`, + '提示', + { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning', + } + ) + + const method = val ? '/m9z/password/enable' : '/m9z/password/disable' + try { + await RPC.post(method, {}) + ElMessage.success(`${actionText}密码保护成功`) + } catch (e) { + // 如果接口失败,回滚状态 + passwordEnabled.value = !val + } + } catch (e) { + // 用户取消,回滚状态 + passwordEnabled.value = !val + } +} + const goBack = () => { router.push('/') } @@ -217,6 +262,7 @@ onMounted(() => { updateTime() timeInterval = setInterval(updateTime, 1000) getSystemTime() + getPasswordStatus() }) onUnmounted(() => { if (timeInterval) clearInterval(timeInterval)