Upload 120 files
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .dockerignore +1 -0
- .eslintrc.js +45 -0
- .gitattributes +1 -0
- .gitignore +1 -0
- .ignore +3 -0
- Dockerfile +32 -0
- LICENSE +21 -0
- client/.gitignore +1 -0
- client/.ignore +1 -0
- client/README.md +1 -0
- client/build/index.bundle.js +0 -0
- client/build/main.css +1095 -0
- client/config/loaders.js +54 -0
- client/config/paths.js +88 -0
- client/config/webpack.config.dev.js +60 -0
- client/config/webpack.config.prod.js +43 -0
- client/package-lock.json +0 -0
- client/package.json +71 -0
- client/public/index.html +11 -0
- client/scripts/build.js +192 -0
- client/scripts/start.js +115 -0
- client/scripts/test.js +51 -0
- client/src/FileChunker.js +39 -0
- client/src/Peer.js +233 -0
- client/src/actions/configureWS.js +23 -0
- client/src/actions/feedback.js +12 -0
- client/src/actions/file.js +28 -0
- client/src/actions/user.js +17 -0
- client/src/common/actionTypes.js +5 -0
- client/src/common/global.css +12 -0
- client/src/common/util.js +3 -0
- client/src/components/App.cm.styl +0 -0
- client/src/components/App.css +22 -0
- client/src/components/App.js +86 -0
- client/src/components/CommonPanel.cm.styl +0 -0
- client/src/components/CommonPanel.js +25 -0
- client/src/components/ContactPanel.cm.styl +38 -0
- client/src/components/ContactPanel.js +92 -0
- client/src/components/FileBox.cm.styl +57 -0
- client/src/components/FileBox.js +80 -0
- client/src/components/Footer.cm.styl +15 -0
- client/src/components/Footer.js +22 -0
- client/src/components/NavBar.cm.styl +79 -0
- client/src/components/NavBar.js +65 -0
- client/src/components/RecvFileModal.cm.styl +27 -0
- client/src/components/RecvFileModal.js +206 -0
- client/src/components/RecvFilePanel.cm.styl +58 -0
- client/src/components/RecvFilePanel.js +288 -0
- client/src/components/SendFileModal.cm.styl +56 -0
- client/src/components/SendFileModal.js +386 -0
.dockerignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
**/node_modules
|
.eslintrc.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
module.exports = {
|
| 2 |
+
env: {
|
| 3 |
+
browser: true,
|
| 4 |
+
es6: true
|
| 5 |
+
},
|
| 6 |
+
extends: [
|
| 7 |
+
"eslint:recommended",
|
| 8 |
+
'plugin:react/recommended',
|
| 9 |
+
'standard',
|
| 10 |
+
],
|
| 11 |
+
globals: {
|
| 12 |
+
Atomics: 'readonly',
|
| 13 |
+
SharedArrayBuffer: 'readonly'
|
| 14 |
+
},
|
| 15 |
+
parserOptions: {
|
| 16 |
+
ecmaFeatures: {
|
| 17 |
+
jsx: true
|
| 18 |
+
},
|
| 19 |
+
ecmaVersion: 2018,
|
| 20 |
+
sourceType: 'module'
|
| 21 |
+
},
|
| 22 |
+
settings: {
|
| 23 |
+
react: {
|
| 24 |
+
version: "detect",
|
| 25 |
+
},
|
| 26 |
+
},
|
| 27 |
+
plugins: [
|
| 28 |
+
'react'
|
| 29 |
+
],
|
| 30 |
+
rules: {
|
| 31 |
+
semi: ["error", "always"],
|
| 32 |
+
"comma-dangle": ["error", {
|
| 33 |
+
"arrays": "always-multiline",
|
| 34 |
+
"objects": "always-multiline",
|
| 35 |
+
"imports": "always-multiline",
|
| 36 |
+
"exports": "always-multiline",
|
| 37 |
+
"functions": "always-multiline",
|
| 38 |
+
}],
|
| 39 |
+
indent: ['error', 2, {
|
| 40 |
+
MemberExpression: 'off',
|
| 41 |
+
SwitchCase: 1,
|
| 42 |
+
}],
|
| 43 |
+
"space-before-function-paren": ["error", "never"],
|
| 44 |
+
},
|
| 45 |
+
}
|
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
server/public/images/favicon.ico filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
node_modules
|
.ignore
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
yarn.lock
|
| 2 |
+
node_modules
|
| 3 |
+
client/build
|
Dockerfile
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM node:16
|
| 2 |
+
|
| 3 |
+
WORKDIR /tmp
|
| 4 |
+
|
| 5 |
+
RUN sed -i 's/deb.debian.org/mirrors.163.com/g' /etc/apt/sources.list \
|
| 6 |
+
# && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
|
| 7 |
+
# && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
|
| 8 |
+
&& apt-get update \
|
| 9 |
+
&& apt-get install -y --no-install-recommends apt-utils \
|
| 10 |
+
&& apt-get install -y \
|
| 11 |
+
wget gnupg fonts-noto-cjk libxss1 \
|
| 12 |
+
fonts-liberation libasound2 libatk-bridge2.0-0 libatspi2.0-0 libdrm2 \
|
| 13 |
+
libgbm1 libgtk-3-0 libnspr4 libnss3 libx11-xcb1 libxkbcommon0 xdg-utils \
|
| 14 |
+
libu2f-udev libvulkan1 \
|
| 15 |
+
--no-install-recommends \
|
| 16 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 17 |
+
|
| 18 |
+
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
|
| 19 |
+
RUN apt-get install ./google-chrome-stable_current_amd64.deb
|
| 20 |
+
|
| 21 |
+
WORKDIR /app
|
| 22 |
+
|
| 23 |
+
COPY server/package.json ./
|
| 24 |
+
COPY server/yarn.lock ./
|
| 25 |
+
|
| 26 |
+
RUN yarn
|
| 27 |
+
|
| 28 |
+
COPY ./server ./
|
| 29 |
+
COPY ./client/build/*.js ./public/static/js/
|
| 30 |
+
COPY ./client/build/*.css ./public/static/css/
|
| 31 |
+
|
| 32 |
+
ENTRYPOINT ["node", "src/index.js"]
|
LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2021 fanchangyong
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
client/.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
node_modules
|
client/.ignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
build
|
client/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
# react-starter-kit
|
client/build/index.bundle.js
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
client/build/main.css
ADDED
|
@@ -0,0 +1,1095 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
|
| 2 |
+
|
| 3 |
+
/* Document
|
| 4 |
+
========================================================================== */
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
* 1. Correct the line height in all browsers.
|
| 8 |
+
* 2. Prevent adjustments of font size after orientation changes in iOS.
|
| 9 |
+
*/
|
| 10 |
+
|
| 11 |
+
html {
|
| 12 |
+
line-height: 1.15; /* 1 */
|
| 13 |
+
-webkit-text-size-adjust: 100%; /* 2 */
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
/* Sections
|
| 17 |
+
========================================================================== */
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* Remove the margin in all browsers.
|
| 21 |
+
*/
|
| 22 |
+
|
| 23 |
+
body {
|
| 24 |
+
margin: 0;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Render the `main` element consistently in IE.
|
| 29 |
+
*/
|
| 30 |
+
|
| 31 |
+
main {
|
| 32 |
+
display: block;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
/**
|
| 36 |
+
* Correct the font size and margin on `h1` elements within `section` and
|
| 37 |
+
* `article` contexts in Chrome, Firefox, and Safari.
|
| 38 |
+
*/
|
| 39 |
+
|
| 40 |
+
h1 {
|
| 41 |
+
font-size: 2em;
|
| 42 |
+
margin: 0.67em 0;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
/* Grouping content
|
| 46 |
+
========================================================================== */
|
| 47 |
+
|
| 48 |
+
/**
|
| 49 |
+
* 1. Add the correct box sizing in Firefox.
|
| 50 |
+
* 2. Show the overflow in Edge and IE.
|
| 51 |
+
*/
|
| 52 |
+
|
| 53 |
+
hr {
|
| 54 |
+
box-sizing: content-box; /* 1 */
|
| 55 |
+
height: 0; /* 1 */
|
| 56 |
+
overflow: visible; /* 2 */
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
/**
|
| 60 |
+
* 1. Correct the inheritance and scaling of font size in all browsers.
|
| 61 |
+
* 2. Correct the odd `em` font sizing in all browsers.
|
| 62 |
+
*/
|
| 63 |
+
|
| 64 |
+
pre {
|
| 65 |
+
font-family: monospace, monospace; /* 1 */
|
| 66 |
+
font-size: 1em; /* 2 */
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
/* Text-level semantics
|
| 70 |
+
========================================================================== */
|
| 71 |
+
|
| 72 |
+
/**
|
| 73 |
+
* Remove the gray background on active links in IE 10.
|
| 74 |
+
*/
|
| 75 |
+
|
| 76 |
+
a {
|
| 77 |
+
background-color: transparent;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
/**
|
| 81 |
+
* 1. Remove the bottom border in Chrome 57-
|
| 82 |
+
* 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
|
| 83 |
+
*/
|
| 84 |
+
|
| 85 |
+
abbr[title] {
|
| 86 |
+
border-bottom: none; /* 1 */
|
| 87 |
+
text-decoration: underline; /* 2 */
|
| 88 |
+
-webkit-text-decoration: underline dotted;
|
| 89 |
+
text-decoration: underline dotted; /* 2 */
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
/**
|
| 93 |
+
* Add the correct font weight in Chrome, Edge, and Safari.
|
| 94 |
+
*/
|
| 95 |
+
|
| 96 |
+
b,
|
| 97 |
+
strong {
|
| 98 |
+
font-weight: bolder;
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
/**
|
| 102 |
+
* 1. Correct the inheritance and scaling of font size in all browsers.
|
| 103 |
+
* 2. Correct the odd `em` font sizing in all browsers.
|
| 104 |
+
*/
|
| 105 |
+
|
| 106 |
+
code,
|
| 107 |
+
kbd,
|
| 108 |
+
samp {
|
| 109 |
+
font-family: monospace, monospace; /* 1 */
|
| 110 |
+
font-size: 1em; /* 2 */
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
/**
|
| 114 |
+
* Add the correct font size in all browsers.
|
| 115 |
+
*/
|
| 116 |
+
|
| 117 |
+
small {
|
| 118 |
+
font-size: 80%;
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
/**
|
| 122 |
+
* Prevent `sub` and `sup` elements from affecting the line height in
|
| 123 |
+
* all browsers.
|
| 124 |
+
*/
|
| 125 |
+
|
| 126 |
+
sub,
|
| 127 |
+
sup {
|
| 128 |
+
font-size: 75%;
|
| 129 |
+
line-height: 0;
|
| 130 |
+
position: relative;
|
| 131 |
+
vertical-align: baseline;
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
sub {
|
| 135 |
+
bottom: -0.25em;
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
sup {
|
| 139 |
+
top: -0.5em;
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
/* Embedded content
|
| 143 |
+
========================================================================== */
|
| 144 |
+
|
| 145 |
+
/**
|
| 146 |
+
* Remove the border on images inside links in IE 10.
|
| 147 |
+
*/
|
| 148 |
+
|
| 149 |
+
img {
|
| 150 |
+
border-style: none;
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
/* Forms
|
| 154 |
+
========================================================================== */
|
| 155 |
+
|
| 156 |
+
/**
|
| 157 |
+
* 1. Change the font styles in all browsers.
|
| 158 |
+
* 2. Remove the margin in Firefox and Safari.
|
| 159 |
+
*/
|
| 160 |
+
|
| 161 |
+
button,
|
| 162 |
+
input,
|
| 163 |
+
optgroup,
|
| 164 |
+
select,
|
| 165 |
+
textarea {
|
| 166 |
+
font-family: inherit; /* 1 */
|
| 167 |
+
font-size: 100%; /* 1 */
|
| 168 |
+
line-height: 1.15; /* 1 */
|
| 169 |
+
margin: 0; /* 2 */
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
/**
|
| 173 |
+
* Show the overflow in IE.
|
| 174 |
+
* 1. Show the overflow in Edge.
|
| 175 |
+
*/
|
| 176 |
+
|
| 177 |
+
button,
|
| 178 |
+
input { /* 1 */
|
| 179 |
+
overflow: visible;
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
/**
|
| 183 |
+
* Remove the inheritance of text transform in Edge, Firefox, and IE.
|
| 184 |
+
* 1. Remove the inheritance of text transform in Firefox.
|
| 185 |
+
*/
|
| 186 |
+
|
| 187 |
+
button,
|
| 188 |
+
select { /* 1 */
|
| 189 |
+
text-transform: none;
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
/**
|
| 193 |
+
* Correct the inability to style clickable types in iOS and Safari.
|
| 194 |
+
*/
|
| 195 |
+
|
| 196 |
+
button,
|
| 197 |
+
[type="button"],
|
| 198 |
+
[type="reset"],
|
| 199 |
+
[type="submit"] {
|
| 200 |
+
-webkit-appearance: button;
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
/**
|
| 204 |
+
* Remove the inner border and padding in Firefox.
|
| 205 |
+
*/
|
| 206 |
+
|
| 207 |
+
button::-moz-focus-inner,
|
| 208 |
+
[type="button"]::-moz-focus-inner,
|
| 209 |
+
[type="reset"]::-moz-focus-inner,
|
| 210 |
+
[type="submit"]::-moz-focus-inner {
|
| 211 |
+
border-style: none;
|
| 212 |
+
padding: 0;
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
/**
|
| 216 |
+
* Restore the focus styles unset by the previous rule.
|
| 217 |
+
*/
|
| 218 |
+
|
| 219 |
+
button:-moz-focusring,
|
| 220 |
+
[type="button"]:-moz-focusring,
|
| 221 |
+
[type="reset"]:-moz-focusring,
|
| 222 |
+
[type="submit"]:-moz-focusring {
|
| 223 |
+
outline: 1px dotted ButtonText;
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
/**
|
| 227 |
+
* Correct the padding in Firefox.
|
| 228 |
+
*/
|
| 229 |
+
|
| 230 |
+
fieldset {
|
| 231 |
+
padding: 0.35em 0.75em 0.625em;
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
/**
|
| 235 |
+
* 1. Correct the text wrapping in Edge and IE.
|
| 236 |
+
* 2. Correct the color inheritance from `fieldset` elements in IE.
|
| 237 |
+
* 3. Remove the padding so developers are not caught out when they zero out
|
| 238 |
+
* `fieldset` elements in all browsers.
|
| 239 |
+
*/
|
| 240 |
+
|
| 241 |
+
legend {
|
| 242 |
+
box-sizing: border-box; /* 1 */
|
| 243 |
+
color: inherit; /* 2 */
|
| 244 |
+
display: table; /* 1 */
|
| 245 |
+
max-width: 100%; /* 1 */
|
| 246 |
+
padding: 0; /* 3 */
|
| 247 |
+
white-space: normal; /* 1 */
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
/**
|
| 251 |
+
* Add the correct vertical alignment in Chrome, Firefox, and Opera.
|
| 252 |
+
*/
|
| 253 |
+
|
| 254 |
+
progress {
|
| 255 |
+
vertical-align: baseline;
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
/**
|
| 259 |
+
* Remove the default vertical scrollbar in IE 10+.
|
| 260 |
+
*/
|
| 261 |
+
|
| 262 |
+
textarea {
|
| 263 |
+
overflow: auto;
|
| 264 |
+
}
|
| 265 |
+
|
| 266 |
+
/**
|
| 267 |
+
* 1. Add the correct box sizing in IE 10.
|
| 268 |
+
* 2. Remove the padding in IE 10.
|
| 269 |
+
*/
|
| 270 |
+
|
| 271 |
+
[type="checkbox"],
|
| 272 |
+
[type="radio"] {
|
| 273 |
+
box-sizing: border-box; /* 1 */
|
| 274 |
+
padding: 0; /* 2 */
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
/**
|
| 278 |
+
* Correct the cursor style of increment and decrement buttons in Chrome.
|
| 279 |
+
*/
|
| 280 |
+
|
| 281 |
+
[type="number"]::-webkit-inner-spin-button,
|
| 282 |
+
[type="number"]::-webkit-outer-spin-button {
|
| 283 |
+
height: auto;
|
| 284 |
+
}
|
| 285 |
+
|
| 286 |
+
/**
|
| 287 |
+
* 1. Correct the odd appearance in Chrome and Safari.
|
| 288 |
+
* 2. Correct the outline style in Safari.
|
| 289 |
+
*/
|
| 290 |
+
|
| 291 |
+
[type="search"] {
|
| 292 |
+
-webkit-appearance: textfield; /* 1 */
|
| 293 |
+
outline-offset: -2px; /* 2 */
|
| 294 |
+
}
|
| 295 |
+
|
| 296 |
+
/**
|
| 297 |
+
* Remove the inner padding in Chrome and Safari on macOS.
|
| 298 |
+
*/
|
| 299 |
+
|
| 300 |
+
[type="search"]::-webkit-search-decoration {
|
| 301 |
+
-webkit-appearance: none;
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
+
/**
|
| 305 |
+
* 1. Correct the inability to style clickable types in iOS and Safari.
|
| 306 |
+
* 2. Change font properties to `inherit` in Safari.
|
| 307 |
+
*/
|
| 308 |
+
|
| 309 |
+
::-webkit-file-upload-button {
|
| 310 |
+
-webkit-appearance: button; /* 1 */
|
| 311 |
+
font: inherit; /* 2 */
|
| 312 |
+
}
|
| 313 |
+
|
| 314 |
+
/* Interactive
|
| 315 |
+
========================================================================== */
|
| 316 |
+
|
| 317 |
+
/*
|
| 318 |
+
* Add the correct display in Edge, IE 10+, and Firefox.
|
| 319 |
+
*/
|
| 320 |
+
|
| 321 |
+
details {
|
| 322 |
+
display: block;
|
| 323 |
+
}
|
| 324 |
+
|
| 325 |
+
/*
|
| 326 |
+
* Add the correct display in all browsers.
|
| 327 |
+
*/
|
| 328 |
+
|
| 329 |
+
summary {
|
| 330 |
+
display: list-item;
|
| 331 |
+
}
|
| 332 |
+
|
| 333 |
+
/* Misc
|
| 334 |
+
========================================================================== */
|
| 335 |
+
|
| 336 |
+
/**
|
| 337 |
+
* Add the correct display in IE 10+.
|
| 338 |
+
*/
|
| 339 |
+
|
| 340 |
+
template {
|
| 341 |
+
display: none;
|
| 342 |
+
}
|
| 343 |
+
|
| 344 |
+
/**
|
| 345 |
+
* Add the correct display in IE 10.
|
| 346 |
+
*/
|
| 347 |
+
|
| 348 |
+
[hidden] {
|
| 349 |
+
display: none;
|
| 350 |
+
}
|
| 351 |
+
|
| 352 |
+
._2Kn0b0 {
|
| 353 |
+
width: 100%;
|
| 354 |
+
text-align: center;
|
| 355 |
+
height: 50px;
|
| 356 |
+
margin-top: -50px;
|
| 357 |
+
padding-bottom: 10px;
|
| 358 |
+
padding-top: 20px;
|
| 359 |
+
color: #b1b1b1;
|
| 360 |
+
}
|
| 361 |
+
._2Kn0b0 a,
|
| 362 |
+
._2Kn0b0 a:hover {
|
| 363 |
+
color: #b1b1b1;
|
| 364 |
+
cursor: pointer;
|
| 365 |
+
}
|
| 366 |
+
._1nK53- {
|
| 367 |
+
white-space: nowrap;
|
| 368 |
+
padding: 0px 20px;
|
| 369 |
+
height: 60px;
|
| 370 |
+
display: flex;
|
| 371 |
+
align-items: center;
|
| 372 |
+
background: #fff;
|
| 373 |
+
}
|
| 374 |
+
@media (max-width: 550px) {
|
| 375 |
+
._1nK53- {
|
| 376 |
+
width: 100vw;
|
| 377 |
+
overflow-x: auto;
|
| 378 |
+
}
|
| 379 |
+
}
|
| 380 |
+
._3jtTy3 {
|
| 381 |
+
height: 40px;
|
| 382 |
+
cursor: pointer;
|
| 383 |
+
}
|
| 384 |
+
.ay1eIM {
|
| 385 |
+
margin-left: 20px;
|
| 386 |
+
}
|
| 387 |
+
._3bzYjy {
|
| 388 |
+
margin-left: 100px;
|
| 389 |
+
flex: 1 1;
|
| 390 |
+
}
|
| 391 |
+
._3veN4E,
|
| 392 |
+
._3veN4E:hover {
|
| 393 |
+
display: inline-block;
|
| 394 |
+
position: relative;
|
| 395 |
+
color: #ff6565;
|
| 396 |
+
}
|
| 397 |
+
@media (hover: hover) {
|
| 398 |
+
._3veN4E:hover ._3Sbc75 {
|
| 399 |
+
display: block;
|
| 400 |
+
position: absolute;
|
| 401 |
+
top: 50px;
|
| 402 |
+
left: -30px;
|
| 403 |
+
width: 200px;
|
| 404 |
+
padding: 12px;
|
| 405 |
+
z-index: 9;
|
| 406 |
+
background: #fff;
|
| 407 |
+
box-shadow: 0px 2px 4px 0px rgba(0,0,0,0.2);
|
| 408 |
+
}
|
| 409 |
+
._3veN4E:hover ._3Sbc75 ._3b_WFu {
|
| 410 |
+
color: #000;
|
| 411 |
+
font-weight: bolder;
|
| 412 |
+
white-space: normal;
|
| 413 |
+
text-align: center;
|
| 414 |
+
margin-bottom: 1em;
|
| 415 |
+
}
|
| 416 |
+
._3veN4E:hover ._3Sbc75 img {
|
| 417 |
+
width: 100%;
|
| 418 |
+
}
|
| 419 |
+
}
|
| 420 |
+
._3Sbc75 {
|
| 421 |
+
display: none;
|
| 422 |
+
}
|
| 423 |
+
._1nX2tW {
|
| 424 |
+
margin-right: 50px;
|
| 425 |
+
cursor: pointer;
|
| 426 |
+
position: relative;
|
| 427 |
+
}
|
| 428 |
+
._1nX2tW:hover {
|
| 429 |
+
color: #19cdd1;
|
| 430 |
+
}
|
| 431 |
+
._1nX2tW._1x8lgF {
|
| 432 |
+
color: #63e9ec;
|
| 433 |
+
}
|
| 434 |
+
._1nX2tW._1x8lgF::after {
|
| 435 |
+
content: '';
|
| 436 |
+
display: inline-block;
|
| 437 |
+
height: 2px;
|
| 438 |
+
width: 56px;
|
| 439 |
+
background: #63e9ec;
|
| 440 |
+
position: absolute;
|
| 441 |
+
left: 0px;
|
| 442 |
+
margin-top: 36px;
|
| 443 |
+
}
|
| 444 |
+
@media (max-width: 768px) {
|
| 445 |
+
.ay1eIM {
|
| 446 |
+
display: none;
|
| 447 |
+
}
|
| 448 |
+
._3bzYjy {
|
| 449 |
+
margin-left: 40px;
|
| 450 |
+
}
|
| 451 |
+
._1nX2tW {
|
| 452 |
+
margin-right: 30px;
|
| 453 |
+
}
|
| 454 |
+
}
|
| 455 |
+
._12DOC1 {
|
| 456 |
+
display: inline-block;
|
| 457 |
+
}
|
| 458 |
+
._1efWOZ,
|
| 459 |
+
._1WZn8u,
|
| 460 |
+
.hSD9ab,
|
| 461 |
+
.hSD9ab:hover,
|
| 462 |
+
._2QRfGO,
|
| 463 |
+
._2QRfGO:hover {
|
| 464 |
+
display: inline-block;
|
| 465 |
+
height: 38px;
|
| 466 |
+
line-height: 38px;
|
| 467 |
+
padding: 0 20px;
|
| 468 |
+
cursor: pointer;
|
| 469 |
+
white-space: nowrap;
|
| 470 |
+
-webkit-user-select: none;
|
| 471 |
+
-moz-user-select: none;
|
| 472 |
+
-ms-user-select: none;
|
| 473 |
+
user-select: none;
|
| 474 |
+
text-align: center;
|
| 475 |
+
vertical-align: middle;
|
| 476 |
+
outline: none;
|
| 477 |
+
}
|
| 478 |
+
._1efWOZ {
|
| 479 |
+
border: none;
|
| 480 |
+
background-color: #3fcfce;
|
| 481 |
+
color: #fff;
|
| 482 |
+
}
|
| 483 |
+
._1efWOZ:hover {
|
| 484 |
+
background-color: #52d4d3;
|
| 485 |
+
}
|
| 486 |
+
._1WZn8u {
|
| 487 |
+
color: #3fcfce;
|
| 488 |
+
border: 1px solid #3fcfce;
|
| 489 |
+
background-color: #fff;
|
| 490 |
+
}
|
| 491 |
+
._1WZn8u:hover {
|
| 492 |
+
background-color: rgba(63,207,206,0.06);
|
| 493 |
+
}
|
| 494 |
+
.hSD9ab,
|
| 495 |
+
.hSD9ab:hover {
|
| 496 |
+
background-color: #79dddd;
|
| 497 |
+
cursor: not-allowed;
|
| 498 |
+
}
|
| 499 |
+
._2QRfGO,
|
| 500 |
+
._2QRfGO:hover {
|
| 501 |
+
background-color: #79dddd;
|
| 502 |
+
cursor: not-allowed;
|
| 503 |
+
}
|
| 504 |
+
.GokVyx {
|
| 505 |
+
margin-right: 8px;
|
| 506 |
+
}
|
| 507 |
+
._1zbcCu {
|
| 508 |
+
height: 50px;
|
| 509 |
+
display: flex;
|
| 510 |
+
align-items: center;
|
| 511 |
+
justify-content: space-between;
|
| 512 |
+
}
|
| 513 |
+
._2LELqN {
|
| 514 |
+
margin-right: 10px;
|
| 515 |
+
flex: 1 1;
|
| 516 |
+
overflow: hidden;
|
| 517 |
+
}
|
| 518 |
+
._2LELqN:last-child {
|
| 519 |
+
flex: none;
|
| 520 |
+
margin-right: 0px;
|
| 521 |
+
}
|
| 522 |
+
._2LELqN:last-child ._2mAZEj {
|
| 523 |
+
padding-right: 0px;
|
| 524 |
+
}
|
| 525 |
+
._2LELqN._3TvyYS ._2mAZEj {
|
| 526 |
+
color: #4e4e4e;
|
| 527 |
+
}
|
| 528 |
+
._3bz5_s {
|
| 529 |
+
display: inline-block;
|
| 530 |
+
height: 23px;
|
| 531 |
+
width: 23px;
|
| 532 |
+
vertical-align: middle;
|
| 533 |
+
border: 1px solid #a0a0a0;
|
| 534 |
+
border-radius: 50%;
|
| 535 |
+
margin-right: 3px;
|
| 536 |
+
}
|
| 537 |
+
._3bz5_s._3TvyYS {
|
| 538 |
+
border: 1px solid #bde48d;
|
| 539 |
+
background: #bde48d;
|
| 540 |
+
}
|
| 541 |
+
._3bz5_s._3TvyYS ._3bZhAh {
|
| 542 |
+
color: #fff;
|
| 543 |
+
}
|
| 544 |
+
._3bZhAh {
|
| 545 |
+
position: relative;
|
| 546 |
+
color: #a0a0a0;
|
| 547 |
+
top: 3px;
|
| 548 |
+
left: 7px;
|
| 549 |
+
}
|
| 550 |
+
._2mAZEj {
|
| 551 |
+
color: #a0a0a0;
|
| 552 |
+
position: relative;
|
| 553 |
+
padding-right: 5px;
|
| 554 |
+
}
|
| 555 |
+
._2mAZEj::after {
|
| 556 |
+
content: '';
|
| 557 |
+
height: 1px;
|
| 558 |
+
background: #a0a0a0;
|
| 559 |
+
position: absolute;
|
| 560 |
+
top: 9px;
|
| 561 |
+
left: 100%;
|
| 562 |
+
width: 5555px;
|
| 563 |
+
display: block;
|
| 564 |
+
}
|
| 565 |
+
._3Xq0PF {
|
| 566 |
+
position: fixed;
|
| 567 |
+
top: 0px;
|
| 568 |
+
left: 50%;
|
| 569 |
+
-webkit-transform: translateX(-50%);
|
| 570 |
+
transform: translateX(-50%);
|
| 571 |
+
z-index: 1000;
|
| 572 |
+
}
|
| 573 |
+
._1zkGIF {
|
| 574 |
+
min-height: 38px;
|
| 575 |
+
width: 260px;
|
| 576 |
+
margin-top: 10px;
|
| 577 |
+
display: flex;
|
| 578 |
+
box-shadow: rgba(0,0,0,0.176) 0px 3px 8px;
|
| 579 |
+
border-radius: 4px;
|
| 580 |
+
}
|
| 581 |
+
.NfC2Sl {
|
| 582 |
+
text-align: center;
|
| 583 |
+
padding-top: 8px;
|
| 584 |
+
width: 26px;
|
| 585 |
+
flex-shrink: 0;
|
| 586 |
+
color: #fff;
|
| 587 |
+
border-top-left-radius: 4px;
|
| 588 |
+
border-bottom-left-radius: 4px;
|
| 589 |
+
}
|
| 590 |
+
.NfC2Sl._1JTff1 {
|
| 591 |
+
background: #37b47e;
|
| 592 |
+
}
|
| 593 |
+
.NfC2Sl._3hnrua {
|
| 594 |
+
background: #da4a4a;
|
| 595 |
+
}
|
| 596 |
+
.NfC2Sl._22hyiO {
|
| 597 |
+
background: #2684ff;
|
| 598 |
+
}
|
| 599 |
+
.HtHZPh {
|
| 600 |
+
flex: 1 1;
|
| 601 |
+
padding: 8px 12px;
|
| 602 |
+
border-top-right-radius: 4px;
|
| 603 |
+
border-bottom-right-radius: 4px;
|
| 604 |
+
}
|
| 605 |
+
.HtHZPh._1JTff1 {
|
| 606 |
+
background: #e3fcef;
|
| 607 |
+
color: #064;
|
| 608 |
+
}
|
| 609 |
+
.HtHZPh._3hnrua {
|
| 610 |
+
color: #ad0101;
|
| 611 |
+
background: #efb7b7;
|
| 612 |
+
}
|
| 613 |
+
.HtHZPh._22hyiO {
|
| 614 |
+
color: #2684ff;
|
| 615 |
+
background: #fff;
|
| 616 |
+
}
|
| 617 |
+
.toast-animation-enter {
|
| 618 |
+
-webkit-transform: translate3D(0, -120%, 0);
|
| 619 |
+
transform: translate3D(0, -120%, 0);
|
| 620 |
+
}
|
| 621 |
+
.toast-animation-enter.toast-animation-enter-active {
|
| 622 |
+
-webkit-transform: translate3D(0, 0, 0);
|
| 623 |
+
transform: translate3D(0, 0, 0);
|
| 624 |
+
-webkit-transition: -webkit-transform 100ms cubic-bezier(0.2, 0, 0, 1);
|
| 625 |
+
transition: -webkit-transform 100ms cubic-bezier(0.2, 0, 0, 1);
|
| 626 |
+
transition: transform 100ms cubic-bezier(0.2, 0, 0, 1);
|
| 627 |
+
transition: transform 100ms cubic-bezier(0.2, 0, 0, 1), -webkit-transform 100ms cubic-bezier(0.2, 0, 0, 1);
|
| 628 |
+
}
|
| 629 |
+
.toast-animation-exit {
|
| 630 |
+
-webkit-transform: scale(0.66);
|
| 631 |
+
transform: scale(0.66);
|
| 632 |
+
opacity: 0;
|
| 633 |
+
-webkit-transition: opacity 220ms ease 0s, -webkit-transform 100ms cubic-bezier(0.2, 0, 0, 1);
|
| 634 |
+
transition: opacity 220ms ease 0s, -webkit-transform 100ms cubic-bezier(0.2, 0, 0, 1);
|
| 635 |
+
transition: transform 100ms cubic-bezier(0.2, 0, 0, 1), opacity 220ms ease 0s;
|
| 636 |
+
transition: transform 100ms cubic-bezier(0.2, 0, 0, 1), opacity 220ms ease 0s, -webkit-transform 100ms cubic-bezier(0.2, 0, 0, 1);
|
| 637 |
+
}
|
| 638 |
+
.toast-animation-exit.toast-animation-exit-active {
|
| 639 |
+
-webkit-transform: scale(0.66);
|
| 640 |
+
transform: scale(0.66);
|
| 641 |
+
opacity: 0;
|
| 642 |
+
}
|
| 643 |
+
._1qOzqf {
|
| 644 |
+
max-height: 300px;
|
| 645 |
+
min-height: 200px;
|
| 646 |
+
padding: 0px 8px;
|
| 647 |
+
background: #fafafa;
|
| 648 |
+
overflow-y: auto;
|
| 649 |
+
}
|
| 650 |
+
._3aoE0Y {
|
| 651 |
+
display: flex;
|
| 652 |
+
justify-content: space-between;
|
| 653 |
+
align-items: center;
|
| 654 |
+
padding: 0px 8px;
|
| 655 |
+
height: 50px;
|
| 656 |
+
line-height: 50px;
|
| 657 |
+
background: #fff;
|
| 658 |
+
border-radius: 2px;
|
| 659 |
+
margin: 10px auto;
|
| 660 |
+
}
|
| 661 |
+
._3xLTNB {
|
| 662 |
+
height: 100%;
|
| 663 |
+
}
|
| 664 |
+
._19-z7S {
|
| 665 |
+
font-size: 28px;
|
| 666 |
+
color: #8e8e8e;
|
| 667 |
+
}
|
| 668 |
+
._1HRqi1 {
|
| 669 |
+
display: inline-block;
|
| 670 |
+
}
|
| 671 |
+
.adZEgA {
|
| 672 |
+
font-size: 16px;
|
| 673 |
+
line-height: 1.4;
|
| 674 |
+
max-width: 12em;
|
| 675 |
+
overflow: hidden;
|
| 676 |
+
text-overflow: ellipsis;
|
| 677 |
+
white-space: nowrap;
|
| 678 |
+
}
|
| 679 |
+
.VqVjWq {
|
| 680 |
+
text-align: left;
|
| 681 |
+
font-size: 12px;
|
| 682 |
+
line-height: 1.2;
|
| 683 |
+
color: #adadad;
|
| 684 |
+
}
|
| 685 |
+
._3x3TWQ {
|
| 686 |
+
cursor: pointer;
|
| 687 |
+
color: #8e8e8e;
|
| 688 |
+
}
|
| 689 |
+
._1LnFOT {
|
| 690 |
+
color: #8e8e8e;
|
| 691 |
+
}
|
| 692 |
+
._2WJStE {
|
| 693 |
+
cursor: pointer;
|
| 694 |
+
}
|
| 695 |
+
._2WJStE,
|
| 696 |
+
._2WJStE:hover {
|
| 697 |
+
color: #649ae4;
|
| 698 |
+
}
|
| 699 |
+
._1u9qTB {
|
| 700 |
+
color: #93ecae;
|
| 701 |
+
}
|
| 702 |
+
._3xR6yF {
|
| 703 |
+
width: 380px;
|
| 704 |
+
margin: 0 auto;
|
| 705 |
+
padding: 20px 25px 10px;
|
| 706 |
+
background: #fff;
|
| 707 |
+
box-shadow: 0px 2px 4px 0px rgba(197,197,197,0.5);
|
| 708 |
+
}
|
| 709 |
+
._1Rgz2l {
|
| 710 |
+
position: relative;
|
| 711 |
+
}
|
| 712 |
+
._1xgR1v {
|
| 713 |
+
text-align: center;
|
| 714 |
+
font-weight: 700;
|
| 715 |
+
color: #757575;
|
| 716 |
+
}
|
| 717 |
+
._16cJdu {
|
| 718 |
+
position: absolute;
|
| 719 |
+
cursor: pointer;
|
| 720 |
+
color: #8e8e8e;
|
| 721 |
+
}
|
| 722 |
+
._3Z-yfm {
|
| 723 |
+
border: 2px dashed #d1d1d1;
|
| 724 |
+
text-align: center;
|
| 725 |
+
margin: 8px auto;
|
| 726 |
+
outline: none;
|
| 727 |
+
}
|
| 728 |
+
._3Z-yfm._29put- {
|
| 729 |
+
border: 2px solid #63e9ec;
|
| 730 |
+
border-radius: 4px;
|
| 731 |
+
}
|
| 732 |
+
._1XnDvl {
|
| 733 |
+
margin-top: 20px;
|
| 734 |
+
}
|
| 735 |
+
._2ObPGq {
|
| 736 |
+
margin-top: 60px;
|
| 737 |
+
}
|
| 738 |
+
._3Bexjs {
|
| 739 |
+
font-size: 42px;
|
| 740 |
+
color: #8e8e8e;
|
| 741 |
+
}
|
| 742 |
+
._1FRSSP {
|
| 743 |
+
color: #8e8e8e;
|
| 744 |
+
margin-top: 8px;
|
| 745 |
+
font-size: 13px;
|
| 746 |
+
}
|
| 747 |
+
.Ua8o6l {
|
| 748 |
+
width: 215px;
|
| 749 |
+
margin-top: 15px;
|
| 750 |
+
margin-bottom: 100px;
|
| 751 |
+
}
|
| 752 |
+
.IL_5aL {
|
| 753 |
+
color: #40af9c;
|
| 754 |
+
}
|
| 755 |
+
.IL_5aL:hover {
|
| 756 |
+
color: #74ccbd;
|
| 757 |
+
}
|
| 758 |
+
._31-MJ1 {
|
| 759 |
+
display: flex;
|
| 760 |
+
justify-content: space-between;
|
| 761 |
+
align-items: center;
|
| 762 |
+
}
|
| 763 |
+
._2OVRj9 {
|
| 764 |
+
cursor: pointer;
|
| 765 |
+
color: #40af9c;
|
| 766 |
+
}
|
| 767 |
+
._3TiMmv {
|
| 768 |
+
text-align: right;
|
| 769 |
+
color: #adadad;
|
| 770 |
+
}
|
| 771 |
+
._3zjNNo {
|
| 772 |
+
width: 100%;
|
| 773 |
+
margin-top: 20px;
|
| 774 |
+
}
|
| 775 |
+
/* STEP 2 */
|
| 776 |
+
._3d5TSD {
|
| 777 |
+
color: #8e8e8e;
|
| 778 |
+
margin-bottom: 10px;
|
| 779 |
+
}
|
| 780 |
+
._19gixB {
|
| 781 |
+
margin: 10px 0px 20px;
|
| 782 |
+
}
|
| 783 |
+
._2qcrGl {
|
| 784 |
+
margin: 10px 0px 20px;
|
| 785 |
+
}
|
| 786 |
+
._2Zoggo {
|
| 787 |
+
display: inline-block;
|
| 788 |
+
height: 36px;
|
| 789 |
+
line-height: 36px;
|
| 790 |
+
vertical-align: middle;
|
| 791 |
+
border: 1px solid #c8c8c8;
|
| 792 |
+
background: #eee;
|
| 793 |
+
padding: 0px 10px;
|
| 794 |
+
margin-right: 10px;
|
| 795 |
+
}
|
| 796 |
+
._1SuOe4 {
|
| 797 |
+
display: inline-block;
|
| 798 |
+
height: 36px;
|
| 799 |
+
line-height: 36px;
|
| 800 |
+
vertical-align: middle;
|
| 801 |
+
border: 1px solid #c8c8c8;
|
| 802 |
+
background: #eee;
|
| 803 |
+
padding: 0px 10px;
|
| 804 |
+
margin-right: 10px;
|
| 805 |
+
width: 238px;
|
| 806 |
+
text-align: center;
|
| 807 |
+
}
|
| 808 |
+
._20RtoV {
|
| 809 |
+
color: #649ae4;
|
| 810 |
+
cursor: pointer;
|
| 811 |
+
-webkit-user-select: none;
|
| 812 |
+
-moz-user-select: none;
|
| 813 |
+
-ms-user-select: none;
|
| 814 |
+
user-select: none;
|
| 815 |
+
}
|
| 816 |
+
._1L_XZ- {
|
| 817 |
+
margin-top: 10px;
|
| 818 |
+
text-align: center;
|
| 819 |
+
}
|
| 820 |
+
._1IkS0W {
|
| 821 |
+
width: 120px;
|
| 822 |
+
}
|
| 823 |
+
._3dHOOW {
|
| 824 |
+
margin-top: 20px;
|
| 825 |
+
color: #a7a7a7;
|
| 826 |
+
line-height: 1.5;
|
| 827 |
+
}
|
| 828 |
+
._3kSmAG {
|
| 829 |
+
margin-top: 20px;
|
| 830 |
+
width: 100%;
|
| 831 |
+
}
|
| 832 |
+
/* step 3 */
|
| 833 |
+
.lbn5Xj {
|
| 834 |
+
margin: 8px auto;
|
| 835 |
+
}
|
| 836 |
+
.PJ7cTz {
|
| 837 |
+
display: flex;
|
| 838 |
+
justify-content: space-between;
|
| 839 |
+
color: #a7a7a7;
|
| 840 |
+
}
|
| 841 |
+
.nkT-WI {
|
| 842 |
+
color: #61f36b;
|
| 843 |
+
}
|
| 844 |
+
._5ew-iS {
|
| 845 |
+
color: #ea7a7a;
|
| 846 |
+
}
|
| 847 |
+
._2_x9HQ {
|
| 848 |
+
margin-top: 20px;
|
| 849 |
+
width: 100%;
|
| 850 |
+
}
|
| 851 |
+
@media (max-width: 1200px) {
|
| 852 |
+
._3xR6yF {
|
| 853 |
+
width: 80%;
|
| 854 |
+
max-width: 650px;
|
| 855 |
+
}
|
| 856 |
+
}
|
| 857 |
+
._2NI-Bu {
|
| 858 |
+
position: relative;
|
| 859 |
+
}
|
| 860 |
+
._38jnea {
|
| 861 |
+
position: relative;
|
| 862 |
+
}
|
| 863 |
+
._1ItMl6 {
|
| 864 |
+
outline: none;
|
| 865 |
+
border: 1px solid #a9a9a9;
|
| 866 |
+
padding-left: 10px;
|
| 867 |
+
-webkit-appearance: none;
|
| 868 |
+
-moz-appearance: none;
|
| 869 |
+
appearance: none;
|
| 870 |
+
}
|
| 871 |
+
._1ItMl6:focus,
|
| 872 |
+
._1ItMl6:active {
|
| 873 |
+
border-color: #56bdc0;
|
| 874 |
+
}
|
| 875 |
+
._1ItMl6::-webkit-input-placeholder {
|
| 876 |
+
color: #b5b5b5;
|
| 877 |
+
}
|
| 878 |
+
._1ItMl6:-ms-input-placeholder {
|
| 879 |
+
color: #b5b5b5;
|
| 880 |
+
}
|
| 881 |
+
._1ItMl6::-ms-input-placeholder {
|
| 882 |
+
color: #b5b5b5;
|
| 883 |
+
}
|
| 884 |
+
._1ItMl6::placeholder {
|
| 885 |
+
color: #b5b5b5;
|
| 886 |
+
}
|
| 887 |
+
._2_bPxy {
|
| 888 |
+
margin-right: 2px;
|
| 889 |
+
}
|
| 890 |
+
.gCi4nG {
|
| 891 |
+
margin-top: 2px;
|
| 892 |
+
position: absolute;
|
| 893 |
+
color: #dc4646;
|
| 894 |
+
}
|
| 895 |
+
._8bl-qe {
|
| 896 |
+
width: 380px;
|
| 897 |
+
margin: 0 auto;
|
| 898 |
+
padding: 20px 22px;
|
| 899 |
+
background: #fff;
|
| 900 |
+
text-align: center;
|
| 901 |
+
box-shadow: 0px 2px 4px 0px rgba(197,197,197,0.5);
|
| 902 |
+
}
|
| 903 |
+
._3AsA1Y {
|
| 904 |
+
position: relative;
|
| 905 |
+
}
|
| 906 |
+
.MQm7zy {
|
| 907 |
+
text-align: center;
|
| 908 |
+
font-weight: 700;
|
| 909 |
+
color: #757575;
|
| 910 |
+
}
|
| 911 |
+
._2Mx9a4 {
|
| 912 |
+
position: absolute;
|
| 913 |
+
cursor: pointer;
|
| 914 |
+
color: #8e8e8e;
|
| 915 |
+
}
|
| 916 |
+
._2iTtOQ {
|
| 917 |
+
width: 100%;
|
| 918 |
+
height: 42px;
|
| 919 |
+
margin-top: 60px;
|
| 920 |
+
}
|
| 921 |
+
._3WTb49 {
|
| 922 |
+
width: 100%;
|
| 923 |
+
margin-top: 20px;
|
| 924 |
+
}
|
| 925 |
+
.zqMaDg {
|
| 926 |
+
text-align: right;
|
| 927 |
+
color: #989898;
|
| 928 |
+
cursor: pointer;
|
| 929 |
+
margin-top: 138px;
|
| 930 |
+
}
|
| 931 |
+
._3DmJej {
|
| 932 |
+
text-align: left;
|
| 933 |
+
margin-top: 25px;
|
| 934 |
+
margin-bottom: 10px;
|
| 935 |
+
color: #8e8e8e;
|
| 936 |
+
}
|
| 937 |
+
.uBaZ2I {
|
| 938 |
+
display: flex;
|
| 939 |
+
justify-content: space-between;
|
| 940 |
+
margin-top: 10px;
|
| 941 |
+
color: #8e8e8e;
|
| 942 |
+
}
|
| 943 |
+
.iVIWn9 {
|
| 944 |
+
color: #61f36b;
|
| 945 |
+
}
|
| 946 |
+
._2eFt-R {
|
| 947 |
+
color: #ea7a7a;
|
| 948 |
+
}
|
| 949 |
+
@media (max-width: 1200px) {
|
| 950 |
+
._8bl-qe {
|
| 951 |
+
width: 80%;
|
| 952 |
+
max-width: 650px;
|
| 953 |
+
}
|
| 954 |
+
}
|
| 955 |
+
._13zwq3 {
|
| 956 |
+
padding: 30px;
|
| 957 |
+
height: 185px;
|
| 958 |
+
text-align: center;
|
| 959 |
+
background: #fff;
|
| 960 |
+
border-radius: 8px;
|
| 961 |
+
box-shadow: 0px 2px 4px 0px rgba(197,197,197,0.5);
|
| 962 |
+
}
|
| 963 |
+
.O7Bq1A {
|
| 964 |
+
font-size: 16px;
|
| 965 |
+
margin-bottom: 25px;
|
| 966 |
+
}
|
| 967 |
+
.BCfR8x {
|
| 968 |
+
letter-spacing: 4px;
|
| 969 |
+
}
|
| 970 |
+
._1-uRnm {
|
| 971 |
+
color: #8e8e8e;
|
| 972 |
+
font-family: serif;
|
| 973 |
+
line-height: 1.4;
|
| 974 |
+
}
|
| 975 |
+
._2LUsdD {
|
| 976 |
+
background: -webkit-gradient(linear, left top, left bottom, from(#bddee1), to(#f0fcfd));
|
| 977 |
+
background: linear-gradient(#bddee1, #f0fcfd);
|
| 978 |
+
min-height: 100%;
|
| 979 |
+
padding-bottom: 50px;
|
| 980 |
+
}
|
| 981 |
+
._2KMkak {
|
| 982 |
+
width: 1110px;
|
| 983 |
+
margin: auto;
|
| 984 |
+
margin-top: 60px;
|
| 985 |
+
display: flex;
|
| 986 |
+
align-items: flex-start;
|
| 987 |
+
}
|
| 988 |
+
.IScM0S {
|
| 989 |
+
margin-left: 80px;
|
| 990 |
+
}
|
| 991 |
+
._22OOXg {
|
| 992 |
+
display: flex;
|
| 993 |
+
justify-content: space-between;
|
| 994 |
+
width: 650px;
|
| 995 |
+
margin-bottom: 50px;
|
| 996 |
+
}
|
| 997 |
+
._19O2vU {
|
| 998 |
+
width: 300px;
|
| 999 |
+
height: 185px;
|
| 1000 |
+
}
|
| 1001 |
+
._2ekLXR {
|
| 1002 |
+
margin-right: 5px;
|
| 1003 |
+
font-size: 18px;
|
| 1004 |
+
color: #f9acef;
|
| 1005 |
+
}
|
| 1006 |
+
._1fZxby {
|
| 1007 |
+
margin-right: 5px;
|
| 1008 |
+
font-size: 18px;
|
| 1009 |
+
color: #f05f5f;
|
| 1010 |
+
}
|
| 1011 |
+
._3jTGm8 {
|
| 1012 |
+
margin-right: 5px;
|
| 1013 |
+
font-size: 18px;
|
| 1014 |
+
color: #5abaf4;
|
| 1015 |
+
}
|
| 1016 |
+
._30NGwS {
|
| 1017 |
+
margin-right: 5px;
|
| 1018 |
+
font-size: 18px;
|
| 1019 |
+
color: #6adf4a;
|
| 1020 |
+
}
|
| 1021 |
+
@media (max-width: 1200px) {
|
| 1022 |
+
._2KMkak {
|
| 1023 |
+
display: block;
|
| 1024 |
+
width: auto;
|
| 1025 |
+
}
|
| 1026 |
+
.IScM0S {
|
| 1027 |
+
margin: auto;
|
| 1028 |
+
}
|
| 1029 |
+
._22OOXg {
|
| 1030 |
+
margin: auto;
|
| 1031 |
+
margin-top: 50px;
|
| 1032 |
+
}
|
| 1033 |
+
}
|
| 1034 |
+
@media (max-width: 768px) {
|
| 1035 |
+
._22OOXg {
|
| 1036 |
+
display: block;
|
| 1037 |
+
width: auto;
|
| 1038 |
+
margin-top: 0px;
|
| 1039 |
+
}
|
| 1040 |
+
._19O2vU {
|
| 1041 |
+
margin: auto;
|
| 1042 |
+
margin-top: 50px;
|
| 1043 |
+
}
|
| 1044 |
+
}
|
| 1045 |
+
html {
|
| 1046 |
+
color: #4a4a4a;
|
| 1047 |
+
}
|
| 1048 |
+
|
| 1049 |
+
html,body {
|
| 1050 |
+
height: 100%;
|
| 1051 |
+
font-size: 14px;
|
| 1052 |
+
box-sizing: border-box;
|
| 1053 |
+
}
|
| 1054 |
+
|
| 1055 |
+
*, *:before, *:after {
|
| 1056 |
+
box-sizing: inherit;
|
| 1057 |
+
}
|
| 1058 |
+
|
| 1059 |
+
div#root {
|
| 1060 |
+
height: 100%;
|
| 1061 |
+
}
|
| 1062 |
+
|
| 1063 |
+
a, a:hover, a:active {
|
| 1064 |
+
color: #6f6f6f;
|
| 1065 |
+
text-decoration: none;
|
| 1066 |
+
}
|
| 1067 |
+
|
| 1068 |
+
|
| 1069 |
+
.animation-spin {
|
| 1070 |
+
-webkit-animation: spin 1s infinite linear;
|
| 1071 |
+
animation: spin 1s infinite linear;
|
| 1072 |
+
}
|
| 1073 |
+
|
| 1074 |
+
@-webkit-keyframes spin {
|
| 1075 |
+
from {
|
| 1076 |
+
-webkit-transform: rotate(0deg);
|
| 1077 |
+
transform: rotate(0deg);
|
| 1078 |
+
}
|
| 1079 |
+
to {
|
| 1080 |
+
-webkit-transform: rotate(359deg);
|
| 1081 |
+
transform: rotate(359deg);
|
| 1082 |
+
}
|
| 1083 |
+
}
|
| 1084 |
+
|
| 1085 |
+
@keyframes spin {
|
| 1086 |
+
from {
|
| 1087 |
+
-webkit-transform: rotate(0deg);
|
| 1088 |
+
transform: rotate(0deg);
|
| 1089 |
+
}
|
| 1090 |
+
to {
|
| 1091 |
+
-webkit-transform: rotate(359deg);
|
| 1092 |
+
transform: rotate(359deg);
|
| 1093 |
+
}
|
| 1094 |
+
}
|
| 1095 |
+
|
client/config/loaders.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const autoprefixer = require('autoprefixer');
|
| 2 |
+
|
| 3 |
+
exports.babelLoader = {
|
| 4 |
+
loader: 'babel-loader',
|
| 5 |
+
options: {
|
| 6 |
+
cacheDirectory: false,
|
| 7 |
+
},
|
| 8 |
+
};
|
| 9 |
+
|
| 10 |
+
exports.styleLoader = {
|
| 11 |
+
loader: 'style-loader',
|
| 12 |
+
options: {
|
| 13 |
+
},
|
| 14 |
+
};
|
| 15 |
+
|
| 16 |
+
exports.cssLoaderWithModules = {
|
| 17 |
+
loader: 'css-loader',
|
| 18 |
+
options: {
|
| 19 |
+
importLoaders: 1,
|
| 20 |
+
localsConvention: 'camelCase',
|
| 21 |
+
sourceMap: true,
|
| 22 |
+
modules: {
|
| 23 |
+
mode: 'local',
|
| 24 |
+
localIdentName: process.env.NODE_ENV === 'production' ? '[hash:base64:6]' : '[path][name]---[local]---[hash:base64:5]',
|
| 25 |
+
},
|
| 26 |
+
},
|
| 27 |
+
};
|
| 28 |
+
|
| 29 |
+
exports.cssLoaderWithoutModules = {
|
| 30 |
+
loader: 'css-loader',
|
| 31 |
+
options: {
|
| 32 |
+
importLoaders: 1,
|
| 33 |
+
},
|
| 34 |
+
};
|
| 35 |
+
|
| 36 |
+
exports.postcssLoader = {
|
| 37 |
+
loader: 'postcss-loader',
|
| 38 |
+
options: {
|
| 39 |
+
ident: 'postcss',
|
| 40 |
+
plugins: () => [
|
| 41 |
+
require('postcss-flexbugs-fixes'),
|
| 42 |
+
autoprefixer({
|
| 43 |
+
flexbox: 'no-2009',
|
| 44 |
+
}),
|
| 45 |
+
],
|
| 46 |
+
},
|
| 47 |
+
};
|
| 48 |
+
|
| 49 |
+
exports.stylusLoader = {
|
| 50 |
+
loader: 'stylus-loader',
|
| 51 |
+
options: {
|
| 52 |
+
sourceMap: true,
|
| 53 |
+
},
|
| 54 |
+
};
|
client/config/paths.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
const path = require('path');
|
| 4 |
+
const fs = require('fs');
|
| 5 |
+
const url = require('url');
|
| 6 |
+
|
| 7 |
+
// Make sure any symlinks in the project folder are resolved:
|
| 8 |
+
// https://github.com/facebook/create-react-app/issues/637
|
| 9 |
+
const appDirectory = fs.realpathSync(process.cwd());
|
| 10 |
+
const resolveApp = relativePath => path.resolve(appDirectory, relativePath);
|
| 11 |
+
|
| 12 |
+
const envPublicUrl = process.env.PUBLIC_URL;
|
| 13 |
+
|
| 14 |
+
function ensureSlash (inputPath, needsSlash) {
|
| 15 |
+
const hasSlash = inputPath.endsWith('/');
|
| 16 |
+
if (hasSlash && !needsSlash) {
|
| 17 |
+
return inputPath.substr(0, inputPath.length - 1);
|
| 18 |
+
} else if (!hasSlash && needsSlash) {
|
| 19 |
+
return `${inputPath}/`;
|
| 20 |
+
} else {
|
| 21 |
+
return inputPath;
|
| 22 |
+
}
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
const getPublicUrl = appPackageJson =>
|
| 26 |
+
envPublicUrl || require(appPackageJson).homepage;
|
| 27 |
+
|
| 28 |
+
// We use `PUBLIC_URL` environment variable or "homepage" field to infer
|
| 29 |
+
// "public path" at which the app is served.
|
| 30 |
+
// Webpack needs to know it to put the right <script> hrefs into HTML even in
|
| 31 |
+
// single-page apps that may serve index.html for nested URLs like /todos/42.
|
| 32 |
+
// We can't use a relative path in HTML because we don't want to load something
|
| 33 |
+
// like /todos/42/static/js/bundle.7289d.js. We have to know the root.
|
| 34 |
+
function getServedPath (appPackageJson) {
|
| 35 |
+
const publicUrl = getPublicUrl(appPackageJson);
|
| 36 |
+
const servedUrl =
|
| 37 |
+
envPublicUrl || (publicUrl ? url.parse(publicUrl).pathname : '/');
|
| 38 |
+
return ensureSlash(servedUrl, true);
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
const moduleFileExtensions = [
|
| 42 |
+
'web.mjs',
|
| 43 |
+
'mjs',
|
| 44 |
+
'web.js',
|
| 45 |
+
'js',
|
| 46 |
+
'web.ts',
|
| 47 |
+
'ts',
|
| 48 |
+
'web.tsx',
|
| 49 |
+
'tsx',
|
| 50 |
+
'json',
|
| 51 |
+
'web.jsx',
|
| 52 |
+
'jsx',
|
| 53 |
+
];
|
| 54 |
+
|
| 55 |
+
// Resolve file paths in the same order as webpack
|
| 56 |
+
const resolveModule = (resolveFn, filePath) => {
|
| 57 |
+
const extension = moduleFileExtensions.find(extension =>
|
| 58 |
+
fs.existsSync(resolveFn(`${filePath}.${extension}`)),
|
| 59 |
+
);
|
| 60 |
+
|
| 61 |
+
if (extension) {
|
| 62 |
+
return resolveFn(`${filePath}.${extension}`);
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
return resolveFn(`${filePath}.js`);
|
| 66 |
+
};
|
| 67 |
+
|
| 68 |
+
// config after eject: we're in ./config/
|
| 69 |
+
module.exports = {
|
| 70 |
+
dotenv: resolveApp('.env'),
|
| 71 |
+
appPath: resolveApp('.'),
|
| 72 |
+
appBuild: resolveApp('build'),
|
| 73 |
+
appPublic: resolveApp('public'),
|
| 74 |
+
appHtml: resolveApp('public/index.html'),
|
| 75 |
+
appIndexJs: resolveModule(resolveApp, 'src/index'),
|
| 76 |
+
appPackageJson: resolveApp('package.json'),
|
| 77 |
+
appSrc: resolveApp('src'),
|
| 78 |
+
appTsConfig: resolveApp('tsconfig.json'),
|
| 79 |
+
appJsConfig: resolveApp('jsconfig.json'),
|
| 80 |
+
yarnLockFile: resolveApp('yarn.lock'),
|
| 81 |
+
testsSetup: resolveModule(resolveApp, 'src/setupTests'),
|
| 82 |
+
proxySetup: resolveApp('src/setupProxy.js'),
|
| 83 |
+
appNodeModules: resolveApp('node_modules'),
|
| 84 |
+
publicUrl: getPublicUrl(resolveApp('package.json')),
|
| 85 |
+
servedPath: getServedPath(resolveApp('package.json')),
|
| 86 |
+
};
|
| 87 |
+
|
| 88 |
+
module.exports.moduleFileExtensions = moduleFileExtensions;
|
client/config/webpack.config.dev.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const {
|
| 2 |
+
styleLoader,
|
| 3 |
+
cssLoaderWithoutModules,
|
| 4 |
+
cssLoaderWithModules,
|
| 5 |
+
postcssLoader,
|
| 6 |
+
stylusLoader,
|
| 7 |
+
babelLoader,
|
| 8 |
+
} = require('./loaders');
|
| 9 |
+
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
| 10 |
+
const paths = require('./paths');
|
| 11 |
+
|
| 12 |
+
const publicPath = '/static/js';
|
| 13 |
+
|
| 14 |
+
module.exports = {
|
| 15 |
+
mode: 'development',
|
| 16 |
+
entry: {
|
| 17 |
+
index: paths.appIndexJs,
|
| 18 |
+
},
|
| 19 |
+
devtool: 'inline-source-map',
|
| 20 |
+
output: {
|
| 21 |
+
filename: '[name].bundle.js',
|
| 22 |
+
publicPath,
|
| 23 |
+
},
|
| 24 |
+
module: {
|
| 25 |
+
rules: [
|
| 26 |
+
{
|
| 27 |
+
test: [/\.(js|jsx|mjs)$/],
|
| 28 |
+
include: paths.appSrc,
|
| 29 |
+
use: [babelLoader],
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
test: /\.css$/,
|
| 33 |
+
use: [styleLoader, cssLoaderWithoutModules, postcssLoader],
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
test: /\.cm\.styl$/,
|
| 37 |
+
use: [styleLoader, cssLoaderWithModules, postcssLoader, stylusLoader],
|
| 38 |
+
},
|
| 39 |
+
],
|
| 40 |
+
},
|
| 41 |
+
plugins: [
|
| 42 |
+
new HtmlWebpackPlugin({
|
| 43 |
+
title: '小鹿快传',
|
| 44 |
+
template: paths.appHtml,
|
| 45 |
+
}),
|
| 46 |
+
],
|
| 47 |
+
devServer: {
|
| 48 |
+
index: '',
|
| 49 |
+
publicPath,
|
| 50 |
+
proxy: {
|
| 51 |
+
'/': {
|
| 52 |
+
target: 'http://localhost:3001',
|
| 53 |
+
},
|
| 54 |
+
'/ws': {
|
| 55 |
+
target: 'ws://localhost:3001',
|
| 56 |
+
ws: true,
|
| 57 |
+
},
|
| 58 |
+
},
|
| 59 |
+
},
|
| 60 |
+
};
|
client/config/webpack.config.prod.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
| 2 |
+
|
| 3 |
+
const {
|
| 4 |
+
cssLoaderWithModules,
|
| 5 |
+
cssLoaderWithoutModules,
|
| 6 |
+
postcssLoader,
|
| 7 |
+
stylusLoader,
|
| 8 |
+
babelLoader,
|
| 9 |
+
} = require('./loaders');
|
| 10 |
+
const paths = require('./paths');
|
| 11 |
+
|
| 12 |
+
module.exports = {
|
| 13 |
+
mode: 'production',
|
| 14 |
+
entry: paths.appIndexJs,
|
| 15 |
+
devtool: false,
|
| 16 |
+
output: {
|
| 17 |
+
path: paths.appBuild,
|
| 18 |
+
filename: 'index.bundle.js',
|
| 19 |
+
},
|
| 20 |
+
module: {
|
| 21 |
+
rules: [
|
| 22 |
+
{
|
| 23 |
+
test: [/\.(js|jsx|mjs)$/],
|
| 24 |
+
include: paths.appSrc,
|
| 25 |
+
use: [babelLoader],
|
| 26 |
+
},
|
| 27 |
+
{
|
| 28 |
+
test: /\.css$/,
|
| 29 |
+
use: [MiniCssExtractPlugin.loader, cssLoaderWithoutModules, postcssLoader],
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
test: /\.cm\.styl$/,
|
| 33 |
+
use: [MiniCssExtractPlugin.loader, cssLoaderWithModules, postcssLoader, stylusLoader],
|
| 34 |
+
},
|
| 35 |
+
],
|
| 36 |
+
},
|
| 37 |
+
plugins: [
|
| 38 |
+
new MiniCssExtractPlugin(),
|
| 39 |
+
],
|
| 40 |
+
devServer: {
|
| 41 |
+
contentBase: './build',
|
| 42 |
+
},
|
| 43 |
+
};
|
client/package-lock.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
client/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "client",
|
| 3 |
+
"version": "1.0.0",
|
| 4 |
+
"description": "",
|
| 5 |
+
"main": "index.js",
|
| 6 |
+
"scripts": {
|
| 7 |
+
"start": "node scripts/start.js",
|
| 8 |
+
"build": "node scripts/build.js"
|
| 9 |
+
},
|
| 10 |
+
"author": "",
|
| 11 |
+
"license": "ISC",
|
| 12 |
+
"dependencies": {
|
| 13 |
+
"@sentry/browser": "^5.11.1",
|
| 14 |
+
"axios": "^0.19.0",
|
| 15 |
+
"classnames": "^2.2.6",
|
| 16 |
+
"file-saver": "^2.0.2",
|
| 17 |
+
"immer": "^5.0.0",
|
| 18 |
+
"normalize.css": "^8.0.1",
|
| 19 |
+
"pretty-bytes": "^5.3.0",
|
| 20 |
+
"qrcode.react": "^1.0.0",
|
| 21 |
+
"react": "^16.12.0",
|
| 22 |
+
"react-copy-to-clipboard": "^5.0.2",
|
| 23 |
+
"react-dom": "^16.12.0",
|
| 24 |
+
"react-dropzone": "^10.2.1",
|
| 25 |
+
"react-ga": "^2.7.0",
|
| 26 |
+
"react-redux": "^7.1.3",
|
| 27 |
+
"react-router-dom": "^5.1.2",
|
| 28 |
+
"react-transition-group": "^4.3.0",
|
| 29 |
+
"redux": "^4.0.4",
|
| 30 |
+
"redux-thunk": "^2.3.0",
|
| 31 |
+
"uuid": "^3.3.3",
|
| 32 |
+
"webrtc-adapter": "^7.3.0"
|
| 33 |
+
},
|
| 34 |
+
"devDependencies": {
|
| 35 |
+
"@babel/core": "^7.7.4",
|
| 36 |
+
"autoprefixer": "^9.7.3",
|
| 37 |
+
"babel-loader": "^8.0.6",
|
| 38 |
+
"babel-preset-react-app": "^9.0.2",
|
| 39 |
+
"css-loader": "^3.2.0",
|
| 40 |
+
"eslint": "^6.7.1",
|
| 41 |
+
"fs-extra": "^8.1.0",
|
| 42 |
+
"html-webpack-plugin": "^3.2.0",
|
| 43 |
+
"mini-css-extract-plugin": "^0.9.0",
|
| 44 |
+
"postcss-flexbugs-fixes": "^4.1.0",
|
| 45 |
+
"postcss-loader": "^3.0.0",
|
| 46 |
+
"react-dev-utils": "^9.1.0",
|
| 47 |
+
"style-loader": "^1.0.1",
|
| 48 |
+
"stylus": "^0.54.7",
|
| 49 |
+
"stylus-loader": "^3.0.2",
|
| 50 |
+
"webpack": "^4.41.2",
|
| 51 |
+
"webpack-cli": "^3.3.10",
|
| 52 |
+
"webpack-dev-server": "^3.9.0"
|
| 53 |
+
},
|
| 54 |
+
"babel": {
|
| 55 |
+
"presets": [
|
| 56 |
+
"react-app"
|
| 57 |
+
]
|
| 58 |
+
},
|
| 59 |
+
"browserslist": {
|
| 60 |
+
"production": [
|
| 61 |
+
">0.2%",
|
| 62 |
+
"not dead",
|
| 63 |
+
"not op_mini all"
|
| 64 |
+
],
|
| 65 |
+
"development": [
|
| 66 |
+
"last 1 chrome version",
|
| 67 |
+
"last 1 firefox version",
|
| 68 |
+
"last 1 safari version"
|
| 69 |
+
]
|
| 70 |
+
}
|
| 71 |
+
}
|
client/public/index.html
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html>
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="utf-8">
|
| 5 |
+
<title> <%= htmlWebpackPlugin.options.title %> </title>
|
| 6 |
+
</head>
|
| 7 |
+
<body>
|
| 8 |
+
<div id="root">
|
| 9 |
+
</div>
|
| 10 |
+
</body>
|
| 11 |
+
</html>
|
client/scripts/build.js
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
// Do this as the first thing so that any code reading it knows the right env.
|
| 4 |
+
process.env.BABEL_ENV = 'production';
|
| 5 |
+
process.env.NODE_ENV = 'production';
|
| 6 |
+
|
| 7 |
+
// Makes the script crash on unhandled rejections instead of silently
|
| 8 |
+
// ignoring them. In the future, promise rejections that are not handled will
|
| 9 |
+
// terminate the Node.js process with a non-zero exit code.
|
| 10 |
+
process.on('unhandledRejection', err => {
|
| 11 |
+
throw err;
|
| 12 |
+
});
|
| 13 |
+
|
| 14 |
+
const path = require('path');
|
| 15 |
+
const chalk = require('react-dev-utils/chalk');
|
| 16 |
+
const fs = require('fs-extra');
|
| 17 |
+
const webpack = require('webpack');
|
| 18 |
+
const config = require('../config/webpack.config.prod');
|
| 19 |
+
const paths = require('../config/paths');
|
| 20 |
+
const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
|
| 21 |
+
const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
|
| 22 |
+
const printHostingInstructions = require('react-dev-utils/printHostingInstructions');
|
| 23 |
+
const FileSizeReporter = require('react-dev-utils/FileSizeReporter');
|
| 24 |
+
const printBuildError = require('react-dev-utils/printBuildError');
|
| 25 |
+
|
| 26 |
+
const measureFileSizesBeforeBuild =
|
| 27 |
+
FileSizeReporter.measureFileSizesBeforeBuild;
|
| 28 |
+
const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild;
|
| 29 |
+
const useYarn = fs.existsSync(paths.yarnLockFile);
|
| 30 |
+
|
| 31 |
+
// These sizes are pretty large. We'll warn for bundles exceeding them.
|
| 32 |
+
const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
|
| 33 |
+
const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
|
| 34 |
+
|
| 35 |
+
const isInteractive = process.stdout.isTTY;
|
| 36 |
+
|
| 37 |
+
// Warn and crash if required files are missing
|
| 38 |
+
if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
|
| 39 |
+
process.exit(1);
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
// We require that you explicitly set browsers and do not fall back to
|
| 43 |
+
// browserslist defaults.
|
| 44 |
+
const { checkBrowsers } = require('react-dev-utils/browsersHelper');
|
| 45 |
+
checkBrowsers(paths.appPath, isInteractive)
|
| 46 |
+
.then(() => {
|
| 47 |
+
// First, read the current file sizes in build directory.
|
| 48 |
+
// This lets us display how much they changed later.
|
| 49 |
+
return measureFileSizesBeforeBuild(paths.appBuild);
|
| 50 |
+
})
|
| 51 |
+
.then(previousFileSizes => {
|
| 52 |
+
// Remove all content but keep the directory so that
|
| 53 |
+
// if you're in it, you don't end up in Trash
|
| 54 |
+
fs.emptyDirSync(paths.appBuild);
|
| 55 |
+
// Merge with the public folder
|
| 56 |
+
copyPublicFolder();
|
| 57 |
+
// Start the webpack build
|
| 58 |
+
return build(previousFileSizes);
|
| 59 |
+
})
|
| 60 |
+
.then(
|
| 61 |
+
({ stats, previousFileSizes, warnings }) => {
|
| 62 |
+
if (warnings.length) {
|
| 63 |
+
console.log(chalk.yellow('Compiled with warnings.\n'));
|
| 64 |
+
console.log(warnings.join('\n\n'));
|
| 65 |
+
console.log(
|
| 66 |
+
'\nSearch for the ' +
|
| 67 |
+
chalk.underline(chalk.yellow('keywords')) +
|
| 68 |
+
' to learn more about each warning.',
|
| 69 |
+
);
|
| 70 |
+
console.log(
|
| 71 |
+
'To ignore, add ' +
|
| 72 |
+
chalk.cyan('// eslint-disable-next-line') +
|
| 73 |
+
' to the line before.\n',
|
| 74 |
+
);
|
| 75 |
+
} else {
|
| 76 |
+
console.log(chalk.green('Compiled successfully.\n'));
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
console.log('File sizes after gzip:\n');
|
| 80 |
+
printFileSizesAfterBuild(
|
| 81 |
+
stats,
|
| 82 |
+
previousFileSizes,
|
| 83 |
+
paths.appBuild,
|
| 84 |
+
WARN_AFTER_BUNDLE_GZIP_SIZE,
|
| 85 |
+
WARN_AFTER_CHUNK_GZIP_SIZE,
|
| 86 |
+
);
|
| 87 |
+
console.log();
|
| 88 |
+
|
| 89 |
+
const appPackage = require(paths.appPackageJson);
|
| 90 |
+
const publicUrl = paths.publicUrl;
|
| 91 |
+
const publicPath = config.output.publicPath;
|
| 92 |
+
const buildFolder = path.relative(process.cwd(), paths.appBuild);
|
| 93 |
+
printHostingInstructions(
|
| 94 |
+
appPackage,
|
| 95 |
+
publicUrl,
|
| 96 |
+
publicPath,
|
| 97 |
+
buildFolder,
|
| 98 |
+
useYarn,
|
| 99 |
+
);
|
| 100 |
+
},
|
| 101 |
+
err => {
|
| 102 |
+
const tscCompileOnError = process.env.TSC_COMPILE_ON_ERROR === 'true';
|
| 103 |
+
if (tscCompileOnError) {
|
| 104 |
+
console.log(chalk.yellow(
|
| 105 |
+
'Compiled with the following type errors (you may want to check these before deploying your app):\n',
|
| 106 |
+
));
|
| 107 |
+
printBuildError(err);
|
| 108 |
+
} else {
|
| 109 |
+
console.log(chalk.red('Failed to compile.\n'));
|
| 110 |
+
printBuildError(err);
|
| 111 |
+
process.exit(1);
|
| 112 |
+
}
|
| 113 |
+
},
|
| 114 |
+
)
|
| 115 |
+
.catch(err => {
|
| 116 |
+
if (err && err.message) {
|
| 117 |
+
console.log(err.message);
|
| 118 |
+
}
|
| 119 |
+
process.exit(1);
|
| 120 |
+
});
|
| 121 |
+
|
| 122 |
+
// Create the production build and print the deployment instructions.
|
| 123 |
+
function build(previousFileSizes) {
|
| 124 |
+
// We used to support resolving modules according to `NODE_PATH`.
|
| 125 |
+
// This now has been deprecated in favor of jsconfig/tsconfig.json
|
| 126 |
+
// This lets you use absolute paths in imports inside large monorepos:
|
| 127 |
+
if (process.env.NODE_PATH) {
|
| 128 |
+
console.log(
|
| 129 |
+
chalk.yellow(
|
| 130 |
+
'Setting NODE_PATH to resolve modules absolutely has been deprecated in favor of setting baseUrl in jsconfig.json (or tsconfig.json if you are using TypeScript) and will be removed in a future major release of create-react-app.',
|
| 131 |
+
),
|
| 132 |
+
);
|
| 133 |
+
console.log();
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
console.log('Creating an optimized production build...');
|
| 137 |
+
|
| 138 |
+
const compiler = webpack(config);
|
| 139 |
+
return new Promise((resolve, reject) => {
|
| 140 |
+
compiler.run((err, stats) => {
|
| 141 |
+
let messages;
|
| 142 |
+
if (err) {
|
| 143 |
+
if (!err.message) {
|
| 144 |
+
return reject(err);
|
| 145 |
+
}
|
| 146 |
+
messages = formatWebpackMessages({
|
| 147 |
+
errors: [err.message],
|
| 148 |
+
warnings: [],
|
| 149 |
+
});
|
| 150 |
+
} else {
|
| 151 |
+
messages = formatWebpackMessages(
|
| 152 |
+
stats.toJson({ all: false, warnings: true, errors: true }),
|
| 153 |
+
);
|
| 154 |
+
}
|
| 155 |
+
if (messages.errors.length) {
|
| 156 |
+
// Only keep the first error. Others are often indicative
|
| 157 |
+
// of the same problem, but confuse the reader with noise.
|
| 158 |
+
if (messages.errors.length > 1) {
|
| 159 |
+
messages.errors.length = 1;
|
| 160 |
+
}
|
| 161 |
+
return reject(new Error(messages.errors.join('\n\n')));
|
| 162 |
+
}
|
| 163 |
+
if (
|
| 164 |
+
process.env.CI &&
|
| 165 |
+
(typeof process.env.CI !== 'string' ||
|
| 166 |
+
process.env.CI.toLowerCase() !== 'false') &&
|
| 167 |
+
messages.warnings.length
|
| 168 |
+
) {
|
| 169 |
+
console.log(
|
| 170 |
+
chalk.yellow(
|
| 171 |
+
'\nTreating warnings as errors because process.env.CI = true.\n' +
|
| 172 |
+
'Most CI servers set it automatically.\n',
|
| 173 |
+
),
|
| 174 |
+
);
|
| 175 |
+
return reject(new Error(messages.warnings.join('\n\n')));
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
return resolve({
|
| 179 |
+
stats,
|
| 180 |
+
previousFileSizes,
|
| 181 |
+
warnings: messages.warnings,
|
| 182 |
+
});
|
| 183 |
+
});
|
| 184 |
+
});
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
function copyPublicFolder() {
|
| 188 |
+
fs.copySync(paths.appPublic, paths.appBuild, {
|
| 189 |
+
dereference: true,
|
| 190 |
+
filter: file => file !== paths.appHtml,
|
| 191 |
+
});
|
| 192 |
+
}
|
client/scripts/start.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
// Do this as the first thing so that any code reading it knows the right env.
|
| 4 |
+
process.env.BABEL_ENV = 'development';
|
| 5 |
+
process.env.NODE_ENV = 'development';
|
| 6 |
+
|
| 7 |
+
// Makes the script crash on unhandled rejections instead of silently
|
| 8 |
+
// ignoring them. In the future, promise rejections that are not handled will
|
| 9 |
+
// terminate the Node.js process with a non-zero exit code.
|
| 10 |
+
process.on('unhandledRejection', err => {
|
| 11 |
+
throw err;
|
| 12 |
+
});
|
| 13 |
+
|
| 14 |
+
const chalk = require('react-dev-utils/chalk');
|
| 15 |
+
const webpack = require('webpack');
|
| 16 |
+
const WebpackDevServer = require('webpack-dev-server');
|
| 17 |
+
const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
|
| 18 |
+
const {
|
| 19 |
+
choosePort,
|
| 20 |
+
prepareUrls,
|
| 21 |
+
} = require('react-dev-utils/WebpackDevServerUtils');
|
| 22 |
+
const openBrowser = require('react-dev-utils/openBrowser');
|
| 23 |
+
const paths = require('../config/paths');
|
| 24 |
+
const config = require('../config/webpack.config.dev');
|
| 25 |
+
|
| 26 |
+
const isInteractive = process.stdout.isTTY;
|
| 27 |
+
|
| 28 |
+
// Warn and crash if required files are missing
|
| 29 |
+
if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
|
| 30 |
+
process.exit(1);
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
// Tools like Cloud9 rely on this.
|
| 34 |
+
const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3000;
|
| 35 |
+
const HOST = process.env.HOST || '0.0.0.0';
|
| 36 |
+
|
| 37 |
+
if (process.env.HOST) {
|
| 38 |
+
console.log(
|
| 39 |
+
chalk.cyan(
|
| 40 |
+
`Attempting to bind to HOST environment variable: ${chalk.yellow(
|
| 41 |
+
chalk.bold(process.env.HOST),
|
| 42 |
+
)}`,
|
| 43 |
+
),
|
| 44 |
+
);
|
| 45 |
+
console.log(
|
| 46 |
+
'If this was unintentional, check that you haven\'t mistakenly set it in your shell.',
|
| 47 |
+
);
|
| 48 |
+
console.log(
|
| 49 |
+
`Learn more here: ${chalk.yellow('https://bit.ly/CRA-advanced-config')}`,
|
| 50 |
+
);
|
| 51 |
+
console.log();
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
// We require that you explicitly set browsers and do not fall back to
|
| 55 |
+
// browserslist defaults.
|
| 56 |
+
const { checkBrowsers } = require('react-dev-utils/browsersHelper');
|
| 57 |
+
checkBrowsers(paths.appPath, isInteractive)
|
| 58 |
+
.then(() => {
|
| 59 |
+
// We attempt to use the default port but if it is busy, we offer the user to
|
| 60 |
+
// run on a different port. `choosePort()` Promise resolves to the next free port.
|
| 61 |
+
return choosePort(HOST, DEFAULT_PORT);
|
| 62 |
+
})
|
| 63 |
+
.then(port => {
|
| 64 |
+
if (port == null) {
|
| 65 |
+
// We have not found a port.
|
| 66 |
+
return;
|
| 67 |
+
}
|
| 68 |
+
const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
|
| 69 |
+
const urls = prepareUrls(protocol, HOST, port);
|
| 70 |
+
|
| 71 |
+
let compiler;
|
| 72 |
+
try {
|
| 73 |
+
compiler = webpack(config);
|
| 74 |
+
} catch (err) {
|
| 75 |
+
console.error('Webpack compile error: ', err);
|
| 76 |
+
process.exit(1);
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
// Serve webpack assets generated by the compiler over a web server.
|
| 80 |
+
const devServer = new WebpackDevServer(compiler, config.devServer);
|
| 81 |
+
// Launch WebpackDevServer.
|
| 82 |
+
devServer.listen(port, HOST, err => {
|
| 83 |
+
if (err) {
|
| 84 |
+
return console.log(err);
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
// We used to support resolving modules according to `NODE_PATH`.
|
| 88 |
+
// This now has been deprecated in favor of jsconfig/tsconfig.json
|
| 89 |
+
// This lets you use absolute paths in imports inside large monorepos:
|
| 90 |
+
if (process.env.NODE_PATH) {
|
| 91 |
+
console.log(
|
| 92 |
+
chalk.yellow(
|
| 93 |
+
'Setting NODE_PATH to resolve modules absolutely has been deprecated in favor of setting baseUrl in jsconfig.json (or tsconfig.json if you are using TypeScript) and will be removed in a future major release of create-react-app.',
|
| 94 |
+
),
|
| 95 |
+
);
|
| 96 |
+
console.log();
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
console.log(chalk.cyan('Starting the development server...\n'));
|
| 100 |
+
openBrowser(urls.localUrlForBrowser);
|
| 101 |
+
});
|
| 102 |
+
|
| 103 |
+
['SIGINT', 'SIGTERM'].forEach(function (sig) {
|
| 104 |
+
process.on(sig, function () {
|
| 105 |
+
devServer.close();
|
| 106 |
+
process.exit();
|
| 107 |
+
});
|
| 108 |
+
});
|
| 109 |
+
})
|
| 110 |
+
.catch(err => {
|
| 111 |
+
if (err && err.message) {
|
| 112 |
+
console.log(err.message);
|
| 113 |
+
}
|
| 114 |
+
process.exit(1);
|
| 115 |
+
});
|
client/scripts/test.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
// Do this as the first thing so that any code reading it knows the right env.
|
| 4 |
+
process.env.BABEL_ENV = 'test';
|
| 5 |
+
process.env.NODE_ENV = 'test';
|
| 6 |
+
process.env.PUBLIC_URL = '';
|
| 7 |
+
|
| 8 |
+
// Makes the script crash on unhandled rejections instead of silently
|
| 9 |
+
// ignoring them. In the future, promise rejections that are not handled will
|
| 10 |
+
// terminate the Node.js process with a non-zero exit code.
|
| 11 |
+
process.on('unhandledRejection', err => {
|
| 12 |
+
throw err;
|
| 13 |
+
});
|
| 14 |
+
|
| 15 |
+
// Ensure environment variables are read.
|
| 16 |
+
require('../config/env');
|
| 17 |
+
|
| 18 |
+
const jest = require('jest');
|
| 19 |
+
const execSync = require('child_process').execSync;
|
| 20 |
+
const argv = process.argv.slice(2);
|
| 21 |
+
|
| 22 |
+
function isInGitRepository () {
|
| 23 |
+
try {
|
| 24 |
+
execSync('git rev-parse --is-inside-work-tree', { stdio: 'ignore' });
|
| 25 |
+
return true;
|
| 26 |
+
} catch (e) {
|
| 27 |
+
return false;
|
| 28 |
+
}
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
function isInMercurialRepository () {
|
| 32 |
+
try {
|
| 33 |
+
execSync('hg --cwd . root', { stdio: 'ignore' });
|
| 34 |
+
return true;
|
| 35 |
+
} catch (e) {
|
| 36 |
+
return false;
|
| 37 |
+
}
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
// Watch unless on CI or explicitly running all tests
|
| 41 |
+
if (
|
| 42 |
+
!process.env.CI &&
|
| 43 |
+
argv.indexOf('--watchAll') === -1 &&
|
| 44 |
+
argv.indexOf('--watchAll=false') === -1
|
| 45 |
+
) {
|
| 46 |
+
// https://github.com/facebook/create-react-app/issues/5210
|
| 47 |
+
const hasSourceControl = isInGitRepository() || isInMercurialRepository();
|
| 48 |
+
argv.push(hasSourceControl ? '--watch' : '--watchAll');
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
jest.run(argv);
|
client/src/FileChunker.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const CHUNK_SIZE = 64 * 1024;
|
| 2 |
+
|
| 3 |
+
class FileChunker {
|
| 4 |
+
constructor(file) {
|
| 5 |
+
this.file = file;
|
| 6 |
+
this.reader = new FileReader();
|
| 7 |
+
this.offset = 0;
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
getNextChunk() {
|
| 11 |
+
return new Promise((resolve, reject) => {
|
| 12 |
+
if (this.offset >= this.file.size) {
|
| 13 |
+
resolve({
|
| 14 |
+
done: true,
|
| 15 |
+
});
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
this.reader.onload = (e) => {
|
| 19 |
+
const chunk = e.target.result;
|
| 20 |
+
this.offset += chunk.byteLength;
|
| 21 |
+
resolve({
|
| 22 |
+
done: this.offset >= this.file.size,
|
| 23 |
+
chunk,
|
| 24 |
+
offset: this.offset,
|
| 25 |
+
});
|
| 26 |
+
};
|
| 27 |
+
this.reader.onabort = () => {
|
| 28 |
+
reject(new Error('FileReader abort'));
|
| 29 |
+
};
|
| 30 |
+
this.reader.onerror = (evt) => {
|
| 31 |
+
reject(new Error('FileReader onerror' + evt));
|
| 32 |
+
};
|
| 33 |
+
const blob = this.file.slice(this.offset, this.offset + CHUNK_SIZE);
|
| 34 |
+
this.reader.readAsArrayBuffer(blob);
|
| 35 |
+
});
|
| 36 |
+
}
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
export default FileChunker;
|
client/src/Peer.js
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import EventEmitter from 'eventemitter3';
|
| 2 |
+
import ws from './ws';
|
| 3 |
+
|
| 4 |
+
const BUFFERED_AMOUNT_LOW_THRESHOLD = 256 * 1024;
|
| 5 |
+
const BUF_WAITING_THRESHOLD = 1024 * 1024;
|
| 6 |
+
|
| 7 |
+
export default class Peer extends EventEmitter {
|
| 8 |
+
constructor() {
|
| 9 |
+
super();
|
| 10 |
+
this.id = null; // not used
|
| 11 |
+
this.targetId = null;
|
| 12 |
+
this.pc = null; // RTCPeerConnection
|
| 13 |
+
this.dc = null; // RTCDataChannel
|
| 14 |
+
this.waitingCallback = null;
|
| 15 |
+
this.isCaller = null;
|
| 16 |
+
|
| 17 |
+
this.onIceCandidate = this.onIceCandidate.bind(this);
|
| 18 |
+
this.onDescription = this.onDescription.bind(this);
|
| 19 |
+
this.connectPeer = this.connectPeer.bind(this);
|
| 20 |
+
this.onConnectionStateChange = this.onConnectionStateChange.bind(this);
|
| 21 |
+
this.onRTCMessage = this.onRTCMessage.bind(this);
|
| 22 |
+
this.onChannelOpen = this.onChannelOpen.bind(this);
|
| 23 |
+
this.onChannelClose = this.onChannelClose.bind(this);
|
| 24 |
+
this.onBufferedAmountLow = this.onBufferedAmountLow.bind(this);
|
| 25 |
+
|
| 26 |
+
this.onS2cSignal = this.onS2cSignal.bind(this);
|
| 27 |
+
this.onS2cOpen = this.onS2cOpen.bind(this);
|
| 28 |
+
ws.registerMessageHandler('s2c_open', this.onS2cOpen);
|
| 29 |
+
ws.registerMessageHandler('s2c_signal', this.onS2cSignal);
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
onS2cOpen(payload) {
|
| 33 |
+
this.id = payload.id;
|
| 34 |
+
this.emit('peerId', this.id);
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
onS2cSignal(payload) {
|
| 38 |
+
if (!this.isCaller) {
|
| 39 |
+
this.targetId = payload.srcId;
|
| 40 |
+
}
|
| 41 |
+
if (!this.pc) {
|
| 42 |
+
this.createRTCConnection(false);
|
| 43 |
+
}
|
| 44 |
+
if (payload.sdp) {
|
| 45 |
+
this.pc.setRemoteDescription(new RTCSessionDescription(payload.sdp))
|
| 46 |
+
.then(_ => {
|
| 47 |
+
if (payload.sdp.type === 'offer') {
|
| 48 |
+
return this.makeAnswer();
|
| 49 |
+
}
|
| 50 |
+
});
|
| 51 |
+
} else if (payload.ice) {
|
| 52 |
+
this.pc.addIceCandidate(new RTCIceCandidate(payload.ice));
|
| 53 |
+
}
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
onDescription(description) {
|
| 57 |
+
this.pc.setLocalDescription(description)
|
| 58 |
+
.then(() => {
|
| 59 |
+
ws.sendJSON({
|
| 60 |
+
type: 'c2s_signal',
|
| 61 |
+
payload: {
|
| 62 |
+
targetId: this.targetId,
|
| 63 |
+
sdp: description,
|
| 64 |
+
},
|
| 65 |
+
});
|
| 66 |
+
})
|
| 67 |
+
.catch(e => console.log('onDescription error: ', e));
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
onConnectionStateChange() {
|
| 71 |
+
if (this.pc.connectionState === 'disconnected') {
|
| 72 |
+
if (this.dc) {
|
| 73 |
+
this.dc.close();
|
| 74 |
+
}
|
| 75 |
+
if (this.waitingCallback) {
|
| 76 |
+
this.waitingCallback(new Error('peer disconnected, cannot send'));
|
| 77 |
+
this.waitingCallback = null;
|
| 78 |
+
}
|
| 79 |
+
this.emit('disconnected');
|
| 80 |
+
} else if (this.pc.connectionState === 'connected') {
|
| 81 |
+
this.emit('connected');
|
| 82 |
+
} else if (this.pc.connectionState === 'connecting') {
|
| 83 |
+
this.emit('connecting');
|
| 84 |
+
} else if (this.pc.connectionState === 'failed') {
|
| 85 |
+
this.emit('connectFailed');
|
| 86 |
+
}
|
| 87 |
+
console.log('onConnectionStateChange: ', this.pc.connectionState);
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
onRTCMessage(e) {
|
| 91 |
+
this.emit('data', e.data);
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
createRTCConnection(isCaller) {
|
| 95 |
+
const config = {
|
| 96 |
+
iceServers: [
|
| 97 |
+
{
|
| 98 |
+
urls: 'stun:deershare.com',
|
| 99 |
+
},
|
| 100 |
+
{
|
| 101 |
+
urls: 'turn:0.peerjs.com:3478',
|
| 102 |
+
username: 'peerjs',
|
| 103 |
+
credential: 'peerjsp',
|
| 104 |
+
},
|
| 105 |
+
],
|
| 106 |
+
};
|
| 107 |
+
const pc = new RTCPeerConnection(config);
|
| 108 |
+
this.pc = pc;
|
| 109 |
+
pc.onconnectionstatechange = e => this.onConnectionStateChange(e);
|
| 110 |
+
pc.onicecandidate = this.onIceCandidate;
|
| 111 |
+
|
| 112 |
+
this.isCaller = isCaller;
|
| 113 |
+
|
| 114 |
+
if (isCaller) {
|
| 115 |
+
const dc = pc.createDataChannel('file-transfer', { ordered: true });
|
| 116 |
+
this.setupDataChannel(dc);
|
| 117 |
+
this.makeOffer();
|
| 118 |
+
} else {
|
| 119 |
+
this.pc.ondatachannel = e => {
|
| 120 |
+
const dc = e.channel || e.target;
|
| 121 |
+
this.setupDataChannel(dc);
|
| 122 |
+
};
|
| 123 |
+
}
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
setupDataChannel(dc) {
|
| 127 |
+
this.dc = dc;
|
| 128 |
+
dc.bufferedAmountLowThreshold = BUFFERED_AMOUNT_LOW_THRESHOLD;
|
| 129 |
+
dc.binaryType = 'arraybuffer';
|
| 130 |
+
dc.onopen = this.onChannelOpen;
|
| 131 |
+
dc.onclose = this.onChannelClose;
|
| 132 |
+
dc.onerror = this.onChannelError;
|
| 133 |
+
dc.onbufferedamountlow = this.onBufferedAmountLow;
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
makeOffer() {
|
| 137 |
+
this.pc.createOffer()
|
| 138 |
+
.then(description => {
|
| 139 |
+
return this.onDescription(description);
|
| 140 |
+
});
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
makeAnswer() {
|
| 144 |
+
return this.pc.createAnswer()
|
| 145 |
+
.then(d => this.onDescription(d));
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
connectPeer(targetId) {
|
| 149 |
+
this.targetId = targetId;
|
| 150 |
+
this.createRTCConnection(true);
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
destroy() {
|
| 154 |
+
this.targetId = null;
|
| 155 |
+
this.waitingCallback = null;
|
| 156 |
+
if (this.pc) {
|
| 157 |
+
this.pc.close();
|
| 158 |
+
this.pc = null;
|
| 159 |
+
}
|
| 160 |
+
if (this.dc) {
|
| 161 |
+
this.dc.close();
|
| 162 |
+
this.dc = null;
|
| 163 |
+
}
|
| 164 |
+
this.removeAllListeners();
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
onIceCandidate(e) {
|
| 168 |
+
if (!e.candidate) {
|
| 169 |
+
return;
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
ws.sendJSON({
|
| 173 |
+
type: 'c2s_signal',
|
| 174 |
+
payload: {
|
| 175 |
+
targetId: this.targetId,
|
| 176 |
+
ice: e.candidate,
|
| 177 |
+
},
|
| 178 |
+
});
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
onChannelOpen(e) {
|
| 182 |
+
this.emit('channelOpen');
|
| 183 |
+
this.dc.onmessage = this.onRTCMessage;
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
onChannelClose(e) {
|
| 187 |
+
console.log('## channel close: ', e);
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
onChannelError(e) {
|
| 191 |
+
console.log('## channel error: ', e);
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
onBufferedAmountLow() {
|
| 195 |
+
if (this.waitingCallback) {
|
| 196 |
+
this.waitingCallback();
|
| 197 |
+
this.waitingCallback = null;
|
| 198 |
+
}
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
send(data) {
|
| 202 |
+
return new Promise((resolve, reject) => {
|
| 203 |
+
if (this.dc.readyState === 'open') {
|
| 204 |
+
if (this.dc.bufferedAmount >= BUF_WAITING_THRESHOLD) {
|
| 205 |
+
this.waitingCallback = (err) => {
|
| 206 |
+
if (err) {
|
| 207 |
+
reject(err);
|
| 208 |
+
} else {
|
| 209 |
+
this.dc.send(data);
|
| 210 |
+
resolve();
|
| 211 |
+
}
|
| 212 |
+
};
|
| 213 |
+
} else {
|
| 214 |
+
try {
|
| 215 |
+
this.dc.send(data);
|
| 216 |
+
resolve();
|
| 217 |
+
} catch (e) {
|
| 218 |
+
console.error('send error: ', e);
|
| 219 |
+
reject(e);
|
| 220 |
+
}
|
| 221 |
+
}
|
| 222 |
+
} else {
|
| 223 |
+
const errMsg = 'send but channel is not open, now state is: ' + this.dc.readyState;
|
| 224 |
+
console.error(errMsg);
|
| 225 |
+
reject(new Error(errMsg));
|
| 226 |
+
}
|
| 227 |
+
});
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
sendJSON(obj) {
|
| 231 |
+
return this.send(JSON.stringify(obj));
|
| 232 |
+
}
|
| 233 |
+
}
|
client/src/actions/configureWS.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* eslint-disable no-unused-vars */
|
| 2 |
+
import ws from '../ws';
|
| 3 |
+
import * as types from '../common/actionTypes';
|
| 4 |
+
import Toast from '../components/common/Toast';
|
| 5 |
+
|
| 6 |
+
export default function configureWS(dispatch) {
|
| 7 |
+
function s2cPrepareSend(payload) {
|
| 8 |
+
dispatch({ type: types.UPDATE_SEND_FILE_INFO, payload });
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
function s2cPrepareRecv(payload) {
|
| 12 |
+
dispatch({ type: types.UPDATE_RECV_FILE_INFO, payload });
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
function s2cError(payload) {
|
| 16 |
+
Toast.error(payload.message);
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
// 移动到HomePage.js中处理
|
| 20 |
+
// ws.registerMessageHandler('s2c_prepare_send', s2cPrepareSend);
|
| 21 |
+
// ws.registerMessageHandler('s2c_prepare_recv', s2cPrepareRecv);
|
| 22 |
+
ws.registerMessageHandler('s2c_error', s2cError);
|
| 23 |
+
}
|
client/src/actions/feedback.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import axios from 'axios';
|
| 2 |
+
|
| 3 |
+
export function sendHello (msg, callback = () => {}) {
|
| 4 |
+
return (dispatch) => {
|
| 5 |
+
axios.post('/api/hello', {
|
| 6 |
+
msg,
|
| 7 |
+
})
|
| 8 |
+
.then((res) => {
|
| 9 |
+
console.log('## res is: ', res.data)
|
| 10 |
+
});
|
| 11 |
+
};
|
| 12 |
+
}
|
client/src/actions/file.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import ws from '../ws';
|
| 2 |
+
|
| 3 |
+
export function prepareSend(files) {
|
| 4 |
+
ws.sendJSON({
|
| 5 |
+
type: 'c2s_prepare_send',
|
| 6 |
+
payload: {
|
| 7 |
+
files,
|
| 8 |
+
},
|
| 9 |
+
});
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
export function deleteRecvCode(recvCode) {
|
| 13 |
+
ws.sendJSON({
|
| 14 |
+
type: 'c2s_delete_recv_code',
|
| 15 |
+
payload: {
|
| 16 |
+
recvCode,
|
| 17 |
+
},
|
| 18 |
+
});
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
export function prepareRecv(recvCode) {
|
| 22 |
+
ws.sendJSON({
|
| 23 |
+
type: 'c2s_prepare_recv',
|
| 24 |
+
payload: {
|
| 25 |
+
recvCode,
|
| 26 |
+
},
|
| 27 |
+
});
|
| 28 |
+
}
|
client/src/actions/user.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import axios from 'axios';
|
| 2 |
+
import * as types from '../common/actionTypes';
|
| 3 |
+
|
| 4 |
+
export function sendHello (msg, callback = () => {}) {
|
| 5 |
+
return (dispatch) => {
|
| 6 |
+
axios.post('/api/hello', {
|
| 7 |
+
msg,
|
| 8 |
+
})
|
| 9 |
+
.then((res) => {
|
| 10 |
+
console.log('## res is: ', res.data)
|
| 11 |
+
dispatch({
|
| 12 |
+
type: types.UPDATE_HELLO_MSG,
|
| 13 |
+
payload: res.data,
|
| 14 |
+
});
|
| 15 |
+
});
|
| 16 |
+
};
|
| 17 |
+
}
|
client/src/common/actionTypes.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export const UPDATE_HELLO_MSG = 'UPDATE_HELLO_MSG';
|
| 2 |
+
|
| 3 |
+
export const UPDATE_SEND_FILE_INFO = 'UPDATE_SEND_FILE_INFO';
|
| 4 |
+
|
| 5 |
+
export const UPDATE_RECV_FILE_INFO = 'UPDATE_RECV_FILE_INFO';
|
client/src/common/global.css
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.animation-spin {
|
| 2 |
+
animation: spin 1s infinite linear;
|
| 3 |
+
}
|
| 4 |
+
|
| 5 |
+
@keyframes spin {
|
| 6 |
+
from {
|
| 7 |
+
transform: rotate(0deg);
|
| 8 |
+
}
|
| 9 |
+
to {
|
| 10 |
+
transform: rotate(359deg);
|
| 11 |
+
}
|
| 12 |
+
}
|
client/src/common/util.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export function calcPercent(a, b) {
|
| 2 |
+
return ((a / b) * 100).toFixed(1);
|
| 3 |
+
}
|
client/src/components/App.cm.styl
ADDED
|
File without changes
|
client/src/components/App.css
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
html {
|
| 2 |
+
color: #4a4a4a;
|
| 3 |
+
}
|
| 4 |
+
|
| 5 |
+
html,body {
|
| 6 |
+
height: 100%;
|
| 7 |
+
font-size: 14px;
|
| 8 |
+
box-sizing: border-box;
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
*, *:before, *:after {
|
| 12 |
+
box-sizing: inherit;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
div#root {
|
| 16 |
+
height: 100%;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
a, a:hover, a:active {
|
| 20 |
+
color: #6f6f6f;
|
| 21 |
+
text-decoration: none;
|
| 22 |
+
}
|
client/src/components/App.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React from 'react';
|
| 2 |
+
import { connect } from 'react-redux';
|
| 3 |
+
import PropTypes from 'prop-types';
|
| 4 |
+
import ReactGA from 'react-ga';
|
| 5 |
+
import {
|
| 6 |
+
withRouter,
|
| 7 |
+
} from 'react-router';
|
| 8 |
+
import {
|
| 9 |
+
Switch,
|
| 10 |
+
Route,
|
| 11 |
+
} from 'react-router-dom';
|
| 12 |
+
import * as Sentry from '@sentry/browser';
|
| 13 |
+
|
| 14 |
+
import Footer from '../components/Footer';
|
| 15 |
+
import HomePage from '../pages/HomePage';
|
| 16 |
+
|
| 17 |
+
import './App.css';
|
| 18 |
+
import './App.cm.styl';
|
| 19 |
+
|
| 20 |
+
class App extends React.Component {
|
| 21 |
+
constructor(props) {
|
| 22 |
+
super(props);
|
| 23 |
+
this.state = {
|
| 24 |
+
hasError: false,
|
| 25 |
+
};
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
componentDidMount() {
|
| 29 |
+
if (process.env.NODE_ENV === 'production') {
|
| 30 |
+
this.props.history.listen(location => {
|
| 31 |
+
ReactGA.pageview(location.pathname);
|
| 32 |
+
});
|
| 33 |
+
}
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
static getDerivedStateFromError() {
|
| 37 |
+
return { hasError: true };
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
componentDidCatch(error, errorInfo) {
|
| 41 |
+
Sentry.withScope(scope => {
|
| 42 |
+
Object.keys(errorInfo).forEach(key => {
|
| 43 |
+
scope.setExtra(key, errorInfo[key]);
|
| 44 |
+
});
|
| 45 |
+
Sentry.captureException(error);
|
| 46 |
+
});
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
render() {
|
| 50 |
+
const {
|
| 51 |
+
hasError,
|
| 52 |
+
} = this.state;
|
| 53 |
+
|
| 54 |
+
if (hasError) {
|
| 55 |
+
return (
|
| 56 |
+
<>
|
| 57 |
+
<h1 style={{ textAlign: 'center' }}>抱歉页面出现错误,我们的工程师已经收到通知,会尽快处理。您可以:<a href="">点此刷新页面重试</a></h1>
|
| 58 |
+
</>
|
| 59 |
+
);
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
return (
|
| 63 |
+
<Switch>
|
| 64 |
+
<Route path="/">
|
| 65 |
+
<HomePage />
|
| 66 |
+
<Footer />
|
| 67 |
+
</Route>
|
| 68 |
+
</Switch>
|
| 69 |
+
);
|
| 70 |
+
}
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
App.propTypes = {
|
| 74 |
+
sendHello: PropTypes.func,
|
| 75 |
+
user: PropTypes.object,
|
| 76 |
+
history: PropTypes.object,
|
| 77 |
+
};
|
| 78 |
+
|
| 79 |
+
function mapStateToProps(state) {
|
| 80 |
+
return {
|
| 81 |
+
user: state.user,
|
| 82 |
+
};
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
export default withRouter(connect(mapStateToProps, {
|
| 86 |
+
})(App));
|
client/src/components/CommonPanel.cm.styl
ADDED
|
File without changes
|
client/src/components/CommonPanel.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React, { Component } from 'react';
|
| 2 |
+
import PropTypes from 'prop-types';
|
| 3 |
+
import styles from './CommonPanel.cm.styl';
|
| 4 |
+
|
| 5 |
+
class CommonPanel extends Component {
|
| 6 |
+
constructor(props) {
|
| 7 |
+
super(props);
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
render() {
|
| 11 |
+
const {
|
| 12 |
+
title,
|
| 13 |
+
} = this.props;
|
| 14 |
+
|
| 15 |
+
return (
|
| 16 |
+
<div className={styles.base}>
|
| 17 |
+
<div className={styles.title}>
|
| 18 |
+
{title}
|
| 19 |
+
</div>
|
| 20 |
+
</div>
|
| 21 |
+
);
|
| 22 |
+
}
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
export default CommonPanel;
|
client/src/components/ContactPanel.cm.styl
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.base
|
| 2 |
+
width 420px
|
| 3 |
+
padding 20px 40px
|
| 4 |
+
background white
|
| 5 |
+
text-align center
|
| 6 |
+
box-shadow 0px 2px 4px 0px rgba(197, 197, 197, 0.5)
|
| 7 |
+
|
| 8 |
+
.title
|
| 9 |
+
text-align center
|
| 10 |
+
margin-bottom 15px
|
| 11 |
+
font-weight 700
|
| 12 |
+
color #757575
|
| 13 |
+
|
| 14 |
+
.input
|
| 15 |
+
width 100%
|
| 16 |
+
height 38px
|
| 17 |
+
margin-bottom 15px
|
| 18 |
+
|
| 19 |
+
.textarea
|
| 20 |
+
width 100%
|
| 21 |
+
padding 10px
|
| 22 |
+
border 1px solid #a9a9a9
|
| 23 |
+
appearance none
|
| 24 |
+
outline none
|
| 25 |
+
margin-bottom 15px
|
| 26 |
+
&:focus
|
| 27 |
+
&:active
|
| 28 |
+
border-color #56BDC0
|
| 29 |
+
&::placeholder
|
| 30 |
+
color #b5b5b5
|
| 31 |
+
|
| 32 |
+
.btn
|
| 33 |
+
width 100%
|
| 34 |
+
margin-bottom 15px
|
| 35 |
+
|
| 36 |
+
.tips
|
| 37 |
+
color #8d8d8d
|
| 38 |
+
text-align left
|
client/src/components/ContactPanel.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React, { Component } from 'react';
|
| 2 |
+
import axios from 'axios';
|
| 3 |
+
import Input from './common/Input';
|
| 4 |
+
import Button from './common/Button';
|
| 5 |
+
import Toast from './common/Toast';
|
| 6 |
+
|
| 7 |
+
import styles from './ContactPanel.cm.styl';
|
| 8 |
+
|
| 9 |
+
class ContactPanel extends Component {
|
| 10 |
+
constructor(props) {
|
| 11 |
+
super(props);
|
| 12 |
+
this.state = {
|
| 13 |
+
contact: '',
|
| 14 |
+
content: '',
|
| 15 |
+
};
|
| 16 |
+
|
| 17 |
+
this.handleContactChange = this.handleContactChange.bind(this);
|
| 18 |
+
this.handleContentChange = this.handleContentChange.bind(this);
|
| 19 |
+
this.handleSubmit = this.handleSubmit.bind(this);
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
componentDidMount() {
|
| 23 |
+
document.title = '小鹿快传|简单安全高效的P2P文件传输服务 - 联系我们';
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
handleContactChange(value) {
|
| 27 |
+
this.setState({
|
| 28 |
+
contact: value,
|
| 29 |
+
});
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
handleContentChange(e) {
|
| 33 |
+
this.setState({
|
| 34 |
+
content: e.target.value,
|
| 35 |
+
});
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
handleSubmit() {
|
| 39 |
+
const {
|
| 40 |
+
contact,
|
| 41 |
+
content,
|
| 42 |
+
} = this.state;
|
| 43 |
+
|
| 44 |
+
if (!contact) {
|
| 45 |
+
Toast.error('请输入联系方式');
|
| 46 |
+
return;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
if (!content) {
|
| 50 |
+
Toast.error('请输入留言内容');
|
| 51 |
+
return;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
axios.post('/api/feedback', {
|
| 55 |
+
contact,
|
| 56 |
+
content,
|
| 57 |
+
})
|
| 58 |
+
.then((res) => {
|
| 59 |
+
Toast.success('留言成功');
|
| 60 |
+
this.setState({
|
| 61 |
+
contact: '',
|
| 62 |
+
content: '',
|
| 63 |
+
});
|
| 64 |
+
});
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
render() {
|
| 68 |
+
const {
|
| 69 |
+
contact,
|
| 70 |
+
content,
|
| 71 |
+
} = this.state;
|
| 72 |
+
|
| 73 |
+
return (
|
| 74 |
+
<div className={styles.base}>
|
| 75 |
+
<div className={styles.title}>
|
| 76 |
+
联系我们
|
| 77 |
+
</div>
|
| 78 |
+
<Input placeholder="请输入您的手机号或邮箱" inputClassName={styles.input} value={contact} onChange={this.handleContactChange} />
|
| 79 |
+
<textarea placeholder="请输入留言内容" rows="6" className={styles.textarea} value={content} onChange={this.handleContentChange} />
|
| 80 |
+
<Button type="primary" className={styles.btn} onClick={this.handleSubmit}>
|
| 81 |
+
留言
|
| 82 |
+
</Button>
|
| 83 |
+
<div className={styles.tips}>
|
| 84 |
+
请直接在上方留言,我们会尽快给您回复,<br />
|
| 85 |
+
您也可以发邮件到 <a target="_blank" rel="noopener noreferrer" href="mailto:support@deershare.com">support@deershare.com</a>
|
| 86 |
+
</div>
|
| 87 |
+
</div>
|
| 88 |
+
);
|
| 89 |
+
}
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
export default ContactPanel;
|
client/src/components/FileBox.cm.styl
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.container
|
| 2 |
+
max-height 300px
|
| 3 |
+
min-height 200px
|
| 4 |
+
padding 0px 8px
|
| 5 |
+
background #fafafa
|
| 6 |
+
overflow-y auto
|
| 7 |
+
|
| 8 |
+
.file-row
|
| 9 |
+
display flex
|
| 10 |
+
justify-content space-between
|
| 11 |
+
align-items center
|
| 12 |
+
padding 0px 8px
|
| 13 |
+
height 50px
|
| 14 |
+
line-height @height
|
| 15 |
+
background white
|
| 16 |
+
border-radius 2px
|
| 17 |
+
margin 10px auto
|
| 18 |
+
|
| 19 |
+
.left
|
| 20 |
+
height 100%
|
| 21 |
+
|
| 22 |
+
.file-icon
|
| 23 |
+
font-size 28px
|
| 24 |
+
color #8e8e8e
|
| 25 |
+
|
| 26 |
+
.file-info
|
| 27 |
+
display inline-block
|
| 28 |
+
|
| 29 |
+
.file-name
|
| 30 |
+
font-size 16px
|
| 31 |
+
line-height 1.4
|
| 32 |
+
max-width 12em
|
| 33 |
+
overflow hidden
|
| 34 |
+
text-overflow ellipsis
|
| 35 |
+
white-space nowrap
|
| 36 |
+
|
| 37 |
+
.file-size
|
| 38 |
+
text-align left
|
| 39 |
+
font-size 12px
|
| 40 |
+
line-height 1.2
|
| 41 |
+
color #adadad
|
| 42 |
+
|
| 43 |
+
.close-icon
|
| 44 |
+
cursor pointer
|
| 45 |
+
color #8e8e8e
|
| 46 |
+
|
| 47 |
+
.waiting
|
| 48 |
+
color #8e8e8e
|
| 49 |
+
|
| 50 |
+
.download
|
| 51 |
+
cursor pointer
|
| 52 |
+
&
|
| 53 |
+
&:hover
|
| 54 |
+
color #649ae4
|
| 55 |
+
|
| 56 |
+
.completed
|
| 57 |
+
color #93ECAE
|
client/src/components/FileBox.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React, { Component } from 'react';
|
| 2 |
+
import PropTypes from 'prop-types';
|
| 3 |
+
import prettyBytes from 'pretty-bytes';
|
| 4 |
+
import FileSaver from 'file-saver';
|
| 5 |
+
import Icon from './common/Icon';
|
| 6 |
+
import styles from './FileBox.cm.styl';
|
| 7 |
+
|
| 8 |
+
class FileBox extends Component {
|
| 9 |
+
constructor(props) {
|
| 10 |
+
super(props);
|
| 11 |
+
this.onDownload = this.onDownload.bind(this);
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
onDownload(url, name) {
|
| 15 |
+
return () => {
|
| 16 |
+
FileSaver.saveAs(url, name);
|
| 17 |
+
};
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
render() {
|
| 21 |
+
const {
|
| 22 |
+
files,
|
| 23 |
+
removable,
|
| 24 |
+
curFileId,
|
| 25 |
+
} = this.props;
|
| 26 |
+
|
| 27 |
+
return (
|
| 28 |
+
<div className={styles.container}>
|
| 29 |
+
{files.map(f => {
|
| 30 |
+
const {
|
| 31 |
+
uid,
|
| 32 |
+
name,
|
| 33 |
+
size,
|
| 34 |
+
downloadUrl,
|
| 35 |
+
pct,
|
| 36 |
+
} = f;
|
| 37 |
+
let downloadInfo = null;
|
| 38 |
+
if (downloadUrl) {
|
| 39 |
+
downloadInfo = <span onClick={this.onDownload(downloadUrl, name)} className={styles.download}>下载</span>;
|
| 40 |
+
} else if (pct >= 100) {
|
| 41 |
+
downloadInfo = <span className={styles.completed}>完成</span>;
|
| 42 |
+
} else if (uid === curFileId) {
|
| 43 |
+
downloadInfo = <span>{pct}%</span>;
|
| 44 |
+
} else {
|
| 45 |
+
downloadInfo = <span className={styles.waiting}>等待</span>;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
return (
|
| 49 |
+
<div key={f.uid} className={styles.fileRow}>
|
| 50 |
+
<div className={styles.left}>
|
| 51 |
+
<Icon name="file" className={styles.fileIcon} />
|
| 52 |
+
<div className={styles.fileInfo}>
|
| 53 |
+
<div className={styles.fileName}>
|
| 54 |
+
{name}
|
| 55 |
+
</div>
|
| 56 |
+
<div className={styles.fileSize}>
|
| 57 |
+
{prettyBytes(size)}
|
| 58 |
+
</div>
|
| 59 |
+
</div>
|
| 60 |
+
</div>
|
| 61 |
+
<div className={styles.right}>
|
| 62 |
+
{!removable && downloadInfo}
|
| 63 |
+
{removable && <Icon name="close" onClick={this.props.onRemoveFile(f.uid)} className={styles.closeIcon} />}
|
| 64 |
+
</div>
|
| 65 |
+
</div>
|
| 66 |
+
);
|
| 67 |
+
})}
|
| 68 |
+
</div>
|
| 69 |
+
);
|
| 70 |
+
}
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
FileBox.propTypes = {
|
| 74 |
+
files: PropTypes.array,
|
| 75 |
+
removable: PropTypes.bool,
|
| 76 |
+
curFileId: PropTypes.string,
|
| 77 |
+
onRemoveFile: PropTypes.func,
|
| 78 |
+
};
|
| 79 |
+
|
| 80 |
+
export default FileBox;
|
client/src/components/Footer.cm.styl
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.base
|
| 2 |
+
width 100%
|
| 3 |
+
text-align center
|
| 4 |
+
height 50px
|
| 5 |
+
margin-top -50px
|
| 6 |
+
padding-bottom 10px
|
| 7 |
+
padding-top 20px
|
| 8 |
+
color #B1B1B1
|
| 9 |
+
a
|
| 10 |
+
&
|
| 11 |
+
&:hover
|
| 12 |
+
color #B1B1B1
|
| 13 |
+
cursor pointer
|
| 14 |
+
|
| 15 |
+
|
client/src/components/Footer.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React from 'react';
|
| 2 |
+
import styles from './Footer.cm.styl';
|
| 3 |
+
|
| 4 |
+
function Footer() {
|
| 5 |
+
return (
|
| 6 |
+
<div className={styles.base}>
|
| 7 |
+
<span>
|
| 8 |
+
© 2020 小鹿快传 | <a target="_blank" rel="noopener noreferrer" href="http://beian.miit.gov.cn/">鲁ICP备18047579号-3</a> | 友情链接:
|
| 9 |
+
</span>
|
| 10 |
+
<a target="_blank" rel="noopener noreferrer" href="https://wonderfulcv.com">橙子简历</a>
|
| 11 |
+
<a target="_blank" rel="noopener noreferrer" href="https://github.com/fanchangyong/deershare"> | GitHub</a>
|
| 12 |
+
<a target="_blank" rel="noopener noreferrer" href="mailto:support@deershare.com"> | 联系我们 </a>
|
| 13 |
+
</div>
|
| 14 |
+
);
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
Footer.defaultProps = {};
|
| 18 |
+
|
| 19 |
+
Footer.propTypes = {
|
| 20 |
+
};
|
| 21 |
+
|
| 22 |
+
export default Footer;
|
client/src/components/NavBar.cm.styl
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.base
|
| 2 |
+
white-space nowrap
|
| 3 |
+
padding 0px 20px
|
| 4 |
+
height 60px
|
| 5 |
+
display flex
|
| 6 |
+
align-items center
|
| 7 |
+
background white
|
| 8 |
+
|
| 9 |
+
@media (max-width: 550px)
|
| 10 |
+
.base
|
| 11 |
+
width 100vw
|
| 12 |
+
overflow-x auto
|
| 13 |
+
|
| 14 |
+
.logo
|
| 15 |
+
height 40px
|
| 16 |
+
cursor pointer
|
| 17 |
+
|
| 18 |
+
.slogan
|
| 19 |
+
margin-left 20px
|
| 20 |
+
|
| 21 |
+
.menus
|
| 22 |
+
margin-left 100px
|
| 23 |
+
flex 1
|
| 24 |
+
|
| 25 |
+
.ad
|
| 26 |
+
&
|
| 27 |
+
&:hover
|
| 28 |
+
display inline-block
|
| 29 |
+
position relative
|
| 30 |
+
color #FF6565
|
| 31 |
+
@media (hover: hover)
|
| 32 |
+
&:hover
|
| 33 |
+
.ad-qrcode
|
| 34 |
+
display block
|
| 35 |
+
position absolute
|
| 36 |
+
top 50px
|
| 37 |
+
left -30px
|
| 38 |
+
width 200px
|
| 39 |
+
padding 12px
|
| 40 |
+
z-index 9
|
| 41 |
+
background white
|
| 42 |
+
box-shadow 0px 2px 4px 0px rgba(0, 0, 0, .2)
|
| 43 |
+
.cv-desc
|
| 44 |
+
color black
|
| 45 |
+
font-weight bolder
|
| 46 |
+
white-space normal
|
| 47 |
+
text-align center
|
| 48 |
+
margin-bottom 1em
|
| 49 |
+
img
|
| 50 |
+
width 100%
|
| 51 |
+
|
| 52 |
+
.ad-qrcode
|
| 53 |
+
display none
|
| 54 |
+
|
| 55 |
+
.menu
|
| 56 |
+
margin-right 50px
|
| 57 |
+
cursor pointer
|
| 58 |
+
position relative
|
| 59 |
+
&:hover
|
| 60 |
+
color darken(#63E9EC, 30%)
|
| 61 |
+
&.active
|
| 62 |
+
color #63E9EC
|
| 63 |
+
&::after
|
| 64 |
+
content ''
|
| 65 |
+
display inline-block
|
| 66 |
+
height 2px
|
| 67 |
+
width 56px
|
| 68 |
+
background #63E9EC
|
| 69 |
+
position absolute
|
| 70 |
+
left 0px
|
| 71 |
+
margin-top 36px
|
| 72 |
+
|
| 73 |
+
@media (max-width: 768px)
|
| 74 |
+
.slogan
|
| 75 |
+
display none
|
| 76 |
+
.menus
|
| 77 |
+
margin-left 40px
|
| 78 |
+
.menu
|
| 79 |
+
margin-right 30px
|
client/src/components/NavBar.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React from 'react';
|
| 2 |
+
import PropTypes from 'prop-types';
|
| 3 |
+
import classnames from 'classnames';
|
| 4 |
+
import {
|
| 5 |
+
withRouter,
|
| 6 |
+
matchPath,
|
| 7 |
+
} from 'react-router';
|
| 8 |
+
|
| 9 |
+
import {
|
| 10 |
+
Link,
|
| 11 |
+
} from 'react-router-dom';
|
| 12 |
+
|
| 13 |
+
import styles from './NavBar.cm.styl';
|
| 14 |
+
|
| 15 |
+
function NavBar(props) {
|
| 16 |
+
const pathname = props.location.pathname;
|
| 17 |
+
|
| 18 |
+
const matchRecv = matchPath(pathname, '/recv/:recvCode?');
|
| 19 |
+
|
| 20 |
+
return (
|
| 21 |
+
<div className={styles.base}>
|
| 22 |
+
<a href="/">
|
| 23 |
+
<img src="/images/logo.png" alt="logo" className={styles.logo} />
|
| 24 |
+
</a>
|
| 25 |
+
<div className={styles.slogan}>
|
| 26 |
+
简单安全高效的P2P文件传输服务
|
| 27 |
+
</div>
|
| 28 |
+
<div className={styles.menus}>
|
| 29 |
+
<Link to="/send">
|
| 30 |
+
<span
|
| 31 |
+
className={classnames(styles.menu, pathname === '/send' && styles.active)}
|
| 32 |
+
>
|
| 33 |
+
发送文件
|
| 34 |
+
</span>
|
| 35 |
+
</Link>
|
| 36 |
+
<Link to="/recv">
|
| 37 |
+
<span
|
| 38 |
+
className={classnames(styles.menu, matchRecv && styles.active)}
|
| 39 |
+
>
|
| 40 |
+
接收文件
|
| 41 |
+
</span>
|
| 42 |
+
</Link>
|
| 43 |
+
<a href="https://wonderfulcv.com" target="_blank" className={styles.ad}>
|
| 44 |
+
橙子简历(友情链接)
|
| 45 |
+
<div className={styles.adQrcode}>
|
| 46 |
+
<div className={styles.cvDesc}>
|
| 47 |
+
微信扫码立即制作简历
|
| 48 |
+
</div>
|
| 49 |
+
<img src="/images/qrcode_wechat.jpg" />
|
| 50 |
+
</div>
|
| 51 |
+
</a>
|
| 52 |
+
|
| 53 |
+
</div>
|
| 54 |
+
<a className="github-button" href="https://github.com/fanchangyong/deershare" data-size="large" data-show-count="true" aria-label="Star fanchangyong/deershare on GitHub">Star</a>
|
| 55 |
+
</div>
|
| 56 |
+
);
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
NavBar.defaultProps = {};
|
| 60 |
+
|
| 61 |
+
NavBar.propTypes = {
|
| 62 |
+
location: PropTypes.object,
|
| 63 |
+
};
|
| 64 |
+
|
| 65 |
+
export default withRouter(NavBar);
|
client/src/components/RecvFileModal.cm.styl
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.message
|
| 2 |
+
font-size 20px
|
| 3 |
+
margin-bottom 5px
|
| 4 |
+
&:before
|
| 5 |
+
content ''
|
| 6 |
+
display inline-block
|
| 7 |
+
width 3px
|
| 8 |
+
height 14px
|
| 9 |
+
background #d2d2d2
|
| 10 |
+
margin-right 5px
|
| 11 |
+
|
| 12 |
+
.file-box
|
| 13 |
+
border 1px solid grey
|
| 14 |
+
padding 10px
|
| 15 |
+
|
| 16 |
+
.file
|
| 17 |
+
display flex
|
| 18 |
+
justify-content space-between
|
| 19 |
+
margin 3px 0px
|
| 20 |
+
|
| 21 |
+
.file-name
|
| 22 |
+
font-weight 700
|
| 23 |
+
|
| 24 |
+
.summary
|
| 25 |
+
color #b0b0b0
|
| 26 |
+
margin-top 5px
|
| 27 |
+
margin-bottom 20px
|
client/src/components/RecvFileModal.js
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React, { Component } from 'react';
|
| 2 |
+
import PropTypes from 'prop-types';
|
| 3 |
+
import { withRouter } from 'react-router';
|
| 4 |
+
import produce from 'immer';
|
| 5 |
+
import { Modal, Button, message } from 'antd';
|
| 6 |
+
import Peer from '../Peer';
|
| 7 |
+
import ws from '../ws';
|
| 8 |
+
|
| 9 |
+
import {
|
| 10 |
+
formatBytes,
|
| 11 |
+
} from '../common/util';
|
| 12 |
+
|
| 13 |
+
import styles from './RecvFileModal.cm.styl';
|
| 14 |
+
|
| 15 |
+
class RecvFileModal extends Component {
|
| 16 |
+
constructor(props) {
|
| 17 |
+
super(props);
|
| 18 |
+
this.state = {
|
| 19 |
+
receivingFileId: null,
|
| 20 |
+
downloadUrls: {},
|
| 21 |
+
recvSizes: {},
|
| 22 |
+
targetId: '',
|
| 23 |
+
message: '',
|
| 24 |
+
files: [],
|
| 25 |
+
peerState: '',
|
| 26 |
+
};
|
| 27 |
+
|
| 28 |
+
this.onDownload = this.onDownload.bind(this);
|
| 29 |
+
this.onRecvData = this.onRecvData.bind(this);
|
| 30 |
+
this.handleMsg = this.handleMsg.bind(this);
|
| 31 |
+
this.handlePrepareDownloadRes = this.handlePrepareDownloadRes.bind(this);
|
| 32 |
+
|
| 33 |
+
this.recvBuffer = [];
|
| 34 |
+
this.recvSizes = {};
|
| 35 |
+
|
| 36 |
+
this.timer = setInterval(() => {
|
| 37 |
+
this.setState(produce(draft => {
|
| 38 |
+
draft.recvSizes = { ...this.recvSizes };
|
| 39 |
+
}));
|
| 40 |
+
}, 1000);
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
componentDidMount() {
|
| 44 |
+
ws.sendJSON({
|
| 45 |
+
type: 'c2s_prepare_download',
|
| 46 |
+
payload: {
|
| 47 |
+
downloadCode: this.props.match.params.downloadCode,
|
| 48 |
+
},
|
| 49 |
+
});
|
| 50 |
+
ws.registerMessageHandler('s2c_prepare_download', this.handlePrepareDownloadRes);
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
handlePrepareDownloadRes(payload) {
|
| 54 |
+
this.setState(produce(draft => {
|
| 55 |
+
draft.showRecvFileModal = true;
|
| 56 |
+
draft.targetId = payload.clientId;
|
| 57 |
+
draft.message = payload.message;
|
| 58 |
+
draft.files = payload.files;
|
| 59 |
+
}));
|
| 60 |
+
ws.removeMessageHandler('s2c_prepare_download', this.handlePrepareDownloadRes);
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
componentWillUnmount() {
|
| 64 |
+
clearInterval(this.timer);
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
onDownload() {
|
| 68 |
+
const peer = new Peer();
|
| 69 |
+
|
| 70 |
+
peer.on('connecting', () => {
|
| 71 |
+
this.setState({
|
| 72 |
+
peerState: '正在连接',
|
| 73 |
+
});
|
| 74 |
+
});
|
| 75 |
+
|
| 76 |
+
peer.on('connected', () => {
|
| 77 |
+
message.success('已连接');
|
| 78 |
+
this.setState({
|
| 79 |
+
peerState: '已连接',
|
| 80 |
+
});
|
| 81 |
+
});
|
| 82 |
+
|
| 83 |
+
peer.on('disconnected', async() => {
|
| 84 |
+
message.error('连接断开');
|
| 85 |
+
this.setState(produce(draft => {
|
| 86 |
+
draft.peerState = '未连接';
|
| 87 |
+
}));
|
| 88 |
+
});
|
| 89 |
+
|
| 90 |
+
peer.on('connectFailed', () => {
|
| 91 |
+
message.error('连接失败');
|
| 92 |
+
this.setState({
|
| 93 |
+
peerState: '连接失败',
|
| 94 |
+
});
|
| 95 |
+
});
|
| 96 |
+
|
| 97 |
+
peer.connectPeer(this.state.targetId);
|
| 98 |
+
peer.on('data', this.onRecvData);
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
onRecvData(data) {
|
| 102 |
+
if (typeof data === 'string') {
|
| 103 |
+
const msg = JSON.parse(data);
|
| 104 |
+
this.handleMsg(msg);
|
| 105 |
+
} else {
|
| 106 |
+
this.recvBuffer.push(data);
|
| 107 |
+
const curRecvBytes = this.recvSizes[this.state.receivingFileId] || 0;
|
| 108 |
+
const newRecvBytes = curRecvBytes + data.byteLength;
|
| 109 |
+
this.recvSizes[this.state.receivingFileId] = newRecvBytes;
|
| 110 |
+
}
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
handleMsg(msg) {
|
| 114 |
+
if (msg.type === 'fileStart') {
|
| 115 |
+
this.setState({
|
| 116 |
+
receivingFileId: msg.fileId,
|
| 117 |
+
});
|
| 118 |
+
} else if (msg.type === 'fileEnd') {
|
| 119 |
+
const fileId = msg.fileId;
|
| 120 |
+
const blob = new Blob(this.recvBuffer);
|
| 121 |
+
const url = window.URL.createObjectURL(blob);
|
| 122 |
+
this.setState(produce(draft => {
|
| 123 |
+
draft.downloadUrls[fileId] = url;
|
| 124 |
+
}));
|
| 125 |
+
}
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
render() {
|
| 129 |
+
const {
|
| 130 |
+
isOpen,
|
| 131 |
+
} = this.props;
|
| 132 |
+
|
| 133 |
+
const {
|
| 134 |
+
message,
|
| 135 |
+
files,
|
| 136 |
+
} = this.state;
|
| 137 |
+
|
| 138 |
+
if (!isOpen) {
|
| 139 |
+
return null;
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
const totalBytes = files.reduce((sum, cur) => {
|
| 143 |
+
return sum + cur.size;
|
| 144 |
+
}, 0);
|
| 145 |
+
|
| 146 |
+
return (
|
| 147 |
+
<div className={styles.base}>
|
| 148 |
+
<Modal
|
| 149 |
+
title="接收文件"
|
| 150 |
+
footer={null}
|
| 151 |
+
visible={isOpen}
|
| 152 |
+
onCancel={this.props.onCancel}
|
| 153 |
+
>
|
| 154 |
+
<h4>对方发送给您以下文件及信息:</h4>
|
| 155 |
+
{!!message && (
|
| 156 |
+
<div className={styles.message}>{message}</div>
|
| 157 |
+
)}
|
| 158 |
+
<div className={styles.fileBox}>
|
| 159 |
+
{files.map(f => {
|
| 160 |
+
const {
|
| 161 |
+
uid,
|
| 162 |
+
name,
|
| 163 |
+
size,
|
| 164 |
+
} = f;
|
| 165 |
+
const downloadUrl = this.state.downloadUrls[uid];
|
| 166 |
+
const recvBytes = this.state.recvSizes[uid] || 0;
|
| 167 |
+
|
| 168 |
+
let downloadInfo = null;
|
| 169 |
+
if (downloadUrl) {
|
| 170 |
+
downloadInfo = <a href={downloadUrl} download={name}>下载</a>;
|
| 171 |
+
} else if (uid === this.state.receivingFileId) {
|
| 172 |
+
downloadInfo = <span>{((recvBytes / size) * 100).toFixed(2)}%</span>;
|
| 173 |
+
} else {
|
| 174 |
+
downloadInfo = <span>等待中</span>;
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
return (
|
| 178 |
+
<div key={uid} className={styles.file}>
|
| 179 |
+
<span className={styles.fileName}>
|
| 180 |
+
{name}
|
| 181 |
+
</span>
|
| 182 |
+
<span>{formatBytes(size)}</span>
|
| 183 |
+
{downloadInfo}
|
| 184 |
+
</div>
|
| 185 |
+
);
|
| 186 |
+
})}
|
| 187 |
+
</div>
|
| 188 |
+
<div className={styles.summary}>
|
| 189 |
+
{files.length} 个文件,共 {formatBytes(totalBytes)}
|
| 190 |
+
</div>
|
| 191 |
+
<Button type="primary" block size="large" onClick={this.onDownload}>
|
| 192 |
+
开始下载
|
| 193 |
+
</Button>
|
| 194 |
+
</Modal>
|
| 195 |
+
</div>
|
| 196 |
+
);
|
| 197 |
+
}
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
RecvFileModal.propTypes = {
|
| 201 |
+
isOpen: PropTypes.bool,
|
| 202 |
+
onCancel: PropTypes.func,
|
| 203 |
+
match: PropTypes.object,
|
| 204 |
+
};
|
| 205 |
+
|
| 206 |
+
export default withRouter(RecvFileModal);
|
client/src/components/RecvFilePanel.cm.styl
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.base
|
| 2 |
+
width 380px
|
| 3 |
+
margin 0 auto
|
| 4 |
+
padding 20px 22px
|
| 5 |
+
background white
|
| 6 |
+
text-align center
|
| 7 |
+
box-shadow 0px 2px 4px 0px rgba(197, 197, 197, 0.5)
|
| 8 |
+
|
| 9 |
+
.title-row
|
| 10 |
+
position relative
|
| 11 |
+
|
| 12 |
+
.title
|
| 13 |
+
text-align center
|
| 14 |
+
font-weight 700
|
| 15 |
+
color #757575
|
| 16 |
+
|
| 17 |
+
.cancel
|
| 18 |
+
position absolute
|
| 19 |
+
cursor pointer
|
| 20 |
+
color #8e8e8e
|
| 21 |
+
|
| 22 |
+
.input
|
| 23 |
+
width 100%
|
| 24 |
+
height 42px
|
| 25 |
+
margin-top 60px
|
| 26 |
+
|
| 27 |
+
.recv-btn
|
| 28 |
+
width 100%
|
| 29 |
+
margin-top 20px
|
| 30 |
+
|
| 31 |
+
.tip
|
| 32 |
+
text-align right
|
| 33 |
+
color #989898
|
| 34 |
+
cursor pointer
|
| 35 |
+
margin-top 138px
|
| 36 |
+
|
| 37 |
+
.msg1
|
| 38 |
+
text-align left
|
| 39 |
+
margin-top 25px
|
| 40 |
+
margin-bottom 10px
|
| 41 |
+
color #8e8e8e
|
| 42 |
+
|
| 43 |
+
.msg2
|
| 44 |
+
display flex
|
| 45 |
+
justify-content space-between
|
| 46 |
+
margin-top 10px
|
| 47 |
+
color #8e8e8e
|
| 48 |
+
|
| 49 |
+
.peer-connected
|
| 50 |
+
color #61F36B
|
| 51 |
+
|
| 52 |
+
.peer-not-connected
|
| 53 |
+
color #EA7A7A
|
| 54 |
+
|
| 55 |
+
@media (max-width: 1200px)
|
| 56 |
+
.base
|
| 57 |
+
width 80%
|
| 58 |
+
max-width 650px
|
client/src/components/RecvFilePanel.js
ADDED
|
@@ -0,0 +1,288 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React, { Component } from 'react';
|
| 2 |
+
import PropTypes from 'prop-types';
|
| 3 |
+
import prettyBytes from 'pretty-bytes';
|
| 4 |
+
import { withRouter } from 'react-router-dom';
|
| 5 |
+
import Icon from './common/Icon';
|
| 6 |
+
import Button from './common/Button';
|
| 7 |
+
import Input from './common/Input';
|
| 8 |
+
import FileBox from './FileBox';
|
| 9 |
+
import Toast from './common/Toast';
|
| 10 |
+
import {
|
| 11 |
+
prepareRecv,
|
| 12 |
+
deleteRecvCode,
|
| 13 |
+
} from '../actions/file';
|
| 14 |
+
import Peer from '../Peer';
|
| 15 |
+
import {
|
| 16 |
+
calcPercent,
|
| 17 |
+
} from '../common/util';
|
| 18 |
+
|
| 19 |
+
import styles from './RecvFilePanel.cm.styl';
|
| 20 |
+
|
| 21 |
+
class RecvFilePanel extends Component {
|
| 22 |
+
constructor(props) {
|
| 23 |
+
super(props);
|
| 24 |
+
this.onChangeRecvCode = this.onChangeRecvCode.bind(this);
|
| 25 |
+
this.onPrepareRecv = this.onPrepareRecv.bind(this);
|
| 26 |
+
this.onStartRecv = this.onStartRecv.bind(this);
|
| 27 |
+
this.onReset = this.onReset.bind(this); // 回到初始状态,比如点击取消或者接收完成继续接收等
|
| 28 |
+
|
| 29 |
+
this.onRecvPeerData = this.onRecvPeerData.bind(this);
|
| 30 |
+
this.handlePeerMsg = this.handlePeerMsg.bind(this);
|
| 31 |
+
|
| 32 |
+
this.peer = new Peer();
|
| 33 |
+
this.recvBuffer = [];
|
| 34 |
+
this.recvSizes = {};
|
| 35 |
+
this.bps = 0;
|
| 36 |
+
|
| 37 |
+
this.timer = setInterval(() => {
|
| 38 |
+
const files = this.props.files.map(f => {
|
| 39 |
+
const recvSize = this.recvSizes[f.uid] || 0;
|
| 40 |
+
const pct = calcPercent(recvSize, f.size);
|
| 41 |
+
return {
|
| 42 |
+
...f,
|
| 43 |
+
pct,
|
| 44 |
+
};
|
| 45 |
+
});
|
| 46 |
+
this.props.setState({
|
| 47 |
+
files,
|
| 48 |
+
});
|
| 49 |
+
this.bps = 0;
|
| 50 |
+
}, 1000);
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
componentDidMount() {
|
| 54 |
+
document.title = '小鹿快传|简单安全高效的P2P文件传输服务 - 接收文件';
|
| 55 |
+
const recvCode = this.props.match.params.recvCode;
|
| 56 |
+
if (recvCode) {
|
| 57 |
+
prepareRecv(recvCode);
|
| 58 |
+
}
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
componentWillUnMount() {
|
| 62 |
+
clearInterval(this.timer);
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
onChangeRecvCode(value) {
|
| 66 |
+
this.props.setState({ recvCode: value });
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
onPrepareRecv() {
|
| 70 |
+
prepareRecv(this.props.recvCode);
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
onReset() {
|
| 74 |
+
this.peer.destroy();
|
| 75 |
+
this.props.setState({
|
| 76 |
+
recvCode: '',
|
| 77 |
+
peerState: '',
|
| 78 |
+
started: false,
|
| 79 |
+
files: [],
|
| 80 |
+
targetId: '',
|
| 81 |
+
});
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
onStartRecv() {
|
| 85 |
+
this.props.setState({
|
| 86 |
+
started: true,
|
| 87 |
+
});
|
| 88 |
+
|
| 89 |
+
const peer = this.peer;
|
| 90 |
+
|
| 91 |
+
peer.on('connecting', () => {
|
| 92 |
+
this.props.setState({
|
| 93 |
+
peerState: 'connecting',
|
| 94 |
+
});
|
| 95 |
+
});
|
| 96 |
+
|
| 97 |
+
peer.on('connected', () => {
|
| 98 |
+
Toast.success('连接成功');
|
| 99 |
+
this.props.setState({
|
| 100 |
+
peerState: 'connected',
|
| 101 |
+
});
|
| 102 |
+
});
|
| 103 |
+
|
| 104 |
+
peer.on('disconnected', () => {
|
| 105 |
+
this.props.setState({
|
| 106 |
+
peerState: 'disconnected',
|
| 107 |
+
});
|
| 108 |
+
});
|
| 109 |
+
|
| 110 |
+
peer.on('connectFailed', () => {
|
| 111 |
+
Toast.error('连接失败,请重试');
|
| 112 |
+
this.props.setState({
|
| 113 |
+
peerState: 'connectFailed',
|
| 114 |
+
});
|
| 115 |
+
});
|
| 116 |
+
|
| 117 |
+
peer.on('channelOpen', () => {
|
| 118 |
+
this.props.setState({
|
| 119 |
+
peerState: 'transfer',
|
| 120 |
+
});
|
| 121 |
+
// 收件码只能使用一次,一旦开始接收就使其失效
|
| 122 |
+
deleteRecvCode(this.props.recvCode || this.props.match.params.recvCode);
|
| 123 |
+
});
|
| 124 |
+
|
| 125 |
+
peer.on('data', this.onRecvPeerData);
|
| 126 |
+
|
| 127 |
+
peer.connectPeer(this.props.targetId);
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
onRecvPeerData(data) {
|
| 131 |
+
const {
|
| 132 |
+
curFileId,
|
| 133 |
+
} = this.props;
|
| 134 |
+
|
| 135 |
+
if (typeof data === 'string') {
|
| 136 |
+
const msg = JSON.parse(data);
|
| 137 |
+
this.handlePeerMsg(msg);
|
| 138 |
+
} else {
|
| 139 |
+
this.recvBuffer.push(data);
|
| 140 |
+
const curRecvBytes = this.recvSizes[curFileId] || 0;
|
| 141 |
+
const newRecvBytes = curRecvBytes + data.byteLength;
|
| 142 |
+
this.recvSizes[curFileId] = newRecvBytes;
|
| 143 |
+
this.bps += data.byteLength;
|
| 144 |
+
this.peer.sendJSON({
|
| 145 |
+
type: 'chunkReceived',
|
| 146 |
+
payload: {
|
| 147 |
+
fileId: curFileId,
|
| 148 |
+
recvBytes: newRecvBytes,
|
| 149 |
+
},
|
| 150 |
+
});
|
| 151 |
+
}
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
handlePeerMsg(msg) {
|
| 155 |
+
if (msg.type === 'fileStart') {
|
| 156 |
+
this.props.setState({
|
| 157 |
+
curFileId: msg.fileId,
|
| 158 |
+
});
|
| 159 |
+
} else if (msg.type === 'fileEnd') {
|
| 160 |
+
const fileId = msg.fileId;
|
| 161 |
+
const file = this.props.files.find(f => f.uid === fileId) || {};
|
| 162 |
+
const blob = new Blob(this.recvBuffer, { type: file.type });
|
| 163 |
+
this.recvBuffer = [];
|
| 164 |
+
const url = window.URL.createObjectURL(blob);
|
| 165 |
+
const files = this.props.files.map(f => {
|
| 166 |
+
if (f.uid === fileId) {
|
| 167 |
+
return {
|
| 168 |
+
...f,
|
| 169 |
+
downloadUrl: url,
|
| 170 |
+
};
|
| 171 |
+
} else {
|
| 172 |
+
return f;
|
| 173 |
+
}
|
| 174 |
+
});
|
| 175 |
+
this.props.setState({
|
| 176 |
+
files,
|
| 177 |
+
});
|
| 178 |
+
}
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
renderStep1() {
|
| 182 |
+
const {
|
| 183 |
+
recvCode,
|
| 184 |
+
} = this.props;
|
| 185 |
+
|
| 186 |
+
return (
|
| 187 |
+
<>
|
| 188 |
+
<Input placeholder="请输入6位收件码" inputClassName={styles.input} value={recvCode} onChange={this.onChangeRecvCode} />
|
| 189 |
+
<Button type="primary" className={styles.recvBtn} onClick={this.onPrepareRecv}>接收文件</Button>
|
| 190 |
+
<div className={styles.tip}>
|
| 191 |
+
<Icon name="info" />
|
| 192 |
+
如何获取收件码?
|
| 193 |
+
</div>
|
| 194 |
+
</>
|
| 195 |
+
);
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
renderStep2() {
|
| 199 |
+
const {
|
| 200 |
+
peerState,
|
| 201 |
+
started,
|
| 202 |
+
curFileId,
|
| 203 |
+
files,
|
| 204 |
+
} = this.props;
|
| 205 |
+
|
| 206 |
+
const totalBytes = files.reduce((sum, cur) => {
|
| 207 |
+
return sum + cur.size;
|
| 208 |
+
}, 0);
|
| 209 |
+
|
| 210 |
+
let allCompleted = true;
|
| 211 |
+
files.forEach(f => {
|
| 212 |
+
if (!f.downloadUrl) {
|
| 213 |
+
allCompleted = false;
|
| 214 |
+
}
|
| 215 |
+
});
|
| 216 |
+
|
| 217 |
+
let btnContent = '开始下载';
|
| 218 |
+
if (allCompleted) {
|
| 219 |
+
btnContent = '继续接收';
|
| 220 |
+
} else if (!started) {
|
| 221 |
+
btnContent = '开始下载';
|
| 222 |
+
} else if (peerState === 'disconnected' || peerState === 'connectFailed') {
|
| 223 |
+
btnContent = '重新下载';
|
| 224 |
+
} else if (peerState === 'connecting') {
|
| 225 |
+
btnContent = '正在连接...';
|
| 226 |
+
} else if (peerState === 'connected') {
|
| 227 |
+
btnContent = '连接成功';
|
| 228 |
+
} else if (peerState === 'transfer') {
|
| 229 |
+
btnContent = `正在下载...(${prettyBytes(this.bps)}/s)`;
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
return (
|
| 233 |
+
<>
|
| 234 |
+
<div className={styles.msg1}>
|
| 235 |
+
对方发送给您以下文件:
|
| 236 |
+
</div>
|
| 237 |
+
<FileBox files={this.props.files} curFileId={curFileId} />
|
| 238 |
+
<div className={styles.msg2}>
|
| 239 |
+
<div>{files.length} 个文件,共 {prettyBytes(totalBytes)}</div>
|
| 240 |
+
</div>
|
| 241 |
+
<Button
|
| 242 |
+
type="primary"
|
| 243 |
+
className={styles.recvBtn}
|
| 244 |
+
loading={started && !allCompleted && (peerState === 'connected' || peerState === 'connecting' || peerState === 'transfer')}
|
| 245 |
+
onClick={allCompleted ? this.onReset : this.onStartRecv}
|
| 246 |
+
>
|
| 247 |
+
{btnContent}
|
| 248 |
+
</Button>
|
| 249 |
+
</>
|
| 250 |
+
);
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
render() {
|
| 254 |
+
const {
|
| 255 |
+
files,
|
| 256 |
+
} = this.props;
|
| 257 |
+
|
| 258 |
+
return (
|
| 259 |
+
<div className={styles.base}>
|
| 260 |
+
<div className={styles.titleRow}>
|
| 261 |
+
{files.length > 0 && (
|
| 262 |
+
<div className={styles.cancel} onClick={this.onReset}>
|
| 263 |
+
取消
|
| 264 |
+
</div>
|
| 265 |
+
)}
|
| 266 |
+
<div className={styles.title}>
|
| 267 |
+
接收文件
|
| 268 |
+
</div>
|
| 269 |
+
</div>
|
| 270 |
+
{files.length === 0 && this.renderStep1()}
|
| 271 |
+
{files.length > 0 && this.renderStep2()}
|
| 272 |
+
</div>
|
| 273 |
+
);
|
| 274 |
+
}
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
RecvFilePanel.propTypes = {
|
| 278 |
+
recvCode: PropTypes.string,
|
| 279 |
+
peerState: PropTypes.string,
|
| 280 |
+
started: PropTypes.bool,
|
| 281 |
+
files: PropTypes.array,
|
| 282 |
+
targetId: PropTypes.string,
|
| 283 |
+
curFileId: PropTypes.string,
|
| 284 |
+
match: PropTypes.object,
|
| 285 |
+
setState: PropTypes.func,
|
| 286 |
+
};
|
| 287 |
+
|
| 288 |
+
export default withRouter(RecvFilePanel);
|
client/src/components/SendFileModal.cm.styl
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.steps
|
| 2 |
+
margin-bottom 20px
|
| 3 |
+
|
| 4 |
+
.file-box
|
| 5 |
+
position relative
|
| 6 |
+
border 1px solid #cacaca
|
| 7 |
+
padding 10px
|
| 8 |
+
margin-bottom 10px
|
| 9 |
+
|
| 10 |
+
.file
|
| 11 |
+
display flex
|
| 12 |
+
justify-content space-between
|
| 13 |
+
padding 10px
|
| 14 |
+
|
| 15 |
+
.file-name
|
| 16 |
+
display inline-block
|
| 17 |
+
vertical-align middle
|
| 18 |
+
max-width 15em
|
| 19 |
+
overflow hidden
|
| 20 |
+
text-overflow ellipsis
|
| 21 |
+
white-space nowrap
|
| 22 |
+
margin-right 10px
|
| 23 |
+
|
| 24 |
+
.summary
|
| 25 |
+
color #b0b0b0
|
| 26 |
+
margin-top 5px
|
| 27 |
+
margin-bottom 20px
|
| 28 |
+
|
| 29 |
+
.upload-btn
|
| 30 |
+
margin-top 15px
|
| 31 |
+
|
| 32 |
+
.icon-x
|
| 33 |
+
position absolute
|
| 34 |
+
right 15px
|
| 35 |
+
top 15px
|
| 36 |
+
font-size 16px
|
| 37 |
+
cursor pointer
|
| 38 |
+
|
| 39 |
+
.icon-plus
|
| 40 |
+
font-size 18px
|
| 41 |
+
margin-right 5px
|
| 42 |
+
|
| 43 |
+
.add-more-file
|
| 44 |
+
cursor pointer
|
| 45 |
+
|
| 46 |
+
.message
|
| 47 |
+
margin-top 20px
|
| 48 |
+
margin-bottom 20px
|
| 49 |
+
|
| 50 |
+
.qrcode-wrapper
|
| 51 |
+
text-align center
|
| 52 |
+
|
| 53 |
+
.tips
|
| 54 |
+
margin-top 20px
|
| 55 |
+
margin-bottom 20px
|
| 56 |
+
color #b0b0b0
|
client/src/components/SendFileModal.js
ADDED
|
@@ -0,0 +1,386 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React, { Component, Fragment } from 'react';
|
| 2 |
+
import produce from 'immer';
|
| 3 |
+
import PropTypes from 'prop-types';
|
| 4 |
+
import { message as toast, Modal, Input, Empty, Button, Icon, Upload, Steps } from 'antd';
|
| 5 |
+
import { CopyToClipboard } from 'react-copy-to-clipboard';
|
| 6 |
+
import QRCode from 'qrcode.react';
|
| 7 |
+
|
| 8 |
+
import Peer from '../Peer';
|
| 9 |
+
|
| 10 |
+
import FileChunker from '../FileChunker';
|
| 11 |
+
import {
|
| 12 |
+
formatBytes,
|
| 13 |
+
} from '../common/util';
|
| 14 |
+
|
| 15 |
+
import styles from './SendFileModal.cm.styl';
|
| 16 |
+
|
| 17 |
+
const { Step } = Steps;
|
| 18 |
+
|
| 19 |
+
function getInitialState(props) {
|
| 20 |
+
return {
|
| 21 |
+
currentStep: 0,
|
| 22 |
+
fileList: props ? props.initFileList : [],
|
| 23 |
+
message: '',
|
| 24 |
+
curFileId: '',
|
| 25 |
+
sendSizes: {},
|
| 26 |
+
peerState: '', // 连接状态
|
| 27 |
+
};
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
class SendFileModal extends Component {
|
| 31 |
+
constructor(props) {
|
| 32 |
+
super(props);
|
| 33 |
+
|
| 34 |
+
this.state = getInitialState(props);
|
| 35 |
+
|
| 36 |
+
this.onChangeFile = this.onChangeFile.bind(this);
|
| 37 |
+
this.onRemoveFile = this.onRemoveFile.bind(this);
|
| 38 |
+
this.onChangeMessage = this.onChangeMessage.bind(this);
|
| 39 |
+
|
| 40 |
+
this.onPrepareUpload = this.onPrepareUpload.bind(this);
|
| 41 |
+
|
| 42 |
+
this.renderStep0Content = this.renderStep0Content.bind(this);
|
| 43 |
+
this.renderStep1Content = this.renderStep1Content.bind(this);
|
| 44 |
+
this.renderStep2Content = this.renderStep2Content.bind(this);
|
| 45 |
+
|
| 46 |
+
this.sendSizes = {};
|
| 47 |
+
|
| 48 |
+
setInterval(() => {
|
| 49 |
+
this.setState(produce(draft => {
|
| 50 |
+
draft.sendSizes = { ...this.sendSizes };
|
| 51 |
+
}));
|
| 52 |
+
}, 1000);
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
onPrepareUpload() {
|
| 56 |
+
const {
|
| 57 |
+
message,
|
| 58 |
+
fileList,
|
| 59 |
+
} = this.state;
|
| 60 |
+
|
| 61 |
+
this.setState(produce(draft => {
|
| 62 |
+
draft.currentStep = 1;
|
| 63 |
+
}));
|
| 64 |
+
|
| 65 |
+
const files = fileList.map(f => {
|
| 66 |
+
return {
|
| 67 |
+
uid: f.uid,
|
| 68 |
+
name: f.name,
|
| 69 |
+
size: f.size,
|
| 70 |
+
type: f.type,
|
| 71 |
+
};
|
| 72 |
+
});
|
| 73 |
+
|
| 74 |
+
this.props.prepareUpload(message, files);
|
| 75 |
+
const peer = new Peer();
|
| 76 |
+
|
| 77 |
+
peer.on('connecting', () => {
|
| 78 |
+
this.setState({
|
| 79 |
+
peerState: '正在连接',
|
| 80 |
+
});
|
| 81 |
+
});
|
| 82 |
+
|
| 83 |
+
peer.on('connected', () => {
|
| 84 |
+
toast.success('已连接');
|
| 85 |
+
this.setState({
|
| 86 |
+
peerState: '已连接',
|
| 87 |
+
});
|
| 88 |
+
});
|
| 89 |
+
|
| 90 |
+
peer.on('connectFailed', () => {
|
| 91 |
+
toast.error('连接失败');
|
| 92 |
+
this.setState({
|
| 93 |
+
peerState: '连接失败',
|
| 94 |
+
});
|
| 95 |
+
});
|
| 96 |
+
|
| 97 |
+
peer.on('disconnected', async() => {
|
| 98 |
+
toast.error('连接断开');
|
| 99 |
+
this.setState(produce(draft => {
|
| 100 |
+
draft.peerState = '未连接';
|
| 101 |
+
}));
|
| 102 |
+
});
|
| 103 |
+
|
| 104 |
+
peer.on('channelOpen', async() => {
|
| 105 |
+
this.setState(produce(draft => {
|
| 106 |
+
if (draft.currentStep === 1) {
|
| 107 |
+
draft.currentStep = 2;
|
| 108 |
+
}
|
| 109 |
+
}));
|
| 110 |
+
|
| 111 |
+
for (let i = 0; i < fileList.length; i++) {
|
| 112 |
+
const file = fileList[i];
|
| 113 |
+
const uid = file.uid;
|
| 114 |
+
await peer.sendJSON({
|
| 115 |
+
type: 'fileStart',
|
| 116 |
+
fileId: file.uid,
|
| 117 |
+
});
|
| 118 |
+
this.setState({ curFileId: uid });
|
| 119 |
+
|
| 120 |
+
const chunker = new FileChunker(file);
|
| 121 |
+
let done = false;
|
| 122 |
+
while (!done) {
|
| 123 |
+
const result = await chunker.getNextChunk();
|
| 124 |
+
done = result.done;
|
| 125 |
+
const {
|
| 126 |
+
chunk,
|
| 127 |
+
offset,
|
| 128 |
+
} = result;
|
| 129 |
+
try {
|
| 130 |
+
await peer.send(chunk);
|
| 131 |
+
} catch (err) {
|
| 132 |
+
toast.error('传输错误:' + err);
|
| 133 |
+
break;
|
| 134 |
+
}
|
| 135 |
+
this.sendSizes[uid] = offset;
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
if (done) {
|
| 139 |
+
await peer.sendJSON({
|
| 140 |
+
type: 'fileEnd',
|
| 141 |
+
fileId: file.uid,
|
| 142 |
+
});
|
| 143 |
+
}
|
| 144 |
+
}
|
| 145 |
+
});
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
onChangeFile(e) {
|
| 149 |
+
this.setState(produce(draft => {
|
| 150 |
+
draft.fileList.push(e.file);
|
| 151 |
+
}));
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
onChangeMessage(e) {
|
| 155 |
+
this.setState({
|
| 156 |
+
message: e.target.value,
|
| 157 |
+
});
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
componentDidUpdate(prevProps, prevState) {
|
| 161 |
+
if (this.props.initFileList !== prevProps.initFileList) {
|
| 162 |
+
this.setState({
|
| 163 |
+
fileList: this.state.fileList.concat(this.props.initFileList),
|
| 164 |
+
});
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
if (!this.props.isOpen && !!prevProps.isOpen) {
|
| 168 |
+
this.setState(getInitialState());
|
| 169 |
+
}
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
onRemoveFile(uid) {
|
| 173 |
+
return () => {
|
| 174 |
+
this.setState({
|
| 175 |
+
fileList: this.state.fileList.filter(f => f.uid !== uid),
|
| 176 |
+
});
|
| 177 |
+
};
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
renderFileList() {
|
| 181 |
+
const {
|
| 182 |
+
fileList,
|
| 183 |
+
} = this.state;
|
| 184 |
+
|
| 185 |
+
return fileList.map(f => {
|
| 186 |
+
return (
|
| 187 |
+
<div key={f.uid} className={styles.fileBox}>
|
| 188 |
+
<span className={styles.fileName}>文件名:{f.name}</span>
|
| 189 |
+
<Icon type="close" className={styles.iconX} onClick={this.onRemoveFile(f.uid)} />
|
| 190 |
+
</div>
|
| 191 |
+
);
|
| 192 |
+
});
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
renderStep0Content() {
|
| 196 |
+
const {
|
| 197 |
+
fileList,
|
| 198 |
+
} = this.state;
|
| 199 |
+
|
| 200 |
+
return (
|
| 201 |
+
<div>
|
| 202 |
+
{this.state.fileList.length > 0 && (
|
| 203 |
+
<Fragment>
|
| 204 |
+
{this.renderFileList()}
|
| 205 |
+
<Upload
|
| 206 |
+
multiple
|
| 207 |
+
fileList={fileList}
|
| 208 |
+
onChange={this.onChangeFile}
|
| 209 |
+
showUploadList={null}
|
| 210 |
+
beforeUpload={() => false}
|
| 211 |
+
>
|
| 212 |
+
<div className={styles.addMoreFile}>
|
| 213 |
+
<Icon type="plus-circle" className={styles.iconPlus} /> 继续添加文件
|
| 214 |
+
</div>
|
| 215 |
+
</Upload>
|
| 216 |
+
</Fragment>
|
| 217 |
+
)}
|
| 218 |
+
|
| 219 |
+
{this.state.fileList.length === 0 && (
|
| 220 |
+
<Empty>
|
| 221 |
+
<Upload
|
| 222 |
+
multiple
|
| 223 |
+
fileList={fileList}
|
| 224 |
+
onChange={this.onChangeFile}
|
| 225 |
+
showUploadList={null}
|
| 226 |
+
beforeUpload={() => false}
|
| 227 |
+
>
|
| 228 |
+
<Button>
|
| 229 |
+
<Icon type="upload" />
|
| 230 |
+
点击上传
|
| 231 |
+
</Button>
|
| 232 |
+
</Upload>
|
| 233 |
+
</Empty>
|
| 234 |
+
)}
|
| 235 |
+
|
| 236 |
+
<div className={styles.message}>
|
| 237 |
+
<Input
|
| 238 |
+
placeholder="给对方捎句话(可选)"
|
| 239 |
+
value={this.state.message}
|
| 240 |
+
onChange={this.onChangeMessage}
|
| 241 |
+
/>
|
| 242 |
+
</div>
|
| 243 |
+
<Button type="primary" block size="large" onClick={this.onPrepareUpload}>
|
| 244 |
+
下一步
|
| 245 |
+
</Button>
|
| 246 |
+
</div>
|
| 247 |
+
);
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
renderStep1Content() {
|
| 251 |
+
const {
|
| 252 |
+
downloadCode,
|
| 253 |
+
} = this.props;
|
| 254 |
+
|
| 255 |
+
const downloadLink = `http://${document.location.host}/r/${downloadCode}`;
|
| 256 |
+
|
| 257 |
+
return (
|
| 258 |
+
<div>
|
| 259 |
+
<div className={styles.tips}>你可以选择通过以下三种方式之一将文件共享给对方:</div>
|
| 260 |
+
<div>
|
| 261 |
+
<span>
|
| 262 |
+
1. 将链接发送给对方:
|
| 263 |
+
</span>
|
| 264 |
+
<span>{downloadLink}</span>
|
| 265 |
+
<CopyToClipboard text={downloadLink} onCopy={() => toast.success('复制成功')}>
|
| 266 |
+
<Button type="link">复制</Button>
|
| 267 |
+
</CopyToClipboard>
|
| 268 |
+
</div>
|
| 269 |
+
<div>
|
| 270 |
+
<span>
|
| 271 |
+
2. 将取件码发送给对方:
|
| 272 |
+
</span>
|
| 273 |
+
<span>{downloadCode}</span>
|
| 274 |
+
<CopyToClipboard text={downloadCode} onCopy={() => toast.success('复制成功')}>
|
| 275 |
+
<Button type="link">复制</Button>
|
| 276 |
+
</CopyToClipboard>
|
| 277 |
+
|
| 278 |
+
</div>
|
| 279 |
+
<div>
|
| 280 |
+
<span>3. 扫描二维码:</span>
|
| 281 |
+
<div className={styles.qrcodeWrapper}>
|
| 282 |
+
<QRCode
|
| 283 |
+
value={downloadLink}
|
| 284 |
+
/>
|
| 285 |
+
</div>
|
| 286 |
+
</div>
|
| 287 |
+
<div className={styles.tips}>文件在10分钟内有效,请尽快将收件码或链接发送给对方<br /> 对方输入收件码后会自动开始发送
|
| 288 |
+
</div>
|
| 289 |
+
<Button type="primary" block size="large" loading>
|
| 290 |
+
等待连接...
|
| 291 |
+
</Button>
|
| 292 |
+
</div>
|
| 293 |
+
);
|
| 294 |
+
}
|
| 295 |
+
|
| 296 |
+
renderStep2Content() {
|
| 297 |
+
const {
|
| 298 |
+
fileList,
|
| 299 |
+
} = this.state;
|
| 300 |
+
|
| 301 |
+
const totalBytes = fileList.reduce((sum, cur) => {
|
| 302 |
+
return sum + cur.size;
|
| 303 |
+
}, 0);
|
| 304 |
+
|
| 305 |
+
return (
|
| 306 |
+
<div>
|
| 307 |
+
<h4>正在发送以下文件:</h4>
|
| 308 |
+
<div className={styles.fileBox}>
|
| 309 |
+
{fileList.map(f => {
|
| 310 |
+
const {
|
| 311 |
+
uid,
|
| 312 |
+
name,
|
| 313 |
+
size,
|
| 314 |
+
} = f;
|
| 315 |
+
|
| 316 |
+
let uploadPct = null;
|
| 317 |
+
const sendSize = this.state.sendSizes[uid] || 0;
|
| 318 |
+
if (sendSize > 0) {
|
| 319 |
+
uploadPct = ((sendSize / size) * 100).toFixed(2);
|
| 320 |
+
} else {
|
| 321 |
+
uploadPct = '等待中';
|
| 322 |
+
}
|
| 323 |
+
|
| 324 |
+
return (
|
| 325 |
+
<div key={uid} className={styles.file}>
|
| 326 |
+
<span className={styles.fileName}>
|
| 327 |
+
{name}
|
| 328 |
+
</span>
|
| 329 |
+
<span>{formatBytes(size)}</span>
|
| 330 |
+
<span>{uploadPct}%</span>
|
| 331 |
+
</div>
|
| 332 |
+
);
|
| 333 |
+
})}
|
| 334 |
+
</div>
|
| 335 |
+
<div className={styles.summary}>
|
| 336 |
+
{fileList.length} 个文件,共 {formatBytes(totalBytes)}
|
| 337 |
+
</div>
|
| 338 |
+
<Button type="primary" block size="large">
|
| 339 |
+
发送中...
|
| 340 |
+
</Button>
|
| 341 |
+
</div>
|
| 342 |
+
);
|
| 343 |
+
}
|
| 344 |
+
|
| 345 |
+
render() {
|
| 346 |
+
const {
|
| 347 |
+
currentStep,
|
| 348 |
+
peerState,
|
| 349 |
+
} = this.state;
|
| 350 |
+
|
| 351 |
+
return (
|
| 352 |
+
<div className={styles.base}>
|
| 353 |
+
<Modal
|
| 354 |
+
title="发送文件"
|
| 355 |
+
footer={null}
|
| 356 |
+
visible={this.props.isOpen}
|
| 357 |
+
onCancel={this.props.onCancel}
|
| 358 |
+
>
|
| 359 |
+
<div className={styles.steps}>
|
| 360 |
+
<div>
|
| 361 |
+
连接状态:{peerState}
|
| 362 |
+
</div>
|
| 363 |
+
<Steps current={currentStep}>
|
| 364 |
+
<Step title="添加文件" />
|
| 365 |
+
<Step title="收件码" />
|
| 366 |
+
<Step title="发送" />
|
| 367 |
+
</Steps>
|
| 368 |
+
</div>
|
| 369 |
+
{currentStep === 0 && this.renderStep0Content()}
|
| 370 |
+
{currentStep === 1 && this.renderStep1Content()}
|
| 371 |
+
{currentStep === 2 && this.renderStep2Content()}
|
| 372 |
+
</Modal>
|
| 373 |
+
</div>
|
| 374 |
+
);
|
| 375 |
+
}
|
| 376 |
+
}
|
| 377 |
+
|
| 378 |
+
SendFileModal.propTypes = {
|
| 379 |
+
isOpen: PropTypes.bool,
|
| 380 |
+
initFileList: PropTypes.array,
|
| 381 |
+
downloadCode: PropTypes.string,
|
| 382 |
+
prepareUpload: PropTypes.func,
|
| 383 |
+
onCancel: PropTypes.func,
|
| 384 |
+
};
|
| 385 |
+
|
| 386 |
+
export default SendFileModal;
|