feat: 退出按钮改用SVG图标,密码配置外部化到auth.ini,设置页添加修改密码功能

This commit is contained in:
2026-04-23 12:03:00 +08:00
parent a378943ec0
commit dce07f2f87
6 changed files with 155 additions and 14 deletions
+61 -7
View File
@@ -41,9 +41,9 @@
<span>系统设置</span>
</a>
</nav>
<div class="sidebar-footer" data-version="v2.0.1">
<div class="sidebar-footer" data-version="v2.0.2">
<div class="sidebar-footer-info">
<span class="version">版本:v2.0.1</span>
<span class="version">版本:v2.0.2</span>
<span class="version">Power by:NIXEVOL</span>
</div>
</div>
@@ -73,7 +73,13 @@
<line x1="8" y1="4" x2="8" y2="6.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
</svg>
</button>
<button class="logout-btn" id="logoutBtn" title="退出登录">⏻</button>
<button class="logout-btn" id="logoutBtn" title="退出登录">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<polyline points="16 17 21 12 16 7" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<line x1="21" y1="12" x2="9" y2="12" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</button>
</div>
</header>
@@ -184,7 +190,13 @@
<line x1="8" y1="4" x2="8" y2="6.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
</svg>
</button>
<button class="logout-btn" id="logoutBtn" title="退出登录">⏻</button>
<button class="logout-btn" id="logoutBtn" title="退出登录">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<polyline points="16 17 21 12 16 7" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<line x1="21" y1="12" x2="9" y2="12" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</button>
</div>
</header>
<div class="page-body">
@@ -219,7 +231,13 @@
<line x1="8" y1="4" x2="8" y2="6.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
</svg>
</button>
<button class="logout-btn" id="logoutBtn" title="退出登录">⏻</button>
<button class="logout-btn" id="logoutBtn" title="退出登录">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<polyline points="16 17 21 12 16 7" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<line x1="21" y1="12" x2="9" y2="12" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</button>
</div>
</header>
<div class="page-body" style="display: flex; flex-direction: column; height: calc(100% - 64px);">
@@ -319,7 +337,13 @@
<line x1="8" y1="4" x2="8" y2="6.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
</svg>
</button>
<button class="logout-btn" id="logoutBtn" title="退出登录">⏻</button>
<button class="logout-btn" id="logoutBtn" title="退出登录">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<polyline points="16 17 21 12 16 7" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<line x1="21" y1="12" x2="9" y2="12" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</button>
</div>
</header>
<div class="page-body script-page-body">
@@ -385,7 +409,13 @@
<line x1="8" y1="4" x2="8" y2="6.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
</svg>
</button>
<button class="logout-btn" id="logoutBtn" title="退出登录">⏻</button>
<button class="logout-btn" id="logoutBtn" title="退出登录">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<polyline points="16 17 21 12 16 7" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<line x1="21" y1="12" x2="9" y2="12" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</button>
</div>
</header>
<div class="page-body settings-page-body">
@@ -453,6 +483,30 @@
<button class="btn btn-primary" id="saveSheetFilter">保存规则</button>
</div>
</div>
<!-- 修改密码 -->
<div class="card settings-card">
<div class="card-header">
<span class="card-title">修改登录密码</span>
</div>
<div class="card-body">
<div class="form-group">
<label>当前密码</label>
<input type="password" id="currentPassword" class="form-input" placeholder="输入当前密码">
</div>
<div class="form-group" style="margin-top: 12px;">
<label>新密码</label>
<input type="password" id="newPassword" class="form-input" placeholder="输入新密码">
</div>
<div class="form-group" style="margin-top: 12px;">
<label>确认新密码</label>
<input type="password" id="confirmPassword" class="form-input" placeholder="再次输入新密码">
</div>
</div>
<div class="card-footer">
<button class="btn btn-primary" id="changePassword">修改密码</button>
</div>
</div>
</div>
<!-- 右侧列 - 字段映射 -->
+32 -1
View File
@@ -2225,7 +2225,7 @@ function initApp() {
// 恢复上次访问的页面
navigation.restorePage();
console.log('CapacityReport v2.0.1 已加载');
console.log('CapacityReport v2.0.2 已加载');
// 退出登录按钮事件(事件委托)
document.addEventListener('click', (e) => {
@@ -2235,6 +2235,37 @@ function initApp() {
logout();
}
});
// 修改密码按钮事件
const changePwdBtn = $('#changePassword');
if (changePwdBtn) {
changePwdBtn.addEventListener('click', async () => {
const currentPwd = $('#currentPassword')?.value;
const newPwd = $('#newPassword')?.value;
const confirmPwd = $('#confirmPassword')?.value;
if (!currentPwd) { showToast('请输入当前密码', 'warning'); return; }
if (!newPwd) { showToast('请输入新密码', 'warning'); return; }
if (newPwd.length < 4) { showToast('新密码长度不能少于4位', 'warning'); return; }
if (newPwd !== confirmPwd) { showToast('两次输入的新密码不一致', 'warning'); return; }
try {
const res = await api('/change-password', {
method: 'POST',
body: JSON.stringify({ current_password: currentPwd, new_password: newPwd })
});
if (res.success) {
showToast('密码修改成功,请重新登录', 'success');
$('#currentPassword').value = '';
$('#newPassword').value = '';
$('#confirmPassword').value = '';
setTimeout(() => logout(), 1500);
}
} catch (err) {
showToast(err.message || '密码修改失败', 'error');
}
});
}
// 重启服务按钮事件(使用事件委托,支持所有页面的重启按钮)
document.addEventListener('click', async (e) => {