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] } }