miao33: 从 main 同步 single_uniapp22miao,dart-sass 兼容修复,DEPLOY.md 更新
- 从 main 获取 single_uniapp22miao 子项目 - dart-sass: /deep/ -> ::v-deep,calc 运算符加空格 - DEPLOY.md 采用 shccd159 版本(4 子项目架构说明) Made-with: Cursor
This commit is contained in:
161
single_uniapp22miao/static/html/pc.html
Normal file
161
single_uniapp22miao/static/html/pc.html
Normal file
@@ -0,0 +1,161 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1,maximum-scale=1,minimum-scale=1">
|
||||
<title>积分商城</title>
|
||||
<meta name="Copyright" content="helang">
|
||||
<meta name="keywords" content="积分商城">
|
||||
<meta name="description" content="积分商城">
|
||||
<style type="text/css">
|
||||
body {
|
||||
margin: 0;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
iframe {
|
||||
width: 375px;
|
||||
height: 667px;
|
||||
background-color: #fff;
|
||||
box-sizing: border-box;
|
||||
border: none;
|
||||
}
|
||||
@media screen and (min-width: 450px) {
|
||||
iframe {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
margin: auto;
|
||||
border: 1px solid #f5f5f5;
|
||||
border-radius: 4px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="/" id="iframe"></iframe>
|
||||
|
||||
<script type="text/javascript">
|
||||
window.isPC = true;
|
||||
|
||||
(function() {
|
||||
var iframe = document.getElementById('iframe');
|
||||
|
||||
// 获取URL参数
|
||||
function getUrlParams() {
|
||||
var params = {};
|
||||
var search = window.location.search.substring(1);
|
||||
if (search) {
|
||||
var pairs = search.split('&');
|
||||
for (var i = 0; i < pairs.length; i++) {
|
||||
var pair = pairs[i].split('=');
|
||||
params[decodeURIComponent(pair[0])] = pair[1] ? decodeURIComponent(pair[1]) : '';
|
||||
}
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
// 初始化:根据父页面URL设置iframe的src
|
||||
function initIframeSrc() {
|
||||
var params = getUrlParams();
|
||||
var hash = window.location.hash;
|
||||
var iframeSrc = '/';
|
||||
|
||||
// 如果父页面有hash,传递给iframe
|
||||
if (hash) {
|
||||
iframeSrc = '/' + hash;
|
||||
}
|
||||
|
||||
// 如果有username参数,附加到iframe URL
|
||||
if (params.username) {
|
||||
var separator = iframeSrc.includes('?') ? '&' : (iframeSrc.includes('#') ? (iframeSrc.includes('?') ? '&' : '?') : '?');
|
||||
// 对于hash模式,参数需要放在hash后面
|
||||
if (hash) {
|
||||
iframeSrc = iframeSrc + (iframeSrc.includes('?') ? '&' : '?') + 'username=' + encodeURIComponent(params.username);
|
||||
} else {
|
||||
iframeSrc = '/#/pages/integral/index?username=' + encodeURIComponent(params.username);
|
||||
}
|
||||
}
|
||||
|
||||
iframe.src = iframeSrc;
|
||||
}
|
||||
|
||||
// 监听iframe内部路由变化,同步到父页面URL
|
||||
function syncIframeUrlToParent() {
|
||||
try {
|
||||
var iframeWindow = iframe.contentWindow;
|
||||
|
||||
// 监听iframe的hashchange事件
|
||||
iframeWindow.addEventListener('hashchange', function() {
|
||||
var iframeHash = iframeWindow.location.hash;
|
||||
if (iframeHash && window.location.hash !== iframeHash) {
|
||||
// 保留原有的search参数
|
||||
var currentSearch = window.location.search;
|
||||
history.replaceState(null, '', currentSearch + iframeHash);
|
||||
}
|
||||
});
|
||||
|
||||
// 初始同步
|
||||
var iframeHash = iframeWindow.location.hash;
|
||||
if (iframeHash && window.location.hash !== iframeHash) {
|
||||
var currentSearch = window.location.search;
|
||||
history.replaceState(null, '', currentSearch + iframeHash);
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('无法访问iframe内容(可能跨域):', e);
|
||||
}
|
||||
}
|
||||
|
||||
// 监听父页面hash变化,同步到iframe
|
||||
window.addEventListener('hashchange', function() {
|
||||
try {
|
||||
var parentHash = window.location.hash;
|
||||
var iframeHash = iframe.contentWindow.location.hash;
|
||||
|
||||
if (parentHash !== iframeHash) {
|
||||
iframe.contentWindow.location.hash = parentHash;
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('无法同步hash到iframe:', e);
|
||||
}
|
||||
});
|
||||
|
||||
// iframe加载完成后设置监听
|
||||
iframe.onload = function() {
|
||||
syncIframeUrlToParent();
|
||||
|
||||
// 定期检查同步(作为备份)
|
||||
setInterval(function() {
|
||||
try {
|
||||
var iframeHash = iframe.contentWindow.location.hash;
|
||||
if (iframeHash && window.location.hash !== iframeHash) {
|
||||
var currentSearch = window.location.search;
|
||||
history.replaceState(null, '', currentSearch + iframeHash);
|
||||
}
|
||||
} catch (e) {}
|
||||
}, 500);
|
||||
};
|
||||
|
||||
// 窗口尺寸检测
|
||||
window.onload = function() {
|
||||
if (window.innerWidth <= 420) {
|
||||
// 小屏幕直接跳转到应用
|
||||
var params = getUrlParams();
|
||||
var targetUrl = '/';
|
||||
if (params.username) {
|
||||
targetUrl = '/#/pages/integral/index?username=' + encodeURIComponent(params.username);
|
||||
} else if (window.location.hash) {
|
||||
targetUrl = '/' + window.location.hash;
|
||||
}
|
||||
window.location.href = targetUrl;
|
||||
}
|
||||
};
|
||||
|
||||
// 初始化
|
||||
initIframeSrc();
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user