From 17928cbc5742fe2b1dd0ae0b23688fd064a8f60d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E4=BC=A0=E9=BE=99?= Date: Sat, 9 Apr 2022 22:29:11 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E9=9B=86=E6=88=90github=20pages?= =?UTF-8?q?=E5=8F=91=E5=B8=83=E7=8E=AF=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.github | 16 ++++++++++++++++ .env.staging | 11 ----------- package.json | 2 +- src/router/index.js | 5 +++-- 4 files changed, 20 insertions(+), 14 deletions(-) create mode 100644 .env.github delete mode 100644 .env.staging diff --git a/.env.github b/.env.github new file mode 100644 index 0000000..953a4fc --- /dev/null +++ b/.env.github @@ -0,0 +1,16 @@ +# 自定义域名CNAME +# VITE_APP_GLOB_CNAME = 'template.qszone.com' + +# 资源公共路径,需要以 /开头和结尾 +VITE_PUBLIC_PATH = '/vue-naive-admin/' + +VITE_APP_USE_HASH = true + +# 是否启用MOCK +VITE_APP_USE_MOCK = true + +# base api +VITE_APP_GLOB_BASE_API = '/api' + +# test base api +VITE_APP_GLOB_BASE_API_TEST = '/api-test' \ No newline at end of file diff --git a/.env.staging b/.env.staging deleted file mode 100644 index 873b602..0000000 --- a/.env.staging +++ /dev/null @@ -1,11 +0,0 @@ -# 资源公共路径,需要以 /开头和结尾 -VITE_PUBLIC_PATH = '/' - -# 是否启用MOCK -VITE_APP_USE_MOCK = false - -# base api -VITE_APP_GLOB_BASE_API = 'http://localhost:8080/api' - -# test base api -VITE_APP_GLOB_BASE_API_TEST = 'http://localhost:8080/api-test' \ No newline at end of file diff --git a/package.json b/package.json index 3b59acb..69a5960 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "lint:fix": "eslint --fix --ext .js,.vue .", "build": "vite build && esno ./build/script", "build:test": "vite build --mode test && esno ./build/script", - "build:staging": "vite build --mode staging && esno ./build/script", + "build:github": "vite build --mode github && esno ./build/script", "preview": "vite preview" }, "dependencies": { diff --git a/src/router/index.js b/src/router/index.js index f9c53c9..ed9fee5 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,9 +1,10 @@ -import { createRouter, createWebHistory } from 'vue-router' +import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router' import { setupRouterGuard } from './guard' import { basicRoutes } from './routes' +const isHash = !!import.meta.env.VITE_APP_USE_HASH export const router = createRouter({ - history: createWebHistory('/'), + history: isHash ? createWebHashHistory('/') : createWebHistory('/'), routes: basicRoutes, scrollBehavior: () => ({ left: 0, top: 0 }), })