Skip to content

Commit

Permalink
fix(projects): 修复 BASE_URL 没有生效的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
pany-ang committed Mar 3, 2022
1 parent 1e2fdda commit 72d7dcf
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
BASE_URL=/
VITE_APP_BASE_URL=/

VITE_APP_NAME=SoybeanAdmin

Expand Down
2 changes: 1 addition & 1 deletion src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { createRouterGuard } from './guard';
const createHistoryFunc = import.meta.env.VITE_IS_VERCEL === '1' ? createWebHashHistory : createWebHistory;

export const router = createRouter({
history: createHistoryFunc(import.meta.env.BASE_URL),
history: createHistoryFunc(import.meta.env.VITE_APP_BASE_URL),
routes: transformAuthRoutesToVueRoutes(constantRoutes),
scrollBehavior
});
Expand Down
2 changes: 1 addition & 1 deletion src/typings/common/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ declare module '*.vue' {

interface ImportMetaEnv {
/** 项目基本地址 */
readonly BASE_URL: string;
readonly VITE_APP_BASE_URL: string;
/** 项目名称 */
readonly VITE_APP_NAME: string;
/** 项目标题 */
Expand Down
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default defineConfig(configEnv => {
const viteEnv = loadEnv(configEnv.mode, `.env.${configEnv.mode}`);

return {
base: viteEnv.BASE_URL,
base: viteEnv.VITE_APP_BASE_URL,
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
Expand Down

0 comments on commit 72d7dcf

Please sign in to comment.