chore: 集成github pages发布环境

This commit is contained in:
张传龙 2022-04-09 22:29:11 +08:00
parent e7fc403c77
commit 17928cbc57
4 changed files with 20 additions and 14 deletions

16
.env.github Normal file
View File

@ -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'

View File

@ -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'

View File

@ -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": {

View File

@ -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 }),
})