Ver Fonte

调整登录跳转逻辑、调整打包配置

yangguanjin há 1 mês atrás
pai
commit
1b77d7687d

+ 2 - 0
env/.env.development

@@ -8,3 +8,5 @@ VITE_SHOW_SOURCEMAP = true
 VITE_SERVER_BASEURL = 'http://192.168.0.53:48080/appapi'
 
 VITE_FILE_URL = 'https://youdao.hofo.co/dexdev'
+
+VITE_APP_PUBLIC_BASE = '/app-h5/'

+ 5 - 1
env/.env.production

@@ -5,4 +5,8 @@ VITE_DELETE_CONSOLE = true
 # 是否开启sourcemap
 VITE_SHOW_SOURCEMAP = false
 
-VITE_SERVER_BASEURL = 'https://api3.boot.jeecg.com'
+VITE_SERVER_BASEURL = 'http://192.168.0.53:48080/appapi'
+
+VITE_FILE_URL = 'https://youdao.hofo.co/dexdev'
+
+VITE_APP_PUBLIC_BASE = '/app-h5/'

+ 1 - 0
manifest.config.ts

@@ -144,6 +144,7 @@ export default defineManifestConfig({
   },
   h5: {
     router: {
+      mode: 'history',
       base: VITE_APP_PUBLIC_BASE,
     },
     sdkConfigs: {

+ 4 - 4
pages.config.ts

@@ -27,14 +27,14 @@ export default defineUniPages({
     spacing: '3px',
     list: [
       {
-        iconPath: 'static/tabbar/tabbar-home-2.png',
-        selectedIconPath: 'static/tabbar/tabbar-home.png',
+        iconPath: '/static/tabbar/tabbar-home-2.png',
+        selectedIconPath: '/static/tabbar/tabbar-home.png',
         pagePath: 'pages/home/index',
         text: '首页',
       },
       {
-        iconPath: 'static/tabbar/tabbar-user-2.png',
-        selectedIconPath: 'static/tabbar/tabbar-user.png',
+        iconPath: '/static/tabbar/tabbar-user-2.png',
+        selectedIconPath: '/static/tabbar/tabbar-user.png',
         pagePath: 'pages/user/index',
         text: '我的',
       },

+ 3 - 0
src/api/version.ts

@@ -0,0 +1,3 @@
+export const getUpdateHistoryApi = () => {
+  return '1.0'
+}

+ 1 - 1
src/common/constants.ts

@@ -8,7 +8,7 @@ export const X_TENANT_ID = 'X-Tenant-Id'
 export const X_Low_App_ID = 'X-Low-App-ID'
 export const TENANT_LIST = 'tenant_list'
 export const ROUTE_PARAMS = "cacheRouteParams"
-export const HOME_PAGE = "/pages/message/message"
+export const HOME_PAGE = "/pages/home/index"
 /**
  * 组件名称前缀
  */

+ 2 - 1
src/manifest.json

@@ -125,7 +125,8 @@
   "vueVersion": "3",
   "h5": {
     "router": {
-      "base": "/"
+      "mode": "history",
+      "base": "/app-h5/"
     },
     "sdkConfigs": {
       "maps": {

+ 52 - 9
src/pages.json

@@ -24,14 +24,14 @@
     "spacing": "3px",
     "list": [
       {
-        "iconPath": "static/tabbar/tabbar-home-2.png",
-        "selectedIconPath": "static/tabbar/tabbar-home.png",
+        "iconPath": "/static/tabbar/tabbar-home-2.png",
+        "selectedIconPath": "/static/tabbar/tabbar-home.png",
         "pagePath": "pages/home/index",
         "text": "首页"
       },
       {
-        "iconPath": "static/tabbar/tabbar-user-2.png",
-        "selectedIconPath": "static/tabbar/tabbar-user.png",
+        "iconPath": "/static/tabbar/tabbar-user-2.png",
+        "selectedIconPath": "/static/tabbar/tabbar-user.png",
         "pagePath": "pages/user/index",
         "text": "我的"
       }
@@ -105,7 +105,13 @@
     },
     {
       "path": "pages/securityCheck/securityCheckEditor",
-      "type": "page"
+      "type": "page",
+      "layout": "default",
+      "style": {
+        "navigationBarTitleText": "",
+        "navigationStyle": "custom",
+        "disableScroll": true
+      }
     },
     {
       "path": "pages/securityCheck/securityCheckList",
@@ -130,6 +136,15 @@
         "disableScroll": true
       }
     },
+    {
+      "path": "pages/sign/index-back",
+      "type": "page",
+      "layout": "default",
+      "style": {
+        "navigationBarTitleText": "签字",
+        "navigationStyle": "custom"
+      }
+    },
     {
       "path": "pages/sign/index",
       "type": "page",
@@ -148,10 +163,6 @@
         "navigationStyle": "custom"
       }
     },
-    {
-      "path": "pages/spread/index",
-      "type": "page"
-    },
     {
       "path": "pages/systemFile/systemFile",
       "type": "page",
@@ -165,6 +176,19 @@
         }
       }
     },
+    {
+      "path": "pages/taskOnline/TaskOnlineEquipmentList",
+      "type": "page",
+      "layout": "default",
+      "style": {
+        "navigationBarTitleText": "设备列表(分配项目)",
+        "navigationStyle": "custom",
+        "disableScroll": true,
+        "app-plus": {
+          "bounce": "none"
+        }
+      }
+    },
     {
       "path": "pages/taskOnlinePage/taskOnline",
       "type": "page",
@@ -213,6 +237,15 @@
         "navigationStyle": "custom"
       }
     },
+    {
+      "path": "pages/uploadFile/UploadFile",
+      "type": "page",
+      "layout": "default",
+      "style": {
+        "navigationBarTitleText": "附件上传",
+        "navigationStyle": "custom"
+      }
+    },
     {
       "path": "pages/user/index",
       "type": "page",
@@ -256,6 +289,16 @@
         "navigationStyle": "custom"
       }
     },
+    {
+      "path": "pages/equipment/detail/equipTestRecordEditor",
+      "type": "page",
+      "layout": "default",
+      "style": {
+        "navigationBarTitleText": "",
+        "navigationStyle": "custom",
+        "disableScroll": true
+      }
+    },
     {
       "path": "pages/inspectionApproval/list/inspectionApprovalList",
       "type": "page",

+ 18 - 19
src/pages/aboutSystem/index.vue

@@ -81,7 +81,6 @@ const fetchUpdateHistory = async () => {
   try {
     loading.value = true
     console.log('开始获取版本更新历史...')
-    
     const response: any = await getUpdateHistoryApi()
     console.log('API 响应:', response)
 
@@ -94,7 +93,7 @@ const fetchUpdateHistory = async () => {
     uni.showToast({
       title: '获取版本历史失败',
       icon: 'none',
-      duration: 2000
+      duration: 2000,
     })
   } finally {
     loading.value = false
@@ -122,14 +121,14 @@ const showVersionDetail = (item: UpdateInfo) => {
   try {
     const dataJson = encodeURIComponent(JSON.stringify(item))
     uni.navigateTo({
-      url: `/pages/aboutSystem/updateDetail?data=${dataJson}`
+      url: `/pages/aboutSystem/updateDetail?data=${dataJson}`,
     })
   } catch (error) {
     console.error('跳转更新详情页面失败:', error)
     uni.showToast({
       title: '跳转失败',
       icon: 'none',
-      duration: 2000
+      duration: 2000,
     })
   }
 }
@@ -142,7 +141,7 @@ onMounted(() => {
   } catch (e) {
     appVersion.value = '1.0.0'
   }
-  
+
   fetchUpdateHistory()
 })
 </script>
@@ -152,18 +151,18 @@ onMounted(() => {
   display: flex;
   flex-direction: column;
   min-height: 100vh;
-  background-color: #ededed;
   padding: 16px;
+  background-color: #ededed;
 }
 
 .header-card {
-  background-color: #ffffff;
-  margin-bottom: 16px;
-  padding: 30px 20px;
-  border-radius: 4px;
   display: flex;
   flex-direction: column;
   align-items: center;
+  padding: 30px 20px;
+  margin-bottom: 16px;
+  background-color: #ffffff;
+  border-radius: 4px;
 }
 
 .logo-container {
@@ -177,16 +176,16 @@ onMounted(() => {
 
 .app-name {
   font-size: 18px;
-  color: #081f50;
   font-weight: 500;
+  color: #081f50;
 }
 
 .version-card {
   flex: 1;
+  overflow: hidden;
   background-color: #fff;
-  border-radius: 8px;
   border: 1px solid #f0f0f0;
-  overflow: hidden;
+  border-radius: 8px;
 }
 
 .card-header {
@@ -221,42 +220,42 @@ onMounted(() => {
 }
 
 .version-number {
+  margin-bottom: 4px;
   font-size: 16px;
   font-weight: 500;
   color: #333;
-  margin-bottom: 4px;
 }
 
 .version-info-row {
   display: flex;
   flex-direction: row;
-  align-items: center;
   gap: 8px;
+  align-items: center;
 }
 
 .version-info {
   font-size: 14px;
-  color: #666;
   line-height: 20px;
+  color: #666;
 }
 
 .version-arrow {
   font-size: 16px;
-  color: #ccc;
   font-weight: bold;
+  color: #ccc;
 }
 
 .version-divider {
   height: 1px;
-  background-color: #f0f0f0;
   margin-left: 16px;
+  background-color: #f0f0f0;
 }
 
 .loading-container,
 .empty-container {
   display: flex;
-  justify-content: center;
   align-items: center;
+  justify-content: center;
   padding: 40px 0;
 }
 

+ 0 - 17
src/pages/spread/index.vue

@@ -1,17 +0,0 @@
-<template>
-    <SpreadViewer />
-</template>
-
-
-<script setup>
-import SpreadViewer from '@/components/DynamicReport/SpreadViewer.vue'
-
-
-let param = useRoute().query
-
-
-
-</script>
-
-<style scoped>
-</style>

+ 18 - 18
src/pages/user/index.vue

@@ -74,7 +74,7 @@ const userConfig = [
   { label: '昵称', field: 'nickname', type: 'text' },
   { label: '手机号', field: 'mobile', type: 'text' },
   { label: '邮箱地址', field: 'email', type: 'text' },
-  { label: '关于系统', field: 'version', type: 'text' },
+  // { label: '关于系统', field: 'version', type: 'text' },
 ]
 
 onMounted(() => {
@@ -84,9 +84,9 @@ onMounted(() => {
 // 加载用户信息
 const loadUserInfo = () => {
   try {
-    const res = uni.getStorageSync('USER_INFO')
-    if (res?.data) {
-      const info = { ...res.data }
+    const userInfo = uni.getStorageSync('USER_INFO')
+    if (userInfo) {
+      const info = { ...userInfo }
       currentUserInfo.value = info
     } else {
       // 没有用户信息,跳转到登录页
@@ -147,11 +147,11 @@ const handleLogout = async () => {
 .header-view {
   display: flex;
   flex-direction: column;
-  align-items: center;
-  background-color: #d8d8d8;
-  padding-bottom: 20px;
   gap: 10px;
+  align-items: center;
   padding-top: 20px;
+  padding-bottom: 20px;
+  background-color: #d8d8d8;
 }
 
 .logo {
@@ -163,8 +163,8 @@ const handleLogout = async () => {
 .dept-view {
   display: flex;
   flex-direction: row;
-  align-items: center;
   gap: 10px;
+  align-items: center;
 }
 
 .dept-text {
@@ -179,9 +179,9 @@ const handleLogout = async () => {
 .form-item {
   display: flex;
   flex-direction: row;
+  gap: 10px;
   align-items: center;
   justify-content: space-between;
-  gap: 10px;
   height: 44px;
   border-bottom: 1px solid rgba(0, 0, 0, 0.1);
 }
@@ -193,39 +193,39 @@ const handleLogout = async () => {
 }
 
 .normal-text {
-  color: #333;
-  font-size: 14px;
   flex: 1;
+  font-size: 14px;
+  color: #333;
   text-align: right;
 }
 
 .arrow-indicator {
   font-size: 16px;
-  color: #ccc;
   font-weight: bold;
+  color: #ccc;
 }
 
 .logout {
-  padding: 0 16px;
-  margin-top: 60px;
   display: flex;
   flex-direction: row;
   justify-content: center;
+  padding: 0 16px;
+  margin-top: 60px;
 }
 
 .logout-btn {
-  height: 40px;
-  border-radius: 20px;
   display: flex;
   align-items: center;
   justify-content: center;
+  height: 40px;
   padding: 0 24px;
-  border: none;
   background-color: transparent;
+  border: none;
+  border-radius: 20px;
 }
 
 .logout-btn-text {
-  color: #081f50;
   font-size: 16px;
+  color: #081f50;
 }
 </style>

+ 11 - 89
src/router/index.ts

@@ -3,11 +3,6 @@ import { createRouter } from '@/plugin/uni-mini-router'
 import pagesJson from '../pages.json'
 // 引入uni-parse-pages
 import pagesJsonToRoutes from 'uni-parse-pages'
-import { useUserStore } from '@/store/user'
-import { HOME_PAGE, ROUTE_PARAMS } from '@/common/constants'
-import { cache, isOAuth2AppEnv } from '@/common/uitls'
-import { isEmpty } from '@/utils/is'
-console.log('pagesJson::', pagesJson)
 // 生成路由表
 const routes = pagesJsonToRoutes(pagesJson)
 setRouteName(routes)
@@ -21,71 +16,17 @@ interface CacheRoute {
   query: Record<string, string | number | boolean>
 }
 export const beforEach = (to, from, next) => {
-  const userStore = useUserStore()
-  next()
-  // update-begin-author:liusq---date:2025-03-20--for: 防止移动端oauth地址和PC不一致的问题
-  // if (to.path == '/oauth2-app/login') {
-  //   let temp = location.href
-  //   location.href = temp.replace('/oauth2-app/login', '/pages/login/loginOauth2')
-  //   return
-  // }
-  // // update-end-author:liusq---date:2025-03-20--for:防止移动端oauth地址和PC不一致的问题
-  // if (userStore.isLogined) {
-  //   // 有登录态
-  //   if (to.path === '/pages/login/loginOauth2') {
-  //     //有跳转地址
-  //     if (to.query && to.query.redirect) {
-  //       next()
-  //     } else {
-  //       //跳转到首页
-  //       next({ path: HOME_PAGE })
-  //     }
-  //   }
-  //   // update-begin-author:liusq---date:2025-03-20--for: 流程路由逻辑
-  //   let flowRoute = getPathAndQuery(to)
-  //   if (flowRoute === false) {
-  //     let cacheRoute = cache(ROUTE_PARAMS)
-  //     if (
-  //       cacheRoute &&
-  //       !isEmpty(cacheRoute) &&
-  //       (cacheRoute as any)?.path == to.path &&
-  //       isEmpty(to.query) &&
-  //       !isEmpty((cacheRoute as any)?.query)
-  //     ) {
-  //       to.query = (cacheRoute as any)?.query
-  //       next({ path: to.path, query: (cacheRoute as any)?.query })
-  //     } else {
-  //       cache(ROUTE_PARAMS, to, 1 * 60 * 10)
-  //       next()
-  //     }
-  //   } else {
-  //     next({ path: flowRoute.path, query: flowRoute.query })
-  //   }
-  //   //update-end-author:liusq---date:2025-03-20--for: 流程路由逻辑
-  // } else {
-  //   // 无登录态
-  //   if (whiteList.includes(to.path)) {
-  //     // 在免登录白名单,如果进入的页面是login页面并且当前是OAuth2app环境,就进入OAuth2登录页面
-  //     if (to.path === '/pages/login/login' && isOAuth2AppEnv()) {
-  //       next({ path: '/pages/login/loginOauth2' })
-  //     } else {
-  //       // 在免登录白名单,直接进入
-  //       next()
-  //     }
-  //   } else {
-  //     // 如果当前是在OAuth2APP环境,就跳转到OAuth2登录页面
-  //     let path = isOAuth2AppEnv() ? '/pages/login/loginOauth2' : '/pages/login/login'
-  //     let temp = to.path
-  //     if (isOAuth2AppEnv() && temp == '/pages/flow/myTaskDetail') {
-  //       if (to.query && to.query.info) {
-  //         temp += '?info=' + to.query.info
-  //       }
-  //       next({ path: path, query: { redirect: encodeURIComponent(temp) } })
-  //     } else {
-  //       next({ path: path })
-  //     }
-  //   }
-  // }
+  try {
+    const userInfo = uni.getStorageSync('USER_INFO')
+    if (userInfo) {
+      next()
+    } else {
+      next({ path: loginPage })
+    }
+  } catch (err) {
+    console.error('获取用户信息失败:', err)
+    next({ path: loginPage })
+  }
 }
 // 全局前置守卫
 router.beforeEach(beforEach)
@@ -100,23 +41,4 @@ function setRouteName(routes) {
   })
 }
 
-/**
- * 路由跳转-已经登录过了 直接next会导致参数丢失,所以需要再走一遍loginOauth2页面的逻辑
- * @param to
- * @returns {{path: string, query: {redirect: string}}|boolean}
- */
-function getPathAndQuery(to) {
-  if (to.path === '/pages/flow/myTaskDetail') {
-    if (to.query && to.query.info) {
-      const info = JSON.parse(to.query.info)
-      info.hasToken = 1
-      const temp = '/pages/flow/myTaskDetail?info=' + JSON.stringify(info)
-      return {
-        path: '/pages/login/loginOauth2',
-        query: { redirect: encodeURI(temp) },
-      }
-    }
-  }
-  return false
-}
 export default router

+ 0 - 1
src/types/uni-pages.d.ts

@@ -16,7 +16,6 @@ interface NavigateToOptions {
        "/pages/sign/index-back" |
        "/pages/sign/index" |
        "/pages/sign-detail/index" |
-       "/pages/spread/index" |
        "/pages/systemFile/systemFile" |
        "/pages/taskOnline/TaskOnlineEquipmentList" |
        "/pages/taskOnlinePage/taskOnline" |

+ 5 - 0
src/utils/fileServices.ts

@@ -0,0 +1,5 @@
+export const formatFileSize = (size: number) => {
+  const units = ['B', 'KB', 'MB', 'GB', 'TB']
+  const unitIndex = Math.floor(Math.log(size) / Math.log(1024))
+  return `${size.toFixed(2)} ${units[unitIndex]}`
+}

+ 36 - 29
src/utils/index.ts

@@ -183,11 +183,11 @@ export const getEnvBaseUploadUrl = () => {
  * @returns {*}
  */
 export function formatDate(value, fmt) {
-  var regPos = /^\d+(\.\d+)?$/;
-  if(regPos.test(value)){
-    //如果是数字
-    let getDate = new Date(value);
-    let o = {
+  const regPos = /^\d+(\.\d+)?$/
+  if (regPos.test(value)) {
+    // 如果是数字
+    const getDate = new Date(value)
+    const o = {
       'M+': getDate.getMonth() + 1,
       'd+': getDate.getDate(),
       'h+': getDate.getHours(),
@@ -195,22 +195,25 @@ export function formatDate(value, fmt) {
       'm+': getDate.getMinutes(),
       's+': getDate.getSeconds(),
       'q+': Math.floor((getDate.getMonth() + 3) / 3),
-      'S': getDate.getMilliseconds()
-    };
+      S: getDate.getMilliseconds(),
+    }
     if (/(y+)/.test(fmt)) {
       fmt = fmt.replace(RegExp.$1, (getDate.getFullYear() + '').substr(4 - RegExp.$1.length))
     }
-    for (let k in o) {
+    for (const k in o) {
       if (new RegExp('(' + k + ')').test(fmt)) {
-        fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
+        fmt = fmt.replace(
+          RegExp.$1,
+          RegExp.$1.length === 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length),
+        )
       }
     }
-    return fmt;
-  }else{
-    //TODO
-    if(value && value.length>0){
-      value = value.trim();
-      return value.substr(0,fmt.length);
+    return fmt
+  } else {
+    // TODO
+    if (value && value.length > 0) {
+      value = value.trim()
+      return value.substr(0, fmt.length)
     }
     return value
   }
@@ -221,39 +224,39 @@ export function formatDate(value, fmt) {
  */
 export function getRefPromise(componentRef) {
   return new Promise((resolve) => {
-    (function next() {
-      let ref = componentRef.value;
+    ;(function next() {
+      const ref = componentRef.value
       if (ref) {
-        resolve(ref);
+        resolve(ref)
       } else {
         setTimeout(() => {
-          next();
-        }, 100);
+          next()
+        }, 100)
       }
-    })();
-  });
+    })()
+  })
 }
 
 /**
  * 构建文件URL
- * 
+ *
  * 将域名和文件名拼接成完整的文件URL,支持自定义域名或使用环境变量
- * 
+ *
  * @param filename 文件名(必需),不能为空
  * @param domain 自定义域名(可选),如未提供则使用环境变量 VITE_FILE_URL
  * @param basePath 基础路径(可选),默认为空
  * @returns 完整的文件URL
- * 
+ *
  * @example
  * // 使用自定义域名
  * buildFileUrl('avatar.jpg', 'https://cdn.example.com')
  * // 返回: 'https://cdn.example.com/avatar.jpg'
- * 
- * @example  
+ *
+ * @example
  * // 使用自定义域名和基础路径
  * buildFileUrl('avatar.jpg', 'https://cdn.example.com', '/uploads')
  * // 返回: 'https://cdn.example.com/uploads/avatar.jpg'
- * 
+ *
  * @example
  * // 使用环境变量域名
  * buildFileUrl('avatar.jpg')
@@ -277,7 +280,7 @@ export const buildFileUrl = (filename: string, domain?: string, basePath?: strin
 
   // 确定使用的域名
   let baseUrl = domain || import.meta.env.VITE_FILE_URL || ''
-  
+
   // 智能协议处理:如果域名不包含协议,自动添加 https://
   if (baseUrl && !baseUrl.match(/^https?:\/\//)) {
     baseUrl = `https://${baseUrl}`
@@ -302,3 +305,7 @@ export const buildFileUrl = (filename: string, domain?: string, basePath?: strin
 
   return fullUrl
 }
+
+export const getTime = () => {
+  return new Date().getTime()
+}

+ 1 - 37
vite.config.ts

@@ -4,7 +4,6 @@ import path from 'node:path'
 import { defineConfig, loadEnv } from 'vite'
 import fs from 'node:fs'
 import { generateComponentTypes } from './vite-plugins/generateComponentTypes'
-console.log('进入 vite')
 // @see https://uni-helper.js.org/vite-plugin-uni-pages
 import UniPages from '@uni-helper/vite-plugin-uni-pages'
 // @see https://uni-helper.js.org/vite-plugin-uni-layouts
@@ -126,40 +125,6 @@ export default ({ command, mode }) => {
         enable: mode === 'development' && JSON.parse(VITE_USE_MOCK),
       }),
       UNI_PLATFORM === 'h5' && mode === 'production' && createEnvConfigPlugin(),
-      // H5 开发环境下提供 hybrid/html 目录的静态文件访问
-      UNI_PLATFORM === 'h5' &&
-        mode === 'development' && {
-          name: 'hybrid-html-server',
-          configureServer(server) {
-            const hybridHtmlDir = path.join(process.cwd(), './src/hybrid/html')
-            server.middlewares.use('/html', (req, res, next) => {
-              const fs = require('fs')
-              // URL 解码,处理空格等特殊字符
-              let urlPath = decodeURIComponent(req.url)
-              // 移除查询参数
-              urlPath = urlPath.split('?')[0]
-              // 移除 /html 前缀
-              urlPath = urlPath.replace(/^\/html/, '')
-              const filePath = path.join(hybridHtmlDir, urlPath)
-              console.log('H5 Hybrid HTML 中间件:', filePath)
-              if (fs.existsSync(filePath)) {
-                res.statusCode = 200
-                // 设置正确的 Content-Type
-                if (urlPath.endsWith('.js')) {
-                  res.setHeader('Content-Type', 'application/javascript')
-                } else if (urlPath.endsWith('.css')) {
-                  res.setHeader('Content-Type', 'text/css')
-                } else if (urlPath.endsWith('.html')) {
-                  res.setHeader('Content-Type', 'text/html')
-                }
-                fs.createReadStream(filePath).pipe(res)
-              } else {
-                console.warn('HTML 文件不存在:', filePath)
-                next()
-              }
-            })
-          },
-        },
     ],
     define: {
       __UNI_PLATFORM__: JSON.stringify(UNI_PLATFORM),
@@ -183,7 +148,6 @@ export default ({ command, mode }) => {
         '@img': path.join(process.cwd(), './src/static/images'),
       },
     },
-    publicDir: path.join(process.cwd(), './src/hybrid'), // 配置静态资源目录
     server: {
       host: '0.0.0.0',
       hmr: true,
@@ -235,7 +199,7 @@ function createEnvConfigPlugin() {
     },
     async writeBundle(options) {
       const env = loadEnv(mode, path.resolve(process.cwd(), 'env'))
-      delete env['VITE_ROOT_DIR']
+      delete env.VITE_ROOT_DIR
       // 生成动态配置文件
       const configContent = `window.__APP_CONFIG__ = ${JSON.stringify(env)};`
       const outputDir = options.dir || path.resolve(envDir, 'dist')