Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
37 lines (37 loc) · 1.55 KB
/
Copy pathindex.html
File metadata and controls
37 lines (37 loc) · 1.55 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
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script>
(() => {
let paint = { system: false, appearance: 'light', light: '#ffffff', dark: '#0b0d11' };
const read = (key, parse) => {
try {
return parse(localStorage.getItem(key));
} catch {
return null;
}
};
const cached = read('easy-cli-proxy-api.theme-paint', (value) => JSON.parse(value ?? 'null'));
const legacy = read('easy-cli-proxy-api.theme', (value) => value);
if (cached && /^#[\da-f]{6}$/i.test(cached.light) && /^#[\da-f]{6}$/i.test(cached.dark)) {
paint = { system: cached.system === true, appearance: cached.appearance === 'dark' ? 'dark' : 'light', light: cached.light, dark: cached.dark };
} else if (legacy === 'dark' || legacy === 'system') {
paint = { ...paint, system: legacy === 'system', appearance: legacy === 'dark' ? 'dark' : 'light' };
}
const theme = paint.system
? window.matchMedia?.('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
: paint.appearance;
document.documentElement.dataset.theme = theme;
document.documentElement.style.colorScheme = theme;
document.documentElement.style.backgroundColor = paint[theme];
})();
</script>
<title>EasyCLIProxyAPI</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>