mirror of
https://github.com/Tencent/tdesign-vue-next-starter.git
synced 2024-11-10 07:08:23 +08:00
fix: site path and use history router (#382)
This commit is contained in:
parent
c9d06f103b
commit
573efe6cd3
3
.env.site
Normal file
3
.env.site
Normal file
|
@ -0,0 +1,3 @@
|
|||
VITE_SOME_KEY=123
|
||||
# 打包路径 根据项目不同按需配置
|
||||
VITE_BASE_URL = https://static.tdesign.tencent.com/starter/vue-next/
|
|
@ -7,6 +7,7 @@
|
|||
"dev:linux": "vite --mode development",
|
||||
"build:test": "vite build --mode test",
|
||||
"build": "vue-tsc --noEmit && vite build --mode release",
|
||||
"build:site": "vue-tsc --noEmit && vite build --mode site",
|
||||
"preview": "vite preview",
|
||||
"lint": "eslint --ext .vue,.js,.jsx,.ts,.tsx ./ --max-warnings 0",
|
||||
"lint:fix": "eslint --ext .vue,.js,jsx,.ts,.tsx ./ --max-warnings 0 --fix",
|
||||
|
|
|
@ -18,4 +18,10 @@ export default {
|
|||
// 正式环境 cdn 路径
|
||||
cdn: '',
|
||||
},
|
||||
site: {
|
||||
// TDesign部署特殊需要 与release功能一致
|
||||
host: 'https://service-bv448zsw-1257786608.gz.apigw.tencentcs.com',
|
||||
// 正式环境 cdn 路径
|
||||
cdn: '',
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import { useRoute, createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router';
|
||||
import { useRoute, createRouter, createWebHistory, RouteRecordRaw } from 'vue-router';
|
||||
import uniq from 'lodash/uniq';
|
||||
|
||||
const env = import.meta.env.MODE || 'development';
|
||||
|
||||
// 自动导入modules文件夹下所有ts文件
|
||||
const modules = import.meta.globEager('./modules/**/*.ts');
|
||||
|
||||
|
@ -8,6 +10,7 @@ const modules = import.meta.globEager('./modules/**/*.ts');
|
|||
const routeModuleList: Array<RouteRecordRaw> = [];
|
||||
|
||||
Object.keys(modules).forEach((key) => {
|
||||
// @ts-ignore
|
||||
const mod = modules[key].default || {};
|
||||
const modList = Array.isArray(mod) ? [...mod] : [mod];
|
||||
routeModuleList.push(...modList);
|
||||
|
@ -70,7 +73,7 @@ export const getActive = (maxLevel = 3): string => {
|
|||
};
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHashHistory(),
|
||||
history: createWebHistory(env === 'site' ? '/starter/vue-next/' : null),
|
||||
routes: allRoutes,
|
||||
scrollBehavior() {
|
||||
return {
|
||||
|
|
Loading…
Reference in New Issue
Block a user