Skip to content

Commit

Permalink
统计预览发布完成
Browse files Browse the repository at this point in the history
  • Loading branch information
tywei90 committed Nov 29, 2017
1 parent 137fbf7 commit f941ca2
Show file tree
Hide file tree
Showing 9 changed files with 163 additions and 108 deletions.
2 changes: 1 addition & 1 deletion public/main.css

Large diffs are not rendered by default.

170 changes: 85 additions & 85 deletions public/main.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/components/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import UnitTextBody from './units/textbody/index'
import UnitAudio from './units/audio/index'
import UnitVideo from './units/video/index'
import UnitCode from './units/code/index'
import UnitStatistic from './units/statistic/index'

import Preview from './preview.js'
import $ from 'jquery'
Expand All @@ -44,6 +45,8 @@ const renderUnits = units => {
return <li key={index} id={index}><UnitVideo id={index} data={item} /></li>
case 'CODE' :
return <li key={index} id={index}><UnitCode id={index} data={item} /></li>
case 'STATISTIC' :
return <li key={index} id={index}><UnitStatistic id={index} data={item} /></li>
}
});
};
Expand Down
20 changes: 16 additions & 4 deletions src/components/mediaQuery.scss
Original file line number Diff line number Diff line change
Expand Up @@ -241,19 +241,31 @@
}
.unit-code {
.show-detail {
height: 400px;
height: 500px;
}
.content {
>ul>li> {
label {
>ul>li{
font-size: 12px;
>label {
width: 60px;
font-size: 12px;
line-height: 20px;
}
ul {
>ul {
line-height: 20px;
width: calc(100% - 80px);
.CodeMirror {
height: 150px;
}
}
&:nth-child(1),&:nth-child(2){
ul{
line-height: 18px;
}
}
&:nth-child(2){
margin-top: 10px;
}
}
button {
margin-left: 80px;
Expand Down
43 changes: 27 additions & 16 deletions src/components/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import PreButton from './previewUnits/preButton';
import PreAudio from './previewUnits/preAudio';
import PreVideo from './previewUnits/preVideo';
import PreCode from './previewUnits/preCode';
import PreStatistic from './previewUnits/PreStatistic';

import $ from 'jquery'

Expand Down Expand Up @@ -59,6 +60,11 @@ const renderUnits = units => {
<PreCode key={index} id={index} data={item} />
)
break;
case 'STATISTIC' :
return (
<PreStatistic key={index} id={index} data={item} />
)
break;
}
});
};
Expand Down Expand Up @@ -346,6 +352,26 @@ class Preview extends React.Component {
let iframe = document.getElementsByTagName('iframe')[0];
let iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
let bodyContext = iframeDoc.getElementById("framePage").outerHTML;
let ids = [];
let scriptIds = [];
for(let i=0, len=localData.length; i<len; i++){
if(localData[i].type = 'STATISTIC' && localData[i].id){
ids.push(localData[i].id);
}
}
for(let i=0, len=ids.length; i<len; i++){
scriptIds.push(
'<script>'+
'var _hmt = _hmt || [];'+
'(function() {'+
'var hm = document.createElement("script");'+
'hm.src = "https://hm.baidu.com/hm.js?'+ ids[i] + '";'+
'var s = document.getElementsByTagName("script")[0]; '+
's.parentNode.insertBefore(hm, s);'+
'})();'+
'</script>'
)
}
let htmlContext =
'<!DOCTYPE html>' +
'<html>' +
Expand All @@ -357,22 +383,7 @@ class Preview extends React.Component {
'<meta name="description" content=' + data.desc + '>'+
'<link type="text/css" rel="stylesheet" href="/release/index.css" />' +
'<style id="insertCSS" type="text/css">' + me.insertCSS + '</style>' +
'<script>'+
'var _hmt = _hmt || [];'+
'(function() {'+
'var hm = document.createElement("script");'+
'hm.src = "https://hm.baidu.com/hm.js?dd6484741f3715e3bb10b2c134341631";'+
'var s = document.getElementsByTagName("script")[0]; '+
's.parentNode.insertBefore(hm, s);'+
'})();'+
'</script>'+
'<script async src="https://www.googletagmanager.com/gtag/js?id=UA-109240313-1"></script>'+
'<script>'+
'window.dataLayer = window.dataLayer || [];'+
'function gtag(){dataLayer.push(arguments);}'+
"gtag('js', new Date());"+
"gtag('config', 'UA-109240313-1');"+
'</script>'+
scriptIds.join('') +
'</head>'+
'<body>' +
bodyContext +
Expand Down
25 changes: 25 additions & 0 deletions src/components/previewUnits/preStatistic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React, {PropTypes} from 'react';
import autoBind from 'autobind-decorator';
import pureRender from 'pure-render-decorator';
import ImmutablePropTypes from 'react-immutable-proptypes';
import immutable from 'immutable';

@pureRender
class PreStatistic extends React.Component {
static propTypes = {
data: ImmutablePropTypes.map
};
constructor(props) {
super(props);
}
render() {
var { data } = this.props;
data = data.toJS();
return (
<setction className="statistic">

</setction>
)
}
}
export default PreStatistic;
1 change: 0 additions & 1 deletion src/components/units/title/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import autoBind from 'autobind-decorator';
import pureRender from 'pure-render-decorator';
import ImmutablePropTypes from 'react-immutable-proptypes';
import immutable from 'immutable';
import { Modal } from 'antd';

import './index.scss';

Expand Down
2 changes: 1 addition & 1 deletion src/components/unitsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class UnitsList extends React.Component {
<li onClick={this.handleClick.bind(this, 'TEXTBODY')}><i className="iconfont icon-zhengwen"></i>正文</li>
<li onClick={this.handleClick.bind(this, 'AUDIO')}><i className="iconfont icon-yinpin"></i>音频</li>
<li onClick={this.handleClick.bind(this, 'VIDEO')}><i className="iconfont icon-x-rmvb"></i>视频</li>
<li onClick={this.handleClick.bind(this, 'STATISTIC')}><i className="iconfont icon-tongji"></i>统计</li>
<li onClick={this.handleClick.bind(this, 'CODE')}><i className="iconfont icon-daima"></i>jscss</li>
<li onClick={this.info}><i className="iconfont icon-tongji"></i>统计</li>
</ul>
</section>
);
Expand Down
5 changes: 5 additions & 0 deletions src/reducer/unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ const unitsConfig = immutable.fromJS({
name: 'JSCSS',
js: '',
css: ''
},
STATISTIC: {
type: 'STATISTIC',
name: '统计',
id: ''
}
})

Expand Down

0 comments on commit f941ca2

Please sign in to comment.