-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathindex.html
More file actions
106 lines (97 loc) · 3.78 KB
/
index.html
File metadata and controls
106 lines (97 loc) · 3.78 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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<script>
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
CSS.supports('top: constant(a)'))
document.write(
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
(coverSupport ? ', viewport-fit=cover' : '') + '" />')
</script>
<title></title>
<!-- #ifdef H5 || WEB -->
<!--2.阿里云验证码-集成主JS-->
<script defer type="text/javascript" src="https://o.alicdn.com/captcha-frontend/aliyunCaptcha/AliyunCaptcha.js"></script>
<!-- #endif -->
<!--preload-links-->
<!--app-context-->
<script>
(function () {
if (typeof window === 'undefined') {
return;
}
// 开发模式检测 - 如果是开发环境则不执行跳转
if (typeof process !== 'undefined' && process.env && process.env.NODE_ENV === 'development') {
console.log('开发模式检测到,跳过双向跳转逻辑');
return;
}
const { protocol, host, href, hash } = window.location;
const isMobile = /Android|iPhone|iPad|iPod|Mobile|Tablet/i.test(navigator.userAgent);
const baseUrl = protocol + '//' + host;
const agentDetailPathMobile = '/pages/agent-detail/agent-detail'; //分包前的页面路径
const chatTempPathMobile = '/pages/chat-temp/chat-temp'; //分包前的页面路径
const newAgentDetailPathMobile = '/subpackages' + agentDetailPathMobile; //分包后的页面路径
const newChatTempPathMobile = '/subpackages' + chatTempPathMobile; //分包后的页面路径
//兼容分包前的页面 先转为分包后的页面 然后跳转
if (isMobile && href.includes('/m/#/pages/')) {
let mHash = hash;
if (hash.indexOf(agentDetailPathMobile) !== -1) {
mHash = mHash.replace(agentDetailPathMobile, newAgentDetailPathMobile);
window.location.replace(baseUrl + '/m/' + mHash);
return;
}
if(hash.indexOf(chatTempPathMobile) !== -1) {
mHash = mHash.replace(chatTempPathMobile, newChatTempPathMobile);
window.location.replace(baseUrl + '/m/' + mHash);
return;
}
}
// PC 端访问 M 页面 => 跳转 PC
if (!isMobile && href.includes('/m/')) {
if (hash && hash.indexOf(agentDetailPathMobile) !== -1) {
const match = hash.match(new RegExp('[?&]id=([^&#]+)'));
if (match && match[1]) {
const agentId = match[1];
window.location.replace(baseUrl + '/agent/' + agentId);
return;
}
}
// 临时会话页面: PC 端访问 M 页面 => 跳转 PC
if (hash && hash.indexOf(chatTempPathMobile) !== -1) {
const matchChatTemp = hash.match(new RegExp('[?&]chatKey=([^&#]+)'));
if (matchChatTemp && matchChatTemp[1]) {
const chatKey = matchChatTemp[1];
window.location.replace(baseUrl + '/chat-temp/' + chatKey);
return;
}
}
window.location.replace(baseUrl + '/');
return;
}
// 移动端访问 PC 页面 => 跳转 M
if (isMobile && !href.includes('/m/')) {
const match = href.match(new RegExp('/agent/([^/?#]+)'));
if (match) {
const agentId = match[1];
window.location.replace(baseUrl + '/m/#' + newAgentDetailPathMobile + '?id=' + agentId);
return;
}
// 临时会话页面: 移动端访问 PC 页面 => 跳转 M
const matchChatTemp = href.match(new RegExp('/chat-temp/([^/?#]+)'));
if (matchChatTemp) {
const chatKey = matchChatTemp[1];
window.location.replace(baseUrl + '/m/#' + newChatTempPathMobile + '?chatKey=' + chatKey);
return;
}
window.location.replace(baseUrl + '/m/');
return;
}
})();
</script>
</head>
<body>
<div id="app"><!--app-html--></div>
<script type="module" src="/main"></script>
</body>
</html>