From cf481b9e6bcc2ed441e867b3821254d2c51ff62f Mon Sep 17 00:00:00 2001 From: CPunisher <1343316114@qq.com> Date: Sat, 16 May 2020 12:31:10 +0800 Subject: [PATCH] fixed database --- src/containers/app/PartDownloadViewer.js | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/containers/app/PartDownloadViewer.js b/src/containers/app/PartDownloadViewer.js index bbb2fac..1db318b 100644 --- a/src/containers/app/PartDownloadViewer.js +++ b/src/containers/app/PartDownloadViewer.js @@ -2,40 +2,36 @@ import { connect } from 'react-redux'; import PartDownload from "../../components/app/PartDownload"; import React from "react"; import {saveImg, saveSvg} from "../../utils/downloader"; -import ReactDOMServer from "react-dom/server"; import {increaseDownloadData, recordDownloadDetail} from "../../api/db"; import {getParamDetailedValue, outerHtml} from "../../utils/util"; -function saveEl(state, type) { - const el = React.createElement(state.rendererType, { - qrcode: state.qrcode, - params: state.paramValue[state.selectedIndex], - setParamInfo: () => {} - }); +function saveDB(state, type) { increaseDownloadData(state.value) recordDownloadDetail({ text: state.textUrl, value: state.value, type: type, params: state.paramInfo[state.selectedIndex].map((item, index) => { - return { - key: item.key, - value: getParamDetailedValue(item, state.paramValue[state.selectedIndex][index]) + const value = getParamDetailedValue(item, state.paramValue[state.selectedIndex][index]) + if (typeof value != "string" || value.length <= 128) { + return { + key: item.key, + value: value + } } }), history: state.history }); - return el; } const mapStateToProps = (state) => ({ value: state.value, onSvgDownload: () => { - // saveSvg(state.value, ReactDOMServer.renderToString(saveEl(state, 'svg'))) saveSvg(state.value, outerHtml(state.selectedIndex)) + saveDB(state, 'svg') }, onJpgDownload: () => { - // return saveImg(state.value, ReactDOMServer.renderToString(saveEl(state, 'jpg')), 1500, 1500) + saveDB(state, 'jpg') return saveImg(state.value, outerHtml(state.selectedIndex), 1500, 1500) } })