systemrobotassistant 3.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of systemrobotassistant might be problematic. Click here for more details.
- package/.eslintignore +6 -0
- package/.eslintrc +45 -0
- package/.gitlab-ci.yml +52 -0
- package/.lecprc.ts +76 -0
- package/.yarnrc +1 -0
- package/CHANGELOG.md +114 -0
- package/README.md +14 -0
- package/custom-amd-plugin.ts +46 -0
- package/es/component/answer-itme/index.d.ts +20 -0
- package/es/component/answer-itme/index.d.ts.map +1 -0
- package/es/component/answer-itme/index.js +41 -0
- package/es/component/answer-itme/style.css +35 -0
- package/es/component/data-container/index.d.ts +19 -0
- package/es/component/data-container/index.d.ts.map +1 -0
- package/es/component/data-container/index.js +37 -0
- package/es/component/data-container/style.css +26 -0
- package/es/component/days-tab/index.d.ts +6 -0
- package/es/component/days-tab/index.d.ts.map +1 -0
- package/es/component/days-tab/index.js +119 -0
- package/es/component/days-tab/style.css +43 -0
- package/es/component/days-tab/utils.d.ts +32 -0
- package/es/component/days-tab/utils.d.ts.map +1 -0
- package/es/component/days-tab/utils.js +98 -0
- package/es/component/error-boundary/index.d.ts +2 -0
- package/es/component/error-boundary/index.d.ts.map +1 -0
- package/es/component/error-boundary/index.js +33 -0
- package/es/component/it-notice-modal/columns.d.ts +11 -0
- package/es/component/it-notice-modal/columns.d.ts.map +1 -0
- package/es/component/it-notice-modal/columns.js +108 -0
- package/es/component/it-notice-modal/double-tab.d.ts +6 -0
- package/es/component/it-notice-modal/double-tab.d.ts.map +1 -0
- package/es/component/it-notice-modal/double-tab.js +94 -0
- package/es/component/it-notice-modal/index.d.ts +6 -0
- package/es/component/it-notice-modal/index.d.ts.map +1 -0
- package/es/component/it-notice-modal/index.js +488 -0
- package/es/component/it-notice-modal/server.d.ts +8 -0
- package/es/component/it-notice-modal/server.d.ts.map +1 -0
- package/es/component/it-notice-modal/server.js +43 -0
- package/es/component/it-notice-modal/single-tab.d.ts +6 -0
- package/es/component/it-notice-modal/single-tab.d.ts.map +1 -0
- package/es/component/it-notice-modal/single-tab.js +82 -0
- package/es/component/it-notice-modal/style.css +301 -0
- package/es/component/it-notice-modal/utils.d.ts +2 -0
- package/es/component/it-notice-modal/utils.d.ts.map +1 -0
- package/es/component/it-notice-modal/utils.js +8 -0
- package/es/component/it-notice-tab/index.d.ts +6 -0
- package/es/component/it-notice-tab/index.d.ts.map +1 -0
- package/es/component/it-notice-tab/index.js +206 -0
- package/es/component/it-notice-tab/server.d.ts +3 -0
- package/es/component/it-notice-tab/server.d.ts.map +1 -0
- package/es/component/it-notice-tab/server.js +13 -0
- package/es/component/it-notice-tab/style.css +103 -0
- package/es/component/mail-list-modal/index.d.ts +2 -0
- package/es/component/mail-list-modal/index.d.ts.map +1 -0
- package/es/component/mail-list-modal/index.js +306 -0
- package/es/component/mail-list-modal/server.d.ts +7 -0
- package/es/component/mail-list-modal/server.d.ts.map +1 -0
- package/es/component/mail-list-modal/server.js +38 -0
- package/es/component/mail-list-modal/style.css +132 -0
- package/es/component/myself-chat-card/index.d.ts +15 -0
- package/es/component/myself-chat-card/index.d.ts.map +1 -0
- package/es/component/myself-chat-card/index.js +25 -0
- package/es/component/myself-chat-card/style.css +22 -0
- package/es/component/need-answer/index.d.ts +15 -0
- package/es/component/need-answer/index.d.ts.map +1 -0
- package/es/component/need-answer/index.js +60 -0
- package/es/component/need-answer/style.css +19 -0
- package/es/component/opppsition-chat-card/index.d.ts +11 -0
- package/es/component/opppsition-chat-card/index.d.ts.map +1 -0
- package/es/component/opppsition-chat-card/index.js +25 -0
- package/es/component/opppsition-chat-card/style.css +23 -0
- package/es/component/question-library/index.d.ts +10 -0
- package/es/component/question-library/index.d.ts.map +1 -0
- package/es/component/question-library/index.js +291 -0
- package/es/component/question-library/server.d.ts +4 -0
- package/es/component/question-library/server.d.ts.map +1 -0
- package/es/component/question-library/server.js +19 -0
- package/es/component/question-library/style.css +75 -0
- package/es/component/question-tag/index.d.ts +11 -0
- package/es/component/question-tag/index.d.ts.map +1 -0
- package/es/component/question-tag/index.js +23 -0
- package/es/component/question-tag/style.css +12 -0
- package/es/component/recommend-questions-card/index.d.ts +10 -0
- package/es/component/recommend-questions-card/index.d.ts.map +1 -0
- package/es/component/recommend-questions-card/index.js +104 -0
- package/es/component/recommend-questions-card/style.css +54 -0
- package/es/component/scroll-view/index.d.ts +3 -0
- package/es/component/scroll-view/index.d.ts.map +1 -0
- package/es/component/scroll-view/index.js +2 -0
- package/es/component/scroll-view/scroll-view.d.ts +18 -0
- package/es/component/scroll-view/scroll-view.d.ts.map +1 -0
- package/es/component/scroll-view/scroll-view.js +66 -0
- package/es/component/scroll-view/style.css +34 -0
- package/es/component/tab/index.d.ts +2 -0
- package/es/component/tab/index.d.ts.map +1 -0
- package/es/component/tab/index.js +18 -0
- package/es/component/tab/style.css +26 -0
- package/es/component/tips-answer/index.d.ts +15 -0
- package/es/component/tips-answer/index.d.ts.map +1 -0
- package/es/component/tips-answer/index.js +28 -0
- package/es/component/tips-answer/style.css +10 -0
- package/es/images/expire-robot.svg +16 -0
- package/es/images/pc-invalid.svg +11 -0
- package/es/images/screenshot-5.png +0 -0
- package/es/index.d.ts +92 -0
- package/es/index.d.ts.map +1 -0
- package/es/index.js +506 -0
- package/es/js/const.d.ts +41 -0
- package/es/js/const.d.ts.map +1 -0
- package/es/js/const.js +46 -0
- package/es/js/gen-render-promise.d.ts +9 -0
- package/es/js/gen-render-promise.d.ts.map +1 -0
- package/es/js/gen-render-promise.js +30 -0
- package/es/js/get-time.d.ts +15 -0
- package/es/js/get-time.d.ts.map +1 -0
- package/es/js/get-time.js +35 -0
- package/es/js/hfc-space.d.ts +16 -0
- package/es/js/hfc-space.d.ts.map +1 -0
- package/es/js/hfc-space.js +71 -0
- package/es/js/render-special.d.ts +16 -0
- package/es/js/render-special.d.ts.map +1 -0
- package/es/js/render-special.js +53 -0
- package/es/js/request/fetch.d.ts +10 -0
- package/es/js/request/fetch.d.ts.map +1 -0
- package/es/js/request/fetch.js +81 -0
- package/es/js/request/request.d.ts +3 -0
- package/es/js/request/request.d.ts.map +1 -0
- package/es/js/request/request.js +63 -0
- package/es/js/showMessage.d.ts +15 -0
- package/es/js/showMessage.d.ts.map +1 -0
- package/es/js/showMessage.js +75 -0
- package/es/js/state-immer.d.ts +3 -0
- package/es/js/state-immer.d.ts.map +1 -0
- package/es/js/state-immer.js +19 -0
- package/es/js/timer-executor.d.ts +3 -0
- package/es/js/timer-executor.d.ts.map +1 -0
- package/es/js/timer-executor.js +83 -0
- package/es/js/to-hfc.d.ts +2 -0
- package/es/js/to-hfc.d.ts.map +1 -0
- package/es/js/to-hfc.js +8 -0
- package/es/js/utils.d.ts +3 -0
- package/es/js/utils.d.ts.map +1 -0
- package/es/js/utils.js +11 -0
- package/es/jsx/chat-modal.d.ts +16 -0
- package/es/jsx/chat-modal.d.ts.map +1 -0
- package/es/jsx/chat-modal.js +268 -0
- package/es/server.d.ts +8 -0
- package/es/server.d.ts.map +1 -0
- package/es/server.js +44 -0
- package/es/style.css +174 -0
- package/lib/component/answer-itme/index.d.ts +20 -0
- package/lib/component/answer-itme/index.d.ts.map +1 -0
- package/lib/component/answer-itme/index.js +51 -0
- package/lib/component/answer-itme/style.css +35 -0
- package/lib/component/data-container/index.d.ts +19 -0
- package/lib/component/data-container/index.d.ts.map +1 -0
- package/lib/component/data-container/index.js +45 -0
- package/lib/component/data-container/style.css +26 -0
- package/lib/component/days-tab/index.d.ts +6 -0
- package/lib/component/days-tab/index.d.ts.map +1 -0
- package/lib/component/days-tab/index.js +129 -0
- package/lib/component/days-tab/style.css +43 -0
- package/lib/component/days-tab/utils.d.ts +32 -0
- package/lib/component/days-tab/utils.d.ts.map +1 -0
- package/lib/component/days-tab/utils.js +110 -0
- package/lib/component/error-boundary/index.d.ts +2 -0
- package/lib/component/error-boundary/index.d.ts.map +1 -0
- package/lib/component/error-boundary/index.js +40 -0
- package/lib/component/it-notice-modal/columns.d.ts +11 -0
- package/lib/component/it-notice-modal/columns.d.ts.map +1 -0
- package/lib/component/it-notice-modal/columns.js +116 -0
- package/lib/component/it-notice-modal/double-tab.d.ts +6 -0
- package/lib/component/it-notice-modal/double-tab.d.ts.map +1 -0
- package/lib/component/it-notice-modal/double-tab.js +104 -0
- package/lib/component/it-notice-modal/index.d.ts +6 -0
- package/lib/component/it-notice-modal/index.d.ts.map +1 -0
- package/lib/component/it-notice-modal/index.js +499 -0
- package/lib/component/it-notice-modal/server.d.ts +8 -0
- package/lib/component/it-notice-modal/server.d.ts.map +1 -0
- package/lib/component/it-notice-modal/server.js +55 -0
- package/lib/component/it-notice-modal/single-tab.d.ts +6 -0
- package/lib/component/it-notice-modal/single-tab.d.ts.map +1 -0
- package/lib/component/it-notice-modal/single-tab.js +92 -0
- package/lib/component/it-notice-modal/style.css +301 -0
- package/lib/component/it-notice-modal/utils.d.ts +2 -0
- package/lib/component/it-notice-modal/utils.d.ts.map +1 -0
- package/lib/component/it-notice-modal/utils.js +15 -0
- package/lib/component/it-notice-tab/index.d.ts +6 -0
- package/lib/component/it-notice-tab/index.d.ts.map +1 -0
- package/lib/component/it-notice-tab/index.js +216 -0
- package/lib/component/it-notice-tab/server.d.ts +3 -0
- package/lib/component/it-notice-tab/server.d.ts.map +1 -0
- package/lib/component/it-notice-tab/server.js +20 -0
- package/lib/component/it-notice-tab/style.css +103 -0
- package/lib/component/mail-list-modal/index.d.ts +2 -0
- package/lib/component/mail-list-modal/index.d.ts.map +1 -0
- package/lib/component/mail-list-modal/index.js +316 -0
- package/lib/component/mail-list-modal/server.d.ts +7 -0
- package/lib/component/mail-list-modal/server.d.ts.map +1 -0
- package/lib/component/mail-list-modal/server.js +50 -0
- package/lib/component/mail-list-modal/style.css +132 -0
- package/lib/component/myself-chat-card/index.d.ts +15 -0
- package/lib/component/myself-chat-card/index.d.ts.map +1 -0
- package/lib/component/myself-chat-card/index.js +35 -0
- package/lib/component/myself-chat-card/style.css +22 -0
- package/lib/component/need-answer/index.d.ts +15 -0
- package/lib/component/need-answer/index.d.ts.map +1 -0
- package/lib/component/need-answer/index.js +70 -0
- package/lib/component/need-answer/style.css +19 -0
- package/lib/component/opppsition-chat-card/index.d.ts +11 -0
- package/lib/component/opppsition-chat-card/index.d.ts.map +1 -0
- package/lib/component/opppsition-chat-card/index.js +35 -0
- package/lib/component/opppsition-chat-card/style.css +23 -0
- package/lib/component/question-library/index.d.ts +10 -0
- package/lib/component/question-library/index.d.ts.map +1 -0
- package/lib/component/question-library/index.js +301 -0
- package/lib/component/question-library/server.d.ts +4 -0
- package/lib/component/question-library/server.d.ts.map +1 -0
- package/lib/component/question-library/server.js +27 -0
- package/lib/component/question-library/style.css +75 -0
- package/lib/component/question-tag/index.d.ts +11 -0
- package/lib/component/question-tag/index.d.ts.map +1 -0
- package/lib/component/question-tag/index.js +33 -0
- package/lib/component/question-tag/style.css +12 -0
- package/lib/component/recommend-questions-card/index.d.ts +10 -0
- package/lib/component/recommend-questions-card/index.d.ts.map +1 -0
- package/lib/component/recommend-questions-card/index.js +114 -0
- package/lib/component/recommend-questions-card/style.css +54 -0
- package/lib/component/scroll-view/index.d.ts +3 -0
- package/lib/component/scroll-view/index.d.ts.map +1 -0
- package/lib/component/scroll-view/index.js +10 -0
- package/lib/component/scroll-view/scroll-view.d.ts +18 -0
- package/lib/component/scroll-view/scroll-view.d.ts.map +1 -0
- package/lib/component/scroll-view/scroll-view.js +76 -0
- package/lib/component/scroll-view/style.css +34 -0
- package/lib/component/tab/index.d.ts +2 -0
- package/lib/component/tab/index.d.ts.map +1 -0
- package/lib/component/tab/index.js +28 -0
- package/lib/component/tab/style.css +26 -0
- package/lib/component/tips-answer/index.d.ts +15 -0
- package/lib/component/tips-answer/index.d.ts.map +1 -0
- package/lib/component/tips-answer/index.js +38 -0
- package/lib/component/tips-answer/style.css +10 -0
- package/lib/images/expire-robot.svg +16 -0
- package/lib/images/pc-invalid.svg +11 -0
- package/lib/images/screenshot-5.png +0 -0
- package/lib/index.d.ts +92 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +516 -0
- package/lib/js/const.d.ts +41 -0
- package/lib/js/const.d.ts.map +1 -0
- package/lib/js/const.js +55 -0
- package/lib/js/gen-render-promise.d.ts +9 -0
- package/lib/js/gen-render-promise.d.ts.map +1 -0
- package/lib/js/gen-render-promise.js +37 -0
- package/lib/js/get-time.d.ts +15 -0
- package/lib/js/get-time.d.ts.map +1 -0
- package/lib/js/get-time.js +43 -0
- package/lib/js/hfc-space.d.ts +16 -0
- package/lib/js/hfc-space.d.ts.map +1 -0
- package/lib/js/hfc-space.js +91 -0
- package/lib/js/render-special.d.ts +16 -0
- package/lib/js/render-special.d.ts.map +1 -0
- package/lib/js/render-special.js +61 -0
- package/lib/js/request/fetch.d.ts +10 -0
- package/lib/js/request/fetch.d.ts.map +1 -0
- package/lib/js/request/fetch.js +88 -0
- package/lib/js/request/request.d.ts +3 -0
- package/lib/js/request/request.d.ts.map +1 -0
- package/lib/js/request/request.js +71 -0
- package/lib/js/showMessage.d.ts +15 -0
- package/lib/js/showMessage.d.ts.map +1 -0
- package/lib/js/showMessage.js +83 -0
- package/lib/js/state-immer.d.ts +3 -0
- package/lib/js/state-immer.d.ts.map +1 -0
- package/lib/js/state-immer.js +27 -0
- package/lib/js/timer-executor.d.ts +3 -0
- package/lib/js/timer-executor.d.ts.map +1 -0
- package/lib/js/timer-executor.js +91 -0
- package/lib/js/to-hfc.d.ts +2 -0
- package/lib/js/to-hfc.d.ts.map +1 -0
- package/lib/js/to-hfc.js +14 -0
- package/lib/js/utils.d.ts +3 -0
- package/lib/js/utils.d.ts.map +1 -0
- package/lib/js/utils.js +19 -0
- package/lib/jsx/chat-modal.d.ts +16 -0
- package/lib/jsx/chat-modal.d.ts.map +1 -0
- package/lib/jsx/chat-modal.js +278 -0
- package/lib/server.d.ts +8 -0
- package/lib/server.d.ts.map +1 -0
- package/lib/server.js +58 -0
- package/lib/style.css +174 -0
- package/package.json +57 -0
- package/rct.config.js +8 -0
- package/src/component/answer-itme/index.jsx +64 -0
- package/src/component/answer-itme/style.less +37 -0
- package/src/component/data-container/index.jsx +45 -0
- package/src/component/data-container/style.less +27 -0
- package/src/component/days-tab/index.jsx +114 -0
- package/src/component/days-tab/style.less +55 -0
- package/src/component/days-tab/utils.js +87 -0
- package/src/component/error-boundary/index.jsx +39 -0
- package/src/component/it-notice-modal/columns.js +102 -0
- package/src/component/it-notice-modal/double-tab.jsx +83 -0
- package/src/component/it-notice-modal/index.jsx +404 -0
- package/src/component/it-notice-modal/server.js +43 -0
- package/src/component/it-notice-modal/single-tab.jsx +70 -0
- package/src/component/it-notice-modal/style.less +367 -0
- package/src/component/it-notice-modal/utils.js +8 -0
- package/src/component/it-notice-tab/index.jsx +196 -0
- package/src/component/it-notice-tab/server.js +14 -0
- package/src/component/it-notice-tab/style.less +120 -0
- package/src/component/mail-list-modal/index.jsx +270 -0
- package/src/component/mail-list-modal/server.js +38 -0
- package/src/component/mail-list-modal/style.less +154 -0
- package/src/component/myself-chat-card/index.jsx +27 -0
- package/src/component/myself-chat-card/style.less +30 -0
- package/src/component/need-answer/index.jsx +56 -0
- package/src/component/need-answer/style.less +21 -0
- package/src/component/opppsition-chat-card/index.jsx +25 -0
- package/src/component/opppsition-chat-card/style.less +33 -0
- package/src/component/question-library/index.jsx +316 -0
- package/src/component/question-library/server.js +19 -0
- package/src/component/question-library/style.less +102 -0
- package/src/component/question-tag/index.jsx +27 -0
- package/src/component/question-tag/style.less +15 -0
- package/src/component/recommend-questions-card/index.jsx +111 -0
- package/src/component/recommend-questions-card/style.less +66 -0
- package/src/component/scroll-view/index.js +3 -0
- package/src/component/scroll-view/scroll-view.jsx +74 -0
- package/src/component/scroll-view/style.less +37 -0
- package/src/component/tab/index.jsx +17 -0
- package/src/component/tab/style.less +26 -0
- package/src/component/tips-answer/index.jsx +38 -0
- package/src/component/tips-answer/style.less +11 -0
- package/src/images/expire-robot.svg +16 -0
- package/src/images/pc-invalid.svg +11 -0
- package/src/images/screenshot-5.png +0 -0
- package/src/index.jsx +554 -0
- package/src/js/const.js +48 -0
- package/src/js/gen-render-promise.js +32 -0
- package/src/js/get-time.js +35 -0
- package/src/js/hfc-space.js +91 -0
- package/src/js/render-special.js +64 -0
- package/src/js/request/fetch.js +87 -0
- package/src/js/request/request.js +74 -0
- package/src/js/showMessage.js +81 -0
- package/src/js/state-immer.js +12 -0
- package/src/js/timer-executor.js +37 -0
- package/src/js/to-hfc.js +9 -0
- package/src/js/utils.js +13 -0
- package/src/jsx/chat-modal.jsx +254 -0
- package/src/main.js +1 -0
- package/src/server.js +45 -0
- package/src/style.less +229 -0
- package/test/cases/case-01.assert.js +6 -0
- package/test/cases/case-01.source.jsx +17 -0
- package/test/cases/case-02.assert.js +6 -0
- package/test/cases/case-02.source.jsx +25 -0
- package/test/cases/case-02.style.less +15 -0
- package/test/cases/case-03.source.jsx +69 -0
- package/test/cases/case-03.style.less +3 -0
- package/tsconfig.json +48 -0
- package/typings.d.ts +5 -0
- package/umd/b415d90208c277ba3703.png +0 -0
- package/umd/index.css +1753 -0
- package/umd/index.js +36258 -0
- package/umd/index.min.css +1 -0
- package/umd/index.min.js +657 -0
package/src/index.jsx
ADDED
|
@@ -0,0 +1,554 @@
|
|
|
1
|
+
import classNames from 'classnames'
|
|
2
|
+
import React, { PureComponent, createRef } from 'react'
|
|
3
|
+
import Proptypes from 'prop-types'
|
|
4
|
+
import { Popover } from 'shineout'
|
|
5
|
+
import Icon from '@shein-components/Icon'
|
|
6
|
+
import { format as bblFormat } from '@shein-bbl/core'
|
|
7
|
+
import * as Server from './server'
|
|
8
|
+
import ChatModal from './jsx/chat-modal'
|
|
9
|
+
import styles from './style.less'
|
|
10
|
+
import {
|
|
11
|
+
setHfcSpace, setHfcEnv, clearAll, setTokenInvalidCallback,
|
|
12
|
+
getHfcToken as hfcIsLogin, setLocalStorage, setTranslateFn,
|
|
13
|
+
} from './js/hfc-space'
|
|
14
|
+
import ErrorBoundary from './component/error-boundary'
|
|
15
|
+
import { openITNoticeModal } from './component/it-notice-modal'
|
|
16
|
+
|
|
17
|
+
const defaultSate = {
|
|
18
|
+
isHover: false,
|
|
19
|
+
isMoving: false,
|
|
20
|
+
bottom: 12,
|
|
21
|
+
right: 32,
|
|
22
|
+
modalVisible: false,
|
|
23
|
+
|
|
24
|
+
// 记录按下去的时间戳
|
|
25
|
+
mouseDownTime: 0,
|
|
26
|
+
|
|
27
|
+
messageCount: 0,
|
|
28
|
+
|
|
29
|
+
isCollapse: false,
|
|
30
|
+
showExpirePopover: false,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @cn 帮助中心机器人组件
|
|
36
|
+
* @desc 帮助中心机器人组件,不需要安装,不能直接使用,@shein-components/hfc-robot 内部调用,安装 @shein-components/hfc-robot 即可使用
|
|
37
|
+
* @author -
|
|
38
|
+
*/
|
|
39
|
+
class SystemRobotAssistant extends PureComponent {
|
|
40
|
+
constructor(props) {
|
|
41
|
+
super(props)
|
|
42
|
+
setHfcSpace(props.hfcSpace)
|
|
43
|
+
setHfcEnv(props.env)
|
|
44
|
+
this.state = defaultSate
|
|
45
|
+
this.iconRef = createRef()
|
|
46
|
+
this.modalRef = createRef()
|
|
47
|
+
this.popoverTimerRef = createRef()
|
|
48
|
+
|
|
49
|
+
this.handleInit = this.handleInit.bind(this)
|
|
50
|
+
this.setMoving = this.setMoving.bind(this)
|
|
51
|
+
this.onMouseDown = this.onMouseDown.bind(this)
|
|
52
|
+
this.onMouseUp = this.onMouseUp.bind(this)
|
|
53
|
+
this.handleTokenInvalid = this.handleTokenInvalid.bind(this)
|
|
54
|
+
this.setModalVisible = this.setModalVisible.bind(this)
|
|
55
|
+
this.closeVisible = this.closeVisible.bind(this)
|
|
56
|
+
this.adjustIconPosition = this.adjustIconPosition.bind(this)
|
|
57
|
+
this.addMoveListener = this.addMoveListener.bind(this)
|
|
58
|
+
this.mouseupListener = this.mouseupListener.bind(this)
|
|
59
|
+
this.getRenderIcon = this.getRenderIcon.bind(this)
|
|
60
|
+
this.isPopITInform = this.isPopITInform.bind(this)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
componentDidMount() {
|
|
64
|
+
const {
|
|
65
|
+
bottom, right, draggable, isLogin, t, hfcSpace, lang,
|
|
66
|
+
} = this.props
|
|
67
|
+
setTranslateFn(t)
|
|
68
|
+
setLocalStorage({
|
|
69
|
+
[`${hfcSpace}-lang`]: lang || 'CN',
|
|
70
|
+
})
|
|
71
|
+
window.addEventListener('mouseup', this.mouseupListener)
|
|
72
|
+
// draggable 为 true 时,才处理图标位置
|
|
73
|
+
if (draggable) {
|
|
74
|
+
window.addEventListener('mousedown', this.addMoveListener)
|
|
75
|
+
}
|
|
76
|
+
if (isLogin) {
|
|
77
|
+
this.handleInit()
|
|
78
|
+
}
|
|
79
|
+
// 登录失效的回调
|
|
80
|
+
setTokenInvalidCallback(this.handleTokenInvalid)
|
|
81
|
+
this.setState({
|
|
82
|
+
bottom,
|
|
83
|
+
right,
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
componentDidUpdate(prevProps, prevState) {
|
|
88
|
+
const { draggable, isLogin, t, hfcSpace, lang } = this.props
|
|
89
|
+
const { isCollapse } = this.state
|
|
90
|
+
// draggable 为 true 时,才处理图标位置
|
|
91
|
+
if (draggable && !isCollapse && isCollapse !== prevState.isCollapse) {
|
|
92
|
+
// 如果当前 icon 在临界点时,不让图标超出外面
|
|
93
|
+
this.adjustIconPosition()
|
|
94
|
+
}
|
|
95
|
+
if (isLogin !== prevProps.isLogin && isLogin) {
|
|
96
|
+
this.handleInit()
|
|
97
|
+
}
|
|
98
|
+
if (t !== prevProps.t || hfcSpace !== prevProps.hfcSpace || lang !== prevProps.lang) {
|
|
99
|
+
setTranslateFn(t)
|
|
100
|
+
setLocalStorage({
|
|
101
|
+
[`${hfcSpace}-lang`]: lang || 'CN',
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
setTokenInvalidCallback(this.handleTokenInvalid)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
componentWillUnmount() {
|
|
108
|
+
clearAll()
|
|
109
|
+
clearInterval(this.timer)
|
|
110
|
+
const { draggable } = this.props
|
|
111
|
+
if (draggable) {
|
|
112
|
+
window.removeEventListener('mousedown', this.addMoveListener)
|
|
113
|
+
}
|
|
114
|
+
window.removeEventListener('mouseup', this.mouseupListener)
|
|
115
|
+
this.timer = null
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
onMouseDown() {
|
|
119
|
+
this.setState({
|
|
120
|
+
isMoving: true,
|
|
121
|
+
mouseDownTime: new Date().getTime(),
|
|
122
|
+
})
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
onMouseUp() {
|
|
126
|
+
this.setState({
|
|
127
|
+
isMoving: false,
|
|
128
|
+
})
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
setMoving(e) {
|
|
132
|
+
const {
|
|
133
|
+
isMoving,
|
|
134
|
+
} = this.state
|
|
135
|
+
if (!isMoving) return
|
|
136
|
+
e.preventDefault()
|
|
137
|
+
const {
|
|
138
|
+
right, bottom,
|
|
139
|
+
} = this.state
|
|
140
|
+
|
|
141
|
+
const {
|
|
142
|
+
movementX,
|
|
143
|
+
movementY,
|
|
144
|
+
} = e
|
|
145
|
+
const { width, height } = this.iconRef.current.getBoundingClientRect()
|
|
146
|
+
const rightBound = window.innerWidth - width
|
|
147
|
+
const topBound = window.innerHeight - height
|
|
148
|
+
|
|
149
|
+
let x = 0
|
|
150
|
+
if (right - movementX >= window.innerWidth) {
|
|
151
|
+
x = window.innerWidth
|
|
152
|
+
} else {
|
|
153
|
+
x = right - movementX
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
let y = 0
|
|
157
|
+
if (bottom - movementY >= window.innerHeight) {
|
|
158
|
+
y = window.innerHeight
|
|
159
|
+
} else {
|
|
160
|
+
y = bottom - movementY
|
|
161
|
+
}
|
|
162
|
+
// 当前图标超出边界
|
|
163
|
+
if (x < 0 || x > rightBound || y < 0 || y > topBound) {
|
|
164
|
+
this.setState({
|
|
165
|
+
isCollapse: true,
|
|
166
|
+
modalVisible: false,
|
|
167
|
+
})
|
|
168
|
+
return
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
this.setState({
|
|
172
|
+
right: x,
|
|
173
|
+
bottom: y,
|
|
174
|
+
})
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
setHover(bool) {
|
|
178
|
+
this.setState({
|
|
179
|
+
isHover: bool,
|
|
180
|
+
})
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
setModalVisible() {
|
|
185
|
+
const {
|
|
186
|
+
modalVisible, mouseDownTime,
|
|
187
|
+
} = this.state
|
|
188
|
+
const { isLogin } = this.props
|
|
189
|
+
const { draggable } = this.props
|
|
190
|
+
if (!isLogin) return
|
|
191
|
+
// 大于 170 豪秒就不要处理点击事件且 draggable 为 true 时,不处理
|
|
192
|
+
if (draggable && (new Date().getTime() - mouseDownTime) > 170) return
|
|
193
|
+
|
|
194
|
+
this.setState({
|
|
195
|
+
modalVisible: !modalVisible,
|
|
196
|
+
messageCount: 0,
|
|
197
|
+
})
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
getRenderIcon() {
|
|
201
|
+
const { renderIcon } = this.props
|
|
202
|
+
const { isLogin } = this.props
|
|
203
|
+
if (typeof renderIcon === 'function') {
|
|
204
|
+
return renderIcon(isLogin)
|
|
205
|
+
}
|
|
206
|
+
return renderIcon
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
mouseupListener(e) {
|
|
210
|
+
if (!this?.modalRef?.current?.contains(e.target)
|
|
211
|
+
&& !this?.iconRef?.current?.contains(e.target)) {
|
|
212
|
+
this.setState({
|
|
213
|
+
modalVisible: false,
|
|
214
|
+
})
|
|
215
|
+
}
|
|
216
|
+
const { draggable } = this.props
|
|
217
|
+
// draggable 为 false 时,不处理
|
|
218
|
+
if (!draggable) return
|
|
219
|
+
this.setState({
|
|
220
|
+
isMoving: false,
|
|
221
|
+
})
|
|
222
|
+
document.body.removeEventListener('mousemove', this.setMoving)
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
addMoveListener() {
|
|
226
|
+
document.body.addEventListener('mousemove', this.setMoving)
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
handleTokenInvalid(argument) {
|
|
231
|
+
const { bottom, right, expireTipUse } = this.props
|
|
232
|
+
// 登录失效要关掉窗口
|
|
233
|
+
this.setState({
|
|
234
|
+
...defaultSate,
|
|
235
|
+
modalVisible: false,
|
|
236
|
+
bottom,
|
|
237
|
+
right,
|
|
238
|
+
}, () => {
|
|
239
|
+
if (expireTipUse) {
|
|
240
|
+
this.setState({
|
|
241
|
+
showExpirePopover: true,
|
|
242
|
+
})
|
|
243
|
+
}
|
|
244
|
+
})
|
|
245
|
+
if (expireTipUse) {
|
|
246
|
+
// eslint-disable-next-line no-unused-expressions
|
|
247
|
+
this.popoverTimerRef && clearTimeout(this.popoverTimerRef)
|
|
248
|
+
this.popoverTimerRef = setTimeout(() => {
|
|
249
|
+
this.setState({
|
|
250
|
+
showExpirePopover: false,
|
|
251
|
+
})
|
|
252
|
+
}, 15000)
|
|
253
|
+
}
|
|
254
|
+
const { tokenInvalidCallback } = this.props
|
|
255
|
+
tokenInvalidCallback(argument)
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
closeVisible() {
|
|
259
|
+
this.setState({
|
|
260
|
+
modalVisible: false,
|
|
261
|
+
})
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
handleInit() {
|
|
265
|
+
this.setState({
|
|
266
|
+
showExpirePopover: false,
|
|
267
|
+
})
|
|
268
|
+
this.statisticsMessageCount()
|
|
269
|
+
this.isPopITInform()
|
|
270
|
+
clearInterval(this.timer)
|
|
271
|
+
this.timer = setInterval(() => {
|
|
272
|
+
this.statisticsMessageCount()
|
|
273
|
+
}, 1000 * 60 * 10)
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
statisticsMessageCount() {
|
|
277
|
+
const { isLogin } = this.props
|
|
278
|
+
if (!isLogin) return
|
|
279
|
+
Server.statisticsMessageCount()
|
|
280
|
+
.then((res) => {
|
|
281
|
+
if (res) {
|
|
282
|
+
this.setState({
|
|
283
|
+
messageCount: res.info && res.info.messageCount,
|
|
284
|
+
})
|
|
285
|
+
}
|
|
286
|
+
})
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// 校正大图标的位置
|
|
290
|
+
adjustIconPosition() {
|
|
291
|
+
const {
|
|
292
|
+
width, height, top, left, right: iconRight, bottom: iconBottom,
|
|
293
|
+
} = this.iconRef.current.getBoundingClientRect()
|
|
294
|
+
const { bottom, right } = this.state
|
|
295
|
+
let x = right
|
|
296
|
+
let y = bottom
|
|
297
|
+
if (top < 0) {
|
|
298
|
+
y = window.innerHeight - height
|
|
299
|
+
} else if (iconBottom < 0) {
|
|
300
|
+
y = 0
|
|
301
|
+
}
|
|
302
|
+
if (left < 0) {
|
|
303
|
+
x = window.innerWidth - width
|
|
304
|
+
} else if (iconRight < 0) {
|
|
305
|
+
x = 0
|
|
306
|
+
}
|
|
307
|
+
this.setState({
|
|
308
|
+
right: x,
|
|
309
|
+
bottom: y,
|
|
310
|
+
})
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// eslint-disable-next-line class-methods-use-this
|
|
314
|
+
async isPopITInform() {
|
|
315
|
+
const { zIndex, t } = this.props
|
|
316
|
+
const res = await Server.isPopITInform()
|
|
317
|
+
if (res?.info) {
|
|
318
|
+
openITNoticeModal({
|
|
319
|
+
zIndex,
|
|
320
|
+
t,
|
|
321
|
+
})
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
render() {
|
|
327
|
+
const {
|
|
328
|
+
isHover, bottom, right, modalVisible,
|
|
329
|
+
messageCount, isCollapse, showExpirePopover,
|
|
330
|
+
} = this.state
|
|
331
|
+
|
|
332
|
+
const {
|
|
333
|
+
zIndex,
|
|
334
|
+
iconWrapperClassName,
|
|
335
|
+
iconClassName,
|
|
336
|
+
textClassName,
|
|
337
|
+
renderIcon,
|
|
338
|
+
draggable,
|
|
339
|
+
nodeIdList,
|
|
340
|
+
isLogin,
|
|
341
|
+
t,
|
|
342
|
+
} = this.props
|
|
343
|
+
|
|
344
|
+
const actualRenderIcon = renderIcon ? React.cloneElement(this.getRenderIcon(renderIcon), {
|
|
345
|
+
onClick: this.setModalVisible,
|
|
346
|
+
...(draggable ? {
|
|
347
|
+
onMouseDown: this.onMouseDown,
|
|
348
|
+
onMouseUp: this.onMouseUp,
|
|
349
|
+
} : {}),
|
|
350
|
+
}) : null
|
|
351
|
+
|
|
352
|
+
return (
|
|
353
|
+
<ErrorBoundary>
|
|
354
|
+
{
|
|
355
|
+
'renderIcon' in this.props ? (
|
|
356
|
+
<div
|
|
357
|
+
className={
|
|
358
|
+
classNames(
|
|
359
|
+
styles.renderIconWrapper, draggable && styles.draggableIcon, iconWrapperClassName,
|
|
360
|
+
)
|
|
361
|
+
}
|
|
362
|
+
style={{
|
|
363
|
+
zIndex,
|
|
364
|
+
bottom,
|
|
365
|
+
right,
|
|
366
|
+
}}
|
|
367
|
+
>
|
|
368
|
+
<div
|
|
369
|
+
ref={this.iconRef}
|
|
370
|
+
>
|
|
371
|
+
{actualRenderIcon}
|
|
372
|
+
</div>
|
|
373
|
+
{
|
|
374
|
+
messageCount && isLogin ? (
|
|
375
|
+
<div
|
|
376
|
+
className={styles.redDot}
|
|
377
|
+
>
|
|
378
|
+
{messageCount}
|
|
379
|
+
</div>
|
|
380
|
+
) : null
|
|
381
|
+
}
|
|
382
|
+
</div>
|
|
383
|
+
) : (
|
|
384
|
+
<div
|
|
385
|
+
className={
|
|
386
|
+
classNames(
|
|
387
|
+
styles.iconWrapper,
|
|
388
|
+
isCollapse && styles.collapseRobotBox,
|
|
389
|
+
iconWrapperClassName,
|
|
390
|
+
)
|
|
391
|
+
}
|
|
392
|
+
style={{
|
|
393
|
+
bottom,
|
|
394
|
+
right,
|
|
395
|
+
zIndex,
|
|
396
|
+
}}
|
|
397
|
+
ref={this.iconRef}
|
|
398
|
+
onMouseDown={draggable ? this.onMouseDown : undefined}
|
|
399
|
+
onMouseUp={draggable ? this.onMouseUp : undefined}
|
|
400
|
+
onClick={this.setModalVisible}
|
|
401
|
+
>
|
|
402
|
+
<Popover
|
|
403
|
+
zIndex={zIndex}
|
|
404
|
+
visible={showExpirePopover}
|
|
405
|
+
>
|
|
406
|
+
{t('有事找 TA 登陆已失效,请刷新页面重试')}
|
|
407
|
+
</Popover>
|
|
408
|
+
{
|
|
409
|
+
!isCollapse ? (
|
|
410
|
+
<div className={classNames(styles.avatarWrap)}>
|
|
411
|
+
<div
|
|
412
|
+
className={classNames(styles.avatarBorder, isHover && styles.hover)}
|
|
413
|
+
onMouseOver={() => {
|
|
414
|
+
this.setHover(true)
|
|
415
|
+
}}
|
|
416
|
+
onMouseOut={() => {
|
|
417
|
+
this.setHover(false)
|
|
418
|
+
}}
|
|
419
|
+
>
|
|
420
|
+
<div
|
|
421
|
+
className={
|
|
422
|
+
classNames(
|
|
423
|
+
styles.robotImg, !isLogin && styles.expireStatus, iconClassName,
|
|
424
|
+
)
|
|
425
|
+
}
|
|
426
|
+
/>
|
|
427
|
+
</div>
|
|
428
|
+
<span className={classNames(styles.switch, textClassName)}>{modalVisible ? t('戳我关闭') : t('有事找TA')}</span>
|
|
429
|
+
</div>
|
|
430
|
+
) : (
|
|
431
|
+
<Icon
|
|
432
|
+
className={styles.collapseIcon}
|
|
433
|
+
name="round-arrow-right"
|
|
434
|
+
onClick={(e) => {
|
|
435
|
+
e.stopPropagation()
|
|
436
|
+
e.preventDefault()
|
|
437
|
+
this.setState({
|
|
438
|
+
isCollapse: !isCollapse,
|
|
439
|
+
})
|
|
440
|
+
}}
|
|
441
|
+
/>
|
|
442
|
+
)
|
|
443
|
+
}
|
|
444
|
+
{
|
|
445
|
+
messageCount && isLogin ? (
|
|
446
|
+
<div
|
|
447
|
+
className={styles.redDot}
|
|
448
|
+
>
|
|
449
|
+
{messageCount}
|
|
450
|
+
</div>
|
|
451
|
+
) : null
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
</div>
|
|
455
|
+
)
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
{
|
|
459
|
+
modalVisible ? (
|
|
460
|
+
<ChatModal
|
|
461
|
+
modalRef={this.modalRef}
|
|
462
|
+
iconRef={this.iconRef?.current}
|
|
463
|
+
onClose={this.closeVisible}
|
|
464
|
+
nodeIdList={nodeIdList}
|
|
465
|
+
{...this.props}
|
|
466
|
+
/>
|
|
467
|
+
) : null
|
|
468
|
+
}
|
|
469
|
+
</ErrorBoundary>
|
|
470
|
+
|
|
471
|
+
)
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
SystemRobotAssistant.defaultProps = {
|
|
476
|
+
tokenInvalidCallback: () => null,
|
|
477
|
+
zIndex: 100,
|
|
478
|
+
iconWrapperClassName: '',
|
|
479
|
+
iconClassName: '',
|
|
480
|
+
textClassName: '',
|
|
481
|
+
spinSize: 40,
|
|
482
|
+
bottom: 12,
|
|
483
|
+
right: 32,
|
|
484
|
+
draggable: true,
|
|
485
|
+
expireTipUse: true,
|
|
486
|
+
chatgptUse: true,
|
|
487
|
+
lang: 'CN',
|
|
488
|
+
t: bblFormat,
|
|
489
|
+
}
|
|
490
|
+
SystemRobotAssistant.propTypes = {
|
|
491
|
+
/** 系统 code,跟后端要或者在帮助中心后台端的系统配置页面查看 */
|
|
492
|
+
hfcSpace: Proptypes.string.isRequired,
|
|
493
|
+
/** 开发环境 可选 'dev'|'test'|'sit'|'online' */
|
|
494
|
+
env: Proptypes.string.isRequired,
|
|
495
|
+
/** 菜单栏名称 */
|
|
496
|
+
menusTitle: Proptypes.string,
|
|
497
|
+
/** 层级,默认 100 */
|
|
498
|
+
zIndex: Proptypes.number,
|
|
499
|
+
/** 帮助中心登录失效回调 */
|
|
500
|
+
tokenInvalidCallback: Proptypes.func,
|
|
501
|
+
|
|
502
|
+
/** 企微唤醒前置判断 */
|
|
503
|
+
checkBeforeCallWechat: Proptypes.func,
|
|
504
|
+
|
|
505
|
+
/** 最外层样式 */
|
|
506
|
+
iconWrapperClassName: Proptypes.string,
|
|
507
|
+
|
|
508
|
+
/** icon 样式 */
|
|
509
|
+
iconClassName: Proptypes.string,
|
|
510
|
+
|
|
511
|
+
/** 文字样式 */
|
|
512
|
+
textClassName: Proptypes.string,
|
|
513
|
+
|
|
514
|
+
/** 加载中的 spin 大小 -- 2.3.0 后废弃 */
|
|
515
|
+
spinSize: Proptypes.number,
|
|
516
|
+
|
|
517
|
+
/** 位置,right */
|
|
518
|
+
right: Proptypes.number,
|
|
519
|
+
|
|
520
|
+
/** 位置,bottom */
|
|
521
|
+
bottom: Proptypes.number,
|
|
522
|
+
|
|
523
|
+
/** 自定义 icon */
|
|
524
|
+
renderIcon: Proptypes.oneOfType([Proptypes.element, Proptypes.func]),
|
|
525
|
+
|
|
526
|
+
/** 是否可移动 */
|
|
527
|
+
draggable: Proptypes.bool,
|
|
528
|
+
|
|
529
|
+
/** 是否显示过期提示 */
|
|
530
|
+
expireTipUse: Proptypes.bool,
|
|
531
|
+
|
|
532
|
+
/** 是否使用 chatgpt */
|
|
533
|
+
chatgptUse: Proptypes.bool,
|
|
534
|
+
|
|
535
|
+
/** 分组 id 列表 */
|
|
536
|
+
nodeIdList: Proptypes.arrayOf(Proptypes.string),
|
|
537
|
+
|
|
538
|
+
/** 是否登录 */
|
|
539
|
+
isLogin: Proptypes.bool,
|
|
540
|
+
|
|
541
|
+
/** 多语言翻译函数 */
|
|
542
|
+
t: Proptypes.func,
|
|
543
|
+
|
|
544
|
+
/** 多语言 */
|
|
545
|
+
lang: Proptypes.string,
|
|
546
|
+
}
|
|
547
|
+
SystemRobotAssistant.hfcIsLogin = hfcIsLogin
|
|
548
|
+
|
|
549
|
+
// 暴露到 window, HFC Bot 组件会用到
|
|
550
|
+
window.SystemRobotAssistant = {
|
|
551
|
+
default: SystemRobotAssistant,
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
export default SystemRobotAssistant
|
package/src/js/const.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export const contentType = {
|
|
2
|
+
OPPOSITION: 2, // 对方的回答
|
|
3
|
+
MYSELF: 1, // 自己的问题
|
|
4
|
+
|
|
5
|
+
TIPS: 3, // 说明更新了
|
|
6
|
+
|
|
7
|
+
NEEDANSWER: 4, // 需要更新
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// 不用包t了
|
|
11
|
+
export const TIPS = {
|
|
12
|
+
globalCount: {
|
|
13
|
+
content: 'SHEIN标准与规范',
|
|
14
|
+
link: '/direction',
|
|
15
|
+
},
|
|
16
|
+
guideCount: {
|
|
17
|
+
content: '新手指南',
|
|
18
|
+
link: '/guide',
|
|
19
|
+
},
|
|
20
|
+
problemCount: {
|
|
21
|
+
content: '问题库',
|
|
22
|
+
link: '/question/list',
|
|
23
|
+
},
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// 不用包t了
|
|
27
|
+
export const TABS = [
|
|
28
|
+
{
|
|
29
|
+
label: '问题库',
|
|
30
|
+
value: 1,
|
|
31
|
+
icon: 'problem-base',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
label: '对接人',
|
|
35
|
+
value: 2,
|
|
36
|
+
icon: 'qiyeweixin',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
label: '系统报障',
|
|
40
|
+
value: 3,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
label: '版本计划',
|
|
44
|
+
value: 4,
|
|
45
|
+
icon: 'pc-notice',
|
|
46
|
+
popoverContent: '版本计划展示产研未来两周的上线计划(含今日)',
|
|
47
|
+
},
|
|
48
|
+
]
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import Render from './render-special'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param {ReactNode} InnerComponent
|
|
7
|
+
* @param {String} name
|
|
8
|
+
* @returns {Promise}
|
|
9
|
+
*/
|
|
10
|
+
const genRenderPromise = (InnerComponent, name, useHistory) => (record = {}) => {
|
|
11
|
+
let render = new Render(name, useHistory)
|
|
12
|
+
return new Promise((resolve, reject) => {
|
|
13
|
+
const el = (
|
|
14
|
+
<InnerComponent
|
|
15
|
+
{...record}
|
|
16
|
+
onOk={(res) => {
|
|
17
|
+
render.unmountComponentAtNode()
|
|
18
|
+
render = null
|
|
19
|
+
resolve(res)
|
|
20
|
+
}}
|
|
21
|
+
onClose={(rej) => {
|
|
22
|
+
render.unmountComponentAtNode()
|
|
23
|
+
render = null
|
|
24
|
+
reject(rej)
|
|
25
|
+
}}
|
|
26
|
+
/>
|
|
27
|
+
)
|
|
28
|
+
render.render(el)
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default genRenderPromise
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export default function getNow() {
|
|
2
|
+
const now = new Date()
|
|
3
|
+
let h = now.getHours()
|
|
4
|
+
h = h < 10 ? `0${h}` : h
|
|
5
|
+
let m = now.getMinutes()
|
|
6
|
+
m = m < 10 ? `0${m}` : m
|
|
7
|
+
return `${h}:${m}`
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 获取指定时间的前几天或者后几天
|
|
12
|
+
* @param date 时间 2012-12-12
|
|
13
|
+
* @param day 前几天 如2 或者后几天 如-2
|
|
14
|
+
* @returns {String} 如2012-12-10
|
|
15
|
+
*/
|
|
16
|
+
export function getNextOrPreDate(date, day) {
|
|
17
|
+
const dd = new Date(date)
|
|
18
|
+
dd.setDate(dd.getDate() + day)
|
|
19
|
+
const y = dd.getFullYear()
|
|
20
|
+
const m = dd.getMonth() + 1 < 10 ? `0${dd.getMonth() + 1}` : dd.getMonth() + 1
|
|
21
|
+
const d = dd.getDate() < 10 ? `0${dd.getDate()}` : dd.getDate()
|
|
22
|
+
return `${y}-${m}-${d}`
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 获取指定时间的当周的周一和周日
|
|
27
|
+
* @param date 时间 2012-12-12
|
|
28
|
+
* @returns {Array} [2012-12-09,2012-12-15]
|
|
29
|
+
*/
|
|
30
|
+
export function getWeekByDate(date) {
|
|
31
|
+
const dt = new Date(date).getDay() === 0 ? 7 : new Date(date).getDay()
|
|
32
|
+
const pre = getNextOrPreDate(date, -dt + 1)
|
|
33
|
+
const next = getNextOrPreDate(date, 7 - dt)
|
|
34
|
+
return [pre, next]
|
|
35
|
+
}
|