Browse Source

fix: 修改构建指令;test环境可以跳过自检

master
guoapeng 3 weeks ago
parent
commit
5ee8123fc5
  1. 2
      .env.prod
  2. 2
      .env.test
  3. 20
      increment-version.js
  4. 17
      src/app.vue
  5. 2
      src/env.d.ts
  6. 3
      src/views/main/index.vue
  7. 2
      vite.config.ts

2
.env.prod

@ -3,4 +3,4 @@
FT_NODE_ENV=prod FT_NODE_ENV=prod
FT_WS_URL=ws://192.168.100.168:8080/ws FT_WS_URL=ws://192.168.100.168:8080/ws
FT_PROXY=http://192.168.1.168
FT_PROXY=http://127.0.0.1:8080

2
.env.test

@ -2,5 +2,5 @@
FT_NODE_ENV=test FT_NODE_ENV=test
FT_WS_URL=ws://192.168.1.200:8080/ws
FT_WS_URL=ws://192.168.100.168:8080/ws
FT_PROXY=http://192.168.1.200:8080 FT_PROXY=http://192.168.1.200:8080

20
increment-version.js

@ -1,3 +1,4 @@
import { execSync } from 'node:child_process'
import fs from 'node:fs' import fs from 'node:fs'
import path, { dirname } from 'node:path' import path, { dirname } from 'node:path'
import { fileURLToPath } from 'node:url' import { fileURLToPath } from 'node:url'
@ -10,6 +11,7 @@ const packagePath = path.resolve(__dirname, 'package.json')
const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf-8')) const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf-8'))
// 读取命令行参数(默认使用 'patch') // 读取命令行参数(默认使用 'patch')
// eslint-disable-next-line node/prefer-global/process
const versionType = process.argv[2] || 'patch' const versionType = process.argv[2] || 'patch'
// 递增版本 // 递增版本
@ -21,3 +23,21 @@ if (!newVersion) {
packageJson.version = newVersion packageJson.version = newVersion
fs.writeFileSync(packagePath, JSON.stringify(packageJson, null, 2)) fs.writeFileSync(packagePath, JSON.stringify(packageJson, null, 2))
console.log(`Version updated to: ${newVersion}`) console.log(`Version updated to: ${newVersion}`)
// 新增:自动提交 package.json 到远程仓库
try {
// 将 package.json 添加到暂存区
execSync('git add package.json')
console.log('Added package.json to staging area.')
// 提交更改
execSync(`git commit -m "fix: Update version to V${newVersion}"`)
console.log(`Committed changes with message: Update version to ${newVersion}`)
// 推送到远程仓库
execSync('git push')
console.log('Pushed changes to remote repository.')
}
catch (error) {
console.error('Failed to commit and push changes:', error.message)
}

17
src/app.vue

@ -1,5 +1,22 @@
<script setup lang="ts"> <script setup lang="ts">
// socket.init(() => {}) // socket.init(() => {})
//
// import { ElMessage } from 'element-plus'
//
// const screenWidth = window.screen.width
//
// //
// const screenHeight = window.screen.height
//
// //
// const docWidth = document.documentElement.clientWidth
//
// //
// const docHeight = document.documentElement.clientHeight
//
// // alert(`${screenWidth}-${screenHeight}`)
// ElMessage.success(`${screenWidth}-${screenHeight}`)
// ElMessage.success(`${docWidth}-${docHeight}`)
</script> </script>
<template> <template>

2
src/env.d.ts

@ -10,6 +10,8 @@ interface ImportMeta {
readonly env: ImportMetaEnv readonly env: ImportMetaEnv
} }
declare const __APP_VERSION__: string;
declare module '*.vue' { declare module '*.vue' {
import type { DefineComponent } from 'vue' import type { DefineComponent } from 'vue'

3
src/views/main/index.vue

@ -16,6 +16,7 @@ const router = useRouter()
const systemStore = useSystemStore() // 使 systemStore const systemStore = useSystemStore() // 使 systemStore
const checkVisible = ref(false) const checkVisible = ref(false)
console.log(import.meta.env.FT_NODE_ENV)
const cancel = () => { const cancel = () => {
checkVisible.value = false checkVisible.value = false
@ -24,7 +25,7 @@ const cancel = () => {
const getStatus = async () => { const getStatus = async () => {
await getDeviceStatus().then((res: any) => { await getDeviceStatus().then((res: any) => {
systemStore.updateSystemStatus(res) systemStore.updateSystemStatus(res)
if (!systemStore.systemStatus.selfTestCompleted) {
if (!systemStore.systemStatus.selfTestCompleted && import.meta.env.FT_NODE_ENV !== 'test') {
ElMessageBox.confirm('检测到您还未完成自检,是否开始自检?', '提示', { ElMessageBox.confirm('检测到您还未完成自检,是否开始自检?', '提示', {
type: 'warning', type: 'warning',
confirmButtonText: '确定', confirmButtonText: '确定',

2
vite.config.ts

@ -84,7 +84,7 @@ export default defineConfig({
host: '0.0.0.0', host: '0.0.0.0',
proxy: { proxy: {
'/api': { '/api': {
target: 'http://192.168.1.199:8080',
target: '192.168.100.168:8080',
// target: 'http://192.168.1.200:8080', // target: 'http://192.168.1.200:8080',
// secure: false, // secure: false,
changeOrigin: true, // 是否跨域 changeOrigin: true, // 是否跨域

Loading…
Cancel
Save