Browse Source

feat: 完善ws心跳机制

lanjianrong 4 years ago
parent
commit
b1cb9a107c
3 changed files with 9 additions and 1 deletions
  1. 3 1
      src/components/RightContent/index.tsx
  2. 4 0
      src/utils/is.ts
  3. 2 0
      src/utils/ws.ts

+ 3 - 1
src/components/RightContent/index.tsx

@@ -8,6 +8,7 @@ import Notify from './NoticeIcon'
 // import HeaderSearch from '../HeaderSearch'
 import styles from './index.less'
 import Book from './Book'
+import { isMobile } from '@/utils/is'
 const ENVTagColor = {
   dev: 'orange',
   test: 'green',
@@ -60,7 +61,8 @@ const GlobalHeaderRight: React.FC = () => {
       >
         <QuestionCircleOutlined />
       </span> */}
-      <Book />
+      {!isMobile() && <Book />}
+
       <Notify />
       <Avatar />
       {REACT_APP_ENV && REACT_APP_ENV !== 'prod' && (

+ 4 - 0
src/utils/is.ts

@@ -51,3 +51,7 @@ export function isEmpty<T = unknown>(val: T): val is T {
 
   return false
 }
+
+export function isMobile() {
+  return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
+}

+ 2 - 0
src/utils/ws.ts

@@ -45,6 +45,8 @@ class Ws {
 
   // 初始化socket,一般在应用启动时初始化一次就好了,或者需要更换wsUrl
   public init(uid: string, uri: string, opts?: Options) {
+    console.log('id', uid)
+
     this.uid = uid
     this.uri = uri
     this.opts = opts