Selaa lähdekoodia

漏洞扫描 需求更新

yuhongqi 2 päivää sitten
vanhempi
commit
306e0bc03b
5 muutettua tiedostoa jossa 17 lisäystä ja 10 poistoa
  1. 1 1
      src/layout/components/Sidebar/Logo.vue
  2. 1 1
      src/settings.js
  3. 13 6
      src/utils/liveWS.js
  4. 1 1
      src/views/login.vue
  5. 1 1
      vue.config.js

+ 1 - 1
src/layout/components/Sidebar/Logo.vue

@@ -26,7 +26,7 @@ export default {
   },
   data() {
     return {
-      title: '芳华悦选',
+      title: '芳华臻选生活馆',
       logo: logoImg
     }
   }

+ 1 - 1
src/settings.js

@@ -1,5 +1,5 @@
 module.exports = {
-  title: '芳华悦选',
+  title: '芳华臻选生活馆',
 
 
 

+ 13 - 6
src/utils/liveWS.js

@@ -16,12 +16,7 @@ export class LiveWS {
    * @param {number} reconnectDelay - 连接断开后重连的延迟,单位毫秒
    */
   constructor(url, liveId, userId, checkInterval = 5000, reconnectDelay = 3000) {
-    let timestamp = new Date().getTime()
-    let userType = 1
-    let signature = CryptoJS.HmacSHA256(
-      CryptoJS.enc.Utf8.parse('' + liveId + userId + userType + timestamp),
-      CryptoJS.enc.Utf8.parse(timestamp)).toString(CryptoJS.enc.Hex)
-    this.url = url + `?liveId=${liveId}&userId=${userId}&userType=${userType}&timestamp=${timestamp}&signature=${signature}`;
+    this.baseUrl = url;
     this.liveId = liveId;
     this.userId = userId;
     this.checkInterval = checkInterval;
@@ -31,16 +26,28 @@ export class LiveWS {
     this.heartbeatTimer = null;
     this.isManualClose = false;
     this._messageHandlers = new Set();
+    this.refreshSignedUrl();
     this.connect();
     this.startHeartbeat();
   }
 
+  /** 每次建连/重连刷新 timestamp+signature,避免验签过期 */
+  refreshSignedUrl() {
+    const timestamp = new Date().getTime();
+    const userType = 1;
+    const signature = CryptoJS.HmacSHA256(
+      CryptoJS.enc.Utf8.parse('' + this.liveId + this.userId + userType + timestamp),
+      CryptoJS.enc.Utf8.parse(String(timestamp))).toString(CryptoJS.enc.Hex);
+    this.url = this.baseUrl + `?liveId=${this.liveId}&userId=${this.userId}&userType=${userType}&timestamp=${timestamp}&signature=${signature}`;
+  }
+
   connect() {
     // 如果已经有一个连接处于 OPEN 或 CONNECTING 状态,则不再创建新连接
     if (this.ws && (this.ws.readyState === WebSocket.OPEN || this.ws.readyState === WebSocket.CONNECTING)) {
       return;
     }
 
+    this.refreshSignedUrl();
     this.ws = new WebSocket(this.url);
 
     // 绑定事件

+ 1 - 1
src/views/login.vue

@@ -65,7 +65,7 @@ export default {
   name: "Login",
   computed: {
     title() {
-      return defaultSettings.title || '御君方管理平台'
+      return defaultSettings.title || '芳华臻选生活馆'
     }
   },
   data() {

+ 1 - 1
vue.config.js

@@ -13,7 +13,7 @@ function resolve(dir) {
   return path.join(__dirname, dir)
 }
 
-const name = defaultSettings.title || '御君方管理平台' // 标题
+const name = defaultSettings.title || '芳华臻选生活馆' // 标题
 
 const port = process.env.port || process.env.npm_config_port || 80 // 端口