소스 검색

更新依赖

ZaiZai 7 달 전
부모
커밋
f13695d649

+ 3 - 3
package.json

@@ -17,8 +17,8 @@
         "crypto-js": "^4.2.0",
         "dayjs": "^1.11.11",
         "echarts": "^5.5.1",
-        "element-plus": "^2.7.6",
-        "hc-vue3-ui": "^4.0.7",
+        "element-plus": "^2.7.7",
+        "hc-vue3-ui": "^4.1.0",
         "js-base64": "^3.7.7",
         "js-cookie": "^3.0.5",
         "js-fast-way": "^0.5.0",
@@ -44,7 +44,7 @@
         "autoprefixer": "^10.4.19",
         "eslint": "^8.57.0",
         "eslint-plugin-vue": "^9.24.0",
-        "sass": "^1.77.6",
+        "sass": "^1.77.8",
         "unocss": "0.58.9",
         "unocss-preset-extra": "0.5.3",
         "vite": "^4.5.0"

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
public/plugins/element-plus/index.css


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
public/plugins/element-plus/theme-chalk/el-drawer.css


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
public/plugins/element-plus/theme-chalk/el-form.css


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
public/plugins/element-plus/theme-chalk/el-select-v2.css


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
public/plugins/element-plus/theme-chalk/el-select.css


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
public/plugins/element-plus/theme-chalk/el-upload.css


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
public/plugins/element-plus/theme-chalk/index.css


+ 1 - 1
public/plugins/element-plus/theme-chalk/src/drawer.scss

@@ -45,7 +45,7 @@ $directions: rtl, ltr, ttb, btt;
     margin: 0;
     flex: 1;
     line-height: inherit;
-    font-size: 1rem;
+    font-size: 16px;
   }
 
   @include e(footer) {

+ 24 - 31
public/plugins/element-plus/theme-chalk/src/form.scss

@@ -58,24 +58,6 @@ $form-item-label-top-margin-bottom: map.merge(
 @include b(form) {
   @include set-component-css-var('form', $form);
 
-  @include m(label-left) {
-    .#{$namespace}-form-item__label {
-      justify-content: flex-start;
-    }
-  }
-  @include m(label-top) {
-    .#{$namespace}-form-item {
-      display: block;
-
-      .#{$namespace}-form-item__label {
-        display: block;
-        height: auto;
-        text-align: left;
-        margin-bottom: #{map.get($form-item-label-top-margin-bottom, 'default')};
-        line-height: #{map.get($form-item-label-top-line-height, 'default')};
-      }
-    }
-  }
   @include m(inline) {
     .#{$namespace}-form-item {
       display: inline-flex;
@@ -92,19 +74,6 @@ $form-item-label-top-margin-bottom: map.merge(
       }
     }
   }
-
-  @each $size in (large, default, small) {
-    @include m($size) {
-      &.#{$namespace}-form--label-top {
-        .#{$namespace}-form-item {
-          .#{$namespace}-form-item__label {
-            margin-bottom: #{map.get($form-item-label-top-margin-bottom, $size)};
-            line-height: #{map.get($form-item-label-top-line-height, $size)};
-          }
-        }
-      }
-    }
-  }
 }
 
 @include b(form-item) {
@@ -131,15 +100,35 @@ $form-item-label-top-margin-bottom: map.merge(
         height: #{map.get($form-item-line-height, $size)};
         line-height: #{map.get($form-item-line-height, $size)};
       }
+
       @include e(content) {
         line-height: #{map.get($form-item-line-height, $size)};
       }
+
       @include e(error) {
         padding-top: #{map.get($form-item-error-padding-top, $size)};
       }
     }
   }
 
+  @include m(label-left) {
+    .#{$namespace}-form-item__label {
+      justify-content: flex-start;
+    }
+  }
+
+  @include m(label-top) {
+    display: block;
+
+    .#{$namespace}-form-item__label {
+      display: block;
+      height: auto;
+      text-align: left;
+      margin-bottom: #{map.get($form-item-label-top-margin-bottom, 'default')};
+      line-height: #{map.get($form-item-label-top-line-height, 'default')};
+    }
+  }
+
   @include e(label-wrap) {
     display: flex;
   }
