feat: 配置nginx支持web路由模式
自动部署 / build (push) Has been cancelled
Details
自动部署 / build (push) Has been cancelled
Details
parent
c8f3a52b72
commit
6de35daab1
2
.env
2
.env
|
|
@ -19,6 +19,8 @@ VITE_HISTORY = web
|
|||
VITE_HOST = 0.0.0.0
|
||||
# 端口
|
||||
VITE_PORT = 3020
|
||||
# 代理前缀
|
||||
VITE_PROXY_PREFIX = /api,/upload
|
||||
# 代理地址
|
||||
VITE_PROXY = http://127.0.0.1:3030/
|
||||
# API文档 说明:需返回符合 OPENAPI 规范的json内容
|
||||
|
|
|
|||
|
|
@ -2,13 +2,14 @@ import { Service } from "./service";
|
|||
import { addToastInterceptor } from "../interceptors/toast";
|
||||
import { addAuthInterceptor } from "../interceptors/auth";
|
||||
import { addExceptionInterceptor } from "../interceptors/exception";
|
||||
import { env } from "@/config/env";
|
||||
|
||||
/**
|
||||
* API 接口实例
|
||||
* @see src/api/instance/instance.ts
|
||||
*/
|
||||
const api = new Service({
|
||||
baseURL: import.meta.env.VITE_API,
|
||||
export const api = new Service({
|
||||
baseURL: env.apiPrefix,
|
||||
});
|
||||
|
||||
/**
|
||||
|
|
@ -25,5 +26,3 @@ addAuthInterceptor(api.instance);
|
|||
* 添加异常处理拦截器
|
||||
*/
|
||||
addExceptionInterceptor(api.instance, () => api.expireHandler?.());
|
||||
|
||||
export { api };
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
/**
|
||||
* 环境变量
|
||||
*/
|
||||
export const env = {
|
||||
/**
|
||||
* 站点标题
|
||||
*/
|
||||
title: import.meta.env.VITE_TITLE,
|
||||
/**
|
||||
* 站点副标题
|
||||
*/
|
||||
subtitle: import.meta.env.VITE_SUBTITLE,
|
||||
/**
|
||||
* 接口前缀
|
||||
*/
|
||||
apiPrefix: import.meta.env.VITE_API,
|
||||
/**
|
||||
* 路由模式
|
||||
*/
|
||||
historyMode: import.meta.env.VITE_HISTORY,
|
||||
/**
|
||||
* 首页路径
|
||||
*/
|
||||
homePath: import.meta.env.VITE_HOME_PATH,
|
||||
};
|
||||
|
|
@ -7,6 +7,7 @@ import { Router } from "vue-router";
|
|||
import { menus } from "../menus";
|
||||
import { APP_HOME_NAME } from "../routes/base";
|
||||
import { APP_ROUTE_NAME, routes } from "../routes/page";
|
||||
import { env } from "@/config/env";
|
||||
|
||||
const WHITE_LIST = ["/:all(.*)*"];
|
||||
const UNSIGNIN_LIST = ["/login"];
|
||||
|
|
@ -49,7 +50,7 @@ export function useAuthGuard(router: Router) {
|
|||
}
|
||||
if (!menuStore.menus.length) {
|
||||
menuStore.setMenus(menus);
|
||||
menuStore.setHome(import.meta.env.VITE_HOME_PATH);
|
||||
menuStore.setHome(env.homePath);
|
||||
for (const route of routes) {
|
||||
router.addRoute(route);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { env } from "@/config/env";
|
||||
import { createWebHashHistory, createWebHistory } from "vue-router";
|
||||
|
||||
/**
|
||||
|
|
@ -12,6 +13,6 @@ const HistoryMap = {
|
|||
* 路由模式
|
||||
*/
|
||||
export function historyMode() {
|
||||
const mode = HistoryMap[import.meta.env.VITE_HISTORY];
|
||||
const mode = HistoryMap[env.historyMode];
|
||||
return mode();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
import { env } from "@/config/env";
|
||||
import { defineStore } from "pinia";
|
||||
|
||||
export const useAppStore = defineStore({
|
||||
id: "app",
|
||||
state: (): AppStore => ({
|
||||
isDarkMode: false,
|
||||
title: import.meta.env.VITE_TITLE,
|
||||
subtitle: import.meta.env.VITE_SUBTITLE,
|
||||
title: env.title,
|
||||
subtitle: env.subtitle,
|
||||
pageLoding: false,
|
||||
pageTags: [],
|
||||
}),
|
||||
|
|
@ -70,7 +71,6 @@ export const useAppStore = defineStore({
|
|||
}
|
||||
},
|
||||
},
|
||||
persist: !import.meta.env.DEV,
|
||||
});
|
||||
|
||||
interface AppStore {
|
||||
|
|
|
|||
|
|
@ -99,11 +99,11 @@ export default defineConfig(({ mode }) => {
|
|||
}),
|
||||
|
||||
/**
|
||||
* 产物分析
|
||||
* 提供产物分析报告
|
||||
* @see https://github.com/btd/rollup-plugin-visualizer
|
||||
*/
|
||||
visualizer({
|
||||
title: "产物分析 | 自动生成",
|
||||
title: `构建统计 | ${env.VITE_SUBTITLE}`,
|
||||
filename: ".gitea/stat.html",
|
||||
}),
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue