@yusho/server 0.0.0-stage → 0.1.17
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 +2715 -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 +138 -0
|
@@ -0,0 +1,609 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-side rendering of the login gate's own pages (login, banned,
|
|
3
|
+
* preview). Everything the page needs ships inline — styles, the form
|
|
4
|
+
* behaviour, and the built-in animated backgrounds — so the page works before
|
|
5
|
+
* authentication and loads nothing from a CDN.
|
|
6
|
+
*
|
|
7
|
+
* Every inline <script> carries a per-response CSP nonce; the response's
|
|
8
|
+
* Content-Security-Policy admits only those, so even a markup-injection bug
|
|
9
|
+
* elsewhere could not run script on this origin.
|
|
10
|
+
*
|
|
11
|
+
* Contract with /usr/local/bin/dsh-gate-check: the login page must keep
|
|
12
|
+
* `id="login-form"` and must never contain `__DSH_TRANSPORT__` or
|
|
13
|
+
* `/assets/index-` (those mark the real app, and the watchdog stops the
|
|
14
|
+
* service if an anonymous request appears to receive it).
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { FISH_LOGO_PATH, FISH_LOGO_VIEWBOX } from './brand.mjs'
|
|
18
|
+
import { BACKGROUND_PRESETS, MEDIA_PATHS } from './login-store.mjs'
|
|
19
|
+
import { whaleScript } from './whale-scene.mjs'
|
|
20
|
+
import { yushoScript, YUSHO_SCENE_HTML, YUSHO_SCENE_CSS } from './yusho-scene.mjs'
|
|
21
|
+
|
|
22
|
+
export function escapeHtml(value) {
|
|
23
|
+
return String(value).replace(/[&<>"']/gu, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c])
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Escape a value for use inside a CSS `url("...")`. */
|
|
27
|
+
function escapeCssUrl(value) {
|
|
28
|
+
return String(value).replace(/[\r\n\f]/gu, '').replace(/[\\"'()]/gu, (c) => `\\${c}`)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Darken (factor < 1) or lighten (factor > 1) a #rgb/#rrggbb colour. */
|
|
32
|
+
function shade(hex, factor) {
|
|
33
|
+
const full = hex.length === 4 ? `#${hex[1]}${hex[1]}${hex[2]}${hex[2]}${hex[3]}${hex[3]}` : hex
|
|
34
|
+
const channels = [1, 3, 5].map((at) => parseInt(full.slice(at, at + 2), 16))
|
|
35
|
+
const mixed = channels.map((c) => Math.round(factor < 1 ? c * factor : c + (255 - c) * (factor - 1)))
|
|
36
|
+
return `#${mixed.map((c) => Math.max(0, Math.min(255, c)).toString(16).padStart(2, '0')).join('')}`
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function rgbTriplet(hex) {
|
|
40
|
+
const full = hex.length === 4 ? `#${hex[1]}${hex[1]}${hex[2]}${hex[2]}${hex[3]}${hex[3]}` : hex
|
|
41
|
+
return [1, 3, 5].map((at) => parseInt(full.slice(at, at + 2), 16)).join(',')
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Headers for every page this plugin renders itself. The CSP is strict
|
|
46
|
+
* because the page is reachable by anyone on the internet before login.
|
|
47
|
+
* @param {string} nonce - the per-response script nonce.
|
|
48
|
+
* @returns {Record<string, string>} the headers.
|
|
49
|
+
*/
|
|
50
|
+
export function pageSecurityHeaders(nonce) {
|
|
51
|
+
return {
|
|
52
|
+
'content-security-policy': [
|
|
53
|
+
"default-src 'none'",
|
|
54
|
+
`script-src 'nonce-${nonce}'`,
|
|
55
|
+
// Inline style attributes carry the operator's colours and media URLs.
|
|
56
|
+
"style-src 'unsafe-inline'",
|
|
57
|
+
"img-src 'self' data: https: http:",
|
|
58
|
+
"media-src 'self' https:",
|
|
59
|
+
"connect-src 'self'",
|
|
60
|
+
"font-src 'self' data:",
|
|
61
|
+
"form-action 'self'",
|
|
62
|
+
"base-uri 'none'",
|
|
63
|
+
"frame-ancestors 'none'",
|
|
64
|
+
"object-src 'none'",
|
|
65
|
+
].join('; '),
|
|
66
|
+
'x-frame-options': 'DENY',
|
|
67
|
+
'x-content-type-options': 'nosniff',
|
|
68
|
+
'referrer-policy': 'no-referrer',
|
|
69
|
+
'permissions-policy': 'camera=(), microphone=(), geolocation=(), payment=(), usb=()',
|
|
70
|
+
'cross-origin-opener-policy': 'same-origin',
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function lockSvg(size) {
|
|
75
|
+
return `<svg width="${size}" height="${size}" viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="11" width="18" height="11" rx="2"></rect><path d="M7 11V7a5 5 0 0 1 10 0v4"></path></svg>`
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function brandSvg(width) {
|
|
79
|
+
const height = (width * FISH_LOGO_VIEWBOX.height) / FISH_LOGO_VIEWBOX.width
|
|
80
|
+
return `<svg width="${width.toFixed(2)}" height="${height.toFixed(2)}" viewBox="0 0 ${FISH_LOGO_VIEWBOX.width} ${FISH_LOGO_VIEWBOX.height}" fill="none" aria-hidden="true"><path d="${FISH_LOGO_PATH}" fill="#fff"/></svg>`
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The mark shown above the login form.
|
|
85
|
+
* @param {{mode: string, value: string}} logo - the stored setting.
|
|
86
|
+
* @param {string|undefined} uploadedUrl - versioned URL of the uploaded logo, when present.
|
|
87
|
+
* @returns {string} badge markup, or '' when the mark is disabled.
|
|
88
|
+
*/
|
|
89
|
+
export function logoMarkup(logo, uploadedUrl) {
|
|
90
|
+
if (logo.mode === 'none') return ''
|
|
91
|
+
if (logo.mode === 'image' || logo.mode === 'url') {
|
|
92
|
+
const source = logo.mode === 'image' ? uploadedUrl : logo.value
|
|
93
|
+
if (source !== undefined) return `<div class="badge badge-image"><img src="${escapeHtml(source)}" alt=""></div>`
|
|
94
|
+
}
|
|
95
|
+
if (logo.mode === 'yusho') return '<div class="badge badge-image badge-yusho"><img src="/_web-login/brand/icon.webp" alt="鱼Sho"></div>'
|
|
96
|
+
return `<div class="badge">${logo.mode === 'lock' ? lockSvg(24) : brandSvg(26)}</div>`
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Base gradient under every media background, visible while media loads. */
|
|
100
|
+
function presetValue(id) {
|
|
101
|
+
return (BACKGROUND_PRESETS.find((entry) => entry.id === id) ?? BACKGROUND_PRESETS[0]).value
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The background layers for one configuration.
|
|
106
|
+
* @returns {{html: string, script: string}} markup and any animation script body.
|
|
107
|
+
*/
|
|
108
|
+
function backgroundLayers(background, appearance, media) {
|
|
109
|
+
const blur = appearance.blur > 0 ? ` style="filter:blur(${appearance.blur}px);transform:scale(1.06)"` : ''
|
|
110
|
+
const blurStyle = appearance.blur > 0 ? `filter:blur(${appearance.blur}px);transform:scale(1.06);` : ''
|
|
111
|
+
const base = `<div class="bg" style="background-image:${presetValue('midnight')}"></div>`
|
|
112
|
+
switch (background.mode) {
|
|
113
|
+
case 'color':
|
|
114
|
+
return { html: `<div class="bg" style="background-color:${escapeHtml(background.value)}"></div>`, script: '' }
|
|
115
|
+
case 'image': {
|
|
116
|
+
if (media.background === undefined) break
|
|
117
|
+
return { html: `${base}<div class="bg bg-media" style="${blurStyle}background-image:url("${escapeHtml(escapeCssUrl(media.background))}")"></div>`, script: '' }
|
|
118
|
+
}
|
|
119
|
+
case 'url':
|
|
120
|
+
return { html: `${base}<div class="bg bg-media" style="${blurStyle}background-image:url("${escapeHtml(escapeCssUrl(background.value))}")"></div>`, script: '' }
|
|
121
|
+
case 'video': {
|
|
122
|
+
const source = background.value === MEDIA_PATHS.video ? media.video : background.value
|
|
123
|
+
if (source === undefined) break
|
|
124
|
+
return {
|
|
125
|
+
html: `${base}<video class="bg bg-video" id="bg-video" autoplay muted loop playsinline preload="auto" aria-hidden="true"${blur}><source src="${escapeHtml(source)}"${media.videoType ? ` type="${escapeHtml(media.videoType)}"` : ''}></video>`,
|
|
126
|
+
script: VIDEO_SCRIPT,
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
case 'animation': {
|
|
130
|
+
if (background.value === 'yusho') {
|
|
131
|
+
// 鱼Sho 的「深海·Sho 酱」:IP logo + 气泡、光束、星星(2D 画布,不要 WebGL)
|
|
132
|
+
return { html: `<style>${YUSHO_SCENE_CSS}</style>${YUSHO_SCENE_HTML}`, script: yushoScript() }
|
|
133
|
+
}
|
|
134
|
+
if (background.value === 'whale') {
|
|
135
|
+
// WebGL scene, with the 2D deep-sea scene parked behind it as the fallback.
|
|
136
|
+
return {
|
|
137
|
+
html: `<div class="bg" style="background-image:radial-gradient(120% 90% at 50% -10%,#0e4f78 0%,#06243f 45%,#020814 100%)"></div><canvas class="bg" id="bg-canvas" data-anim="deepsea" data-deferred="1" hidden aria-hidden="true"${blur}></canvas><canvas class="bg" id="bg-gl" aria-hidden="true"${blur}></canvas>`,
|
|
138
|
+
script: `${CANVAS_SCRIPT}\n${whaleScript({ title: appearance.title, logo: media.logo })}`,
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (background.value === 'aurora') {
|
|
142
|
+
return { html: `<div class="bg aurora"${blur}><span></span><span></span><span></span><span></span></div>`, script: '' }
|
|
143
|
+
}
|
|
144
|
+
const tint = background.value === 'deepsea'
|
|
145
|
+
? 'radial-gradient(120% 90% at 50% -10%,#0e4f78 0%,#06243f 45%,#020814 100%)'
|
|
146
|
+
: 'radial-gradient(120% 120% at 50% 0%,#151a3a 0%,#080a18 60%,#030409 100%)'
|
|
147
|
+
return {
|
|
148
|
+
html: `<div class="bg" style="background-image:${tint}"></div><canvas class="bg" id="bg-canvas" data-anim="${escapeHtml(background.value)}" aria-hidden="true"${blur}></canvas>`,
|
|
149
|
+
script: CANVAS_SCRIPT,
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
default:
|
|
153
|
+
break
|
|
154
|
+
}
|
|
155
|
+
const preset = background.mode === 'preset' ? background.value : 'aurora'
|
|
156
|
+
return { html: `<div class="bg" style="background-image:${presetValue(preset)}"></div>`, script: '' }
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const BASE_CSS = `
|
|
160
|
+
:root { color-scheme: dark; }
|
|
161
|
+
* { box-sizing: border-box; }
|
|
162
|
+
html, body { height: 100%; }
|
|
163
|
+
body {
|
|
164
|
+
margin: 0; min-height: 100vh; display: flex; align-items: center; justify-content: center;
|
|
165
|
+
padding: 24px; overflow: hidden; background: #0a0a0f; color: #f4f4f7;
|
|
166
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
|
|
167
|
+
}
|
|
168
|
+
body.layout-left { justify-content: flex-start; padding-left: max(24px, 8vw); }
|
|
169
|
+
body.layout-right { justify-content: flex-end; padding-right: max(24px, 8vw); }
|
|
170
|
+
@media (max-width: 760px) { body.layout-left, body.layout-right { justify-content: center; padding: 24px; } }
|
|
171
|
+
.bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; background-size: cover; background-position: center; pointer-events: none; }
|
|
172
|
+
.bg-video { object-fit: cover; }
|
|
173
|
+
.veil { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
|
|
174
|
+
[hidden] { display: none !important; }
|
|
175
|
+
|
|
176
|
+
.badge.badge-yusho { background: #EEF3FF !important; box-shadow: 0 8px 24px -8px rgba(77,107,254,.7) !important; overflow: hidden; }
|
|
177
|
+
.badge.badge-yusho img { width: 100%; height: 100%; object-fit: cover; }
|
|
178
|
+
.card { position: relative; z-index: 2; width: min(92vw, 380px); padding: 34px 30px 30px; border-radius: 18px; }
|
|
179
|
+
.card-glass { background: rgba(20,20,28,.58); border: 1px solid rgba(255,255,255,.13); backdrop-filter: blur(22px) saturate(1.4); -webkit-backdrop-filter: blur(22px) saturate(1.4); box-shadow: 0 24px 70px rgba(0,0,0,.55); }
|
|
180
|
+
.card-solid { background: #14151d; border: 1px solid rgba(255,255,255,.07); box-shadow: 0 30px 80px rgba(0,0,0,.6); }
|
|
181
|
+
.card-minimal { background: transparent; border: 0; box-shadow: none; padding-left: 8px; padding-right: 8px; text-shadow: 0 1px 3px rgba(0,0,0,.65); }
|
|
182
|
+
/* No panel behind the minimal card, so a soft halo keeps text readable over busy backgrounds. */
|
|
183
|
+
.card-minimal::before { content: ''; position: absolute; inset: -60px -80px; z-index: -1; pointer-events: none;
|
|
184
|
+
background: radial-gradient(closest-side, rgba(3,5,12,.72), rgba(3,5,12,.45) 55%, transparent); }
|
|
185
|
+
.card-minimal input.pw { background: transparent; border: 0; border-bottom: 1px solid rgba(255,255,255,.35); border-radius: 0; padding-left: 2px; }
|
|
186
|
+
.card-minimal input.pw:focus { box-shadow: none; border-bottom-color: var(--accent); }
|
|
187
|
+
.card-neon { background: rgba(8,8,16,.78); border: 1px solid rgba(var(--accent-rgb),.55); box-shadow: 0 0 0 1px rgba(var(--accent-rgb),.25), 0 0 34px rgba(var(--accent-rgb),.45), inset 0 0 24px rgba(var(--accent-rgb),.12); animation: neon 3.2s ease-in-out infinite alternate; }
|
|
188
|
+
@keyframes neon { to { box-shadow: 0 0 0 1px rgba(var(--accent-rgb),.4), 0 0 52px rgba(var(--accent-rgb),.65), inset 0 0 30px rgba(var(--accent-rgb),.2); } }
|
|
189
|
+
|
|
190
|
+
.badge { width: 46px; height: 46px; border-radius: 13px; margin-bottom: 18px; display: flex; align-items: center; justify-content: center;
|
|
191
|
+
background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 8px 24px rgba(var(--accent-rgb),.45); }
|
|
192
|
+
.badge-image { background: rgba(255,255,255,.06); box-shadow: 0 8px 24px rgba(0,0,0,.35); overflow: hidden; }
|
|
193
|
+
.badge-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
|
|
194
|
+
h1 { margin: 0 0 6px; font-size: 19px; font-weight: 600; letter-spacing: .2px; }
|
|
195
|
+
p.sub { margin: 0 0 22px; font-size: 13px; color: #a1a1b5; }
|
|
196
|
+
label { display: block; font-size: 12px; color: #b6b6c8; margin-bottom: 8px; }
|
|
197
|
+
.field { position: relative; }
|
|
198
|
+
input.pw { width: 100%; padding: 12px 44px 12px 14px; font-size: 15px; color: #f4f4f7; background: rgba(0,0,0,.32);
|
|
199
|
+
border: 1px solid rgba(255,255,255,.16); border-radius: 11px; outline: none; transition: border-color .15s, box-shadow .15s; }
|
|
200
|
+
input.pw:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb),.28); }
|
|
201
|
+
.eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; padding: 0; margin: 0;
|
|
202
|
+
display: flex; align-items: center; justify-content: center; border: 0; border-radius: 8px; background: transparent; color: #a1a1b5; cursor: pointer; }
|
|
203
|
+
.eye:hover { color: #fff; background: rgba(255,255,255,.07); }
|
|
204
|
+
.caps { margin: 8px 0 0; font-size: 12px; color: #fcd34d; }
|
|
205
|
+
.submit { position: relative; width: 100%; margin-top: 16px; padding: 12px 14px; font-size: 15px; font-weight: 600; color: #fff;
|
|
206
|
+
background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: 0; border-radius: 11px; cursor: pointer;
|
|
207
|
+
transition: filter .15s, transform .05s, background .3s; }
|
|
208
|
+
.submit:hover { filter: brightness(1.08); }
|
|
209
|
+
.submit:active { transform: translateY(1px); }
|
|
210
|
+
.submit:disabled { cursor: default; filter: saturate(.7); }
|
|
211
|
+
.submit .spin { display: inline-block; width: 14px; height: 14px; margin-right: 8px; vertical-align: -2px; border-radius: 50%;
|
|
212
|
+
border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; animation: spin .7s linear infinite; }
|
|
213
|
+
@keyframes spin { to { transform: rotate(360deg); } }
|
|
214
|
+
.error { margin: 0 0 16px; padding: 10px 12px; font-size: 13px; color: #fecaca; background: rgba(239,68,68,.16);
|
|
215
|
+
border: 1px solid rgba(239,68,68,.35); border-radius: 10px; }
|
|
216
|
+
.muted { margin: 14px 0 0; font-size: 12px; color: #8b8ba0; text-align: center; }
|
|
217
|
+
.preview-banner { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 5; padding: 6px 14px; border-radius: 999px;
|
|
218
|
+
font-size: 12px; background: rgba(250,204,21,.16); border: 1px solid rgba(250,204,21,.45); color: #fde68a; }
|
|
219
|
+
|
|
220
|
+
.intro-rise { animation: rise .7s cubic-bezier(.2,.8,.2,1) both; }
|
|
221
|
+
.intro-zoom { animation: zoom .6s cubic-bezier(.2,.9,.25,1.15) both; }
|
|
222
|
+
.intro-fade { animation: fade .8s ease both; }
|
|
223
|
+
.card-neon.intro-rise, .card-neon.intro-zoom, .card-neon.intro-fade { animation-name: var(--intro), neon; animation-duration: .7s, 3.2s;
|
|
224
|
+
animation-iteration-count: 1, infinite; animation-direction: normal, alternate; animation-delay: 0s, .7s; }
|
|
225
|
+
.intro-rise > *, .intro-zoom > *, .intro-fade > * { animation: rise-child .6s cubic-bezier(.2,.8,.2,1) both; }
|
|
226
|
+
.intro-rise > *:nth-child(2), .intro-zoom > *:nth-child(2), .intro-fade > *:nth-child(2) { animation-delay: .06s; }
|
|
227
|
+
.intro-rise > *:nth-child(3), .intro-zoom > *:nth-child(3), .intro-fade > *:nth-child(3) { animation-delay: .12s; }
|
|
228
|
+
.intro-rise > *:nth-child(n+4), .intro-zoom > *:nth-child(n+4), .intro-fade > *:nth-child(n+4) { animation-delay: .18s; }
|
|
229
|
+
@keyframes rise { from { opacity: 0; transform: translateY(26px) scale(.98); } to { opacity: 1; transform: none; } }
|
|
230
|
+
@keyframes zoom { from { opacity: 0; transform: scale(.86); } to { opacity: 1; transform: none; } }
|
|
231
|
+
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
|
|
232
|
+
@keyframes rise-child { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
|
|
233
|
+
.shake { animation: shake .42s cubic-bezier(.36,.07,.19,.97) both !important; }
|
|
234
|
+
@keyframes shake { 10%,90% { transform: translateX(-2px); } 20%,80% { transform: translateX(4px); } 30%,50%,70% { transform: translateX(-8px); } 40%,60% { transform: translateX(8px); } }
|
|
235
|
+
.success { animation: success .55s ease .25s forwards !important; }
|
|
236
|
+
.success .submit { background: linear-gradient(135deg, #22c55e, #16a34a); }
|
|
237
|
+
@keyframes success { to { opacity: 0; transform: scale(1.04) translateY(-8px); filter: blur(4px); } }
|
|
238
|
+
|
|
239
|
+
.aurora { background: #050816; overflow: hidden; }
|
|
240
|
+
.aurora span { position: absolute; width: 75vmax; height: 75vmax; border-radius: 50%; filter: blur(70px); opacity: .55; mix-blend-mode: screen; will-change: transform; }
|
|
241
|
+
.aurora span:nth-child(1) { background: radial-gradient(circle, var(--accent) 0%, transparent 62%); top: -30%; left: -20%; animation: drift1 19s ease-in-out infinite alternate; }
|
|
242
|
+
.aurora span:nth-child(2) { background: radial-gradient(circle, #22d3ee 0%, transparent 62%); top: 10%; right: -30%; animation: drift2 23s ease-in-out infinite alternate; }
|
|
243
|
+
.aurora span:nth-child(3) { background: radial-gradient(circle, #db2777 0%, transparent 62%); bottom: -40%; left: 5%; animation: drift3 27s ease-in-out infinite alternate; }
|
|
244
|
+
.aurora span:nth-child(4) { background: radial-gradient(circle, #10b981 0%, transparent 60%); top: 30%; left: 30%; opacity: .35; animation: drift4 31s ease-in-out infinite alternate; }
|
|
245
|
+
@keyframes drift1 { to { transform: translate(28vw, 18vh) rotate(40deg) scale(1.15); } }
|
|
246
|
+
@keyframes drift2 { to { transform: translate(-32vw, 12vh) rotate(-30deg) scale(.9); } }
|
|
247
|
+
@keyframes drift3 { to { transform: translate(22vw, -26vh) rotate(25deg) scale(1.2); } }
|
|
248
|
+
@keyframes drift4 { to { transform: translate(-18vw, -14vh) scale(1.3); } }
|
|
249
|
+
|
|
250
|
+
@media (prefers-reduced-motion: reduce) {
|
|
251
|
+
*, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition: none !important; }
|
|
252
|
+
.aurora span { animation: none !important; }
|
|
253
|
+
}
|
|
254
|
+
`
|
|
255
|
+
|
|
256
|
+
/** Login form behaviour: in-place errors, shake, success transition, eye toggle, Caps Lock hint. */
|
|
257
|
+
const FORM_SCRIPT = `
|
|
258
|
+
(() => {
|
|
259
|
+
const form = document.getElementById('login-form')
|
|
260
|
+
const input = document.getElementById('password')
|
|
261
|
+
const errorBox = document.getElementById('login-error')
|
|
262
|
+
const button = document.getElementById('login-button')
|
|
263
|
+
const eye = document.getElementById('toggle-password')
|
|
264
|
+
const caps = document.getElementById('caps-hint')
|
|
265
|
+
const label = button.textContent
|
|
266
|
+
const preview = form.dataset.preview === '1'
|
|
267
|
+
const emit = (type) => dispatchEvent(new CustomEvent('dsh-login', { detail: { type } }))
|
|
268
|
+
input.addEventListener('focus', () => emit('focus'))
|
|
269
|
+
input.addEventListener('blur', () => emit('blur'))
|
|
270
|
+
input.addEventListener('input', () => emit('input'))
|
|
271
|
+
const show = (message) => { errorBox.textContent = message; errorBox.hidden = false }
|
|
272
|
+
const shake = () => { form.classList.remove('shake'); void form.offsetWidth; form.classList.add('shake') }
|
|
273
|
+
const busy = (on, text) => {
|
|
274
|
+
button.disabled = on
|
|
275
|
+
button.textContent = ''
|
|
276
|
+
if (on) { const s = document.createElement('span'); s.className = 'spin'; button.append(s) }
|
|
277
|
+
button.append(text)
|
|
278
|
+
}
|
|
279
|
+
eye.addEventListener('click', () => {
|
|
280
|
+
const hidden = input.type === 'password'
|
|
281
|
+
input.type = hidden ? 'text' : 'password'
|
|
282
|
+
eye.setAttribute('aria-label', hidden ? '隐藏密码' : '显示密码')
|
|
283
|
+
eye.dataset.on = hidden ? '1' : '0'
|
|
284
|
+
input.focus()
|
|
285
|
+
})
|
|
286
|
+
const capsCheck = (event) => { if (event.getModifierState) caps.hidden = !event.getModifierState('CapsLock') }
|
|
287
|
+
input.addEventListener('keydown', capsCheck)
|
|
288
|
+
input.addEventListener('keyup', capsCheck)
|
|
289
|
+
// Drop the intro class once it has played: otherwise removing .shake hands the
|
|
290
|
+
// animation property back to the intro, and the card fades in all over again.
|
|
291
|
+
form.addEventListener('animationend', (event) => {
|
|
292
|
+
if (event.target !== form) return
|
|
293
|
+
if (event.animationName === 'shake') form.classList.remove('shake')
|
|
294
|
+
if (event.animationName === 'rise' || event.animationName === 'zoom' || event.animationName === 'fade') {
|
|
295
|
+
form.classList.remove('intro-rise', 'intro-zoom', 'intro-fade')
|
|
296
|
+
}
|
|
297
|
+
})
|
|
298
|
+
form.addEventListener('submit', async (event) => {
|
|
299
|
+
event.preventDefault()
|
|
300
|
+
if (preview) {
|
|
301
|
+
// Preview: an empty field plays the failure, anything typed plays the success.
|
|
302
|
+
if (input.value === '') { show('预览:输错密码的效果'); shake(); emit('error'); return }
|
|
303
|
+
errorBox.hidden = true
|
|
304
|
+
busy(true, '欢迎回来')
|
|
305
|
+
form.classList.add('success')
|
|
306
|
+
emit('success')
|
|
307
|
+
setTimeout(() => { form.classList.remove('success'); busy(false, label); input.value = '' }, 2400)
|
|
308
|
+
return
|
|
309
|
+
}
|
|
310
|
+
errorBox.hidden = true
|
|
311
|
+
busy(true, '验证中…')
|
|
312
|
+
try {
|
|
313
|
+
const response = await fetch(form.getAttribute('action'), {
|
|
314
|
+
method: 'POST',
|
|
315
|
+
credentials: 'same-origin',
|
|
316
|
+
headers: { 'content-type': 'application/x-www-form-urlencoded', accept: 'application/json' },
|
|
317
|
+
body: new URLSearchParams({ password: input.value }),
|
|
318
|
+
})
|
|
319
|
+
const data = await response.json().catch(() => ({}))
|
|
320
|
+
if (data.ok === true && typeof data.redirect === 'string') {
|
|
321
|
+
busy(true, '欢迎回来')
|
|
322
|
+
form.classList.add('success')
|
|
323
|
+
emit('success')
|
|
324
|
+
setTimeout(() => location.replace(data.redirect), document.getElementById('bg-gl') ? 1100 : 650)
|
|
325
|
+
return
|
|
326
|
+
}
|
|
327
|
+
show(typeof data.message === 'string' ? data.message : '密码不正确,请重试')
|
|
328
|
+
shake()
|
|
329
|
+
emit('error')
|
|
330
|
+
if (data.fatal === true) {
|
|
331
|
+
busy(true, '已封禁')
|
|
332
|
+
input.disabled = true
|
|
333
|
+
return
|
|
334
|
+
}
|
|
335
|
+
input.select()
|
|
336
|
+
} catch {
|
|
337
|
+
show('网络错误,请重试')
|
|
338
|
+
shake()
|
|
339
|
+
}
|
|
340
|
+
busy(false, label)
|
|
341
|
+
})
|
|
342
|
+
})()
|
|
343
|
+
`
|
|
344
|
+
|
|
345
|
+
/** Autoplay can be refused (data saver, iOS low power): fall back to the poster gradient quietly. */
|
|
346
|
+
const VIDEO_SCRIPT = `
|
|
347
|
+
(() => {
|
|
348
|
+
const video = document.getElementById('bg-video')
|
|
349
|
+
if (!video) return
|
|
350
|
+
if (matchMedia('(prefers-reduced-motion: reduce)').matches) { video.removeAttribute('autoplay'); video.pause(); return }
|
|
351
|
+
const attempt = () => { const p = video.play(); if (p && p.catch) p.catch(() => {}) }
|
|
352
|
+
video.addEventListener('error', () => { video.hidden = true }, true)
|
|
353
|
+
document.addEventListener('visibilitychange', () => { document.hidden ? video.pause() : attempt() })
|
|
354
|
+
attempt()
|
|
355
|
+
})()
|
|
356
|
+
`
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Canvas animations. One loop, two scenes; each scene is (init, frame).
|
|
360
|
+
* The loop caps DPR at 2, pauses while the tab is hidden, and draws a single
|
|
361
|
+
* still frame under prefers-reduced-motion.
|
|
362
|
+
*/
|
|
363
|
+
const CANVAS_SCRIPT = `
|
|
364
|
+
(() => {
|
|
365
|
+
const canvas = document.getElementById('bg-canvas')
|
|
366
|
+
if (!canvas) return
|
|
367
|
+
const g = canvas.getContext('2d')
|
|
368
|
+
const reduce = matchMedia('(prefers-reduced-motion: reduce)').matches
|
|
369
|
+
const accent = getComputedStyle(document.body).getPropertyValue('--accent-rgb').trim() || '99,102,241'
|
|
370
|
+
let w = 0, h = 0, t = 0, last = 0, raf = 0
|
|
371
|
+
const mouse = { x: -1e4, y: -1e4 }
|
|
372
|
+
addEventListener('pointermove', (e) => { mouse.x = e.clientX; mouse.y = e.clientY }, { passive: true })
|
|
373
|
+
addEventListener('pointerleave', () => { mouse.x = mouse.y = -1e4 })
|
|
374
|
+
const rand = (a, b) => a + Math.random() * (b - a)
|
|
375
|
+
|
|
376
|
+
const constellation = {
|
|
377
|
+
pts: [],
|
|
378
|
+
init() {
|
|
379
|
+
const n = Math.round(Math.min(150, Math.max(40, (w * h) / 10000)))
|
|
380
|
+
this.pts = Array.from({ length: n }, () => ({ x: rand(0, w), y: rand(0, h), vx: rand(-.3, .3), vy: rand(-.3, .3), r: rand(.6, 2.1), p: rand(0, 6.28) }))
|
|
381
|
+
},
|
|
382
|
+
frame(dt) {
|
|
383
|
+
g.clearRect(0, 0, w, h)
|
|
384
|
+
const pts = this.pts, link = Math.min(140, Math.max(90, w / 12))
|
|
385
|
+
for (const p of pts) {
|
|
386
|
+
const dx = mouse.x - p.x, dy = mouse.y - p.y, d2 = dx * dx + dy * dy
|
|
387
|
+
if (d2 < 200 * 200) { p.vx += dx * 0.000035 * dt; p.vy += dy * 0.000035 * dt }
|
|
388
|
+
p.vx *= 0.995; p.vy *= 0.995
|
|
389
|
+
const sp = Math.hypot(p.vx, p.vy); if (sp < 0.08) { p.vx += rand(-.02, .02); p.vy += rand(-.02, .02) }
|
|
390
|
+
p.x += p.vx * dt * 0.06; p.y += p.vy * dt * 0.06
|
|
391
|
+
if (p.x < -20) p.x = w + 20; else if (p.x > w + 20) p.x = -20
|
|
392
|
+
if (p.y < -20) p.y = h + 20; else if (p.y > h + 20) p.y = -20
|
|
393
|
+
}
|
|
394
|
+
g.lineWidth = 1
|
|
395
|
+
for (let i = 0; i < pts.length; i++) {
|
|
396
|
+
const a = pts[i]
|
|
397
|
+
for (let j = i + 1; j < pts.length; j++) {
|
|
398
|
+
const b = pts[j], dx = a.x - b.x, dy = a.y - b.y, d = Math.hypot(dx, dy)
|
|
399
|
+
if (d < link) { g.strokeStyle = 'rgba(' + accent + ',' + ((1 - d / link) * 0.42).toFixed(3) + ')'; g.beginPath(); g.moveTo(a.x, a.y); g.lineTo(b.x, b.y); g.stroke() }
|
|
400
|
+
}
|
|
401
|
+
const md = Math.hypot(a.x - mouse.x, a.y - mouse.y)
|
|
402
|
+
if (md < 180) { g.strokeStyle = 'rgba(255,255,255,' + ((1 - md / 180) * 0.35).toFixed(3) + ')'; g.beginPath(); g.moveTo(a.x, a.y); g.lineTo(mouse.x, mouse.y); g.stroke() }
|
|
403
|
+
}
|
|
404
|
+
for (const p of pts) {
|
|
405
|
+
const tw = 0.55 + 0.45 * Math.sin(t * 0.002 + p.p)
|
|
406
|
+
g.fillStyle = 'rgba(255,255,255,' + (0.35 + 0.6 * tw).toFixed(3) + ')'
|
|
407
|
+
g.beginPath(); g.arc(p.x, p.y, p.r, 0, 6.2832); g.fill()
|
|
408
|
+
}
|
|
409
|
+
},
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
const fish = new Path2D(${JSON.stringify(FISH_LOGO_PATH)})
|
|
413
|
+
const FW = ${FISH_LOGO_VIEWBOX.width}, FH = ${FISH_LOGO_VIEWBOX.height}
|
|
414
|
+
const deepsea = {
|
|
415
|
+
bubbles: [], snow: [], whales: [],
|
|
416
|
+
spawnWhale(far, initial) {
|
|
417
|
+
const size = far ? rand(.07, .11) * Math.max(w, 700) : rand(.14, .2) * Math.max(w, 700)
|
|
418
|
+
return { far, size, x: initial ? rand(w * .3, w * 1.1) : w + size * 1.2, y: rand(h * .18, h * .78), speed: (far ? .010 : .022) * (size / 120 + .6), phase: rand(0, 6.28) }
|
|
419
|
+
},
|
|
420
|
+
init() {
|
|
421
|
+
this.bubbles = Array.from({ length: Math.round(Math.max(24, w / 28)) }, () => this.bubble(true))
|
|
422
|
+
this.snow = Array.from({ length: Math.round(Math.max(40, (w * h) / 16000)) }, () => ({ x: rand(0, w), y: rand(0, h), r: rand(.4, 1.4), v: rand(.004, .014), a: rand(.15, .5) }))
|
|
423
|
+
this.whales = [this.spawnWhale(true, true), this.spawnWhale(false, true)]
|
|
424
|
+
},
|
|
425
|
+
bubble(initial) {
|
|
426
|
+
return { x: rand(0, w), y: initial ? rand(0, h) : h + rand(10, 80), r: rand(1.5, 6.5), v: rand(.025, .07), wob: rand(0, 6.28), k: rand(.6, 1.6) }
|
|
427
|
+
},
|
|
428
|
+
frame(dt) {
|
|
429
|
+
g.clearRect(0, 0, w, h)
|
|
430
|
+
// Light shafts from the surface, swaying slowly.
|
|
431
|
+
g.save(); g.globalCompositeOperation = 'lighter'
|
|
432
|
+
for (let i = 0; i < 5; i++) {
|
|
433
|
+
const cx = w * (0.15 + i * 0.18) + Math.sin(t * 0.00025 + i * 1.7) * w * 0.05
|
|
434
|
+
const spread = w * (0.05 + 0.025 * Math.sin(t * 0.0004 + i))
|
|
435
|
+
const grad = g.createLinearGradient(0, 0, 0, h * 0.95)
|
|
436
|
+
grad.addColorStop(0, 'rgba(140,210,255,' + (0.10 + 0.04 * Math.sin(t * 0.0006 + i * 2)).toFixed(3) + ')')
|
|
437
|
+
grad.addColorStop(1, 'rgba(140,210,255,0)')
|
|
438
|
+
g.fillStyle = grad
|
|
439
|
+
g.beginPath(); g.moveTo(cx - spread * .3, -10); g.lineTo(cx + spread * .3, -10); g.lineTo(cx + spread * 2.4, h); g.lineTo(cx - spread * 1.2, h); g.closePath(); g.fill()
|
|
440
|
+
}
|
|
441
|
+
g.restore()
|
|
442
|
+
// Marine snow.
|
|
443
|
+
for (const s of this.snow) {
|
|
444
|
+
s.y += s.v * dt; s.x += Math.sin(t * 0.0005 + s.y * 0.01) * 0.05
|
|
445
|
+
if (s.y > h + 4) { s.y = -4; s.x = rand(0, w) }
|
|
446
|
+
g.fillStyle = 'rgba(200,230,255,' + s.a + ')'; g.beginPath(); g.arc(s.x, s.y, s.r, 0, 6.2832); g.fill()
|
|
447
|
+
}
|
|
448
|
+
// Whales: the far one first, faint and slow; the near one larger.
|
|
449
|
+
for (let i = 0; i < this.whales.length; i++) {
|
|
450
|
+
const wh = this.whales[i]
|
|
451
|
+
wh.x -= wh.speed * dt
|
|
452
|
+
if (wh.x < -wh.size * 1.3) this.whales[i] = this.spawnWhale(wh.far, false)
|
|
453
|
+
const bob = Math.sin(t * 0.0012 + wh.phase) * (wh.far ? 4 : 9)
|
|
454
|
+
const tilt = Math.cos(t * 0.0012 + wh.phase) * 0.045
|
|
455
|
+
const scale = wh.size / FW
|
|
456
|
+
g.save()
|
|
457
|
+
g.translate(wh.x, wh.y + bob); g.rotate(tilt); g.scale(scale, scale); g.translate(-FW / 2, -FH / 2)
|
|
458
|
+
g.shadowColor = 'rgba(' + accent + ',.55)'; g.shadowBlur = wh.far ? 10 : 26
|
|
459
|
+
g.fillStyle = wh.far ? 'rgba(150,200,255,.16)' : 'rgba(170,215,255,.30)'
|
|
460
|
+
g.fill(fish)
|
|
461
|
+
g.restore()
|
|
462
|
+
}
|
|
463
|
+
// Rising bubbles with a highlight.
|
|
464
|
+
for (let i = 0; i < this.bubbles.length; i++) {
|
|
465
|
+
const b = this.bubbles[i]
|
|
466
|
+
b.y -= b.v * dt * b.k; b.wob += 0.002 * dt
|
|
467
|
+
const x = b.x + Math.sin(b.wob) * 6
|
|
468
|
+
if (b.y < -12) { this.bubbles[i] = this.bubble(false); continue }
|
|
469
|
+
g.strokeStyle = 'rgba(190,230,255,.45)'; g.lineWidth = 1
|
|
470
|
+
g.beginPath(); g.arc(x, b.y, b.r, 0, 6.2832); g.stroke()
|
|
471
|
+
g.fillStyle = 'rgba(255,255,255,.55)'; g.beginPath(); g.arc(x - b.r * .35, b.y - b.r * .35, b.r * .28, 0, 6.2832); g.fill()
|
|
472
|
+
}
|
|
473
|
+
},
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
const scene = canvas.dataset.anim === 'deepsea' ? deepsea : constellation
|
|
477
|
+
const resize = () => {
|
|
478
|
+
const dpr = Math.min(devicePixelRatio || 1, 2)
|
|
479
|
+
w = innerWidth; h = innerHeight
|
|
480
|
+
canvas.width = Math.round(w * dpr); canvas.height = Math.round(h * dpr)
|
|
481
|
+
g.setTransform(dpr, 0, 0, dpr, 0, 0)
|
|
482
|
+
scene.init()
|
|
483
|
+
if (reduce) scene.frame(16)
|
|
484
|
+
}
|
|
485
|
+
const loop = (now) => {
|
|
486
|
+
const dt = Math.min(48, last === 0 ? 16 : now - last)
|
|
487
|
+
last = now; t = now
|
|
488
|
+
scene.frame(dt)
|
|
489
|
+
raf = requestAnimationFrame(loop)
|
|
490
|
+
}
|
|
491
|
+
const start = () => {
|
|
492
|
+
canvas.hidden = false
|
|
493
|
+
let resizeTimer
|
|
494
|
+
addEventListener('resize', () => { clearTimeout(resizeTimer); resizeTimer = setTimeout(resize, 120) })
|
|
495
|
+
resize()
|
|
496
|
+
if (reduce) return
|
|
497
|
+
document.addEventListener('visibilitychange', () => {
|
|
498
|
+
if (document.hidden) { cancelAnimationFrame(raf); raf = 0 } else if (raf === 0) { last = 0; raf = requestAnimationFrame(loop) }
|
|
499
|
+
})
|
|
500
|
+
raf = requestAnimationFrame(loop)
|
|
501
|
+
}
|
|
502
|
+
// Parked as the WebGL scene's fallback: start only when asked.
|
|
503
|
+
if (canvas.dataset.deferred === '1') window.__startDeepsea = start
|
|
504
|
+
else start()
|
|
505
|
+
})()
|
|
506
|
+
`
|
|
507
|
+
|
|
508
|
+
const EYE_ICON = '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7S2 12 2 12z"></path><circle cx="12" cy="12" r="3"></circle></svg>'
|
|
509
|
+
|
|
510
|
+
function pageShell({ title, nonce, appearance, layers, body, scripts }) {
|
|
511
|
+
const accent = appearance.accent
|
|
512
|
+
const vars = `--accent:${accent};--accent-2:${shade(accent, 0.72)};--accent-rgb:${rgbTriplet(accent)};--intro:${appearance.intro === 'none' ? 'none' : appearance.intro};`
|
|
513
|
+
const overlay = appearance.overlay > 0 ? `<div class="veil" style="background:rgba(4,5,12,${(appearance.overlay / 100).toFixed(2)})"></div>` : ''
|
|
514
|
+
const scriptTags = scripts.filter(Boolean).map((source) => `<script nonce="${nonce}">${source}</script>`).join('\n')
|
|
515
|
+
return `<!doctype html>
|
|
516
|
+
<html lang="zh-CN">
|
|
517
|
+
<head>
|
|
518
|
+
<meta charset="utf-8">
|
|
519
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
520
|
+
<meta name="robots" content="noindex, nofollow">
|
|
521
|
+
<meta name="referrer" content="no-referrer">
|
|
522
|
+
<title>${escapeHtml(title)}</title>
|
|
523
|
+
<link rel="icon" href="/favicon.svg">
|
|
524
|
+
<style>${BASE_CSS}</style>
|
|
525
|
+
</head>
|
|
526
|
+
<body class="layout-${escapeHtml(appearance.layout)}" style="${vars}">
|
|
527
|
+
${layers}
|
|
528
|
+
${overlay}
|
|
529
|
+
${body}
|
|
530
|
+
${scriptTags}
|
|
531
|
+
</body>
|
|
532
|
+
</html>`
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Render the login page.
|
|
537
|
+
* @param {object} options - render inputs.
|
|
538
|
+
* @param {string} options.nonce - CSP nonce for this response.
|
|
539
|
+
* @param {{mode: string, value: string}} options.background - the background setting.
|
|
540
|
+
* @param {object} options.appearance - the appearance setting.
|
|
541
|
+
* @param {string} options.logo - badge markup from {@link logoMarkup}.
|
|
542
|
+
* @param {{background?: string, video?: string, videoType?: string}} options.media - versioned upload URLs.
|
|
543
|
+
* @param {string} [options.errorMessage] - an error to show up front (no-JS path).
|
|
544
|
+
* @param {boolean} [options.preview] - render the operator preview (form never submits).
|
|
545
|
+
* @returns {string} the HTML document.
|
|
546
|
+
*/
|
|
547
|
+
export function loginPage({ nonce, background, appearance, logo, media, errorMessage, preview = false }) {
|
|
548
|
+
const layers = backgroundLayers(background, appearance, media)
|
|
549
|
+
const error = errorMessage === undefined ? '' : escapeHtml(errorMessage)
|
|
550
|
+
const errorHidden = errorMessage === undefined ? ' hidden' : ''
|
|
551
|
+
const intro = appearance.intro === 'none' ? '' : ` intro-${appearance.intro}`
|
|
552
|
+
const subtitle = appearance.subtitle.trim() === '' ? '' : `<p class="sub">${escapeHtml(appearance.subtitle)}</p>`
|
|
553
|
+
return pageShell({
|
|
554
|
+
title: `登录 · ${appearance.title}`,
|
|
555
|
+
nonce,
|
|
556
|
+
appearance,
|
|
557
|
+
layers: layers.html,
|
|
558
|
+
scripts: [FORM_SCRIPT, layers.script],
|
|
559
|
+
body: `${preview ? '<div class="preview-banner">预览模式 · 密码不会被提交 · 空着点登录看失败效果,随便输点内容看成功效果</div>' : ''}
|
|
560
|
+
<form class="card card-${escapeHtml(appearance.card)}${intro}" id="login-form" method="POST" action="/"${preview ? ' data-preview="1"' : ''}>
|
|
561
|
+
${logo}
|
|
562
|
+
<div><h1>${escapeHtml(appearance.title)}</h1>${subtitle}</div>
|
|
563
|
+
<p class="error" id="login-error" role="alert"${errorHidden}>${error}</p>
|
|
564
|
+
<div>
|
|
565
|
+
<label for="password">访问密码</label>
|
|
566
|
+
<div class="field">
|
|
567
|
+
<input class="pw" id="password" name="password" type="password" autocomplete="current-password" autofocus required maxlength="256">
|
|
568
|
+
<button class="eye" id="toggle-password" type="button" aria-label="显示密码">${EYE_ICON}</button>
|
|
569
|
+
</div>
|
|
570
|
+
<p class="caps" id="caps-hint" hidden>大写锁定已开启</p>
|
|
571
|
+
</div>
|
|
572
|
+
<button class="submit" type="submit" id="login-button">登录</button>
|
|
573
|
+
</form>`,
|
|
574
|
+
})
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/** Format a remaining ban duration for display. */
|
|
578
|
+
export function formatRemaining(remainingMs) {
|
|
579
|
+
if (remainingMs === null) return '永久'
|
|
580
|
+
const minutes = Math.ceil(remainingMs / 60000)
|
|
581
|
+
if (minutes < 60) return `${minutes} 分钟`
|
|
582
|
+
const hours = Math.ceil(minutes / 60)
|
|
583
|
+
return hours < 48 ? `${hours} 小时` : `${Math.ceil(hours / 24)} 天`
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* Render the "address banned" page. Uses a static background: a banned
|
|
588
|
+
* client does not get to pull the operator's video on every retry.
|
|
589
|
+
*/
|
|
590
|
+
export function bannedPage({ nonce, appearance, ban, ip }) {
|
|
591
|
+
const remaining = formatRemaining(ban.remainingMs)
|
|
592
|
+
const until = ban.permanent ? '' : `(至 ${escapeHtml(new Date(ban.until).toLocaleString('zh-CN', { timeZone: 'Asia/Shanghai' }))})`
|
|
593
|
+
return pageShell({
|
|
594
|
+
title: `访问受限 · ${appearance.title}`,
|
|
595
|
+
nonce,
|
|
596
|
+
appearance: { ...appearance, overlay: 0, intro: 'fade' },
|
|
597
|
+
layers: `<div class="bg" style="background-image:${presetValue('graphite')}"></div>`,
|
|
598
|
+
scripts: [],
|
|
599
|
+
body: ` <div class="card card-solid intro-fade">
|
|
600
|
+
<div class="badge" style="background:linear-gradient(135deg,#ef4444,#b91c1c);box-shadow:0 8px 24px rgba(239,68,68,.45)">
|
|
601
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><path d="M4.9 4.9l14.2 14.2"></path></svg>
|
|
602
|
+
</div>
|
|
603
|
+
<h1>访问已封禁</h1>
|
|
604
|
+
<p class="sub">你的地址因多次密码错误已被封禁</p>
|
|
605
|
+
<p class="error">剩余时间:${escapeHtml(remaining)}${until}</p>
|
|
606
|
+
<p class="muted">来源地址:${escapeHtml(ip)}</p>
|
|
607
|
+
</div>`,
|
|
608
|
+
})
|
|
609
|
+
}
|