From 0af5e35af8338cc8a2e38c19ab79efbb9eff0b2c Mon Sep 17 00:00:00 2001
From: liu <2021943741@qq.com>
Date: 星期三, 16 九月 2026 17:02:52 +0800
Subject: [PATCH] feat(crm): 信用评级评定人改为下拉选择并默认当前账号

---
 vite.config.ts |   32 +++++++++++++++++++++++---------
 1 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/vite.config.ts b/vite.config.ts
index ef69137..58d7189 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -1,17 +1,32 @@
 import { resolve } from "node:path";
+import { loadEnv } from "vite";
 import { defineConfig } from "./internal/vite-config/src";
 import { companies } from "./company.config";
 
-const company = companies[process.env.COMPANY || ''];
-if (company) {
-  process.env.VITE_APP_LOGO = company.logo;
-  process.env.VITE_APP_FAVICON = company.favicon;
-}
+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)');
 
-export default defineConfig(async () => {
+  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'),
@@ -25,7 +40,7 @@
         enable: false,
       },
       optimizeDeps: {
-        include: ["vue", "vue-router", "pinia", "ant-design-vue", "dayjs", "@vueuse/core", "axios", "@vue-office/pdf", "@vue-office/docx", "@vue-office/excel", "@vue-office/pptx"],
+        include: ["vue", "vue-router", "pinia", "ant-design-vue", "dayjs", "@vueuse/core", "axios"],
         exclude: ["dhtmlx-gantt", "tinymce", "bpmn-js", "bpmn-js-properties-panel", "video.js"],
       },
       build: {
@@ -61,8 +76,7 @@
         proxy: {
           "/admin-api": {
             changeOrigin: true,
-            rewrite: path => path.replace(/^\/admin-api/, ""),
-            target: "http://192.168.0.10:48080/admin-api",
+            target: "http://127.0.0.1:48080",
             ws: true,
           },
         },

--
Gitblit v1.9.3