林旭祥 2 weeks ago
parent
commit
6ba8937ed0
7 changed files with 20 additions and 19 deletions
  1. 0 2
      .env.development
  2. 1 3
      .env.production
  3. 15 0
      package-lock.json
  4. 1 0
      package.json
  5. 0 8
      src/types/auto-imports.d.ts
  6. 1 1
      src/views/set/index.vue
  7. 2 5
      vite.config.ts

+ 0 - 2
.env.development

@@ -7,5 +7,3 @@ VITE_BUILD_COMPRESS = gzip
 VITE_APP_CONTEXT_PATH = '/'
 # 获取配置项
 VITE_APP_BASE_CTRL = 'https://allctrltst.tropsx.com'
-# 获取git提交记录编码
-VITE_GIT_COMMIT = ''

+ 1 - 3
.env.production

@@ -6,6 +6,4 @@ VITE_BUILD_COMPRESS = gzip
 # 应用访问路径 例如使用前缀 /admin/
 VITE_APP_CONTEXT_PATH = '/'
 # 获取配置项
-VITE_APP_BASE_CTRL = 'https://allctrl.tropsx.com'
-# 获取git提交记录编码
-VITE_GIT_COMMIT = ''
+VITE_APP_BASE_CTRL = 'https://allctrl.tropsx.com'

+ 15 - 0
package-lock.json

@@ -25,6 +25,7 @@
         "socket.io-client": "^2.5.0",
         "speak-tts": "^2.0.8",
         "swiper": "^11.1.4",
+        "vite-plugin-git-commit-hash": "^1.0.7",
         "vite-plugin-package-version": "^1.1.0",
         "vue": "^3.4.21",
         "vue-lazyload": "^3.0.0",
@@ -7497,6 +7498,14 @@
         "vite": ">=2.0.0"
       }
     },
+    "node_modules/vite-plugin-git-commit-hash": {
+      "version": "1.0.7",
+      "resolved": "https://registry.npmjs.org/vite-plugin-git-commit-hash/-/vite-plugin-git-commit-hash-1.0.7.tgz",
+      "integrity": "sha512-/OgmrY2nL6PrIeR+aVbjC5JQJCfBc+Wrzr7wGjvRQ7DMh3e/XADhbbvkKZQmUaS+HO6oUDtsApuFYa5njNt31Q==",
+      "peerDependencies": {
+        "vite": ">=3"
+      }
+    },
     "node_modules/vite-plugin-package-version": {
       "version": "1.1.0",
       "resolved": "https://registry.npmjs.org/vite-plugin-package-version/-/vite-plugin-package-version-1.1.0.tgz",
@@ -13186,6 +13195,12 @@
         "fs-extra": "^10.0.0"
       }
     },
+    "vite-plugin-git-commit-hash": {
+      "version": "1.0.7",
+      "resolved": "https://registry.npmjs.org/vite-plugin-git-commit-hash/-/vite-plugin-git-commit-hash-1.0.7.tgz",
+      "integrity": "sha512-/OgmrY2nL6PrIeR+aVbjC5JQJCfBc+Wrzr7wGjvRQ7DMh3e/XADhbbvkKZQmUaS+HO6oUDtsApuFYa5njNt31Q==",
+      "requires": {}
+    },
     "vite-plugin-package-version": {
       "version": "1.1.0",
       "resolved": "https://registry.npmjs.org/vite-plugin-package-version/-/vite-plugin-package-version-1.1.0.tgz",

+ 1 - 0
package.json

@@ -29,6 +29,7 @@
     "socket.io-client": "^2.5.0",
     "speak-tts": "^2.0.8",
     "swiper": "^11.1.4",
+    "vite-plugin-git-commit-hash": "^1.0.7",
     "vite-plugin-package-version": "^1.1.0",
     "vue": "^3.4.21",
     "vue-lazyload": "^3.0.0",

+ 0 - 8
src/types/auto-imports.d.ts

@@ -296,10 +296,6 @@ declare module 'vue' {
   interface GlobalComponents {}
   interface ComponentCustomProperties {
     readonly EffectScope: UnwrapRef<typeof import('vue')['EffectScope']>
-    readonly ElLoading: UnwrapRef<typeof import('element-plus/es')['ElLoading']>
-    readonly ElMessage: UnwrapRef<typeof import('element-plus/es')['ElMessage']>
-    readonly ElMessageBox: UnwrapRef<typeof import('element-plus/es')['ElMessageBox']>
-    readonly ElNotification: UnwrapRef<typeof import('element-plus/es')['ElNotification']>
     readonly acceptHMRUpdate: UnwrapRef<typeof import('pinia')['acceptHMRUpdate']>
     readonly asyncComputed: UnwrapRef<typeof import('@vueuse/core')['asyncComputed']>
     readonly autoResetRef: UnwrapRef<typeof import('@vueuse/core')['autoResetRef']>
@@ -579,10 +575,6 @@ declare module '@vue/runtime-core' {
   interface GlobalComponents {}
   interface ComponentCustomProperties {
     readonly EffectScope: UnwrapRef<typeof import('vue')['EffectScope']>
-    readonly ElLoading: UnwrapRef<typeof import('element-plus/es')['ElLoading']>
-    readonly ElMessage: UnwrapRef<typeof import('element-plus/es')['ElMessage']>
-    readonly ElMessageBox: UnwrapRef<typeof import('element-plus/es')['ElMessageBox']>
-    readonly ElNotification: UnwrapRef<typeof import('element-plus/es')['ElNotification']>
     readonly acceptHMRUpdate: UnwrapRef<typeof import('pinia')['acceptHMRUpdate']>
     readonly asyncComputed: UnwrapRef<typeof import('@vueuse/core')['asyncComputed']>
     readonly autoResetRef: UnwrapRef<typeof import('@vueuse/core')['autoResetRef']>

+ 1 - 1
src/views/set/index.vue

@@ -79,7 +79,7 @@ const confirmExit = () => {
 };
 
 onMounted(() => {
-  gitCommitHash.value = import.meta.env.VITE_GIT_COMMIT || ''
+  console.info(GIT_COMMIT_HASH);
 })
 </script>
 

+ 2 - 5
vite.config.ts

@@ -1,7 +1,7 @@
 import { UserConfig, ConfigEnv, loadEnv, defineConfig } from 'vite';
 import createPlugins from './vite/plugins';
 import path from 'path';
-import version from 'vite-plugin-package-version';
+import { gitCommitHashPlugin } from "vite-plugin-git-commit-hash";
 const timeStamp = new Date().getTime();
 export default defineConfig(({ mode, command }: ConfigEnv): UserConfig => {
   const env = loadEnv(mode, process.cwd());
@@ -15,10 +15,7 @@ export default defineConfig(({ mode, command }: ConfigEnv): UserConfig => {
       extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
     },
     // https://cn.vitejs.dev/config/#resolve-extensions
-    plugins: [createPlugins(env, command === 'build'),version()],
-    define: {
-      __VITE_GIT_HASH__: JSON.stringify(process.env.VITE_GIT_HASH),
-    },
+    plugins: [createPlugins(env, command === 'build'),gitCommitHashPlugin()],
     server: {
       host: '0.0.0.0',
       port: Number(env.VITE_APP_PORT),