-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
49 lines (43 loc) · 1.26 KB
/
index.html
File metadata and controls
49 lines (43 loc) · 1.26 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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Listen - Redirecting...</title>
<style>
/* 保持与你主题一致的深色背景,防止跳转瞬间闪烁白光 */
body {
background-color: #0d0d0c;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
color: #e9e2d5;
font-family: 'Segoe UI', sans-serif;
}
</style>
<script>
(function () {
// 1. 获取用户浏览器语言
// navigator.languages 获取的是一个语言数组(按优先级排序)
// navigator.language 获取的是首选语言
var lang = (navigator.languages && navigator.languages[0]) ||
navigator.language ||
navigator.userLanguage;
// 2. 预设目标路径
var target = '/zh/index.html'; // 默认为中文
// 3. 判断是否为英文环境
// 匹配以 'en' 开头的语言代码,如 'en', 'en-US', 'en-GB'
if (lang && lang.toLowerCase().indexOf('en') === 0) {
target = '/en/index.html';
}
// 4. 执行跳转
// 使用 replace 确保用户点击“返回”时不会陷入死循环
window.location.replace(target);
})();
</script>
</head>
<body>
<p>Loading...</p>
</body>
</html>