fix: H5本地运行白屏及登录获取验证码去除安全验证弹窗
- manifest.json: H5 devServer 关闭 https,修复本地开发 WDS 断连问题 - App.vue: 大屏跳转 pc.html 时动态推导路径前缀,兼容本地(/)和部署(/h5/)两种场景 - static/html/pc.html: iframe src 根据当前页面路径动态计算,修复本地白屏问题 - login/index.vue: 获取验证码直接调用接口,跳过前端安全验证弹窗(后端已注释校验) Made-with: Cursor
This commit is contained in:
@@ -95,7 +95,11 @@
|
||||
success(e) {
|
||||
/* 窗口宽度大于420px且不在PC页面且不在移动设备时跳转至 PC.html 页面 */
|
||||
if (e.windowWidth > 420 && !window.top.isPC && !/iOS|Android/i.test(e.system)) {
|
||||
window.location.pathname = '/h5/static/html/pc.html';
|
||||
const p = (window.location.pathname || '/').replace(/\/$/, '') || '/';
|
||||
if (p.endsWith('/static/html/pc.html')) return;
|
||||
/* 与 manifest h5.router.base 一致:根路径为 / 或子路径 /h5/ */
|
||||
const h5Base = p.startsWith('/h5/') || p === '/h5' ? '/h5' : '';
|
||||
window.location.pathname = `${h5Base}/static/html/pc.html`;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name" : "黄精粉",
|
||||
"name" : "范氏国香",
|
||||
"appid" : "__UNI__6691FE3",
|
||||
"description" : "黄精粉商城",
|
||||
"description" : "范氏国香商城",
|
||||
"versionName" : "3.5.1",
|
||||
"versionCode" : 351,
|
||||
"transformPx" : false,
|
||||
@@ -214,7 +214,7 @@
|
||||
},
|
||||
"h5" : {
|
||||
"devServer" : {
|
||||
"https" : true
|
||||
"https" : false
|
||||
},
|
||||
"router" : {
|
||||
"mode" : "history",
|
||||
|
||||
@@ -397,7 +397,7 @@
|
||||
Date.parse(new Date());
|
||||
},
|
||||
success(data) {
|
||||
this.$refs.verify.hide()
|
||||
if (this.$refs.verify) this.$refs.verify.hide()
|
||||
getCodeApi()
|
||||
.then(res => {
|
||||
this.keyCode = res.data.key;
|
||||
@@ -423,17 +423,16 @@
|
||||
if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
|
||||
title: '请输入正确的手机号码'
|
||||
});
|
||||
// getCodeApi()
|
||||
// .then(res => {
|
||||
// that.keyCode = res.data.key;
|
||||
// that.getCode();
|
||||
// })
|
||||
// .catch(res => {
|
||||
// that.$util.Tips({
|
||||
// title: res
|
||||
// });
|
||||
// });
|
||||
this.$refs.verify.show()
|
||||
getCodeApi()
|
||||
.then(res => {
|
||||
that.keyCode = res.data.key;
|
||||
that.getCode({ captchaVerification: '' });
|
||||
})
|
||||
.catch(res => {
|
||||
that.$util.Tips({
|
||||
title: res
|
||||
});
|
||||
});
|
||||
},
|
||||
async getLogoImage() {
|
||||
let that = this;
|
||||
@@ -569,7 +568,7 @@
|
||||
that.sendCode();
|
||||
})
|
||||
.catch(res => {
|
||||
this.$refs.verify.refresh()
|
||||
if (this.$refs.verify) this.$refs.verify.refresh()
|
||||
that.$util.Tips({
|
||||
title: res
|
||||
});
|
||||
|
||||
@@ -35,21 +35,30 @@
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
window.isPC = true;
|
||||
|
||||
window.onload = function(){
|
||||
/* 监听电脑浏览器窗口尺寸改变 */
|
||||
window.onresize = function(){
|
||||
/* 窗口宽度 小于或等于420px 时,跳转回H5页面 */
|
||||
if(window.innerWidth <= 420){
|
||||
window.location.pathname = '/h5/';
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="/h5/?type=1"></iframe>
|
||||
<iframe id="app-frame"></iframe>
|
||||
<script type="text/javascript">
|
||||
window.isPC = true;
|
||||
/* 根据当前地址推导 H5 根路径:本地 dev 多为 /,线上部署多为 /h5/ */
|
||||
function h5AppRootPathname() {
|
||||
var path = (window.location.pathname || '/').replace(/\/$/, '') || '/';
|
||||
var marker = '/static/html/pc.html';
|
||||
if (path.endsWith(marker)) {
|
||||
var root = path.slice(0, -marker.length);
|
||||
if (!root) root = '/';
|
||||
return root === '/' ? '/' : (root + '/');
|
||||
}
|
||||
return '/';
|
||||
}
|
||||
var H5_ROOT = h5AppRootPathname();
|
||||
document.getElementById('app-frame').src = H5_ROOT + '?type=1';
|
||||
window.onresize = function(){
|
||||
if (window.innerWidth <= 420) {
|
||||
var target = H5_ROOT.replace(/\/$/, '');
|
||||
window.location.pathname = target || '/';
|
||||
}
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user