Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
289 lines (272 loc) · 12.1 KB
/
Copy pathindex.html
File metadata and controls
289 lines (272 loc) · 12.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="referrer" content="no-referrer" />
<meta name="description" content="一个动态歌词播放器,支持 AI 主题生成" />
<meta name="theme-color" content="#09090b" />
<meta name="mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="apple-mobile-web-app-title" content="Folia" />
<link rel="icon" type="image/svg+xml" href="/icon.svg" />
<link rel="apple-touch-icon" href="/icon.svg" />
<title>Folia</title>
<script src="/runtime-config.js"></script>
<script type="importmap">
{
"imports": {
"@google/genai": "https://aistudiocdn.com/@google/genai@^1.30.0",
"react/": "https://aistudiocdn.com/react@^19.2.0/",
"react": "https://aistudiocdn.com/react@^19.2.0",
"framer-motion": "https://aistudiocdn.com/framer-motion@^12.23.24",
"react-dom/": "https://aistudiocdn.com/react-dom@^19.2.0/",
"lucide-react": "https://aistudiocdn.com/lucide-react@^0.554.0",
"react-i18next": "https://aistudiocdn.com/react-i18next@^16.3.5",
"i18next": "https://aistudiocdn.com/i18next@^25.6.3",
"i18next-browser-languagedetector": "https://aistudiocdn.com/i18next-browser-languagedetector@^8.2.0"
}
}
</script>
<!-- 首屏加载遮罩:内联样式,随 HTML 首帧一起绘制,不等 index.css 与 JS bundle。
由 src/utils/appSplash.ts 在 React 挂载后淡出并移除。 -->
<style>
html,
body {
background-color: #09090b;
}
#app-splash {
position: fixed;
inset: 0;
z-index: 2147483000;
display: flex;
align-items: center;
justify-content: center;
background-color: #09090b;
font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
transition: opacity 320ms ease;
}
#app-splash.is-hiding {
opacity: 0;
pointer-events: none;
}
#app-splash .app-splash-inner {
display: flex;
flex-direction: column;
align-items: center;
gap: 28px;
opacity: 0;
/* 延迟淡入:命中缓存的秒开不会闪一下遮罩内容。 */
animation: app-splash-in 420ms ease 180ms forwards;
}
#app-splash .app-splash-title {
/* 巨大字号,随视口收缩,窄屏也不会溢出。 */
font-size: clamp(64px, 17vw, 200px);
font-weight: 600;
line-height: 1;
letter-spacing: 0.06em;
text-indent: 0.06em;
}
/* 每个字母占一个固定宽度的盒子(宽度由脚本按各字体的最大字宽测出来,单位 em,
跟着 font-size 缩放),字体来回切换时字形变但排版不抖。
纯白 + text-shadow 辉光,辉光强度由脚本逐字母随机,这里的值是脚本失败时的兜底。 */
#app-splash .app-splash-title span {
display: inline-block;
text-align: center;
font-family: inherit;
color: #ffffff;
text-shadow: 0 0 8px rgba(255, 255, 255, 0.55), 0 0 28px rgba(255, 255, 255, 0.3);
/* 缩放原点压到基线附近,字母大小浮动时底边大致对齐。 */
transform-origin: center 78%;
}
/* 循环波形:每根竖条只做 transform 动画,合成器线程执行,不占主线程。 */
#app-splash .app-splash-wave {
display: flex;
align-items: center;
gap: clamp(6px, 1.1vw, 11px);
height: clamp(42px, 7.5vw, 92px);
}
/* --floor / --peak / --alpha / --glow / --w 由下面的内联脚本逐条随机化;
这里的默认值是脚本失败时的静态兜底。纯白平涂 + 外发光,不做渐变。 */
#app-splash .app-splash-wave span {
width: var(--w, 5px);
height: 100%;
transform: scaleY(var(--floor, 0.18));
background-color: rgba(255, 255, 255, var(--alpha, 0.85));
box-shadow: 0 0 var(--glow, 14px) rgba(255, 255, 255, 0.35);
animation: app-splash-wave 1100ms ease-in-out infinite;
}
#app-splash .app-splash-wave span:nth-child(even) {
animation-delay: -550ms;
}
@keyframes app-splash-in {
to {
opacity: 1;
}
}
@keyframes app-splash-wave {
0%,
100% {
transform: scaleY(var(--floor, 0.18));
}
50% {
transform: scaleY(var(--peak, 1));
}
}
@media (prefers-reduced-motion: reduce) {
#app-splash .app-splash-inner {
opacity: 1;
animation: none;
}
#app-splash .app-splash-wave span {
/* 不动,但保留随机高度,静态波形仍然有形状。 */
transform: scaleY(calc(var(--peak, 0.5) * 0.7));
animation: none;
opacity: 0.5;
}
}
</style>
</head>
<body>
<div id="app-splash" role="status" aria-live="polite" aria-label="Loading Folia">
<div class="app-splash-inner">
<div class="app-splash-title" aria-label="Folia"><span>F</span><span>o</span><span>l</span><span>i</span><span>a</span></div>
<div class="app-splash-wave" aria-hidden="true">
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
</div>
</div>
</div>
<script>
(function () {
try {
// 需要透明背景的入口不能盖遮罩:OBS 浏览器源会被直接推流捕获,
// Electron 的透明播放背景 / 壁纸窗口(main.cjs 传 splash=0)会在桌面上闪一个黑块。
var params = new URLSearchParams(window.location.search);
if (params.get('obs') === '1' || window.location.pathname === '/obs' || params.get('splash') === '0') {
var splash = document.getElementById('app-splash');
if (splash) {
splash.remove();
}
return;
}
} catch (error) {
// 探测失败时保留遮罩,React 挂载后仍会移除它。
}
// 波形逐条随机化:高度、宽度、节奏、相位和颜色都带抖动,每次加载的形状都不一样。
// 同步执行,在首帧绘制前完成;失败时 CSS 里的默认值会兜底成一条静态波形。
try {
var rand = function (min, max) {
return min + Math.random() * (max - min);
};
var bars = document.querySelectorAll('#app-splash .app-splash-wave span');
for (var i = 0; i < bars.length; i += 1) {
var bar = bars[i];
// 中间高、两端低的整体包络,再叠加随机量,形状既像波形又不规整。
var envelope = Math.sin(((i + 0.5) / bars.length) * Math.PI);
var peak = Math.min(1, 0.32 + envelope * rand(0.38, 0.72));
bar.style.setProperty('--peak', peak.toFixed(3));
bar.style.setProperty('--floor', rand(0.08, 0.24).toFixed(3));
bar.style.setProperty('--w', rand(3.5, 6.5).toFixed(2) + 'px');
// 白色平涂,只在亮度和辉光半径上留随机:高的条更亮、光晕更散。
bar.style.setProperty('--alpha', rand(0.55, 1).toFixed(2));
bar.style.setProperty('--glow', Math.round(rand(6, 26)) + 'px');
bar.style.animationDuration = Math.round(rand(820, 1500)) + 'ms';
bar.style.animationDelay = '-' + Math.round(rand(0, 1500)) + 'ms';
}
} catch (error) {
// 随机化失败无所谓,CSS 默认值已经能跑一条波形。
}
// Folia 五个字母不断跳到不同字形(Loki 片头那种字体轮盘),偶尔整体落回基准样式。
// 只用通用字族,再叠加字重、斜体和横向拉伸——不同机器上装的字体不一样,
// 单靠字体名会退化成同一张脸,加上这几个轴才保证每次跳变都看得出来。
try {
if (window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
return;
}
var BASE_FONT = "'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif";
var FAMILIES = [BASE_FONT, 'serif', 'monospace', 'cursive', 'fantasy', 'system-ui'];
var WEIGHTS = ['400', '600', '800'];
var SCALES = [0.86, 0.94, 1, 1.06, 1.12];
var letters = document.querySelectorAll('#app-splash .app-splash-title span');
if (!letters.length) {
return;
}
// 用 canvas 在 100px 基准下量出每个字母在所有候选字形里的最大宽度,换算成 em 写死盒子宽度,
// 这样字形来回换、词标整体不会左右乱跳。
var measure = document.createElement('canvas').getContext('2d');
for (var m = 0; m < letters.length; m += 1) {
var glyph = letters[m].textContent;
var widest = 0;
for (var f = 0; f < FAMILIES.length; f += 1) {
measure.font = 'italic 800 100px ' + FAMILIES[f];
widest = Math.max(widest, measure.measureText(glyph).width);
measure.font = '800 100px ' + FAMILIES[f];
widest = Math.max(widest, measure.measureText(glyph).width);
}
if (widest > 0) {
// 余量留给最大的缩放组合(1.12 × 1.12),字形放大时不会压到相邻字母。
letters[m].style.width = ((widest / 100) * 1.26 + 0.04).toFixed(3) + 'em';
}
}
var pick = function (list) {
return list[Math.floor(Math.random() * list.length)];
};
var jitter = function (min, max) {
return min + Math.random() * (max - min);
};
// 辉光分三档:干净、微光、过曝。片头里字母亮度参差不齐,靠这个模拟。
var randomGlow = function () {
var roll = Math.random();
if (roll < 0.3) {
return '0 0 ' + (2 + Math.random() * 4).toFixed(1) + 'px rgba(255,255,255,0.35)';
}
if (roll < 0.75) {
return '0 0 ' + (6 + Math.random() * 8).toFixed(1) + 'px rgba(255,255,255,0.7), 0 0 ' +
(20 + Math.random() * 16).toFixed(1) + 'px rgba(255,255,255,0.35)';
}
return '0 0 ' + (10 + Math.random() * 8).toFixed(1) + 'px rgba(255,255,255,0.95), 0 0 ' +
(34 + Math.random() * 20).toFixed(1) + 'px rgba(255,255,255,0.7), 0 0 ' +
(70 + Math.random() * 40).toFixed(1) + 'px rgba(255,255,255,0.45)';
};
var timer = window.setInterval(function () {
// 遮罩被移除后自己停掉,不留空转的定时器。
if (!document.getElementById('app-splash')) {
window.clearInterval(timer);
return;
}
// 一拍只换一个字母,偶尔两个,节奏克制。
var swaps = Math.random() < 0.25 ? 2 : 1;
for (var i = 0; i < swaps; i += 1) {
var letter = pick(letters);
letter.style.fontFamily = pick(FAMILIES);
letter.style.fontWeight = pick(WEIGHTS);
letter.style.fontStyle = Math.random() < 0.25 ? 'italic' : 'normal';
// 大小和宽窄都用 transform 做:不进入布局,盒子宽度不受影响,排版才不会抖。
var sizeScale = jitter(0.86, 1.12);
letter.style.transform =
'scale(' + (sizeScale * pick(SCALES)).toFixed(3) + ',' + sizeScale.toFixed(3) + ')';
letter.style.textShadow = randomGlow();
}
}, 380);
} catch (error) {
// 字体轮盘失败就保持静态词标。
}
})();
</script>
<div id="root"></div>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>