From aa24ed9f3e1ba9a6af2f51460acb4dc12b2a5d9a Mon Sep 17 00:00:00 2001 From: zhangguoping Date: Wed, 19 Jun 2024 22:30:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=89=93=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- env/.env | 2 +- manifest.config.ts | 1 + src/pages/index/index.vue | 14 ++++++++++---- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/env/.env b/env/.env index a43a47a..09a6096 100644 --- a/env/.env +++ b/env/.env @@ -5,7 +5,7 @@ VITE_UNI_APPID = 'H57F2ACE4' VITE_WX_APPID = 'wxa2abb91f64032a2b' # h5部署网站的base,配置到 manifest.config.ts 里的 h5.router.base -VITE_APP_PUBLIC_BASE = ./ +VITE_APP_PUBLIC_BASE = 'test' # VITE_SERVER_BASEURL = 'https://gateway.dev.cdlsxd.cn' VITE_SERVER_BASEURL = 'https://gateway.dev.cdlsxd.cn' diff --git a/manifest.config.ts b/manifest.config.ts index e53d2fe..be6cba4 100644 --- a/manifest.config.ts +++ b/manifest.config.ts @@ -24,6 +24,7 @@ export default defineManifestConfig({ locale: VITE_FALLBACK_LOCALE, // 'zh-Hans' h5: { router: { + mode: 'history', base: VITE_APP_PUBLIC_BASE, }, }, diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 91bdf10..6eabc68 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -43,11 +43,17 @@ const srcList = reactive({ const getUrlPathName = () => { const url = window.location.href - const str = url.split('#/')[1] - if (str.indexOf('/') === -1) { - return str || '' + if (url.indexOf('#/') !== -1) { + const str = + url.indexOf('#/') !== -1 ? url.split('#/')[1] : url.split('/')[url.split('/').length - 1] + if (str.indexOf('/') === -1) { + return str || '' + } else { + return str.split('/')[0] + } } else { - return str.split('/')[0] + const strP = url.split('/') + return strP[strP.length - 1] } }