From e26b286079c8e1d1214ca0860a21b3cee4055ee0 Mon Sep 17 00:00:00 2001 From: CPunisher <1343316114@qq.com> Date: Tue, 19 May 2020 12:36:23 +0800 Subject: [PATCH] [QR scan] --- package-lock.json | 5 ++ package.json | 1 + src/components/app/App.js | 8 +-- .../{footer/Footer.js => app/PartFooter.js} | 4 +- .../{header/Header.js => app/PartHeader.js} | 4 +- src/components/renderer/RendererRandRect.js | 2 - src/components/renderer/RendererResImage.js | 2 +- src/constant/ActionTypes.js | 2 +- src/containers/app/InputText.js | 64 +++++++++++++++---- src/containers/app/PartDownloadViewer.js | 1 - src/containers/param/ParamUploadViewer.js | 14 +--- src/containers/style/StyleListViewer.js | 5 +- src/reducers/index.js | 8 +-- src/utils/{qrcode.js => qrcodeEncoder.js} | 3 +- src/utils/qrcodeHandler.js | 30 ++++++++- src/utils/util.js | 13 +++- 16 files changed, 114 insertions(+), 52 deletions(-) rename src/components/{footer/Footer.js => app/PartFooter.js} (95%) rename src/components/{header/Header.js => app/PartHeader.js} (91%) rename src/utils/{qrcode.js => qrcodeEncoder.js} (99%) diff --git a/package-lock.json b/package-lock.json index c7d0a6f..49f28e5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8091,6 +8091,11 @@ "verror": "1.10.0" } }, + "jsqr": { + "version": "1.3.1", + "resolved": "https://registry.npm.taobao.org/jsqr/download/jsqr-1.3.1.tgz", + "integrity": "sha1-UVp2bliwDIAULzotxLh1EQDO7c8=" + }, "jsx-ast-utils": { "version": "2.2.3", "resolved": "https://registry.npm.taobao.org/jsx-ast-utils/download/jsx-ast-utils-2.2.3.tgz", diff --git a/package.json b/package.json index a5c0897..b91ac60 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "@testing-library/jest-dom": "^4.2.4", "@testing-library/react": "^9.3.2", "@testing-library/user-event": "^7.1.2", + "jsqr": "^1.3.1", "prop-types": "^15.7.2", "react": "^16.13.1", "react-color": "^2.18.1", diff --git a/src/components/app/App.js b/src/components/app/App.js index 4318bae..be8419b 100644 --- a/src/components/app/App.js +++ b/src/components/app/App.js @@ -1,8 +1,8 @@ import React from 'react'; import './App.css'; import '../Qrcode.css'; -import Footer from "../footer/Footer"; -import Header from "../header/Header"; +import PartFooter from "./PartFooter"; +import PartHeader from "./PartHeader"; import PartMore from "./PartMore"; import PartParams from "./PartParams"; import PartDownloadViewer from "../../containers/app/PartDownloadViewer"; @@ -14,12 +14,12 @@ function App() {
-
+ -
diff --git a/src/components/footer/Footer.js b/src/components/app/PartFooter.js similarity index 95% rename from src/components/footer/Footer.js rename to src/components/app/PartFooter.js index 1950b93..fe5bee6 100644 --- a/src/components/footer/Footer.js +++ b/src/components/app/PartFooter.js @@ -3,7 +3,7 @@ import '../Qrcode.css'; const currentYear = new Date().getFullYear(); -const Footer = () => ( +const PartFooter = () => (
@@ -33,4 +33,4 @@ const Footer = () => (
) -export default Footer +export default PartFooter diff --git a/src/components/header/Header.js b/src/components/app/PartHeader.js similarity index 91% rename from src/components/header/Header.js rename to src/components/app/PartHeader.js index d65d5cb..c6870de 100644 --- a/src/components/header/Header.js +++ b/src/components/app/PartHeader.js @@ -9,7 +9,7 @@ const logoStyle = { backgroundPosition: 'left' }; -const Header = () => ( +const PartHeader = () => (

@@ -19,4 +19,4 @@ const Header = () => (
) -export default Header +export default PartHeader diff --git a/src/components/renderer/RendererRandRect.js b/src/components/renderer/RendererRandRect.js index cf357bf..e2a3352 100644 --- a/src/components/renderer/RendererRandRect.js +++ b/src/components/renderer/RendererRandRect.js @@ -1,7 +1,5 @@ import React, { useEffect } from "react"; import {defaultViewBox, rand} from "../../utils/util"; -import {ParamTypes} from "../../constant/ParamTypes"; -import {getTypeTable, QRPointType} from "../../utils/qrcodeHandler"; function listPoints(qrcode, params) { if (!qrcode) return [] diff --git a/src/components/renderer/RendererResImage.js b/src/components/renderer/RendererResImage.js index 345ec6b..6920211 100644 --- a/src/components/renderer/RendererResImage.js +++ b/src/components/renderer/RendererResImage.js @@ -167,7 +167,7 @@ const RendererResImage = ({qrcode, params, setParamInfo}) => { const [gpl, setGPL] = useState([]); useMemo(() => { getGrayPointList(params, qrcode.getModuleCount(), "#S-black", "#S-white").then(res => setGPL(res)); - }, [setGPL, params[0], params[1], params[2], qrcode]) + }, [setGPL, params, qrcode]) return ( ( -