feat(server): 新增修改密码接口 POST /api/auth/password(验原密码、作废会话)
This commit is contained in:
1 parent
ad2322d558
commit
4cbf5a74f0
13 files changed
+528
-20
No files matched your search
+29
-8
@@ -20,7 +20,11 @@ const el = {
|
||||
btnRestart: document.getElementById('btn-restart'),
|
||||
btnRelayout: document.getElementById('btn-relayout'),
|
||||
btnOpenAdmin: document.getElementById('btn-open-admin'),
|
||||
btnClearLog: document.getElementById('btn-clear-log')
|
||||
btnClearLog: document.getElementById('btn-clear-log'),
|
||||
titlebar: document.getElementById('titlebar'),
|
||||
winMin: document.getElementById('win-min'),
|
||||
winMax: document.getElementById('win-max'),
|
||||
winClose: document.getElementById('win-close')
|
||||
}
|
||||
|
||||
const DOT_CLASS = {
|
||||
@@ -31,10 +35,7 @@ const DOT_CLASS = {
|
||||
stopped: ''
|
||||
}
|
||||
|
||||
let lastStatus = null
|
||||
|
||||
function renderStatus(status) {
|
||||
lastStatus = status
|
||||
el.version.textContent = status.appVersion ? `v${status.appVersion}` : ''
|
||||
|
||||
el.stateDot.className = `dot ${status.healthy ? 'ok' : DOT_CLASS[status.state] || ''}`
|
||||
@@ -104,6 +105,28 @@ async function refresh() {
|
||||
renderStatus(await window.consoleApi.getStatus())
|
||||
}
|
||||
|
||||
function renderMaximized(maximized) {
|
||||
el.winMax.classList.toggle('is-maximized', maximized)
|
||||
const label = maximized ? '还原' : '最大化'
|
||||
el.winMax.title = label
|
||||
el.winMax.setAttribute('aria-label', label)
|
||||
}
|
||||
|
||||
function bindWindowControls() {
|
||||
el.winMin.addEventListener('click', () => window.consoleApi.minimize())
|
||||
el.winMax.addEventListener('click', () => window.consoleApi.maximize())
|
||||
el.winClose.addEventListener('click', () => window.consoleApi.close())
|
||||
|
||||
// 双击标题栏切换最大化;点在按钮上的双击不算,否则连点会误触
|
||||
el.titlebar.addEventListener('dblclick', (event) => {
|
||||
if (event.target instanceof Element && event.target.closest('.win-btn')) return
|
||||
window.consoleApi.maximize()
|
||||
})
|
||||
|
||||
window.consoleApi.onMaximizeChange(renderMaximized)
|
||||
window.consoleApi.isMaximized().then(renderMaximized)
|
||||
}
|
||||
|
||||
function bindActions() {
|
||||
el.btnStart.addEventListener('click', async () => renderStatus(await window.consoleApi.startService()))
|
||||
el.btnStop.addEventListener('click', async () => renderStatus(await window.consoleApi.stopService()))
|
||||
@@ -113,14 +136,12 @@ function bindActions() {
|
||||
await window.consoleApi.clearLog()
|
||||
setLog([])
|
||||
})
|
||||
el.btnOpenAdmin.addEventListener('click', () => {
|
||||
const url = (lastStatus && lastStatus.adminUrl) || 'http://127.0.0.1:8080/admin'
|
||||
window.consoleApi.openExternal(url)
|
||||
})
|
||||
el.btnOpenAdmin.addEventListener('click', () => window.consoleApi.openServerAdmin())
|
||||
}
|
||||
|
||||
async function boot() {
|
||||
bindActions()
|
||||
bindWindowControls()
|
||||
window.consoleApi.onStatus(renderStatus)
|
||||
window.consoleApi.onLog(appendLog)
|
||||
setLog(await window.consoleApi.getLog())
|
||||
|
||||
Reference in new issue
Block a user