xujing 5 lat temu
rodzic
commit
d904ec41f7
3 zmienionych plików z 16 dodań i 5 usunięć
  1. 4
    4
      config/prod.js
  2. 5
    1
      src/app.js
  3. 7
    0
      src/utils/im.js

+ 4
- 4
config/prod.js Wyświetl plik

@@ -3,10 +3,10 @@ module.exports = {
3 3
     NODE_ENV: '"production"'
4 4
   },
5 5
   defineConstants: {
6
-    // HOST: '"http://192.168.0.218:8080"',
7
-    // WSS_HOST: '"ws://192.168.0.218:8080"',
8
-    HOST: '"https://dev.jinchengjiaye.com"',//测试
9
-    WSS_HOST: '"wss://dev.jinchengjiaye.com"',
6
+    HOST: '"http://192.168.2.54:8080"',
7
+    WSS_HOST: '"ws://192.168.2.54:8080"',
8
+    // HOST: '"https://dev.jinchengjiaye.com"',//测试
9
+    // WSS_HOST: '"wss://dev.jinchengjiaye.com"',
10 10
     // HOST: '"https://lt.pawoma.cn"',
11 11
     // WSS_HOST: '"wss://lt.pawoma.cn"',
12 12
     Version:'V3.5.5_2019-12-24'

+ 5
- 1
src/app.js Wyświetl plik

@@ -152,7 +152,7 @@ class App extends Component {
152 152
 
153 153
   componentDidHide() {
154 154
     // ready.close()
155
-    // socket.closeSocket()
155
+    socket.closeSocket()
156 156
   }
157 157
 
158 158
   componentDidShow() {
@@ -174,10 +174,14 @@ class App extends Component {
174 174
         }
175 175
       })
176 176
     })
177
+
178
+    socket.reconnect()
177 179
   }
180
+  
178 181
   componentDidMount() {
179 182
     // console.info('app componentDidMount')
180 183
   }
184
+
181 185
   componentWillMount(params) {
182 186
     // console.info('app componentWillMount', params)
183 187
     this.initData()

+ 7
- 0
src/utils/im.js Wyświetl plik

@@ -13,7 +13,10 @@ class IMManager {
13 13
   }
14 14
 
15 15
   reconnect() {
16
+    if (!this.option) return;
17
+    if (this.socketOpen) return;
16 18
     if (this.lockReconnect) return;
19
+
17 20
     this.lockReconnect = true;
18 21
     clearTimeout(this.timer)
19 22
     console.log('reconnect')
@@ -54,6 +57,7 @@ class IMManager {
54 57
     this.wss.onClose(res => {
55 58
       console.log('已关闭', res)
56 59
       close && close(res)
60
+      this.socketOpen = false
57 61
 
58 62
       // 手动关闭的就不要重启了 
59 63
       if (!this.selfClose) {
@@ -64,6 +68,8 @@ class IMManager {
64 68
     this.wss.onError(err => {
65 69
       console.log('打印错误', err)
66 70
       fail && fail(err)
71
+      this.socketOpen = false
72
+      
67 73
       if (!this.selfClose) {
68 74
         this.reconnect()
69 75
       }
@@ -91,6 +97,7 @@ class IMManager {
91 97
         code: 1000,
92 98
         reason: '退出页面'
93 99
       })
100
+      this.socketOpen = false
94 101
       console.log('已退出 scoket')
95 102
     } else {
96 103
       console.error('scoket 没有启动')