Merge branch 'develop' of github.com:Tencent/tdesign-vue-next-starter into main

This commit is contained in:
Uyarn 2022-12-28 15:13:06 +08:00
commit ae90d88fac
4 changed files with 15 additions and 2 deletions

3
.env.site Normal file
View File

@ -0,0 +1,3 @@
VITE_SOME_KEY=123
# 打包路径 根据项目不同按需配置
VITE_BASE_URL = https://static.tdesign.tencent.com/starter/vue-next/

View File

@ -7,6 +7,7 @@
"dev:linux": "vite --mode development", "dev:linux": "vite --mode development",
"build:test": "vite build --mode test", "build:test": "vite build --mode test",
"build": "vue-tsc --noEmit && vite build --mode release", "build": "vue-tsc --noEmit && vite build --mode release",
"build:site": "vue-tsc --noEmit && vite build --mode site",
"preview": "vite preview", "preview": "vite preview",
"lint": "eslint --ext .vue,.js,.jsx,.ts,.tsx ./ --max-warnings 0", "lint": "eslint --ext .vue,.js,.jsx,.ts,.tsx ./ --max-warnings 0",
"lint:fix": "eslint --ext .vue,.js,jsx,.ts,.tsx ./ --max-warnings 0 --fix", "lint:fix": "eslint --ext .vue,.js,jsx,.ts,.tsx ./ --max-warnings 0 --fix",

View File

@ -18,4 +18,10 @@ export default {
// 正式环境 cdn 路径 // 正式环境 cdn 路径
cdn: '', cdn: '',
}, },
site: {
// TDesign部署特殊需要 与release功能一致
host: 'https://service-bv448zsw-1257786608.gz.apigw.tencentcs.com',
// 正式环境 cdn 路径
cdn: '',
},
}; };

View File

@ -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'; import uniq from 'lodash/uniq';
const env = import.meta.env.MODE || 'development';
// 自动导入modules文件夹下所有ts文件 // 自动导入modules文件夹下所有ts文件
const modules = import.meta.globEager('./modules/**/*.ts'); const modules = import.meta.globEager('./modules/**/*.ts');
@ -8,6 +10,7 @@ const modules = import.meta.globEager('./modules/**/*.ts');
const routeModuleList: Array<RouteRecordRaw> = []; const routeModuleList: Array<RouteRecordRaw> = [];
Object.keys(modules).forEach((key) => { Object.keys(modules).forEach((key) => {
// @ts-ignore
const mod = modules[key].default || {}; const mod = modules[key].default || {};
const modList = Array.isArray(mod) ? [...mod] : [mod]; const modList = Array.isArray(mod) ? [...mod] : [mod];
routeModuleList.push(...modList); routeModuleList.push(...modList);
@ -70,7 +73,7 @@ export const getActive = (maxLevel = 3): string => {
}; };
const router = createRouter({ const router = createRouter({
history: createWebHashHistory(), history: createWebHistory(env === 'site' ? '/starter/vue-next/' : null),
routes: allRoutes, routes: allRoutes,
scrollBehavior() { scrollBehavior() {
return { return {