fixed database
This commit is contained in:
parent
c82f0e72f8
commit
cf481b9e6b
|
@ -2,40 +2,36 @@ import { connect } from 'react-redux';
|
||||||
import PartDownload from "../../components/app/PartDownload";
|
import PartDownload from "../../components/app/PartDownload";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import {saveImg, saveSvg} from "../../utils/downloader";
|
import {saveImg, saveSvg} from "../../utils/downloader";
|
||||||
import ReactDOMServer from "react-dom/server";
|
|
||||||
import {increaseDownloadData, recordDownloadDetail} from "../../api/db";
|
import {increaseDownloadData, recordDownloadDetail} from "../../api/db";
|
||||||
import {getParamDetailedValue, outerHtml} from "../../utils/util";
|
import {getParamDetailedValue, outerHtml} from "../../utils/util";
|
||||||
|
|
||||||
function saveEl(state, type) {
|
function saveDB(state, type) {
|
||||||
const el = React.createElement(state.rendererType, {
|
|
||||||
qrcode: state.qrcode,
|
|
||||||
params: state.paramValue[state.selectedIndex],
|
|
||||||
setParamInfo: () => {}
|
|
||||||
});
|
|
||||||
increaseDownloadData(state.value)
|
increaseDownloadData(state.value)
|
||||||
recordDownloadDetail({
|
recordDownloadDetail({
|
||||||
text: state.textUrl,
|
text: state.textUrl,
|
||||||
value: state.value,
|
value: state.value,
|
||||||
type: type,
|
type: type,
|
||||||
params: state.paramInfo[state.selectedIndex].map((item, index) => {
|
params: state.paramInfo[state.selectedIndex].map((item, index) => {
|
||||||
|
const value = getParamDetailedValue(item, state.paramValue[state.selectedIndex][index])
|
||||||
|
if (typeof value != "string" || value.length <= 128) {
|
||||||
return {
|
return {
|
||||||
key: item.key,
|
key: item.key,
|
||||||
value: getParamDetailedValue(item, state.paramValue[state.selectedIndex][index])
|
value: value
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
history: state.history
|
history: state.history
|
||||||
});
|
});
|
||||||
return el;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapStateToProps = (state) => ({
|
const mapStateToProps = (state) => ({
|
||||||
value: state.value,
|
value: state.value,
|
||||||
onSvgDownload: () => {
|
onSvgDownload: () => {
|
||||||
// saveSvg(state.value, ReactDOMServer.renderToString(saveEl(state, 'svg')))
|
|
||||||
saveSvg(state.value, outerHtml(state.selectedIndex))
|
saveSvg(state.value, outerHtml(state.selectedIndex))
|
||||||
|
saveDB(state, 'svg')
|
||||||
},
|
},
|
||||||
onJpgDownload: () => {
|
onJpgDownload: () => {
|
||||||
// return saveImg(state.value, ReactDOMServer.renderToString(saveEl(state, 'jpg')), 1500, 1500)
|
saveDB(state, 'jpg')
|
||||||
return saveImg(state.value, outerHtml(state.selectedIndex), 1500, 1500)
|
return saveImg(state.value, outerHtml(state.selectedIndex), 1500, 1500)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue