From d1cf2e1b5d3f56d14e5d75024ce2d054f9142b2e Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期四, 06 八月 2026 17:54:54 +0800
Subject: [PATCH] refactor(components): 重构多个组件以提升代码质量和可维护性

---
 vite.config.ts |   74 ++++++++++++++++++++++++++++++++++---
 1 files changed, 68 insertions(+), 6 deletions(-)

diff --git a/vite.config.ts b/vite.config.ts
index f12fa6d..825d4d4 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -1,20 +1,82 @@
-import { defineConfig } from './src/internal/vite-config/src';
+import { resolve } from "node:path";
+import { loadEnv } from "vite";
+import { defineConfig } from "./internal/vite-config/src";
 
-export default defineConfig(async () => {
+/** 鍏徃閰嶇疆锛氭柊澧炲叕鍙稿彧闇�鍔犱竴琛岋紝logo 鍥剧墖鏀� public/logos/ 鐩綍 */
+const companyConfigs: Record<string, { favicon: string; logo: string; name: string }> = {
+  TEST: { name: '娴嬭瘯鍏徃', logo: '/logos/TEST.png', favicon: '/logos/TEST.ico' },
+};
+
+export default defineConfig(async ({ mode }) => {
+  const env = loadEnv(mode, process.cwd(), 'VITE_');
+  const companyKey = env.VITE_COMPANY || '';
+  const company = companyConfigs[companyKey];
+  const appLogo = company?.logo ?? '';
+  const appFavicon = company?.favicon ?? '';
+  console.log('[company]', companyKey, '-> logo:', appLogo, 'favicon:', appFavicon);
+
   return {
     application: {},
     vite: {
+      define: {
+        __APP_LOGO__: JSON.stringify(appLogo),
+        __APP_FAVICON__: JSON.stringify(appFavicon),
+      },
+      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", "@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: {
+        rollupOptions: {
+          output: {
+            manualChunks: id => {
+              if (id.includes("node_modules")) {
+                if (["vue", "vue-router", "pinia"].some(dep => id.includes(dep))) {
+                  return "vendor-vue";
+                }
+                if (["ant-design-vue", "@vueuse/core"].some(dep => id.includes(dep))) {
+                  return "vendor-ui";
+                }
+                if (["dayjs", "axios", "@vee-validate/zod", "zod"].some(dep => id.includes(dep))) {
+                  return "vendor-utils";
+                }
+                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";
+                }
+              }
+            },
+          },
+        },
+      },
       server: {
         allowedHosts: true,
+        watch: {
+          ignored: ["**/node_modules/**", "**/dist/**", "**/.git/**"],
+        },
         proxy: {
-          '/admin-api': {
+          "/admin-api": {
             changeOrigin: true,
-            rewrite: (path) => path.replace(/^\/admin-api/, ''),
-            target: 'http://192.168.0.226:48080/admin-api',
+            rewrite: path => path.replace(/^\/admin-api/, ""),
+            target: "http://192.168.0.10:48080/admin-api",
             ws: true,
           },
         },
       },
     },
   };
-});
\ No newline at end of file
+});

--
Gitblit v1.9.3