@@ -159,6 +148,7 @@ $form-item-label-top-margin-bottom: map.merge(
     padding: 0 12px 0 0;
     box-sizing: border-box;
   }
+
   @include e(content) {
     display: flex;
     flex-wrap: wrap;
@@ -173,6 +163,7 @@ $form-item-label-top-margin-bottom: map.merge(
       vertical-align: top;
     }
   }
+
   @include e(error) {
     color: getCssVar('color-danger');
     font-size: 12px;
@@ -202,6 +193,7 @@ $form-item-label-top-margin-bottom: map.merge(
           margin-right: 4px;
         }
       }
+
       &.asterisk-right {
         > .#{$namespace}-form-item__label:after,
         > .#{$namespace}-form-item__label-wrap
@@ -232,6 +224,7 @@ $form-item-label-top-margin-bottom: map.merge(
         box-shadow: 0 0 0 1px transparent inset;
       }
     }
+
     .#{$namespace}-input__validateIcon {
       color: getCssVar('color-danger');
     }

+ 4 - 0
public/plugins/element-plus/theme-chalk/src/select.scss

@@ -137,6 +137,10 @@
       cursor: pointer;
       border-color: transparent;
 
+      &.#{$namespace}-tag--plain {
+        border-color: getCssVar('tag', 'border-color');
+      }
+
       .#{$namespace}-tag__content {
         min-width: 0;
       }

+ 1 - 1
public/plugins/element-plus/theme-chalk/src/upload.scss

@@ -393,7 +393,7 @@
       }
 
       span + span {
-        margin-left: 1rem;
+        margin-left: 16px;
       }
 
       .#{bem('upload-list', 'item-delete')} {

+ 0 - 0
public/plugins/element-plus/v2.7.6 → public/plugins/element-plus/v2.7.7


+ 2 - 1
src/config/index.js

