From e9bd1e4b0eeb27a7c27d87a3d271954a23463083 Mon Sep 17 00:00:00 2001 From: ciaochaos <1272777550@qq.com> Date: Sat, 13 Jun 2020 00:15:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=A5=E6=A0=BC=E7=9B=B8=E7=AD=89=E6=94=B9?= =?UTF-8?q?=E8=BF=9B=EF=BC=88=3D=3D=3D=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/renderer/Renderer25D.js | 4 +-- src/components/renderer/RendererBase.js | 1 - src/components/renderer/RendererDSJ.js | 12 ++++---- src/components/renderer/RendererImage.js | 32 ++++++++++----------- src/components/renderer/RendererResImage.js | 11 +++---- src/components/style/Renderer.js | 2 +- src/containers/style/RendererViewer.js | 2 +- src/containers/style/StyleListViewer.js | 2 +- src/reducers/index.js | 4 +-- src/utils/navigatorUtils.js | 2 +- src/utils/qrcodeHandler.js | 6 ++-- src/utils/util.js | 2 +- 12 files changed, 38 insertions(+), 42 deletions(-) diff --git a/src/components/renderer/Renderer25D.js b/src/components/renderer/Renderer25D.js index 9d9ff0b..d11080a 100644 --- a/src/components/renderer/Renderer25D.js +++ b/src/components/renderer/Renderer25D.js @@ -30,8 +30,8 @@ function listPoints(qrcode, params) { for (let x = 0; x < nCount; x++) { for (let y = 0; y < nCount; y++) { - if (qrcode.isDark(x, y) == false) continue; - else if (typeTable[x][y] == QRPointType.POS_OTHER || typeTable[x][y] == QRPointType.POS_CENTER) { + if (qrcode.isDark(x, y) === false) continue; + else if (typeTable[x][y] === QRPointType.POS_OTHER || typeTable[x][y] === QRPointType.POS_CENTER) { pointList.push(); pointList.push(); pointList.push(); diff --git a/src/components/renderer/RendererBase.js b/src/components/renderer/RendererBase.js index 149507f..5a76b0c 100644 --- a/src/components/renderer/RendererBase.js +++ b/src/components/renderer/RendererBase.js @@ -22,7 +22,6 @@ function listPoints(qrcode, params) { const vw = [3, -3]; const vh = [3, -3]; - const sq20 = "M25.638852,-1.03584031e-15 L74.361148,1.03584031e-15 C83.2763354,-6.01853049e-16 86.5091978,0.928256111 89.768457,2.67132704 C93.0277163,4.41439796 95.585602,6.97228371 97.328673,10.231543 C99.0717439,13.4908022 100,16.7236646 100,25.638852 L100,74.361148 C100,83.2763354 99.0717439,86.5091978 97.328673,89.768457 C95.585602,93.0277163 93.0277163,95.585602 89.768457,97.328673 C86.5091978,99.0717439 83.2763354,100 74.361148,100 L25.638852,100 C16.7236646,100 13.4908022,99.0717439 10.231543,97.328673 C6.97228371,95.585602 4.41439796,93.0277163 2.67132704,89.768457 C0.928256111,86.5091978 4.01235366e-16,83.2763354 -6.90560205e-16,74.361148 L6.90560205e-16,25.638852 C-4.01235366e-16,16.7236646 0.928256111,13.4908022 2.67132704,10.231543 C4.41439796,6.97228371 6.97228371,4.41439796 10.231543,2.67132704 C13.4908022,0.928256111 16.7236646,6.01853049e-16 25.638852,-1.03584031e-15 Z"; const sq25 = "M32.048565,-1.29480038e-15 L67.951435,1.29480038e-15 C79.0954192,-7.52316311e-16 83.1364972,1.16032014 87.2105713,3.3391588 C91.2846454,5.51799746 94.4820025,8.71535463 96.6608412,12.7894287 C98.8396799,16.8635028 100,20.9045808 100,32.048565 L100,67.951435 C100,79.0954192 98.8396799,83.1364972 96.6608412,87.2105713 C94.4820025,91.2846454 91.2846454,94.4820025 87.2105713,96.6608412 C83.1364972,98.8396799 79.0954192,100 67.951435,100 L32.048565,100 C20.9045808,100 16.8635028,98.8396799 12.7894287,96.6608412 C8.71535463,94.4820025 5.51799746,91.2846454 3.3391588,87.2105713 C1.16032014,83.1364972 5.01544207e-16,79.0954192 -8.63200256e-16,67.951435 L8.63200256e-16,32.048565 C-5.01544207e-16,20.9045808 1.16032014,16.8635028 3.3391588,12.7894287 C5.51799746,8.71535463 8.71535463,5.51799746 12.7894287,3.3391588 C16.8635028,1.16032014 20.9045808,7.52316311e-16 32.048565,-1.29480038e-15 Z"; if (size <= 0) size = 1.0 diff --git a/src/components/renderer/RendererDSJ.js b/src/components/renderer/RendererDSJ.js index 117bcaa..90756b5 100644 --- a/src/components/renderer/RendererDSJ.js +++ b/src/components/renderer/RendererDSJ.js @@ -34,12 +34,12 @@ function listPoints(qrcode, params) { for (let y = 0; y < nCount; y++) { for (let x = 0; x < nCount; x++) { - if (qrcode.isDark(x, y) == false) continue; + if (qrcode.isDark(x, y) === false) continue; - else if (typeTable[x][y] == QRPointType.POS_CENTER) { - if (posType == 0) { + else if (typeTable[x][y] === QRPointType.POS_CENTER) { + if (posType === 0) { pointList.push(); - } else if (posType == 1) { + } else if (posType === 1) { pointList.push(); pointList.push(); pointList.push(); @@ -47,8 +47,8 @@ function listPoints(qrcode, params) { pointList.push(); } } - else if (typeTable[x][y] == QRPointType.POS_OTHER) { - if (posType == 0) { + else if (typeTable[x][y] === QRPointType.POS_OTHER) { + if (posType === 0) { pointList.push(); } } diff --git a/src/components/renderer/RendererImage.js b/src/components/renderer/RendererImage.js index 489237d..a0a200b 100644 --- a/src/components/renderer/RendererImage.js +++ b/src/components/renderer/RendererImage.js @@ -30,28 +30,28 @@ function listPoints(qrcode, params) { for (let x = 0; x < nCount; x++) { for (let y = 0; y < nCount; y++) { - if (typeTable[x][y] == QRPointType.ALIGN_CENTER || typeTable[x][y] == QRPointType.ALIGN_OTHER || typeTable[x][y] == QRPointType.TIMING) { + if (typeTable[x][y] === QRPointType.ALIGN_CENTER || typeTable[x][y] === QRPointType.ALIGN_OTHER || typeTable[x][y] === QRPointType.TIMING) { if (qrcode.isDark(x, y)) { - if (type == 0) + if (type === 0) pointList.push() - else if (type == 1) + else if (type === 1) pointList.push() } else { - if (type == 0) + if (type === 0) pointList.push() - else if (type == 1) + else if (type === 1) pointList.push() } } - else if (typeTable[x][y] == QRPointType.POS_CENTER) { + else if (typeTable[x][y] === QRPointType.POS_CENTER) { if (qrcode.isDark(x, y)) { - if (posType == 0) { + if (posType === 0) { pointList.push(); - } else if (posType == 1) { + } else if (posType === 1) { pointList.push() pointList.push() pointList.push() - } else if (posType == 2) { + } else if (posType === 2) { pointList.push() pointList.push() pointList.push() @@ -65,13 +65,13 @@ function listPoints(qrcode, params) { } } - else if (typeTable[x][y] == QRPointType.POS_OTHER) { + else if (typeTable[x][y] === QRPointType.POS_OTHER) { if (qrcode.isDark(x, y)) { - if (posType == 0) { + if (posType === 0) { pointList.push(); } } else { - if (posType == 0) { + if (posType === 0) { pointList.push(); } } @@ -79,14 +79,14 @@ function listPoints(qrcode, params) { } else { if (qrcode.isDark(x, y)) { - if (type == 0) + if (type === 0) pointList.push() - else if (type == 1) + else if (type === 1) pointList.push() } else { - if (type == 0) + if (type === 0) pointList.push() - else if (type == 1) + else if (type === 1) pointList.push() } diff --git a/src/components/renderer/RendererResImage.js b/src/components/renderer/RendererResImage.js index b6bc6f5..b1491e7 100644 --- a/src/components/renderer/RendererResImage.js +++ b/src/components/renderer/RendererResImage.js @@ -10,18 +10,15 @@ function listPoints(qrcode, params) { const nCount = qrcode.getModuleCount(); const typeTable = getTypeTable(qrcode); const pointList = new Array(nCount); - let contrast = params[1]; - let exposure = params[2]; let alignType = params[3]; let timingType = params[4]; - let otherColor = params[5]; let posColor = params[6]; let id = 0; for (let x = 0; x < nCount; x++) { for (let y = 0; y < nCount; y++) { const posX = 3 * x, posY = 3 * y; - if (typeTable[x][y] == QRPointType.ALIGN_CENTER || typeTable[x][y] == QRPointType.ALIGN_OTHER) { + if (typeTable[x][y] === QRPointType.ALIGN_CENTER || typeTable[x][y] === QRPointType.ALIGN_OTHER) { if (qrcode.isDark(x, y)) { if (alignType === 2) { pointList.push() @@ -35,7 +32,7 @@ function listPoints(qrcode, params) { pointList.push() } } - } else if (typeTable[x][y] == QRPointType.TIMING) { + } else if (typeTable[x][y] === QRPointType.TIMING) { if (qrcode.isDark(x, y)) { if (timingType === 2) { pointList.push() @@ -49,11 +46,11 @@ function listPoints(qrcode, params) { pointList.push() } } - } else if (typeTable[x][y] == QRPointType.POS_CENTER) { + } else if (typeTable[x][y] === QRPointType.POS_CENTER) { if (qrcode.isDark(x, y)) { pointList.push() } - } else if (typeTable[x][y] == QRPointType.POS_OTHER) { + } else if (typeTable[x][y] === QRPointType.POS_OTHER) { if (qrcode.isDark(x, y)) { pointList.push() } else { diff --git a/src/components/style/Renderer.js b/src/components/style/Renderer.js index 1af19e8..8a64af6 100644 --- a/src/components/style/Renderer.js +++ b/src/components/style/Renderer.js @@ -6,7 +6,7 @@ const Renderer = ({ rendererType, ...other }) => ( ) function areEqual(prevProps, nextProps) { - return !(prevProps.selected == true || nextProps.selected == true) + return !(prevProps.selected === true || nextProps.selected === true) } export function createRenderer(renderer) { diff --git a/src/containers/style/RendererViewer.js b/src/containers/style/RendererViewer.js index ecc2d14..6553625 100644 --- a/src/containers/style/RendererViewer.js +++ b/src/containers/style/RendererViewer.js @@ -7,7 +7,7 @@ const mapStateToProps = (state, ownProps) => ({ rendererIndex: ownProps.index, qrcode: state.qrcode, params: fillEmptyWith(state.paramValue[ownProps.index].slice(), 0), - selected: state.selectedIndex == ownProps.index, + selected: state.selectedIndex === ownProps.index, }) const mapDispatchToProps = (dispatch, ownProps) => ({ diff --git a/src/containers/style/StyleListViewer.js b/src/containers/style/StyleListViewer.js index 4ac27e2..da99b82 100644 --- a/src/containers/style/StyleListViewer.js +++ b/src/containers/style/StyleListViewer.js @@ -33,7 +33,7 @@ const mapStateToProps = state => ({ styles: styles.map((style, index) => { return { value: style.value, - selected: state.selectedIndex == index, + selected: state.selectedIndex === index, renderer: } }) diff --git a/src/reducers/index.js b/src/reducers/index.js index 75a7b1f..417abf0 100644 --- a/src/reducers/index.js +++ b/src/reducers/index.js @@ -21,7 +21,7 @@ export default function appReducer(state = initialState, action) { switch (action.type) { case actionTypes.GENERATE_QR_INFO: { let text = action.text; - if (!text || text.length == 0) text = QRBTF_URL; + if (!text || text.length === 0) text = QRBTF_URL; return Object.assign({}, state, { textUrl: text, qrcode: encodeData({text: text, correctLevel: state.correctLevel}) @@ -50,7 +50,7 @@ export default function appReducer(state = initialState, action) { case actionTypes.CHANGE_PARAM: { return Object.assign({}, state, { paramValue: state.paramValue.map((item, index) => { - if (index != action.rendererIndex) { + if (index !== action.rendererIndex) { return item; } diff --git a/src/utils/navigatorUtils.js b/src/utils/navigatorUtils.js index 31cd97a..e321596 100644 --- a/src/utils/navigatorUtils.js +++ b/src/utils/navigatorUtils.js @@ -1,6 +1,6 @@ export function isWeiXin(){ const ua = window.navigator.userAgent.toLowerCase(); - if(ua.match(/MicroMessenger/i) == 'micromessenger'){ + if(ua.match(/MicroMessenger/i) === 'micromessenger'){ return true; }else{ return false; diff --git a/src/utils/qrcodeHandler.js b/src/utils/qrcodeHandler.js index 5c45718..32335de 100644 --- a/src/utils/qrcodeHandler.js +++ b/src/utils/qrcodeHandler.js @@ -49,7 +49,7 @@ export function getTypeTable(qrcode) { typeTable[position[i][0]][position[i][1]] = QRPointType.ALIGN_CENTER; for (let r = -2; r <= 2; r++) { for (let c = -2; c <= 2; c++) { - if (!(r == 0 && c == 0)) + if (!(r === 0 && c === 0)) typeTable[position[i][0] + r][position[i][1] + c] = QRPointType.ALIGN_OTHER; } } @@ -60,14 +60,14 @@ export function getTypeTable(qrcode) { for (let r = -4; r <= 4; r++) { for (let c = -4; c <= 4; c++) { if (PD[i][0] + r >= 0 && PD[i][0] + r < nCount && PD[i][1] + c >=0 && PD[i][1] + c < nCount) - if (!(r == 0 && c == 0)) + if (!(r === 0 && c === 0)) typeTable[PD[i][0] + r][PD[i][1] + c] = QRPointType.POS_OTHER; } } } for (let i = 0; i <= 8; i++) { - if (i != 6) typeTable[i][8] = typeTable[8][i] = QRPointType.FORMAT; + if (i !== 6) typeTable[i][8] = typeTable[8][i] = QRPointType.FORMAT; if (i < 7) typeTable[nCount - i - 1][8] = QRPointType.FORMAT; if (i < 8) typeTable[8][nCount - i - 1] = QRPointType.FORMAT; } diff --git a/src/utils/util.js b/src/utils/util.js index 7d3a6cb..e2f1003 100644 --- a/src/utils/util.js +++ b/src/utils/util.js @@ -17,7 +17,7 @@ export function fillEmptyWith(arr, value) { } export function getParamDetailedValue(item, paramValue) { - if (item.type == ParamTypes.SELECTOR) return item.choices[paramValue]; + if (item.type === ParamTypes.SELECTOR) return item.choices[paramValue]; return paramValue; }