From e8f85cd9f369f8290d55b0e041be35c9c0b50fb6 Mon Sep 17 00:00:00 2001
From: schangxiang@126.com <schangxiang@126.com>
Date: 周二, 06 5月 2025 11:40:26 +0800
Subject: [PATCH] 222

---
 HIAWms/web/vite.lib.config.ts |   48 +++++++++++-------------------------------------
 1 files changed, 11 insertions(+), 37 deletions(-)

diff --git a/HIAWms/web/vite.lib.config.ts b/HIAWms/web/vite.lib.config.ts
index 00b95dd..a76ad4e 100644
--- a/HIAWms/web/vite.lib.config.ts
+++ b/HIAWms/web/vite.lib.config.ts
@@ -14,38 +14,26 @@
 import VueTypeImports from 'vite-plugin-vue-type-imports'
 const execa = require('execa')
 const isWin = process.platform === 'win32'
-let getWidgetNames: Array<string> = []
 const argvPath: string = './script/.argv'
-const isAllBuild = existsSync(argvPath)
+const isSingleBuild = existsSync(argvPath)
+const nodeIndex = process.env.NODE_INDEX
+const baseBuildFile = './node_modules/.cache/widgets.json'
+let getWidgetNames: Array<string> = []
 
-function getGitHash() {
-  return execa('git', ['rev-parse', '--short', 'HEAD'])
-}
-
-function getGitBranch() {
-  return execa('git', ['rev-parse', '--abbrev-ref', 'HEAD'])
-}
-
-function getGitUserName() {
-  return execa('git', ['config', 'user.name'])
-}
-
-if (isAllBuild) {
+if (isSingleBuild) {
   const widgetName = readFileSync(argvPath, { encoding: 'utf8' })
   getWidgetNames.push(widgetName)
 } else {
-  const widgetsPath = globSync(`./src/widgets/*/index.ts`)
-  getWidgetNames = widgetsPath.map((file) => {
-    const parts = isWin
-      ? path.resolve(file).split('\\')
-      : path.resolve(file).split('/')
-    return parts[parts.length - 2]
-  })
+  // 鎵ц澶氭牳鍛戒护鎵撳寘
+  if (nodeIndex) {
+    const widgetNameMap = require(path.resolve(process.cwd(), baseBuildFile))
+    getWidgetNames = widgetNameMap[nodeIndex]
+  }
 }
 
 const library: any = getWidgetNames.map((name) => {
   return {
-    outDir: isWin ? 'C:/Program Files/CMS Editor/host/wwwroot/widgets' : 'dist',
+    outDir: isWin ? 'D:/syc/CMS Editor/host/wwwroot/widgets' : 'dist',
     target: 'ES2022',
     rollupOptions: {
       external: ['vue', 'sdk'],
@@ -69,24 +57,10 @@
 
 //@ts-ignore
 export default defineConfig(async ({ mode }) => {
-  let commit
-  let branch
-  let userName
-  try {
-    commit = await getGitHash()
-    branch = await getGitBranch()
-    userName = await getGitUserName()
-  } catch (e) {
-    console.log(e)
-  }
-
   return {
     define: {
       'process.env': process.env,
       'window.__BUILD_TIME__': `"${dayjs().format('YYYY-MM-DD HH:mm:ss')}"`,
-      'window.__COMMIT__': `"${commit?.stdout}"`,
-      'window.__BRANCH__': `"${branch?.stdout}"`,
-      'window.__USER_NAME__': `"${userName?.stdout}"`,
     },
     resolve: {
       alias: {

--
Gitblit v1.9.3