Files
qiming/qiming-mobile/index.html

162 lines
6.1 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!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 appDetailsPathMobile = '/subpackages/pages/app-details/app-details';
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 matchId = hash.match(new RegExp('[?&]id=([^&#]+)'));
const matchConversationId = hash.match(new RegExp('[?&]conversationId=([^&#]+)'));
if (matchId && matchId[1]) {
const agentId = matchId[1];
// 若带 conversationId 则跳转到 PC 会话详情页,否则跳转到智能体详情页
if (matchConversationId && matchConversationId[1]) {
const conversationId = matchConversationId[1];
window.location.replace(baseUrl + '/home/chat/' + conversationId + '/' + agentId);
} else {
window.location.replace(baseUrl + '/agent/' + agentId);
}
return;
}
}
// 应用详情页
if (hash && hash.indexOf(appDetailsPathMobile) !== -1) {
const matchId = hash.match(new RegExp('[?&]id=([^&#]+)'));
const matchConversationId = hash.match(new RegExp('[?&]conversationId=([^&#]+)'));
if (matchId && matchId[1]) {
const agentId = matchId[1];
if (matchConversationId && matchConversationId[1]) {
const conversationId = matchConversationId[1];
replaceUrl = baseUrl + '/app/chat/' + agentId + '/' + conversationId;
} else {
replaceUrl = baseUrl + '/app/' + agentId;
}
window.location.replace(replaceUrl);
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;
}
// 应用会话页 (这里必须要放在应用详情页匹配之前,否则会匹配到应用详情页)
const matchAppChat = href.match(new RegExp('app/chat/([^/]+)/([^/]+)'));
if (matchAppChat) {
const agentId = matchAppChat[1];
const conversationId = matchAppChat[2];
replaceUrl = baseUrl + '/m/#' + appDetailsPathMobile + '?id=' + agentId + '&conversationId=' + conversationId;
return replaceUrl;
}
// 应用详情页
const matchAppDetails = href.match(new RegExp('/app/([^/?#]+)'));
if (matchAppDetails) {
replaceUrl = baseUrl + '/m/#' + appDetailsPathMobile + '?id=' + matchAppDetails[1];
return replaceUrl;
}
// 临时会话页面: 移动端访问 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;
}
// H5 会话详情链接: /home/chat/conversationId/agentId在移动端打开时跳转到 M 端 agent-detail 并带 id、conversationId
const matchHomeChat = href.match(new RegExp('home/chat/([^/]+)/([^/]+)'));
if (matchHomeChat) {
const conversationId = matchHomeChat[1];
const agentId = matchHomeChat[2];
window.location.replace(baseUrl + '/m/#' + newAgentDetailPathMobile + '?id=' + agentId + '&conversationId=' + conversationId);
return;
}
window.location.replace(baseUrl + '/m/');
return;
}
})();
</script>
</head>
<body>
<div id="app"><!--app-html--></div>
<script type="module" src="/main"></script>
</body>
</html>