@@ -23,7 +23,8 @@ export default {
     ports: ['7777'],
     //其它地址
     ossUrl: 'https://blade-oss-chongqing.oss-cn-shenzhen.aliyuncs.com', //oss地址
-    socket: 'wss://archives.hczcxx.cn/wss/websocket/archive/',
+    //线上还没有,先关掉,防止控制他一直连接失败
+    //socket: 'ws://192.168.0.125:9527/websocket',
 
     //这里不再支持配置请求地址,请在 src/config/index.json 文件中配置。
     //相关参数,可查阅 src/config/index.md 文件说明

+ 10 - 7
src/layout/index.vue

@@ -56,8 +56,8 @@ import { nextTick, onMounted, ref, watch } from 'vue'
 import { useAppStore } from '~src/store'
 import { useRoute, useRouter } from 'vue-router'
 import { initButtons } from '~sto/app'
-import HcSocket from '~src/plugins/HcSocket'
-import { getObjValue, isNullES } from 'js-fast-way'
+import { HcSocket } from '~src/plugins/HcSocket'
+import { isNullES } from 'js-fast-way'
 import website from '~src/config'
 
 //初始组合式
@@ -155,16 +155,19 @@ const msgCount = ref({
 const msgChange = ref(0)
 
 //用户信息
+const userId = ref('')
 const userInfoLoad = ({ user_id }) => {
-    HcSocket.create(user_id, (data) => {
-        msgCount.value = getObjValue(data)
-        msgChange.value++
-    })
+    userId.value = user_id
 }
 
 //项目合同段的ID
+let socket
 const cascaderSend = ({ projectId, contractId }) => {
-    HcSocket.send(projectId + ',' + contractId)
+    //链接webSocket
+    if (!isNullES(socket)) socket.close()
+    socket = new HcSocket({ projectId, contractId, userId: userId.value }, (data) => {
+        console.log('socket:', data)
+    })
 }
 
 // 项目切换

+ 72 - 35
src/plugins/HcSocket.js

@@ -1,55 +1,92 @@
 import website from '~src/config/index'
-import { isNullES } from 'js-fast-way'
+import { getObjValue, isNullES } from 'js-fast-way'
 
 // 长链接推送插件
-export default class HcSocket {
+class HcSocket {
 
-    static socket = null
-    static create(data, change) {
-        const socket = new WebSocket(website.socket + data)
-        socket.onopen = function () {
-            console.log('websocket 链接成功')
+    constructor(data, change) {
+        this.limit = 30
+        this.interval = 10000
+        this.param = getObjValue(data)
+        this.onChange = change
+        this.socket = null
+        this.create()
+        this.moreTabs()
+    }
+
+    //创建连接
+    create() {
+        const { projectId, contractId, userId } = this.param
+        const { socket: socketUrl, clientId } = website
+
+        if (isNullES(socketUrl) || isNullES(clientId) || isNullES(projectId) || isNullES(contractId) || isNullES(userId)) {
+            return
+        }
+
+        //拼接URL并登录socket
+        const url = `${socketUrl}/blade-${clientId}/${projectId}/${contractId}/${userId}`
+        this.socket = new WebSocket(url)
+
+        this.socket.onopen = ()=> {
+            console.log('WebSocket 链接成功')
         }
-        socket.onclose = function () {
-            console.log('websocket 链接已断开')
+
+        this.socket.onclose = async () => {
+            console.log('WebSocket 链接已断开')
+            await this.reconnect()
         }
-        socket.onmessage = function ({ data }) {
-            if (typeof change !== 'function') {
-                return false
-            } else {
-                change(data)
+
+        this.socket.onmessage = ({ data })=> {
+            try {
+                const parsedData = JSON.parse(data)
+                if (typeof this.onChange === 'function') {
+                    this.onChange(parsedData)
+                }
+            } catch (error) {
+                console.error('解析 WebSocket 数据时出错:', error)
             }
         }
-        socket.onerror = function ({ data }) {
-            console.log('websocket 发生错误:', data)
-        }
-        this.socket = socket
     }
 
     //发送消息
-    static async send(data) {
-        const is_socket = await this.isSocket()
-        if (!is_socket) return false
+    async send(data) {
+        if (!this.isSocket()) return
         this.socket.send(data)
     }
 
     //链接是否存在
-    static async isSocket(i = 0) {
-        let _this = this
-        return new Promise((resolve) => {
-            if (isNullES(_this.socket)) {
-                if (i <= 30) {
-                    setTimeout(async () => {
-                        i++
-                        resolve(await _this.isSocket(i))
-                    }, 1000)
-                } else {
-                    resolve(false)
-                }
-            } else {
-                resolve(true)
+    isSocket() {
+        return !isNullES(this.socket) && (this.socket.readyState === WebSocket.OPEN)
+    }
+
+    //尝试重连
+    async reconnect(attempts = 0) {
+        if (attempts >= this.limit) return
+        if (isNullES(this.socket) || this.socket.readyState === WebSocket.CLOSED) {
+            this.create()
+        }
+        await new Promise(resolve => setTimeout(resolve, this.interval))
+        if (!this.isSocket()) {
+            await this.reconnect(attempts + 1)
+        }
+    }
+
+    // 处理多标签页问题
+    moreTabs() {
+        document.addEventListener('visibilitychange', () => {
+            if (document.visibilityState === 'visible' && !this.isSocket()) {
+                this.create()
+            } else if (document.visibilityState === 'hidden') {
+                this.close()
             }
         })
     }
 
+    //关闭或断开连接
+    close() {
+        if (!this.isSocket()) return
+        this.socket.close()
+    }
 }
+
+export { HcSocket }

+ 12 - 12
yarn.lock

@@ -1525,10 +1525,10 @@ electron-to-chromium@^1.4.668:
   resolved "http://39.108.216.210:9000/electron-to-chromium/-/electron-to-chromium-1.4.682.tgz#27577b88ccccc810e09b05093345cf1830f1bd65"
   integrity sha512-oCglfs8yYKs9RQjJFOHonSnhikPK3y+0SvSYc/YpYJV//6rqc0/hbwd0c7vgK4vrl6y2gJAwjkhkSGWK+z4KRA==
 
-element-plus@^2.7.6:
-  version "2.7.6"
-  resolved "http://39.108.216.210:9000/element-plus/-/element-plus-2.7.6.tgz#09b2c9c1de46dcc6778d37a29d9c0948ce40d635"
-  integrity sha512-36sw1K23hYjgeooR10U6CiCaCp2wvOqwoFurADZVlekeQ9v5U1FhJCFGEXO6i/kZBBMwsE1c9fxjLs9LENw2Rg==
+element-plus@^2.7.7:
+  version "2.7.7"
+  resolved "http://39.108.216.210:9000/element-plus/-/element-plus-2.7.7.tgz#317a4b826d577f4572ca040f2568eb751edd891d"
+  integrity sha512-7ucUiDAxevyBE8JbXBTe9ofHhS047VmWMLoksE45zZ08XSnhnyG7WUuk3gmDbAklfVMHedb9sEV3OovPUWt+Sw==
   dependencies:
     "@ctrl/tinycolor" "^3.4.1"
     "@element-plus/icons-vue" "^2.3.1"
@@ -1952,10 +1952,10 @@ has-flag@^4.0.0:
   resolved "http://39.108.216.210:9000/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b"
   integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==
 
-hc-vue3-ui@^4.0.7:
-  version "4.0.7"
-  resolved "http://39.108.216.210:9000/hc-vue3-ui/-/hc-vue3-ui-4.0.7.tgz#11160f4f9599ca41d55aa958e85991ef18c11bd3"
-  integrity sha512-27bvvdDLDBPLeNhufnyT11X0K0lMii7MqyUoTxWtzCzmLg0ToJVATKunhw77J4e5Zmz3JBFH2DXyspoTQfVTmw==
+hc-vue3-ui@^4.1.0:
+  version "4.1.0"
+  resolved "http://39.108.216.210:9000/hc-vue3-ui/-/hc-vue3-ui-4.1.0.tgz#90d71a49762fd6ccd9834a66ae51e27b4513978b"
+  integrity sha512-b9kaDU2BnBIUs9yzQG4EuQyfh22hcobArodBTnEhK5mkUl1eD86jfd13aseaZbI7r3+bqRW1CsFm7cHJMJ6xsw==
   dependencies:
     axios "^1.7.2"
     dayjs "^1.11.11"
@@ -2668,10 +2668,10 @@ safe-buffer@~5.2.0:
   resolved "http://39.108.216.210:9000/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6"
   integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==
 
-sass@^1.77.6:
-  version "1.77.6"
-  resolved "http://39.108.216.210:9000/sass/-/sass-1.77.6.tgz#898845c1348078c2e6d1b64f9ee06b3f8bd489e4"
-  integrity sha512-ByXE1oLD79GVq9Ht1PeHWCPMPB8XHpBuz1r85oByKHjZY6qV6rWnQovQzXJXuQ/XyE1Oj3iPk3lo28uzaRA2/Q==
+sass@^1.77.8:
+  version "1.77.8"
+  resolved "http://39.108.216.210:9000/sass/-/sass-1.77.8.tgz#9f18b449ea401759ef7ec1752a16373e296b52bd"
+  integrity sha512-4UHg6prsrycW20fqLGPShtEvo/WyHRVRHwOP4DzkUrObWoWI05QBSfzU71TVB7PFaL104TwNaHpjlWXAZbQiNQ==
   dependencies:
     chokidar ">=3.0.0 <4.0.0"
     immutable "^4.0.0"

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.