This commit is contained in:
CPunisher 2020-06-16 16:24:13 +08:00
parent 9bd461dfac
commit 4c83262ec7
8 changed files with 72 additions and 23 deletions

View File

@ -1,5 +1,5 @@
import {actionTypes} from "../constant/ActionTypes"; import {actionTypes} from "../constant/ActionTypes";
import ReactGA from "react-ga"; import {handleStyle} from "../utils/gaHelper";
export const genQRInfo = text => ({ export const genQRInfo = text => ({
type: actionTypes.GENERATE_QR_INFO, type: actionTypes.GENERATE_QR_INFO,
@ -7,12 +7,7 @@ export const genQRInfo = text => ({
}) })
export const changeStyle = (rendererIndex, rendererType, value) => { export const changeStyle = (rendererIndex, rendererType, value) => {
ReactGA.event({ handleStyle(value);
category: 'Style',
action: 'Switch',
value: value
});
return { return {
type: actionTypes.CHANGE_STYLE, type: actionTypes.CHANGE_STYLE,
rendererIndex, rendererType, value rendererIndex, rendererType, value
@ -29,10 +24,13 @@ export const createParam = (paramInfo, paramValue) => ({
paramInfo, paramValue paramInfo, paramValue
}) })
export const changeParam = (rendererIndex, paramIndex, value) => ({ export const changeParam = (rendererIndex, paramIndex, value) => {
type: actionTypes.CHANGE_PARAM,
rendererIndex, paramIndex, value return {
}) type: actionTypes.CHANGE_PARAM,
rendererIndex, paramIndex, value
};
}
export const loadDownloadData = (data) => ({ export const loadDownloadData = (data) => ({
type: actionTypes.LOAD_DOWNLOAD_DATA, type: actionTypes.LOAD_DOWNLOAD_DATA,

View File

@ -1,5 +1,6 @@
import React from "react"; import React from "react";
import '../Qrcode.css'; import '../Qrcode.css';
import {handleLink} from "../../utils/gaHelper";
const currentYear = new Date().getFullYear(); const currentYear = new Date().getFullYear();
@ -13,26 +14,26 @@ const PartFooter = () => (
rel="noopener noreferrer" rel="noopener noreferrer"
target="_blank">ciaochaos target="_blank">ciaochaos
</a>&emsp; </a>&emsp;
<a href="https://github.com/CPunisher/" <a onClick={ (e) => handleLink(e.target.href) } href="https://github.com/CPunisher/"
rel="noopener noreferrer" rel="noopener noreferrer"
target="_blank">CPunisher target="_blank">CPunisher
</a> </a>
<span className="gray">&ensp;&ensp;</span> <span className="gray">&ensp;&ensp;</span>
<span><a href="https://www.yuque.com/qrbtf/docs/contact" rel="noopener noreferrer" target="_blank">联系我们</a><span className="gray">&ensp;&ensp;</span></span> <span><a onClick={ (e) => handleLink(e.target.href) } href="https://www.yuque.com/qrbtf/docs/contact" rel="noopener noreferrer" target="_blank">联系我们</a><span className="gray">&ensp;&ensp;</span></span>
<span><a href="https://www.yuque.com/qrbtf/docs/coop" rel="noopener noreferrer" target="_blank">合作咨询</a></span> <span><a onClick={ (e) => handleLink(e.target.href) } href="https://www.yuque.com/qrbtf/docs/coop" rel="noopener noreferrer" target="_blank">合作咨询</a></span>
</div> </div>
<div className="Qr-footer-part"> <div className="Qr-footer-part">
<strong>更多产品</strong>&emsp; <strong>更多产品</strong>&emsp;
<span><a href="https://mdnice.com" rel="noopener noreferrer" target="_blank">mdnice 公众号排版</a><span className="gray">&ensp;&ensp;</span></span> <span><a onClick={ (e) => handleLink(e.target.href) } href="https://mdnice.com" rel="noopener noreferrer" target="_blank">mdnice 公众号排版</a><span className="gray">&ensp;&ensp;</span></span>
<span><a href="https://urlify.cn/" rel="noopener noreferrer" target="_blank">Urlify 短链接</a><span className="gray">&ensp;&ensp;</span></span> <span><a onClick={ (e) => handleLink(e.target.href) } href="https://urlify.cn/" rel="noopener noreferrer" target="_blank">Urlify 短链接</a><span className="gray">&ensp;&ensp;</span></span>
<span><a href="https://imgkr.com/" rel="noopener noreferrer" target="_blank">imgkr 图壳图床</a><span className="gray">&ensp;&ensp;</span></span> <span><a onClick={ (e) => handleLink(e.target.href) } href="https://imgkr.com/" rel="noopener noreferrer" target="_blank">imgkr 图壳图床</a><span className="gray">&ensp;&ensp;</span></span>
<span><a href="https://blog.ciaochaos.com/mpmath/" rel="noopener noreferrer" target="_blank">mpMath 公众号公式插件</a></span> <span><a onClick={ (e) => handleLink(e.target.href) } href="https://blog.ciaochaos.com/mpmath/" rel="noopener noreferrer" target="_blank">mpMath 公众号公式插件</a></span>
</div> </div>
<div className="Gray"> <div className="Gray">
Copyright © {currentYear} QRBTF. 保留所有权利<br /> Copyright © {currentYear} QRBTF. 保留所有权利<br />
<a href="http://www.beian.miit.gov.cn/" rel="noopener noreferrer" target="_blank"> <a onClick={ (e) => handleLink(e.target.href) } href="http://www.beian.miit.gov.cn/" rel="noopener noreferrer" target="_blank">
ICP 19005869 ICP 19005869
</a> </a>

View File

@ -2,6 +2,7 @@ import React from 'react';
import './App.css'; import './App.css';
import LinkButton from "../link/LinkButton"; import LinkButton from "../link/LinkButton";
import GitHubButton from 'react-github-btn' import GitHubButton from 'react-github-btn'
import {handleLink} from "../../utils/gaHelper";
const PartMore = () => ( const PartMore = () => (
<div className="Qr-titled-nobg"> <div className="Qr-titled-nobg">
@ -11,11 +12,11 @@ const PartMore = () => (
<div className="Qr-article"> <div className="Qr-article">
<p><GitHubButton className="github-btn" href="https://github.com/ciaochaos/qrbtf" data-icon="octicon-star" data-size="large" data-show-count="true" aria-label="Star ciaochaos/qrbtf on GitHub">Star</GitHubButton></p> <p><GitHubButton className="github-btn" href="https://github.com/ciaochaos/qrbtf" data-icon="octicon-star" data-size="large" data-show-count="true" aria-label="Star ciaochaos/qrbtf on GitHub">Star</GitHubButton></p>
<h2>最新消息</h2> <h2>最新消息</h2>
<p><b>2020.6.11</b><br/>QRBTF React 组件发布快在你的应用中引入 react-qrbtf <a href='https://github.com/cpunisher/react-qrbtf' rel="noopener noreferrer" target="_blank">访问项目</a></p> <p><b>2020.6.11</b><br/>QRBTF React 组件发布快在你的应用中引入 react-qrbtf <a onClick={ (e) => handleLink(e.target.href) } href='https://github.com/cpunisher/react-qrbtf' rel="noopener noreferrer" target="_blank">访问项目</a></p>
<p><b>2020.5.23</b><br/>网站开源啦<a href='https://github.com/ciaochaos/qrbtf' rel="noopener noreferrer" target="_blank">点击访问</a> 我们的 Github。期待你也来参与设计、开发给个 Star 支持一下不?查看文章 <a href='https://mp.weixin.qq.com/s/GFEMCWQu3e2qhTuBabnHmQ' rel="noopener noreferrer" target="_blank">QRBTF 开源啦来写个二维码样式吧</a></p> <p><b>2020.5.23</b><br/>网站开源啦<a onClick={ (e) => handleLink(e.target.href) } href='https://github.com/ciaochaos/qrbtf' rel="noopener noreferrer" target="_blank">点击访问</a> 我们的 Github。期待你也来参与设计、开发给个 Star 支持一下不?查看文章 <a onClick={ (e) => handleLink(e.target.href) } href='https://mp.weixin.qq.com/s/GFEMCWQu3e2qhTuBabnHmQ' rel="noopener noreferrer" target="_blank">QRBTF 开源啦来写个二维码样式吧</a></p>
<p><b>2020.5.22</b><br/>新增 C2 样式下载计数好像还不太稳定普通二维码上传颜色选择背景图片上传输入提示桌面端横向滚动提示</p> <p><b>2020.5.22</b><br/>新增 C2 样式下载计数好像还不太稳定普通二维码上传颜色选择背景图片上传输入提示桌面端横向滚动提示</p>
<h2>为什么要做一个二维码生成器</h2> <h2>为什么要做一个二维码生成器</h2>
<p>看这里<a href='https://mp.weixin.qq.com/s/_Oy9I9FqPXhfwN9IUhf6_g' rel="noopener noreferrer" target="_blank">如何制作一个漂亮的二维码</a> </p> <p>看这里<a onClick={ (e) => handleLink(e.target.href) } href='https://mp.weixin.qq.com/s/_Oy9I9FqPXhfwN9IUhf6_g' rel="noopener noreferrer" target="_blank">如何制作一个漂亮的二维码</a> </p>
<h2>这个生成器的特别之处在哪里</h2> <h2>这个生成器的特别之处在哪里</h2>
<p>普通的二维码样式单一不能与环境较好的融合这一个生成器有着 <b>丰富的参数化样式基于 SVG 的二维码生成能力</b> SVG </p> <p>普通的二维码样式单一不能与环境较好的融合这一个生成器有着 <b>丰富的参数化样式基于 SVG 的二维码生成能力</b> SVG </p>
<h2>如何使用</h2> <h2>如何使用</h2>

View File

@ -1,9 +1,10 @@
import React from "react"; import React from "react";
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import '../Qrcode.css'; import '../Qrcode.css';
import {handleLink} from "../../utils/gaHelper";
const LinkButton = ({ href, value }) => ( const LinkButton = ({ href, value }) => (
<a href={href} rel="noopener noreferrer" target="_blank"> <a onClick={ (e) => handleLink(e.target.href) } href={href} rel="noopener noreferrer" target="_blank">
<button className="dl-btn">{value}</button> <button className="dl-btn">{value}</button>
</a> </a>
) )

View File

@ -3,6 +3,7 @@ import {genQRInfo} from "../../actions";
import React, {useRef} from "react"; import React, {useRef} from "react";
import {isPicture} from "../../utils/imageUtils"; import {isPicture} from "../../utils/imageUtils";
import {decodeData} from "../../utils/qrcodeHandler"; import {decodeData} from "../../utils/qrcodeHandler";
import {handleUpload} from "../../utils/gaHelper";
const InputText = ({dispatch}) => { const InputText = ({dispatch}) => {
const textRef = useRef(); const textRef = useRef();
@ -36,6 +37,7 @@ const InputText = ({dispatch}) => {
if (e.target.files.length > 0) { if (e.target.files.length > 0) {
const file = e.target.files[0]; const file = e.target.files[0];
if (isPicture(file)) { if (isPicture(file)) {
handleUpload();
decodeData(file).then((res) => { decodeData(file).then((res) => {
if (res) { if (res) {
textRef.current.value = res.data; textRef.current.value = res.data;

View File

@ -3,6 +3,7 @@ import PartDownload from "../../components/app/PartDownload";
import {saveImg, saveSvg} from "../../utils/downloader"; import {saveImg, saveSvg} from "../../utils/downloader";
import {getDownloadCount, increaseDownloadData, recordDownloadDetail} from "../../api/db"; import {getDownloadCount, increaseDownloadData, recordDownloadDetail} from "../../api/db";
import {getParamDetailedValue, outerHtml} from "../../utils/util"; import {getParamDetailedValue, outerHtml} from "../../utils/util";
import {handleDownloadEvent} from "../../utils/gaHelper";
function saveDB(state, type, updateDownloadData) { function saveDB(state, type, updateDownloadData) {
return new Promise(resolve => { return new Promise(resolve => {
@ -41,11 +42,13 @@ const mapStateToProps = (state, ownProps) => ({
onSvgDownload: () => { onSvgDownload: () => {
saveSvg(state.value, outerHtml(state.selectedIndex)); saveSvg(state.value, outerHtml(state.selectedIndex));
saveDB(state, 'svg', ownProps.updateDownloadData); saveDB(state, 'svg', ownProps.updateDownloadData);
handleDownloadEvent(state.value, 0);
}, },
onJpgDownload: () => { onJpgDownload: () => {
return new Promise(resolve => { return new Promise(resolve => {
saveImg(state.value, outerHtml(state.selectedIndex), 1500, 1500).then((res) => { saveImg(state.value, outerHtml(state.selectedIndex), 1500, 1500).then((res) => {
saveDB(state, 'jpg', ownProps.updateDownloadData).then(() => { saveDB(state, 'jpg', ownProps.updateDownloadData).then(() => {
handleDownloadEvent(state.value, 1);
resolve(res) resolve(res)
}); });
}); });

View File

@ -2,6 +2,7 @@ import { connect } from 'react-redux';
import {changeParam} from "../../actions"; import {changeParam} from "../../actions";
import ParamUpload from "../../components/param/ParamUpload"; import ParamUpload from "../../components/param/ParamUpload";
import {isPicture, toBase64} from "../../utils/imageUtils"; import {isPicture, toBase64} from "../../utils/imageUtils";
import {handleUpload} from "../../utils/gaHelper";
const mapStateToProps = (state, ownProps) => ({ const mapStateToProps = (state, ownProps) => ({
rendererIndex: ownProps.rendererIndex, rendererIndex: ownProps.rendererIndex,
@ -15,6 +16,7 @@ const mapDispatchToProps = (dispatch, ownProps) => ({
if (e.target.files.length > 0) { if (e.target.files.length > 0) {
const file = e.target.files[0]; const file = e.target.files[0];
if (isPicture(file)) { if (isPicture(file)) {
handleUpload();
toBase64(file, 500, 500).then(res => { toBase64(file, 500, 500).then(res => {
dispatch(changeParam(ownProps.rendererIndex, ownProps.paramIndex, res)) dispatch(changeParam(ownProps.rendererIndex, ownProps.paramIndex, res))
}) })

41
src/utils/gaHelper.js Normal file
View File

@ -0,0 +1,41 @@
import ReactGA from "react-ga";
export function handleStyle(rendererName) {
ReactGA.event({
category: 'Style',
action: 'Switch',
label: rendererName
});
}
export function handleDownloadEvent(rendererName, value) {
ReactGA.event({
category: 'Style',
action: 'Download',
label: rendererName,
value: value
});
}
export function handleParam(rendererName, paramName) {
ReactGA.event({
category: 'Param',
action: rendererName,
label: paramName,
});
}
export function handleLink(link) {
ReactGA.event({
category: 'Link',
action: 'Click',
label: link,
});
}
export function handleUpload() {
ReactGA.event({
category: 'Upload',
action: 'Click',
});
}