@yusho/server 0.0.0-stage → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +135 -2
- package/app/appguide.mjs +33 -0
- package/app/asr.mjs +82 -0
- package/app/assets/agents/claude-192.webp +0 -0
- package/app/assets/agents/claude-96.webp +0 -0
- package/app/assets/agents/codex-192.webp +0 -0
- package/app/assets/agents/codex-96.webp +0 -0
- package/app/assets/agents/default-192.webp +0 -0
- package/app/assets/agents/default-96.webp +0 -0
- package/app/assets/agents/dsh-192.webp +0 -0
- package/app/assets/agents/dsh-96.webp +0 -0
- package/app/assets/brand/logo.webp +0 -0
- package/app/assets/lib/THIRD-PARTY.txt +1 -0
- package/app/assets/lib/jsqr.js +10102 -0
- package/app/assets/linux/alpine-arm64.tar.gz +0 -0
- package/app/assets/linux/alpine-x64.tar.gz +0 -0
- package/app/assets/live/claude.livliv +0 -0
- package/app/assets/live/dafeiyu.livliv +0 -0
- package/app/assets/live/gpt.livliv +0 -0
- package/app/assets/live/sho.livliv +0 -0
- package/app/assets/live//345/275/242/350/261/241/346/235/245/346/272/220.md +5 -0
- package/app/assets/livliv/LICENSE +202 -0
- package/app/assets/livliv/NOTICE +7 -0
- package/app/assets/livliv/player.mjs +15 -0
- package/app/assets/looks/claude.webp +0 -0
- package/app/assets/looks/dafeiyu.webp +0 -0
- package/app/assets/looks/gpt.webp +0 -0
- package/app/assets/looks//345/275/242/350/261/241/346/235/245/346/272/220.md +5 -0
- package/app/assets/sho/avatar.webp +0 -0
- package/app/assets/sho/done.webp +0 -0
- package/app/assets/sho/eat.webp +0 -0
- package/app/assets/sho/idle-blink.webp +0 -0
- package/app/assets/sho/idle.webp +0 -0
- package/app/assets/sho/listen.webp +0 -0
- package/app/assets/sho/need.webp +0 -0
- package/app/assets/sho/work.webp +0 -0
- package/app/companion.mjs +519 -0
- package/app/diag.mjs +51 -0
- package/app/index.html +497 -0
- package/app/judge.mjs +103 -0
- package/app/lanxfer.mjs +157 -0
- package/app/launcher.mjs +2711 -0
- package/app/linux.mjs +97 -0
- package/app/livliv-pack.mjs +12 -0
- package/app/memory.mjs +53 -0
- package/app/net.mjs +717 -0
- package/app/office.mjs +172 -0
- package/app/p2plink.mjs +134 -0
- package/app/pcupdate.mjs +55 -0
- package/app/plans.mjs +126 -0
- package/app/plugins.mjs +79 -0
- package/app/realtime.mjs +67 -0
- package/app/skills/app-icon/SKILL.md +31 -0
- package/app/skills/daily-brief/SKILL.md +29 -0
- package/app/skills/expense-review/SKILL.md +28 -0
- package/app/skills/make-app/SKILL.md +92 -0
- package/app/skills/make-skin/SKILL.md +51 -0
- package/app/skills/meeting-notes/SKILL.md +23 -0
- package/app/skills/reading-notes/SKILL.md +25 -0
- package/app/skills/sho-stickers/SKILL.md +34 -0
- package/app/skills/sho-stickers/stickers/eat.webp +0 -0
- package/app/skills/sho-stickers/stickers/got-it.webp +0 -0
- package/app/skills/sho-stickers/stickers/hi.webp +0 -0
- package/app/skills/sho-stickers/stickers/huh.webp +0 -0
- package/app/skills/sho-stickers/stickers/on-it.webp +0 -0
- package/app/skills/sho-stickers/stickers/yay.webp +0 -0
- package/app/skills/sho-stickers/stickers.json +12 -0
- package/app/skills/study-plan/SKILL.md +30 -0
- package/app/skills/trip-planner/SKILL.md +29 -0
- package/app/skills/weekly-report/SKILL.md +30 -0
- package/app/skills/workout-plan/SKILL.md +30 -0
- package/app/skills/writing-polish/SKILL.md +33 -0
- package/app/skills.mjs +173 -0
- package/app/skins.mjs +40 -0
- package/app/social.mjs +1067 -0
- package/app/storage.mjs +143 -0
- package/app/tts.mjs +68 -0
- package/app/ttslocal.mjs +77 -0
- package/app/voices.mjs +102 -0
- package/backup.mjs +109 -0
- package/bin/yusho.mjs +141 -0
- package/connector/lib/api.mjs +14 -0
- package/connector/lib/autostart.mjs +40 -0
- package/connector/lib/client.js +165 -0
- package/connector/lib/connector.mjs +468 -0
- package/connector/lib/dsh-acp.mjs +129 -0
- package/connector/lib/dsh-headless.patch.yml +4 -0
- package/connector/lib/dsh-plugin.mjs +80 -0
- package/connector/lib/lanfile.mjs +151 -0
- package/connector/lib/nostr.mjs +53 -0
- package/connector/lib/page.html +121 -0
- package/connector/lib/qr.mjs +4 -0
- package/connector/lib/service.mjs +54 -0
- package/node_modules/@local/shoal-mobile/lib/index.js +485 -0
- package/node_modules/@local/shoal-mobile/lib/polyfill.js +82 -0
- package/node_modules/@local/shoal-mobile/lib/session-context.js +34 -0
- package/node_modules/@local/shoal-mobile/lib/shell.js +60 -0
- package/node_modules/@local/shoal-mobile/lib/web-startup.js +33 -0
- package/node_modules/@local/shoal-mobile/package.json +24 -0
- package/node_modules/@local/yusho-pc/lib/client.js +9100 -0
- package/node_modules/@local/yusho-pc/lib/index.js +3 -0
- package/node_modules/@local/yusho-pc/package.json +28 -0
- package/node_modules/@local/yusho-web-login/brand/icon-192.webp +0 -0
- package/node_modules/@local/yusho-web-login/brand/logo-dark.svg +25 -0
- package/node_modules/@local/yusho-web-login/brand.mjs +8 -0
- package/node_modules/@local/yusho-web-login/dsh-web-login.mjs +974 -0
- package/node_modules/@local/yusho-web-login/lib/client.js +607 -0
- package/node_modules/@local/yusho-web-login/login-page.mjs +609 -0
- package/node_modules/@local/yusho-web-login/login-store.mjs +708 -0
- package/node_modules/@local/yusho-web-login/package.json +25 -0
- package/node_modules/@local/yusho-web-login/whale-scene.mjs +509 -0
- package/node_modules/@local/yusho-web-login/yusho-scene.mjs +227 -0
- package/package.json +38 -4
- package/pc.patch.yml +83 -0
- package/run.mjs +136 -0
|
@@ -0,0 +1,607 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh-web-login — browser half.
|
|
3
|
+
*
|
|
4
|
+
* Contributes one lazy tab to the Settings -> Plugins section. It talks to the
|
|
5
|
+
* host half over plain same-origin fetch against the plugin's own
|
|
6
|
+
* `/_web-login/api/*` routes rather than the harness Remote layer, so it needs
|
|
7
|
+
* nothing but the seeded `react` module and works before any codegen step.
|
|
8
|
+
*
|
|
9
|
+
* This file is the module-system's closure-factory artifact shape (not ESM):
|
|
10
|
+
* the host half reads it from disk and serves it at /plugins/dsh-web-login/client.js.
|
|
11
|
+
*/
|
|
12
|
+
window.__ModuleLoader__.load({
|
|
13
|
+
id: '@local/yusho-web-login',
|
|
14
|
+
factory: (require) => {
|
|
15
|
+
var module = { exports: {} }
|
|
16
|
+
var exports = module.exports
|
|
17
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' })
|
|
18
|
+
|
|
19
|
+
const React = require('react')
|
|
20
|
+
const { useState, useEffect, useCallback } = React
|
|
21
|
+
|
|
22
|
+
const S = {
|
|
23
|
+
root: { display: 'flex', flexDirection: 'column', gap: '18px', fontSize: '13px', lineHeight: 1.6, maxWidth: '780px' },
|
|
24
|
+
section: { border: '1px solid rgba(128,128,128,0.28)', borderRadius: '10px', padding: '14px 16px', display: 'flex', flexDirection: 'column', gap: '10px' },
|
|
25
|
+
danger: { border: '1px solid rgba(239,68,68,0.45)', borderRadius: '10px', padding: '14px 16px', display: 'flex', flexDirection: 'column', gap: '10px' },
|
|
26
|
+
h: { margin: 0, fontSize: '14px', fontWeight: 600 },
|
|
27
|
+
h4: { margin: '4px 0 0', fontSize: '13px', fontWeight: 600 },
|
|
28
|
+
row: { display: 'flex', alignItems: 'center', gap: '10px', flexWrap: 'wrap' },
|
|
29
|
+
stack: { display: 'flex', flexDirection: 'column', gap: '8px' },
|
|
30
|
+
grid: { display: 'grid', gridTemplateColumns: '84px 1fr', alignItems: 'center', gap: '10px 12px' },
|
|
31
|
+
input: { padding: '6px 9px', border: '1px solid rgba(128,128,128,0.4)', borderRadius: '7px', background: 'transparent', color: 'inherit', font: 'inherit', minWidth: '190px' },
|
|
32
|
+
btn: { padding: '6px 13px', border: '1px solid transparent', borderRadius: '7px', background: '#4f46e5', color: '#fff', font: 'inherit', fontWeight: 600, cursor: 'pointer' },
|
|
33
|
+
red: { padding: '6px 13px', border: '1px solid transparent', borderRadius: '7px', background: '#dc2626', color: '#fff', font: 'inherit', fontWeight: 600, cursor: 'pointer' },
|
|
34
|
+
ghost: { padding: '5px 11px', border: '1px solid rgba(128,128,128,0.45)', borderRadius: '7px', background: 'transparent', color: 'inherit', font: 'inherit', cursor: 'pointer' },
|
|
35
|
+
on: { padding: '5px 11px', border: '1px solid #4f46e5', borderRadius: '7px', background: 'rgba(79,70,229,0.16)', color: 'inherit', font: 'inherit', cursor: 'pointer', fontWeight: 600 },
|
|
36
|
+
err: { margin: 0, padding: '9px 11px', borderRadius: '8px', background: 'rgba(239,68,68,0.15)', border: '1px solid rgba(239,68,68,0.4)' },
|
|
37
|
+
ok: { margin: 0, padding: '9px 11px', borderRadius: '8px', background: 'rgba(34,197,94,0.15)', border: '1px solid rgba(34,197,94,0.4)' },
|
|
38
|
+
warn: { margin: 0, padding: '9px 11px', borderRadius: '8px', background: 'rgba(250,204,21,0.12)', border: '1px solid rgba(250,204,21,0.4)' },
|
|
39
|
+
muted: { margin: 0, opacity: 0.68, fontSize: '12px' },
|
|
40
|
+
chip: { width: '34px', height: '34px', borderRadius: '9px', background: 'rgba(255,255,255,0.92)', display: 'flex', alignItems: 'center', justifyContent: 'center', overflow: 'hidden' },
|
|
41
|
+
code: { fontFamily: 'ui-monospace, SFMono-Regular, Menlo, monospace', fontSize: '12px' },
|
|
42
|
+
bar: { height: '6px', borderRadius: '3px', background: 'rgba(128,128,128,0.25)', overflow: 'hidden', width: '260px' },
|
|
43
|
+
table: { width: '100%', borderCollapse: 'collapse', fontSize: '12px' },
|
|
44
|
+
td: { padding: '4px 8px 4px 0', borderBottom: '1px solid rgba(128,128,128,0.15)', verticalAlign: 'top' },
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const h = React.createElement
|
|
48
|
+
|
|
49
|
+
/** Call one host-half JSON endpoint and unwrap its `value`. */
|
|
50
|
+
async function callApi(path, options) {
|
|
51
|
+
const { method = 'GET', body, contentType = 'application/json' } = options ?? {}
|
|
52
|
+
const response = await fetch(`/_web-login/api/${path}`, {
|
|
53
|
+
method,
|
|
54
|
+
credentials: 'same-origin',
|
|
55
|
+
...(body === undefined ? {} : { headers: { 'content-type': contentType }, body }),
|
|
56
|
+
})
|
|
57
|
+
const text = await response.text()
|
|
58
|
+
let parsed
|
|
59
|
+
try {
|
|
60
|
+
parsed = JSON.parse(text)
|
|
61
|
+
} catch {
|
|
62
|
+
throw new Error(`HTTP ${response.status}`)
|
|
63
|
+
}
|
|
64
|
+
if (!response.ok || parsed.ok === false) throw new Error(parsed.error ?? parsed.message ?? `HTTP ${response.status}`)
|
|
65
|
+
return parsed.value
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Upload with progress (fetch cannot report upload progress). */
|
|
69
|
+
function uploadFile(path, file, onProgress) {
|
|
70
|
+
return new Promise((resolve, reject) => {
|
|
71
|
+
const xhr = new XMLHttpRequest()
|
|
72
|
+
xhr.open('POST', `/_web-login/api/${path}`)
|
|
73
|
+
xhr.withCredentials = true
|
|
74
|
+
xhr.setRequestHeader('content-type', file.type || 'application/octet-stream')
|
|
75
|
+
xhr.upload.onprogress = (event) => { if (event.lengthComputable) onProgress(event.loaded / event.total) }
|
|
76
|
+
xhr.onerror = () => reject(new Error('网络错误:上传中断'))
|
|
77
|
+
xhr.onload = () => {
|
|
78
|
+
let parsed
|
|
79
|
+
try { parsed = JSON.parse(xhr.responseText) } catch { reject(new Error(`HTTP ${xhr.status}`)); return }
|
|
80
|
+
if (xhr.status >= 400 || parsed.ok === false) reject(new Error(parsed.error ?? `HTTP ${xhr.status}`))
|
|
81
|
+
else resolve(parsed.value)
|
|
82
|
+
}
|
|
83
|
+
xhr.send(file)
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function formatRemaining(remainingMs) {
|
|
88
|
+
if (remainingMs === null) return '永久'
|
|
89
|
+
const minutes = Math.ceil(remainingMs / 60000)
|
|
90
|
+
if (minutes < 60) return `${minutes} 分钟`
|
|
91
|
+
const hours = Math.ceil(minutes / 60)
|
|
92
|
+
return hours < 48 ? `${hours} 小时` : `${Math.ceil(hours / 24)} 天`
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const formatTime = (at) => new Date(at).toLocaleString('zh-CN', { hour12: false })
|
|
96
|
+
const formatMB = (bytes) => `${(bytes / 1024 / 1024).toFixed(bytes < 1024 * 1024 ? 2 : 1)} MB`
|
|
97
|
+
|
|
98
|
+
const EVENT_LABELS = {
|
|
99
|
+
banned: '自动封禁',
|
|
100
|
+
unban: '手动解封',
|
|
101
|
+
'password-changed': '修改密码',
|
|
102
|
+
'password-reset': '重置密码',
|
|
103
|
+
settings: '修改设置',
|
|
104
|
+
upload: '上传/删除媒体',
|
|
105
|
+
'revoke-all': '注销所有会话',
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const KIND_ACCEPT = {
|
|
109
|
+
png: 'image/png', jpg: 'image/jpeg', webp: 'image/webp', gif: 'image/gif', avif: 'image/avif',
|
|
110
|
+
svg: 'image/svg+xml', mp4: 'video/mp4', webm: 'video/webm',
|
|
111
|
+
}
|
|
112
|
+
const acceptFor = (kinds) => kinds.map((kind) => KIND_ACCEPT[kind]).filter(Boolean).join(',')
|
|
113
|
+
|
|
114
|
+
function Choice(props) {
|
|
115
|
+
return h('button', {
|
|
116
|
+
type: 'button',
|
|
117
|
+
style: props.active ? S.on : S.ghost,
|
|
118
|
+
disabled: props.disabled,
|
|
119
|
+
title: props.title,
|
|
120
|
+
onClick: props.onClick,
|
|
121
|
+
}, props.label)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function Progress({ value }) {
|
|
125
|
+
return h('div', { style: S.row },
|
|
126
|
+
h('div', { style: S.bar }, h('div', { style: { width: `${Math.round(value * 100)}%`, height: '100%', background: '#4f46e5', transition: 'width .2s' } })),
|
|
127
|
+
h('span', { style: S.muted }, `${Math.round(value * 100)}%`),
|
|
128
|
+
)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function LoginSecurityTab() {
|
|
132
|
+
const [data, setData] = useState(null)
|
|
133
|
+
const [error, setError] = useState(null)
|
|
134
|
+
const [flash, setFlash] = useState(null)
|
|
135
|
+
const [busy, setBusy] = useState(false)
|
|
136
|
+
const [progress, setProgress] = useState(null)
|
|
137
|
+
|
|
138
|
+
const [bgMode, setBgMode] = useState('preset')
|
|
139
|
+
const [presetId, setPresetId] = useState('aurora')
|
|
140
|
+
const [animationId, setAnimationId] = useState('constellation')
|
|
141
|
+
const [color, setColor] = useState('#4f46e5')
|
|
142
|
+
const [url, setUrl] = useState('')
|
|
143
|
+
const [videoUrl, setVideoUrl] = useState('')
|
|
144
|
+
|
|
145
|
+
const [look, setLook] = useState(null)
|
|
146
|
+
|
|
147
|
+
const [logoMode, setLogoMode] = useState('yusho')
|
|
148
|
+
const [logoUrl, setLogoUrl] = useState('')
|
|
149
|
+
|
|
150
|
+
const [banEnabled, setBanEnabled] = useState(true)
|
|
151
|
+
const [threshold, setThreshold] = useState(5)
|
|
152
|
+
const [duration, setDuration] = useState('15m')
|
|
153
|
+
|
|
154
|
+
const [pwCurrent, setPwCurrent] = useState('')
|
|
155
|
+
const [pwNext, setPwNext] = useState('')
|
|
156
|
+
const [pwConfirm, setPwConfirm] = useState('')
|
|
157
|
+
const [confirmReset, setConfirmReset] = useState(false)
|
|
158
|
+
const [resetResult, setResetResult] = useState(null)
|
|
159
|
+
const [confirmRevoke, setConfirmRevoke] = useState(false)
|
|
160
|
+
const [revoked, setRevoked] = useState(false)
|
|
161
|
+
|
|
162
|
+
const adopt = useCallback((value) => {
|
|
163
|
+
setData(value)
|
|
164
|
+
setBanEnabled(value.ban.enabled)
|
|
165
|
+
setThreshold(value.ban.threshold)
|
|
166
|
+
setDuration(value.ban.duration)
|
|
167
|
+
const background = value.background
|
|
168
|
+
setBgMode(background.mode)
|
|
169
|
+
if (background.mode === 'preset') setPresetId(background.value)
|
|
170
|
+
if (background.mode === 'animation') setAnimationId(background.value)
|
|
171
|
+
if (background.mode === 'color') setColor(background.value)
|
|
172
|
+
if (background.mode === 'url') setUrl(background.value)
|
|
173
|
+
if (background.mode === 'video' && background.value.startsWith('https://')) setVideoUrl(background.value)
|
|
174
|
+
setLook(value.appearance)
|
|
175
|
+
setLogoMode(value.logo.mode)
|
|
176
|
+
if (value.logo.mode === 'url') setLogoUrl(value.logo.value)
|
|
177
|
+
}, [])
|
|
178
|
+
|
|
179
|
+
const load = useCallback(async () => {
|
|
180
|
+
setBusy(true)
|
|
181
|
+
setError(null)
|
|
182
|
+
try {
|
|
183
|
+
adopt(await callApi('settings'))
|
|
184
|
+
} catch (caught) {
|
|
185
|
+
setError(String(caught && caught.message ? caught.message : caught))
|
|
186
|
+
} finally {
|
|
187
|
+
setBusy(false)
|
|
188
|
+
}
|
|
189
|
+
}, [adopt])
|
|
190
|
+
|
|
191
|
+
useEffect(() => { void load() }, [load])
|
|
192
|
+
|
|
193
|
+
const run = useCallback(async (label, task) => {
|
|
194
|
+
setBusy(true)
|
|
195
|
+
setError(null)
|
|
196
|
+
setFlash(null)
|
|
197
|
+
try {
|
|
198
|
+
await task()
|
|
199
|
+
if (label) setFlash(label)
|
|
200
|
+
} catch (caught) {
|
|
201
|
+
setError(String(caught && caught.message ? caught.message : caught))
|
|
202
|
+
} finally {
|
|
203
|
+
setBusy(false)
|
|
204
|
+
setProgress(null)
|
|
205
|
+
}
|
|
206
|
+
}, [])
|
|
207
|
+
|
|
208
|
+
const post = (path, payload) => callApi(path, { method: 'POST', body: JSON.stringify(payload) })
|
|
209
|
+
|
|
210
|
+
const saveBackground = () => run('背景已保存', async () => {
|
|
211
|
+
const value = bgMode === 'preset' ? presetId
|
|
212
|
+
: bgMode === 'animation' ? animationId
|
|
213
|
+
: bgMode === 'color' ? color
|
|
214
|
+
: bgMode === 'url' ? url.trim()
|
|
215
|
+
: bgMode === 'video' ? (videoUrl.trim() !== '' ? videoUrl.trim() : '/_web-login/video')
|
|
216
|
+
: '/_web-login/bg'
|
|
217
|
+
await post('settings', { background: { mode: bgMode, value } })
|
|
218
|
+
await load()
|
|
219
|
+
})
|
|
220
|
+
|
|
221
|
+
const upload = (slot, label) => (event) => {
|
|
222
|
+
const input = event.target
|
|
223
|
+
const file = input.files && input.files[0]
|
|
224
|
+
if (!file) return
|
|
225
|
+
const limit = data.limits[slot]
|
|
226
|
+
if (file.size > limit.maxBytes) {
|
|
227
|
+
setError(`文件 ${formatMB(file.size)},超过上限 ${formatMB(limit.maxBytes)}`)
|
|
228
|
+
input.value = ''
|
|
229
|
+
return
|
|
230
|
+
}
|
|
231
|
+
void run(label, async () => {
|
|
232
|
+
setProgress(0)
|
|
233
|
+
await uploadFile(`${slot}/upload`, file, setProgress)
|
|
234
|
+
if (slot === 'video') setVideoUrl('')
|
|
235
|
+
await load()
|
|
236
|
+
}).then(() => { input.value = '' })
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const removeVideo = () => run('已删除上传的视频', async () => {
|
|
240
|
+
await post('video/remove', {})
|
|
241
|
+
await load()
|
|
242
|
+
})
|
|
243
|
+
|
|
244
|
+
const saveLook = () => run('外观已保存', async () => {
|
|
245
|
+
await post('settings', { appearance: look })
|
|
246
|
+
await load()
|
|
247
|
+
})
|
|
248
|
+
|
|
249
|
+
const saveLogo = () => run('Logo 已保存', async () => {
|
|
250
|
+
await post('settings', { logo: { mode: logoMode, value: logoMode === 'url' ? logoUrl.trim() : logoMode === 'image' ? '/_web-login/logo' : '' } })
|
|
251
|
+
await load()
|
|
252
|
+
})
|
|
253
|
+
|
|
254
|
+
const saveBan = () => run('封禁策略已保存', async () => {
|
|
255
|
+
await post('settings', { ban: { enabled: banEnabled, threshold, duration } })
|
|
256
|
+
await load()
|
|
257
|
+
})
|
|
258
|
+
|
|
259
|
+
const savePassword = () => run('密码已更新', async () => {
|
|
260
|
+
if (pwNext !== pwConfirm) throw new Error('两次输入的新密码不一致')
|
|
261
|
+
await post('password', { currentPassword: pwCurrent, newPassword: pwNext })
|
|
262
|
+
setPwCurrent('')
|
|
263
|
+
setPwNext('')
|
|
264
|
+
setPwConfirm('')
|
|
265
|
+
await load()
|
|
266
|
+
})
|
|
267
|
+
|
|
268
|
+
const doReset = () => run(null, async () => {
|
|
269
|
+
const value = await post('password/reset', {})
|
|
270
|
+
setResetResult(value.password)
|
|
271
|
+
setConfirmReset(false)
|
|
272
|
+
await load()
|
|
273
|
+
})
|
|
274
|
+
|
|
275
|
+
const doRevoke = () => run(null, async () => {
|
|
276
|
+
await post('sessions/revoke-all', { confirm: 'REVOKE' })
|
|
277
|
+
setRevoked(true)
|
|
278
|
+
setConfirmRevoke(false)
|
|
279
|
+
})
|
|
280
|
+
|
|
281
|
+
const unban = (ip) => run(`已解封 ${ip}`, async () => {
|
|
282
|
+
await post('bans/unban', { ip })
|
|
283
|
+
await load()
|
|
284
|
+
})
|
|
285
|
+
|
|
286
|
+
const openPreview = (animation) => {
|
|
287
|
+
window.open(`/_web-login/preview${animation ? `?animation=${encodeURIComponent(animation)}` : ''}`, '_blank', 'noopener')
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
if (revoked) {
|
|
291
|
+
return h('div', { style: S.root },
|
|
292
|
+
h('p', { style: S.warn }, '会话密钥已轮换,dsh web 正在重启(约 15–30 秒)。所有设备(包括当前这个)都已退出,请稍后刷新页面并用密码重新登录。'),
|
|
293
|
+
h('div', { style: S.row }, h('button', { type: 'button', style: S.btn, onClick: () => location.reload() }, '刷新页面')),
|
|
294
|
+
)
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
if (data === null || look === null) {
|
|
298
|
+
return h('div', { style: S.root },
|
|
299
|
+
error === null ? h('p', { style: S.muted }, '正在加载…')
|
|
300
|
+
: h('p', { style: S.err }, `加载失败:${error}`),
|
|
301
|
+
error === null ? null : h('div', { style: S.row }, h('button', { type: 'button', style: S.btn, onClick: load }, '重试')),
|
|
302
|
+
)
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
const opts = data.options
|
|
306
|
+
const setField = (field) => (value) => setLook({ ...look, [field]: value })
|
|
307
|
+
const notices = []
|
|
308
|
+
if (error !== null) notices.push(h('p', { key: 'e', style: S.err }, error))
|
|
309
|
+
if (flash !== null) notices.push(h('p', { key: 'f', style: S.ok }, flash))
|
|
310
|
+
if (progress !== null) notices.push(h(Progress, { key: 'p', value: progress }))
|
|
311
|
+
else if (busy) notices.push(h('p', { key: 'b', style: S.muted }, '处理中…'))
|
|
312
|
+
|
|
313
|
+
const uploads = data.uploads
|
|
314
|
+
const currentAnimation = opts.animations.find((entry) => entry.id === animationId) ?? opts.animations[0]
|
|
315
|
+
|
|
316
|
+
return h('div', { style: S.root },
|
|
317
|
+
notices,
|
|
318
|
+
|
|
319
|
+
// --- background -------------------------------------------------------
|
|
320
|
+
h('section', { style: S.section },
|
|
321
|
+
h('h3', { style: S.h }, '登录页背景'),
|
|
322
|
+
h('div', { style: S.row },
|
|
323
|
+
h(Choice, { label: '预设渐变', active: bgMode === 'preset', disabled: busy, onClick: () => setBgMode('preset') }),
|
|
324
|
+
h(Choice, { label: '动画', active: bgMode === 'animation', disabled: busy, onClick: () => setBgMode('animation') }),
|
|
325
|
+
h(Choice, { label: '视频', active: bgMode === 'video', disabled: busy, onClick: () => setBgMode('video') }),
|
|
326
|
+
h(Choice, { label: '上传图片 / 动图', active: bgMode === 'image', disabled: busy, onClick: () => setBgMode('image') }),
|
|
327
|
+
h(Choice, { label: '图片链接', active: bgMode === 'url', disabled: busy, onClick: () => setBgMode('url') }),
|
|
328
|
+
h(Choice, { label: '纯色', active: bgMode === 'color', disabled: busy, onClick: () => setBgMode('color') }),
|
|
329
|
+
),
|
|
330
|
+
|
|
331
|
+
bgMode === 'preset'
|
|
332
|
+
? h('div', { style: S.row }, opts.presets.map((preset) => h('button', {
|
|
333
|
+
key: preset.id,
|
|
334
|
+
type: 'button',
|
|
335
|
+
title: preset.label,
|
|
336
|
+
disabled: busy,
|
|
337
|
+
onClick: () => setPresetId(preset.id),
|
|
338
|
+
style: {
|
|
339
|
+
width: '64px', height: '40px', borderRadius: '8px', cursor: 'pointer', backgroundImage: preset.value,
|
|
340
|
+
border: presetId === preset.id ? '2px solid #4f46e5' : '1px solid rgba(128,128,128,0.4)',
|
|
341
|
+
color: '#fff', fontSize: '11px', textShadow: '0 1px 2px rgba(0,0,0,.6)',
|
|
342
|
+
},
|
|
343
|
+
}, preset.label)))
|
|
344
|
+
: null,
|
|
345
|
+
|
|
346
|
+
bgMode === 'animation'
|
|
347
|
+
? h('div', { style: S.stack },
|
|
348
|
+
h('div', { style: S.row }, opts.animations.map((entry) => h(Choice, {
|
|
349
|
+
key: entry.id, label: entry.label, title: entry.hint, active: animationId === entry.id, disabled: busy, onClick: () => setAnimationId(entry.id),
|
|
350
|
+
}))),
|
|
351
|
+
h('p', { style: S.muted }, `${currentAnimation.hint}。由登录页本地绘制,不加载外部资源;系统开启「减少动态效果」时自动静止,标签页不可见时暂停。`),
|
|
352
|
+
h('div', { style: S.row },
|
|
353
|
+
opts.animations.map((entry) => h('button', { key: entry.id, type: 'button', style: S.ghost, onClick: () => openPreview(entry.id) }, `试看「${entry.label}」`)),
|
|
354
|
+
),
|
|
355
|
+
)
|
|
356
|
+
: null,
|
|
357
|
+
|
|
358
|
+
bgMode === 'video'
|
|
359
|
+
? h('div', { style: S.stack },
|
|
360
|
+
h('p', { style: S.muted }, `上传 MP4(H.264)或 WebM,最大 ${formatMB(data.limits.video.maxBytes)}。视频会静音循环播放;建议 1080p、10–30 秒、码率 4Mbps 以内,体积越小首屏越快。`),
|
|
361
|
+
h('input', { type: 'file', accept: acceptFor(data.limits.video.kinds), disabled: busy, onChange: upload('video', '视频已上传并设为背景') }),
|
|
362
|
+
uploads.video.present
|
|
363
|
+
? h('div', { style: S.stack },
|
|
364
|
+
h('video', { src: uploads.video.url, muted: true, loop: true, autoPlay: true, playsInline: true, style: { width: '300px', maxHeight: '170px', borderRadius: '8px', border: '1px solid rgba(128,128,128,0.4)', objectFit: 'cover', background: '#000' } }),
|
|
365
|
+
h('div', { style: S.row },
|
|
366
|
+
h('span', { style: S.muted }, `已上传:${uploads.video.ext.toUpperCase()},${formatMB(uploads.video.bytes)}`),
|
|
367
|
+
h('button', { type: 'button', style: S.ghost, disabled: busy, onClick: removeVideo }, '删除视频'),
|
|
368
|
+
))
|
|
369
|
+
: h('p', { style: S.muted }, '尚未上传视频。'),
|
|
370
|
+
h('label', { style: S.muted }, '或使用 https 视频链接(填写后优先于上传的视频)'),
|
|
371
|
+
h('input', { style: { ...S.input, width: '100%' }, value: videoUrl, disabled: busy, placeholder: 'https://example.com/background.mp4', onChange: (event) => setVideoUrl(event.target.value) }),
|
|
372
|
+
)
|
|
373
|
+
: null,
|
|
374
|
+
|
|
375
|
+
bgMode === 'image'
|
|
376
|
+
? h('div', { style: S.stack },
|
|
377
|
+
h('p', { style: S.muted }, `支持 PNG / JPEG / WebP / AVIF,以及会动的 GIF、动态 WebP、APNG 和 SVG 动画(SMIL/CSS),最大 ${formatMB(data.limits.background.maxBytes)}。`),
|
|
378
|
+
h('input', { type: 'file', accept: acceptFor(data.limits.background.kinds), disabled: busy, onChange: upload('background', '背景图片已上传并启用') }),
|
|
379
|
+
uploads.background.present
|
|
380
|
+
? h('img', { src: uploads.background.url, alt: '当前登录页背景', style: { maxWidth: '300px', maxHeight: '150px', borderRadius: '8px', border: '1px solid rgba(128,128,128,0.4)', objectFit: 'cover' } })
|
|
381
|
+
: h('p', { style: S.muted }, '尚未上传图片。'),
|
|
382
|
+
)
|
|
383
|
+
: null,
|
|
384
|
+
|
|
385
|
+
bgMode === 'url'
|
|
386
|
+
? h('input', { style: { ...S.input, width: '100%' }, value: url, disabled: busy, placeholder: 'https://example.com/background.jpg', onChange: (event) => setUrl(event.target.value) })
|
|
387
|
+
: null,
|
|
388
|
+
|
|
389
|
+
bgMode === 'color'
|
|
390
|
+
? h('div', { style: S.row },
|
|
391
|
+
h('input', { type: 'color', value: color, disabled: busy, onChange: (event) => setColor(event.target.value) }),
|
|
392
|
+
h('input', { style: S.input, value: color, disabled: busy, placeholder: '#rrggbb', onChange: (event) => setColor(event.target.value) }),
|
|
393
|
+
)
|
|
394
|
+
: null,
|
|
395
|
+
|
|
396
|
+
h('div', { style: S.row },
|
|
397
|
+
h('button', { type: 'button', style: S.btn, disabled: busy, onClick: saveBackground }, '保存背景'),
|
|
398
|
+
h('button', { type: 'button', style: S.ghost, onClick: () => openPreview() }, '预览登录页'),
|
|
399
|
+
),
|
|
400
|
+
),
|
|
401
|
+
|
|
402
|
+
// --- appearance ------------------------------------------------------
|
|
403
|
+
h('section', { style: S.section },
|
|
404
|
+
h('h3', { style: S.h }, '登录卡片样式与动画'),
|
|
405
|
+
h('div', { style: S.grid },
|
|
406
|
+
h('span', { style: S.muted }, '卡片样式'),
|
|
407
|
+
h('div', { style: S.row }, opts.cards.map((entry) => h(Choice, { key: entry.id, label: entry.label, active: look.card === entry.id, disabled: busy, onClick: () => setField('card')(entry.id) }))),
|
|
408
|
+
h('span', { style: S.muted }, '位置'),
|
|
409
|
+
h('div', { style: S.row }, opts.layouts.map((entry) => h(Choice, { key: entry.id, label: entry.label, active: look.layout === entry.id, disabled: busy, onClick: () => setField('layout')(entry.id) }))),
|
|
410
|
+
h('span', { style: S.muted }, '入场动画'),
|
|
411
|
+
h('div', { style: S.row }, opts.intros.map((entry) => h(Choice, { key: entry.id, label: entry.label, active: look.intro === entry.id, disabled: busy, onClick: () => setField('intro')(entry.id) }))),
|
|
412
|
+
h('span', { style: S.muted }, '主题色'),
|
|
413
|
+
h('div', { style: S.row },
|
|
414
|
+
h('input', { type: 'color', value: look.accent, disabled: busy, onChange: (event) => setField('accent')(event.target.value) }),
|
|
415
|
+
['#6366f1', '#0ea5e9', '#22d3ee', '#10b981', '#f59e0b', '#ef4444', '#ec4899', '#a855f7'].map((swatch) => h('button', {
|
|
416
|
+
key: swatch, type: 'button', title: swatch, disabled: busy, onClick: () => setField('accent')(swatch),
|
|
417
|
+
style: { width: '20px', height: '20px', borderRadius: '50%', background: swatch, cursor: 'pointer', border: look.accent === swatch ? '2px solid #fff' : '1px solid rgba(128,128,128,0.5)', boxShadow: look.accent === swatch ? '0 0 0 2px #4f46e5' : 'none' },
|
|
418
|
+
})),
|
|
419
|
+
),
|
|
420
|
+
h('span', { style: S.muted }, `暗化遮罩 ${look.overlay}%`),
|
|
421
|
+
h('input', { type: 'range', min: 0, max: 85, step: 5, value: look.overlay, disabled: busy, onChange: (event) => setField('overlay')(Number(event.target.value)), style: { width: '260px' } }),
|
|
422
|
+
h('span', { style: S.muted }, `背景模糊 ${look.blur}px`),
|
|
423
|
+
h('input', { type: 'range', min: 0, max: 24, step: 1, value: look.blur, disabled: busy, onChange: (event) => setField('blur')(Number(event.target.value)), style: { width: '260px' } }),
|
|
424
|
+
h('span', { style: S.muted }, '标题'),
|
|
425
|
+
h('input', { style: S.input, value: look.title, maxLength: 40, disabled: busy, onChange: (event) => setField('title')(event.target.value) }),
|
|
426
|
+
h('span', { style: S.muted }, '副标题'),
|
|
427
|
+
h('input', { style: { ...S.input, width: '100%' }, value: look.subtitle, maxLength: 80, disabled: busy, onChange: (event) => setField('subtitle')(event.target.value) }),
|
|
428
|
+
),
|
|
429
|
+
h('p', { style: S.muted }, '登录页另带:密码显示/隐藏、大写锁定提示、输错时卡片抖动、登录成功的过渡动画。'),
|
|
430
|
+
h('div', { style: S.row },
|
|
431
|
+
h('button', { type: 'button', style: S.btn, disabled: busy, onClick: saveLook }, '保存样式'),
|
|
432
|
+
h('button', { type: 'button', style: S.ghost, onClick: () => openPreview() }, '预览登录页'),
|
|
433
|
+
),
|
|
434
|
+
),
|
|
435
|
+
|
|
436
|
+
// --- logo -----------------------------------------------------------
|
|
437
|
+
h('section', { style: S.section },
|
|
438
|
+
h('h3', { style: S.h }, '登录页 Logo'),
|
|
439
|
+
h('div', { style: S.row },
|
|
440
|
+
h(Choice, { label: '鱼Sho 图标(Sho 酱)', active: logoMode === 'yusho', disabled: busy, onClick: () => setLogoMode('yusho') }),
|
|
441
|
+
h(Choice, { label: 'DeepSeek 鲸鱼标', active: logoMode === 'brand', disabled: busy, onClick: () => setLogoMode('brand') }),
|
|
442
|
+
h(Choice, { label: '锁形图标', active: logoMode === 'lock', disabled: busy, onClick: () => setLogoMode('lock') }),
|
|
443
|
+
h(Choice, { label: '上传图片', active: logoMode === 'image', disabled: busy, onClick: () => setLogoMode('image') }),
|
|
444
|
+
h(Choice, { label: '图片链接', active: logoMode === 'url', disabled: busy, onClick: () => setLogoMode('url') }),
|
|
445
|
+
h(Choice, { label: '不显示', active: logoMode === 'none', disabled: busy, onClick: () => setLogoMode('none') }),
|
|
446
|
+
),
|
|
447
|
+
logoMode === 'url'
|
|
448
|
+
? h('input', { style: { ...S.input, width: '100%' }, value: logoUrl, disabled: busy, placeholder: 'https://example.com/logo.svg', onChange: (event) => setLogoUrl(event.target.value) })
|
|
449
|
+
: null,
|
|
450
|
+
logoMode === 'image'
|
|
451
|
+
? h('div', { style: S.stack },
|
|
452
|
+
h('p', { style: S.muted }, `PNG / JPEG / WebP / GIF / AVIF / SVG,最大 ${formatMB(data.limits.logo.maxBytes)}。`),
|
|
453
|
+
h('input', { type: 'file', accept: acceptFor(data.limits.logo.kinds), disabled: busy, onChange: upload('logo', 'Logo 已上传并启用') }),
|
|
454
|
+
)
|
|
455
|
+
: null,
|
|
456
|
+
h('div', { style: S.row },
|
|
457
|
+
h('span', { style: S.muted }, '预览'),
|
|
458
|
+
h('span', { style: S.chip },
|
|
459
|
+
logoMode === 'brand'
|
|
460
|
+
? h('img', { src: '/favicon.svg', alt: '官方鲸鱼标', style: { width: '22px', height: '22px', display: 'block' } })
|
|
461
|
+
: logoMode === 'lock'
|
|
462
|
+
? h('svg', { width: 18, height: 18, viewBox: '0 0 24 24', fill: 'none', stroke: '#111', strokeWidth: 2, strokeLinecap: 'round', strokeLinejoin: 'round' },
|
|
463
|
+
h('rect', { x: 3, y: 11, width: 18, height: 11, rx: 2 }), h('path', { d: 'M7 11V7a5 5 0 0 1 10 0v4' }))
|
|
464
|
+
: logoMode === 'url' && logoUrl !== ''
|
|
465
|
+
? h('img', { src: logoUrl, alt: '自定义 logo', style: { width: '22px', height: '22px', objectFit: 'contain', display: 'block' } })
|
|
466
|
+
: logoMode === 'image' && uploads.logo.present
|
|
467
|
+
? h('img', { src: uploads.logo.url, alt: '上传的 logo', style: { width: '30px', height: '30px', objectFit: 'cover', display: 'block' } })
|
|
468
|
+
: h('span', { style: { fontSize: '12px', color: '#666' } }, '无'),
|
|
469
|
+
),
|
|
470
|
+
),
|
|
471
|
+
logoMode === 'image' && uploads.logo.present
|
|
472
|
+
? null
|
|
473
|
+
: h('div', { style: S.row }, h('button', { type: 'button', style: S.btn, disabled: busy || (logoMode === 'image' && !uploads.logo.present), onClick: saveLogo }, '保存 Logo')),
|
|
474
|
+
),
|
|
475
|
+
|
|
476
|
+
// --- password -------------------------------------------------------
|
|
477
|
+
h('section', { style: S.section },
|
|
478
|
+
h('h3', { style: S.h }, '修改密码'),
|
|
479
|
+
h('p', { style: S.muted },
|
|
480
|
+
data.password.stored
|
|
481
|
+
? '当前密码以 scrypt 哈希保存在服务端。'
|
|
482
|
+
: '当前仍在用启动配置里的初始密码;修改一次后即改为哈希存储。'),
|
|
483
|
+
data.password.stored && data.password.fallbackConfigured
|
|
484
|
+
? h('p', { style: S.muted }, '提示:cordis.patch.yml 里仍留着明文的启动兜底密码。哈希已生效,它只在 state.json 丢失时才会用到,可以考虑删掉。')
|
|
485
|
+
: null,
|
|
486
|
+
h('div', { style: S.stack },
|
|
487
|
+
h('input', { style: S.input, type: 'password', value: pwCurrent, disabled: busy, placeholder: '原密码', autoComplete: 'current-password', onChange: (event) => setPwCurrent(event.target.value) }),
|
|
488
|
+
h('input', { style: S.input, type: 'password', value: pwNext, disabled: busy, placeholder: `新密码(至少 ${data.password.minLength} 位)`, autoComplete: 'new-password', onChange: (event) => setPwNext(event.target.value) }),
|
|
489
|
+
h('input', { style: S.input, type: 'password', value: pwConfirm, disabled: busy, placeholder: '确认新密码', autoComplete: 'new-password', onChange: (event) => setPwConfirm(event.target.value) }),
|
|
490
|
+
),
|
|
491
|
+
h('p', { style: S.muted }, '这个页面暴露在公网上,建议用 14 位以上的随机密码(密码管理器生成)。'),
|
|
492
|
+
h('div', { style: S.row },
|
|
493
|
+
h('button', { type: 'button', style: S.btn, disabled: busy || pwCurrent === '' || pwNext === '', onClick: savePassword }, '更新密码'),
|
|
494
|
+
),
|
|
495
|
+
h('h4', { style: S.h4 }, '忘记密码'),
|
|
496
|
+
h('p', { style: S.muted }, '在已登录的会话里,把密码重置为一个随机生成的 16 位新密码。新密码只显示这一次,请立即保存或改成你自己的。'),
|
|
497
|
+
resetResult !== null
|
|
498
|
+
? h('div', { style: S.ok },
|
|
499
|
+
h('div', null, '新密码(只显示一次):'),
|
|
500
|
+
h('div', { style: { ...S.code, fontSize: '16px', margin: '6px 0', userSelect: 'all' } }, resetResult),
|
|
501
|
+
h('div', { style: S.row },
|
|
502
|
+
h('button', { type: 'button', style: S.ghost, onClick: () => { void navigator.clipboard?.writeText(resetResult) } }, '复制'),
|
|
503
|
+
h('button', { type: 'button', style: S.ghost, onClick: () => setResetResult(null) }, '我已保存'),
|
|
504
|
+
))
|
|
505
|
+
: confirmReset
|
|
506
|
+
? h('div', { style: S.row },
|
|
507
|
+
h('span', { style: S.muted }, '确认重置?旧密码将立即失效。'),
|
|
508
|
+
h('button', { type: 'button', style: S.red, disabled: busy, onClick: doReset }, '确认重置'),
|
|
509
|
+
h('button', { type: 'button', style: S.ghost, disabled: busy, onClick: () => setConfirmReset(false) }, '取消'),
|
|
510
|
+
)
|
|
511
|
+
: h('div', { style: S.row }, h('button', { type: 'button', style: S.ghost, disabled: busy, onClick: () => setConfirmReset(true) }, '重置为随机密码')),
|
|
512
|
+
),
|
|
513
|
+
|
|
514
|
+
// --- protection -----------------------------------------------------
|
|
515
|
+
h('section', { style: S.section },
|
|
516
|
+
h('h3', { style: S.h }, '防暴力破解'),
|
|
517
|
+
h('p', { style: S.muted },
|
|
518
|
+
`始终生效:每个地址每分钟最多尝试 ${data.protection.perIpPerMinute} 次;所有「从未登录成功过的地址」合计每分钟最多 ${data.protection.unknownPerMinute} 次(30 天内登录成功过的地址不受这条限制);每输错一次,下一次回应的延迟翻倍(最长 5 秒)。IPv6 按 /64 网段计数。`),
|
|
519
|
+
h('label', { style: { ...S.row, cursor: 'pointer' } },
|
|
520
|
+
h('input', { type: 'checkbox', checked: banEnabled, disabled: busy, onChange: (event) => setBanEnabled(event.target.checked) }),
|
|
521
|
+
'同一地址累计输错达到阈值后自动封禁',
|
|
522
|
+
),
|
|
523
|
+
h('div', { style: S.row },
|
|
524
|
+
h('span', { style: S.muted }, '失败次数'),
|
|
525
|
+
opts.thresholds.map((value) => h(Choice, { key: value, label: `${value} 次`, active: threshold === value, disabled: busy || !banEnabled, onClick: () => setThreshold(value) })),
|
|
526
|
+
),
|
|
527
|
+
h('div', { style: S.row },
|
|
528
|
+
h('span', { style: S.muted }, '封禁时长'),
|
|
529
|
+
opts.durations.map((entry) => h(Choice, { key: entry.id, label: entry.label, active: duration === entry.id, disabled: busy || !banEnabled, onClick: () => setDuration(entry.id) })),
|
|
530
|
+
),
|
|
531
|
+
h('div', { style: S.row }, h('button', { type: 'button', style: S.btn, disabled: busy, onClick: saveBan }, '保存封禁策略')),
|
|
532
|
+
),
|
|
533
|
+
|
|
534
|
+
// --- audit ----------------------------------------------------------
|
|
535
|
+
h('section', { style: S.section },
|
|
536
|
+
h('h3', { style: S.h }, '安全记录'),
|
|
537
|
+
h('h4', { style: S.h4 }, '最近成功登录'),
|
|
538
|
+
data.logins.length === 0
|
|
539
|
+
? h('p', { style: S.muted }, '暂无记录。')
|
|
540
|
+
: h('table', { style: S.table }, h('tbody', null, data.logins.slice(0, 12).map((entry, i) => h('tr', { key: `${entry.at}-${i}` },
|
|
541
|
+
h('td', { style: { ...S.td, whiteSpace: 'nowrap' } }, formatTime(entry.at)),
|
|
542
|
+
h('td', { style: { ...S.td, ...S.code, whiteSpace: 'nowrap' } }, entry.ip, entry.ip === data.you ? ' (你)' : ''),
|
|
543
|
+
h('td', { style: { ...S.td, opacity: 0.7 } }, entry.agent),
|
|
544
|
+
)))),
|
|
545
|
+
h('h4', { style: S.h4 }, '安全事件'),
|
|
546
|
+
data.events.length === 0
|
|
547
|
+
? h('p', { style: S.muted }, '暂无记录。')
|
|
548
|
+
: h('table', { style: S.table }, h('tbody', null, data.events.slice(0, 15).map((entry, i) => h('tr', { key: `${entry.at}-${i}` },
|
|
549
|
+
h('td', { style: { ...S.td, whiteSpace: 'nowrap' } }, formatTime(entry.at)),
|
|
550
|
+
h('td', { style: { ...S.td, whiteSpace: 'nowrap' } }, EVENT_LABELS[entry.kind] ?? entry.kind),
|
|
551
|
+
h('td', { style: { ...S.td, ...S.code, whiteSpace: 'nowrap' } }, entry.ip),
|
|
552
|
+
h('td', { style: { ...S.td, opacity: 0.7 } }, entry.detail),
|
|
553
|
+
)))),
|
|
554
|
+
h('h4', { style: S.h4 }, `当前封禁(${data.bans.length})`),
|
|
555
|
+
data.bans.length === 0
|
|
556
|
+
? h('p', { style: S.muted }, '暂无封禁。')
|
|
557
|
+
: h('div', { style: S.stack }, data.bans.slice(0, 30).map((ban) => h('div', { key: ban.ip, style: S.row },
|
|
558
|
+
h('span', { style: S.code }, ban.ip),
|
|
559
|
+
h('span', { style: S.muted }, ban.permanent ? '永久封禁' : `剩余 ${formatRemaining(ban.remainingMs)}`),
|
|
560
|
+
h('button', { type: 'button', style: S.ghost, disabled: busy, onClick: () => unban(ban.ip) }, '解封'),
|
|
561
|
+
))),
|
|
562
|
+
h('h4', { style: S.h4 }, `待触发的失败计数(${data.attempts.length})`),
|
|
563
|
+
data.attempts.length === 0
|
|
564
|
+
? h('p', { style: S.muted }, '暂无失败记录。')
|
|
565
|
+
: h('div', { style: S.stack }, data.attempts.slice(0, 30).map((attempt) => h('div', { key: attempt.ip, style: S.row },
|
|
566
|
+
h('span', { style: S.code }, attempt.ip),
|
|
567
|
+
h('span', { style: S.muted }, `已失败 ${attempt.count} 次 / 阈值 ${data.ban.threshold} 次`),
|
|
568
|
+
))),
|
|
569
|
+
h('div', { style: S.row }, h('button', { type: 'button', style: S.ghost, disabled: busy, onClick: load }, '刷新')),
|
|
570
|
+
),
|
|
571
|
+
|
|
572
|
+
// --- sessions -------------------------------------------------------
|
|
573
|
+
h('section', { style: S.danger },
|
|
574
|
+
h('h3', { style: S.h }, '注销所有会话'),
|
|
575
|
+
h('p', { style: S.muted }, '怀疑登录 Cookie 泄露、或在别人电脑上登录过时使用:轮换会话签名密钥,所有已登录的浏览器(包括你现在这个)立即失效。dsh web 会自动重启一次(约 15–30 秒),正在运行的 AI 会话会被中断。修改密码不会让已登录的设备下线,需要配合这个操作。'),
|
|
576
|
+
confirmRevoke
|
|
577
|
+
? h('div', { style: S.row },
|
|
578
|
+
h('span', { style: S.muted }, '确认注销所有会话并重启?'),
|
|
579
|
+
h('button', { type: 'button', style: S.red, disabled: busy, onClick: doRevoke }, '确认注销并重启'),
|
|
580
|
+
h('button', { type: 'button', style: S.ghost, disabled: busy, onClick: () => setConfirmRevoke(false) }, '取消'),
|
|
581
|
+
)
|
|
582
|
+
: h('div', { style: S.row }, h('button', { type: 'button', style: S.ghost, disabled: busy, onClick: () => setConfirmRevoke(true) }, '注销所有会话…')),
|
|
583
|
+
),
|
|
584
|
+
)
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
const inject = ['slots']
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* Contribute the tab to Settings -> Plugins.
|
|
591
|
+
* @param {object} ctx - the client plugin context.
|
|
592
|
+
*/
|
|
593
|
+
function apply(ctx) {
|
|
594
|
+
ctx.slots.inject('settings.plugins.tab', () => ctx.slots.register({
|
|
595
|
+
name: 'settings.plugins.tab',
|
|
596
|
+
id: 'web-login',
|
|
597
|
+
order: 20,
|
|
598
|
+
label: '登录与安全',
|
|
599
|
+
}, LoginSecurityTab))
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
exports.LoginSecurityTab = LoginSecurityTab
|
|
603
|
+
exports.apply = apply
|
|
604
|
+
exports.inject = inject
|
|
605
|
+
return module.exports
|
|
606
|
+
},
|
|
607
|
+
})
|