From 91c82965b2d987452ca276e3a03b48c8dcda2ae9 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期三, 19 八月 2026 11:47:26 +0800
Subject: [PATCH] config(env): 更新生产环境配置和公司名称
---
vite.config.ts | 42 ++++++++++++++++++++++++++++++++++++++----
1 files changed, 38 insertions(+), 4 deletions(-)
diff --git a/vite.config.ts b/vite.config.ts
index 5a07335..8404698 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -1,14 +1,46 @@
+import { resolve } from "node:path";
+import { loadEnv } from "vite";
import { defineConfig } from "./internal/vite-config/src";
+import { companies } from "./company.config";
-export default defineConfig(async () => {
+export default defineConfig(async ({ mode }) => {
+ const env = loadEnv(mode, process.cwd(), 'VITE_');
+ const companyKey = env.VITE_COMPANY || '';
+ const company = companies[companyKey];
+ const appLogo = company?.logo ?? '';
+ const appFavicon = company?.favicon ?? '';
+ const appApiUrl = company?.apiUrl ?? '';
+ const isDev = mode === 'development';
+ console.log('[company]', companyKey, '-> name:', company?.name, 'logo:', appLogo, 'api:', appApiUrl || '(from env)');
+
+ const defineVars: Record<string, string> = {
+ __APP_LOGO__: JSON.stringify(appLogo),
+ __APP_FAVICON__: JSON.stringify(appFavicon),
+ __APP_NAME__: JSON.stringify(company?.name ?? ''),
+ };
+ if (!isDev && appApiUrl) {
+ defineVars['import.meta.env.VITE_GLOB_API_URL'] = JSON.stringify(appApiUrl);
+ defineVars['import.meta.env.VITE_BASE_URL'] = JSON.stringify(new URL(appApiUrl).origin);
+ }
+
return {
application: {},
vite: {
+ define: defineVars,
+ resolve: {
+ alias: {
+ '@vue-office/pdf': resolve(__dirname, 'node_modules/@vue-office/pdf/lib/v3/vue-office-pdf.mjs'),
+ '@vue-office/docx': resolve(__dirname, 'node_modules/@vue-office/docx/lib/v3/vue-office-docx.mjs'),
+ '@vue-office/excel': resolve(__dirname, 'node_modules/@vue-office/excel/lib/v3/vue-office-excel.mjs'),
+ '@vue-office/excel-css': resolve(__dirname, 'node_modules/@vue-office/excel/lib/v3/index.css'),
+ '@vue-office/pptx': resolve(__dirname, 'node_modules/@vue-office/pptx/lib/v3/vue-office-pptx.mjs'),
+ },
+ },
oxc: {
enable: false,
},
optimizeDeps: {
- include: ["vue", "vue-router", "pinia", "ant-design-vue", "dayjs", "@vueuse/core", "axios"],
+ include: ["vue", "vue-router", "pinia", "ant-design-vue", "dayjs", "@vueuse/core", "axios", "@vue-office/pdf", "@vue-office/docx", "@vue-office/excel", "@vue-office/pptx"],
exclude: ["dhtmlx-gantt", "tinymce", "bpmn-js", "bpmn-js-properties-panel", "video.js"],
},
build: {
@@ -28,6 +60,9 @@
if (["tinymce", "@tinymce/tinymce-vue", "@form-create/ant-design-vue"].some(dep => id.includes(dep))) {
return "vendor-editor";
}
+ if (["@vue-office"].some(dep => id.includes(dep))) {
+ return "vendor-office-preview";
+ }
}
},
},
@@ -41,8 +76,7 @@
proxy: {
"/admin-api": {
changeOrigin: true,
- rewrite: path => path.replace(/^\/admin-api/, ""),
- target: "http://192.168.0.226:48080/admin-api",
+ target: "http://192.168.0.10:48080",
ws: true,
},
},
--
Gitblit v1.9.3