소스 검색

feat(env): 更新项目环境配置及工具函数

- 修改开发、生产和预发布环境的页面标题为中科盛阳管理系统- 更新各环境下的基础API和URL配置
- 在index.html中更新页面标题
- 新增深度比较和数组差异查找工具函数
- 集成UnoCSS插件到Vite配置中
nahida 8 달 전
부모
커밋
243e695451
6개의 변경된 파일101개의 추가작업 그리고 10개의 파일을 삭제
  1. 4 2
      .env.development
  2. 5 3
      .env.production
  3. 2 2
      .env.staging
  4. 1 1
      index.html
  5. 87 1
      src/utils/index.js
  6. 2 1
      vite/plugins/index.js

+ 4 - 2
.env.development

@@ -1,8 +1,10 @@
 # 页面标题
-VITE_APP_TITLE = 若依管理系统
+VITE_APP_TITLE = 中科盛阳管理系统
 
 # 开发环境配置
 VITE_APP_ENV = 'development'
 
-# 若依管理系统/开发环境
+# 中科盛阳管理系统/开发环境
 VITE_APP_BASE_API = '/dev-api'
+
+VITE_APP_BASE_URL = 'http://localhost:8040'

+ 5 - 3
.env.production

@@ -1,11 +1,13 @@
 # 页面标题
-VITE_APP_TITLE = 若依管理系统
+VITE_APP_TITLE = 中科盛阳管理系统
 
 # 生产环境配置
 VITE_APP_ENV = 'production'
 
-# 若依管理系统/生产环境
-VITE_APP_BASE_API = '/prod-api'
+# 中科盛阳管理系统/生产环境
+VITE_APP_BASE_API = 'http://47.107.107.47:8040'
+
+VITE_APP_BASE_URL = 'http://47.107.107.47:8040'
 
 # 是否在打包时开启压缩,支持 gzip 和 brotli
 VITE_BUILD_COMPRESS = gzip

+ 2 - 2
.env.staging

@@ -1,10 +1,10 @@
 # 页面标题
-VITE_APP_TITLE = 若依管理系统
+VITE_APP_TITLE = 中科盛阳管理系统
 
 # 生产环境配置
 VITE_APP_ENV = 'staging'
 
-# 若依管理系统/生产环境
+# 中科盛阳管理系统/生产环境
 VITE_APP_BASE_API = '/stage-api'
 
 # 是否在打包时开启压缩,支持 gzip 和 brotli

+ 1 - 1
index.html

@@ -7,7 +7,7 @@
   <meta name="renderer" content="webkit">
   <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
   <link rel="icon" href="/favicon.ico">
-  <title>若依管理系统</title>
+  <title>中科盛阳管理系统</title>
   <!--[if lt IE 11]><script>window.location.href='/html/ie.html';</script><![endif]-->
   <style>
     html,

+ 87 - 1
src/utils/index.js

@@ -387,4 +387,90 @@ export function camelCase(str) {
 export function isNumberStr(str) {
   return /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g.test(str)
 }
- 
+
+
+/**
+ * 深度比较两个值是否相等
+ * @param {*} a 要比较的值
+ * @param {*} b 要比较的值
+ * @returns {boolean} 两个值是否相等
+ */
+export function deepEqual(a, b) {
+  // 如果是基本类型或null,直接比较
+  if (a === b) return true;
+
+  // 如果其中一个不是对象或为null,不相等
+  if (a === null || b === null || typeof a !== 'object' || typeof b !== 'object') {
+    return false;
+  }
+
+  // 处理数组
+  if (Array.isArray(a) && Array.isArray(b)) {
+    if (a.length !== b.length) return false;
+    for (let i = 0; i < a.length; i++) {
+      if (!deepEqual(a[i], b[i])) return false;
+    }
+    return true;
+  }
+
+  // 处理对象
+  const keysA = Object.keys(a);
+  const keysB = Object.keys(b);
+
+  if (keysA.length !== keysB.length) return false;
+
+  for (const key of keysA) {
+    if (!keysB.includes(key) || !deepEqual(a[key], b[key])) {
+      return false;
+    }
+  }
+
+  return true;
+}
+
+/**
+ * 找出两个数组之间的差异项(数组项可能是深层对象)
+ * @param {Array} arr1 第一个数组
+ * @param {Array} arr2 第二个数组
+ * @returns {Object} 包含差异项的对象,{ onlyInFirst: [], onlyInSecond: [] }
+ */
+export function findArrayDifferences(arr1, arr2) {
+  // 存储只在第一个数组中存在的项
+  const onlyInFirst = [];
+  // 存储只在第二个数组中存在的项
+  const onlyInSecond = [];
+
+  // 检查第一个数组中的项是否在第二个数组中存在
+  for (const item1 of arr1) {
+    let found = false;
+    for (const item2 of arr2) {
+      if (deepEqual(item1, item2)) {
+        found = true;
+        break;
+      }
+    }
+    if (!found) {
+      onlyInFirst.push(item1);
+    }
+  }
+
+  // 检查第二个数组中的项是否在第一个数组中存在
+  for (const item2 of arr2) {
+    let found = false;
+    for (const item1 of arr1) {
+      if (deepEqual(item1, item2)) {
+        found = true;
+        break;
+      }
+    }
+    if (!found) {
+      onlyInSecond.push(item2);
+    }
+  }
+
+  return {
+    onlyInFirst: onlyInFirst,
+    onlyInSecond: onlyInSecond
+  };
+}
+

+ 2 - 1
vite/plugins/index.js

@@ -4,9 +4,10 @@ import createAutoImport from './auto-import'
 import createSvgIcon from './svg-icon'
 import createCompression from './compression'
 import createSetupExtend from './setup-extend'
+import UnoCSS from 'unocss/vite'
 
 export default function createVitePlugins(viteEnv, isBuild = false) {
-    const vitePlugins = [vue()]
+    const vitePlugins = [vue(),UnoCSS()]
     vitePlugins.push(createAutoImport())
 	vitePlugins.push(createSetupExtend())
     vitePlugins.push(createSvgIcon(isBuild))