fix: H5 白屏 - index.html 预加载脚本添加根路径默认路由到登录页
This commit is contained in:
parent
06765f99db
commit
6b97cd78ad
3
.gitignore
vendored
3
.gitignore
vendored
@ -35,6 +35,9 @@ tasks/
|
|||||||
# Build artifacts
|
# Build artifacts
|
||||||
dist/
|
dist/
|
||||||
|
|
||||||
|
# SWC compiler platform plugins (auto-downloaded by Taro)
|
||||||
|
.swc/
|
||||||
|
|
||||||
# Test
|
# Test
|
||||||
换电柜用锂电池充电器1TN标准通信协议*.pdf
|
换电柜用锂电池充电器1TN标准通信协议*.pdf
|
||||||
生产环境.txt
|
生产环境.txt
|
||||||
|
|||||||
@ -38,11 +38,6 @@ const config = {
|
|||||||
staticDirectory: 'static',
|
staticDirectory: 'static',
|
||||||
router: {
|
router: {
|
||||||
mode: 'browser',
|
mode: 'browser',
|
||||||
customRoutes: {
|
|
||||||
'/pages/home/index': '/pms/home',
|
|
||||||
'/pages/devices/index': '/pms/devices',
|
|
||||||
'/pages/me/index': '/pms/me',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
postcss: {
|
postcss: {
|
||||||
autoprefixer: { enable: true, config: {} },
|
autoprefixer: { enable: true, config: {} },
|
||||||
|
|||||||
@ -5,12 +5,17 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
||||||
<title>安知充</title>
|
<title>安知充</title>
|
||||||
<script>
|
<script>
|
||||||
// 扫码入口: 提取 URL 中的 abstract_id 并重写路由
|
// 默认路由:根路径跳转到登录页
|
||||||
;(function () {
|
;(function () {
|
||||||
var match = window.location.pathname.match(/\/h5\/(\d{2}-\d{8})/);
|
var path = window.location.pathname;
|
||||||
|
// 扫码入口: 提取 URL 中的 abstract_id 并重写路由
|
||||||
|
var match = path.match(/\/h5\/(\d{2}-\d{8})/);
|
||||||
if (match) {
|
if (match) {
|
||||||
window.__SCAN_ABSTRACT_ID__ = match[1];
|
window.__SCAN_ABSTRACT_ID__ = match[1];
|
||||||
window.history.replaceState({}, '', '/h5/');
|
window.history.replaceState({}, '', '/h5/');
|
||||||
|
} else if (path === '/h5/' || path === '/h5') {
|
||||||
|
// 纯根路径访问,重定向到登录页让 Taro 能匹配路由
|
||||||
|
window.history.replaceState({}, '', '/h5/pages/login/index');
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
// Taro H5 路由 base
|
// Taro H5 路由 base
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user