Przeglądaj źródła

打包自动获取git SHA1

林旭祥 3 tygodni temu
rodzic
commit
959762c122
4 zmienionych plików z 13 dodań i 1 usunięć
  1. 3 1
      .env.development
  2. 2 0
      .env.production
  3. 5 0
      src/views/set/index.vue
  4. 3 0
      vite.config.ts

+ 3 - 1
.env.development

@@ -1,5 +1,5 @@
 # 开发环境
-VITE_APP_BASE_API = 'https://api-edutst.tropsx.com'
+VITE_APP_BASE_API = 'https://api-aiexamtst.tropsx.com'
 VITE_APP_PORT = 80
 # 是否在打包时开启压缩,支持 gzip 和 brotli
 VITE_BUILD_COMPRESS = gzip
@@ -7,3 +7,5 @@ VITE_BUILD_COMPRESS = gzip
 VITE_APP_CONTEXT_PATH = '/'
 # 获取配置项
 VITE_APP_BASE_CTRL = 'https://allctrltst.tropsx.com'
+# 获取git提交记录编码
+VITE_GIT_SHA1 = $(git rev-parse HEAD)

+ 2 - 0
.env.production

@@ -7,3 +7,5 @@ VITE_BUILD_COMPRESS = gzip
 VITE_APP_CONTEXT_PATH = '/'
 # 获取配置项
 VITE_APP_BASE_CTRL = 'https://allctrl.tropsx.com'
+# 获取git提交记录编码
+VITE_GIT_SHA1 = $(git rev-parse HEAD)

+ 5 - 0
src/views/set/index.vue

@@ -27,12 +27,17 @@
         </div>
       </div> -->
     </div>
+    {{ gitSha1 }}
   </div>
 </template>
 
 <script setup name="Login" lang="ts">
 const { proxy } = getCurrentInstance() as any;
 const router = useRouter();
+const data = reactive<any>({
+  gitSha1: __VUE_APP_GIT_SHA1__
+});
+const { gitSha1 } = toRefs(data);
 
 //设置
 const getConfig = () => {

+ 3 - 0
vite.config.ts

@@ -15,6 +15,9 @@ export default defineConfig(({ mode, command }: ConfigEnv): UserConfig => {
     },
     // https://cn.vitejs.dev/config/#resolve-extensions
     plugins: createPlugins(env, command === 'build'),
+    define: {
+      __VUE_APP_GIT_SHA1__: JSON.stringify(process.env.VITE_GIT_SHA1)
+    },
     server: {
       host: '0.0.0.0',
       port: Number(env.VITE_APP_PORT),