diff --git a/.gitignore b/.gitignore
index d944170..b678901 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,3 +9,5 @@ npm-debug.log.*
package-lock.json
sftp-config.json
build
+yarn-error.*
+tslint.json
diff --git a/README.md b/README.md
index 440d6cd..c2575b4 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,2 @@
-# react-pro-webpack4
\ No newline at end of file
+# react-pro-webpack4
+## webpack4 + react + react-router + mobx + react-mobx + typescript
diff --git a/package.json b/package.json
index d2f5a2e..fd02a04 100644
--- a/package.json
+++ b/package.json
@@ -4,34 +4,67 @@
"description": "koa2-code-demo",
"main": "index.js",
"scripts": {
- "dev": "webpack-dev-server --open --mode development --config ./static/config/webpack.config.base.js",
+ "init_sql": "node --harmony ./sql",
+ "dev_server": "nodemon ./app.js",
+ "devServer": "webpack-dev-server --open --mode development --config ./static/config/webpack.config.base.js",
"watch": "webpack --mode development --config ./static/config/webpack.config.dev.js",
- "prod": "webpack --mode production --config ./static/config/webpack.config.prod.js"
+ "prod": "webpack --mode production --config ./static/config/webpack.config.prod.js",
+ "start_server": "node --harmony ./app.js",
+ "dev": "npm run dev_server & npm run watch",
+ "start": "npm run prod & npm run start_server"
},
"license": "MIT",
"dependencies": {
"axios": "^0.18.0",
+ "busboy": "^0.2.14",
+ "co": "^4.6.0",
+ "debug": "^2.6.0",
"echarts": "^4.0.4",
+ "ejs": "^2.5.5",
"element-react": "^1.4.10",
"element-theme-default": "^1.4.13",
"glob": "^5.0.15",
"iconv-lite": "^0.4.19",
+ "koa": "^2.0.0",
+ "koa-bodyparser": "^3.2.0",
+ "koa-convert": "^1.2.0",
+ "koa-ejs": "4.1.0",
+ "koa-log4": "^2.3.0",
+ "koa-logger": "^1.3.0",
+ "koa-mysql-session": "0.0.2",
+ "koa-router": "^7.0.1",
+ "koa-send": "^3.2.0",
+ "koa-session-minimal": "^3.0.3",
+ "koa-static": "^2.0.0",
+ "koa-views": "^5.2.0",
"lodash": "^4.17.4",
- "mobx": "^4.1.0",
+ "mobx": "^4.2.0",
"mobx-react": "^5.0.0",
+ "mysql": "^2.12.0",
+ "qs": "^6.5.1",
"react": "^16.2.0",
"react-dev-utils": "^5.0.0",
"react-dom": "^16.2.0",
"react-loadable": "^5.3.1",
"react-router-config": "^1.0.0-beta.4",
"react-router-dom": "^4.2.2",
- "ua-parser-js": "^0.7.17"
+ "ua-parser-js": "^0.7.17",
+ "validator": "^6.2.0"
},
"devDependencies": {
- "autoprefixer": "7.1.6",
+ "@babel/preset-react": "^7.0.0-beta.44",
+ "@types/echarts": "^0.0.12",
+ "@types/qs": "^6.5.1",
+ "@types/react": "^16.3.11",
+ "@types/react-dom": "^16.0.5",
+ "@types/react-loadable": "^5.3.4",
+ "@types/react-router-config": "^1.0.6",
+ "@types/react-router-dom": "^4.2.6",
+ "@types/ua-parser-js": "^0.7.32",
+ "autoprefixer": "^7.1.6",
"babel-core": "^6.26.0",
"babel-eslint": "^7.2.3",
- "babel-jest": "20.0.3",
+ "babel-jest": "^20.0.3",
"babel-loader": "^7.1.4",
"babel-plugin-import": "^1.7.0",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
@@ -61,7 +94,6 @@
"eslint-plugin-import": "2.8.0",
"eslint-plugin-jsx-a11y": "5.1.1",
"eslint-plugin-react": "7.4.0",
- "extract-text-webpack-plugin": "^2.0.0-beta.4",
"file-loader": "^1.1.5",
"fs-extra": "^3.0.1",
"html-loader": "^0.5.5",
@@ -75,12 +107,13 @@
"optimize-css-assets-webpack-plugin": "^4.0.0",
"postcss-flexbugs-fixes": "^3.2.0",
"postcss-loader": "^2.0.8",
- "promise": "8.0.1",
- "qs": "^6.5.1",
+ "promise": "^8.0.1",
"raf": "^3.4.0",
"source-map-loader": "^0.2.3",
"style-loader": "^0.13.1",
"sw-precache-webpack-plugin": "^0.11.4",
+ "ts-loader": "^4.2.0",
+ "typescript": "^2.8.1",
"uglifyjs-webpack-plugin": "^1.2.4",
"url-loader": "^0.6.2",
"webpack": "^4.5.0",
diff --git a/static/config/webpack.config.base.js b/static/config/webpack.config.base.js
index 7cb4883..b21a49d 100644
--- a/static/config/webpack.config.base.js
+++ b/static/config/webpack.config.base.js
@@ -1,111 +1,10 @@
-const merge = require('webpack-merge');
-const webpack = require('webpack');
-// const baseWebpackConfig = require('./webpack.config.base');
const path = require('path');
-const outputPath = path.join(__dirname, './../build');
-const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const rootPath = path.join(__dirname, './../../');
function resolve(dir) {
return path.join(__dirname, './../../', dir)
}
-module.exports = {
- context: rootPath,
- module: {
- rules: [
- {
- test: /\.(js|jsx)$/,
- exclude: resolve('node_modules'),
- loader: ['babel-loader']
- }, {
- test: /\.less$/,
- use: [
- MiniCssExtractPlugin.loader, 'css-loader', 'less-loader'
- ],
- // use:['css-loader','less-loader'], include: []
- }, {
- test: /\.css$/,
- // use:['css-loader','postcss-loader'],
- use: [
- MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader'
- ],
- // include:['../node_modules/element-theme-default']
- }, {
- test: [
- /\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/
- ],
- loader: require.resolve('url-loader'),
- options: {
- limit: 10000,
- name: 'assets/images/[name].[hash:8].[ext]'
- }
- }, {
- test: /\.(eot|woff|woff2|svg|ttf)([?]?.*)$/,
- use: [
- {
- loader: 'file-loader',
- options: {
- name: 'assets/fonts/[name].[ext]',
- context: rootPath
- }
- }
- ]
- }
- ]
- },
- resolve: {
- extensions: [
- '.ts', '.tsx', '.js', '.jsx'
- ],
- modules: [resolve('static/src'), resolve('node_modules')]
- },
- entry: {
- 'main': ['./static/src/index.js'],
- vendor: [
- 'react',
- 'react-dom',
- 'react-router-dom',
- 'react-router-config',
- 'react-loadable',
- 'mobx',
- 'mobx-react'
- ]
- },
- output: {
- path: outputPath,
- publicPath: '/',
- filename: 'assets/js/[name].[chunkhash:8].js',
- chunkFilename: 'assets/js/[name].[chunkhash:8].js'
- },
- optimization: {
- runtimeChunk: {
- name: "manifest"
- },
- splitChunks: {
- cacheGroups: {
- vendor: {
- test: /[\\/]node_modules[\\/]/,
- name: "vendors",
- priority: -20,
- chunks: "all"
- }
- }
- }
- },
- plugins: [
- new webpack.DefinePlugin({
- 'process.env': {
- NODE_ENV: JSON.stringify('development')
- }
- }),
- new HtmlWebpackPlugin({
- title: 'My App',
- filename: 'index.html',
- template: resolve('static/public/index.html')
- }),
- new MiniCssExtractPlugin({filename: "assets/css/app.[contenthash].css", chunkFilename: "assets/css/app.[contenthash].[contenthash].css"})
- ]
-}
-
+module.exports = {
+}
\ No newline at end of file
diff --git a/static/config/webpack.config.dev.js b/static/config/webpack.config.dev.js
index b7ec4c0..eccc9e8 100644
--- a/static/config/webpack.config.dev.js
+++ b/static/config/webpack.config.dev.js
@@ -14,6 +14,12 @@ module.exports = {
module: {
rules: [
{
+ test: /\.(ts|tsx)$/,
+ include: resolve('static/src'),
+ exclude: resolve('node_modules'),
+ // loader: ['babel-loader', 'awesome-typescript-loader']
+ loader: ['babel-loader', 'ts-loader']
+ }, {
test: /\.(js|jsx)$/,
exclude: resolve('node_modules'),
loader: ['babel-loader']
@@ -60,7 +66,7 @@ module.exports = {
modules: [resolve('static/src'), resolve('node_modules')]
},
entry: {
- 'main': ['./static/src/index.js'],
+ 'main': ['./static/src/index.tsx'],
vendor: [
'react',
'react-dom',
diff --git a/static/config/webpack.config.prod.js b/static/config/webpack.config.prod.js
index 97af0a7..dd3a8b9 100644
--- a/static/config/webpack.config.prod.js
+++ b/static/config/webpack.config.prod.js
@@ -12,8 +12,14 @@ function resolve(dir) {
module.exports = {
context: rootPath,
module: {
- rules: [
+ rules: [
{
+ test: /\.(ts|tsx)$/,
+ include: resolve('static/src'),
+ exclude: resolve('node_modules'),
+ // loader: ['babel-loader', 'awesome-typescript-loader']
+ loader: ['babel-loader', 'ts-loader']
+ }, {
test: /\.(js|jsx)$/,
exclude: resolve('node_modules'),
loader: ['babel-loader']
@@ -60,7 +66,7 @@ module.exports = {
modules: [resolve('static/src'), resolve('node_modules')]
},
entry: {
- 'main': ['./static/src/index.js'],
+ 'main': ['./static/src/index.tsx'],
vendor: [
'react',
'react-dom',
diff --git a/static/src/AppStatic.js b/static/src/AppStatic.js
deleted file mode 100644
index 97adc51..0000000
--- a/static/src/AppStatic.js
+++ /dev/null
@@ -1,30 +0,0 @@
-import React, {Component} from 'react'
-import {renderRoutes} from 'react-router-config'
-import {HashRouter} from 'react-router-dom'
-import Qs from 'qs';
-import List from './routerStatic'
-
-const routes = [...List]
-// console.log(routes);
-class App extends Component {
- constructor(props, context) {
- super(props, context)
- console.log('App');
- // if(!window.location.hash) {
- // window.location.href = '/#/overview/list?pid=0'
- // }
- }
- render() {
- return (
-
-
-
- {renderRoutes(routes)}
-
-
-
- )
- }
-}
-
-export default App
\ No newline at end of file
diff --git a/static/src/AppStatic.tsx b/static/src/AppStatic.tsx
new file mode 100644
index 0000000..c380815
--- /dev/null
+++ b/static/src/AppStatic.tsx
@@ -0,0 +1,63 @@
+// import React, {Component} from 'react';
+import * as React from "react";
+import {observer, inject} from 'mobx-react';
+import {renderRoutes} from 'react-router-config'
+import {withRouter} from 'react-router-dom';
+import * as Qs from 'qs';
+import List from './routerStatic';
+import { Props } from "./utils/interface";
+
+const routes = [...List];
+interface Params {
+ pid:string,
+ start_time:any,
+ end_time:any
+}
+
+@inject('store')
+@observer
+class App extends React.Component < Props, {} > {
+ constructor(props:any, context?: any) {
+ super(props, context)
+ console.log('App-TS');
+ this.setUrlParamsToStore()
+ }
+ formatParams() {
+ let res:Params = {} as Params;
+ res.pid = this.props.store.actived;
+ if(this.props.store.projectTime.startTime) res.start_time = this.props.store.projectTime.startTime;
+ if(this.props.store.projectTime.endTime) res.end_time = this.props.store.projectTime.endTime;
+ return res;
+ }
+ setUrlParamsToStore() {
+ let isLoginPages = this.props.location.pathname.indexOf('/login')>-1;
+ if(isLoginPages) return;
+ let urlParams:Params = Qs.parse(this.props.location.search.replace(/^\?/, ''));
+ if(urlParams&&urlParams.pid) {
+ if(urlParams.pid !== this.props.store.actived) this.props.store.updateActive(urlParams.pid);
+ if(urlParams.start_time&&urlParams.end_time) {
+ this.props.store.updateProjectTime({
+ startTime:urlParams.start_time,
+ endTime:urlParams.end_time
+ });
+ }
+ } else {
+ console.log('setUrlParamsToStore');
+ console.log(routes,'routes')
+ this.props.history.push({
+ pathname: '/overview/list',
+ search: '?'+ Qs.stringify(this.formatParams())
+ });
+ }
+ }
+ render() {
+ return (
+
+
+ {renderRoutes(routes)}
+
+
+ )
+ }
+}
+export default withRouter(App)
\ No newline at end of file
diff --git a/static/src/components/Left/index.js b/static/src/components/Left/index.js
deleted file mode 100644
index d3cee96..0000000
--- a/static/src/components/Left/index.js
+++ /dev/null
@@ -1,66 +0,0 @@
-import React, {Component} from 'react'
-import {observer, inject} from 'mobx-react';
-import {withRouter, NavLink} from 'react-router-dom'
-import Qs from 'qs';
-import './left.less';
-
-@withRouter
-@inject('store')
-@observer
-class Left extends Component {
- constructor(props) {
- super(props);
- this.props = props;
- // console.log(this.props, 'Left')
- // console.log(props, 'params')
-
- this.menuLink = [
- {
- name: '概览',
- action: '/list',
- },
- {
- name: '点赞',
- action: '/like',
- }, {
- name: '评论',
- action: '/comment',
- }, {
- name: '埋点',
- action: '/points',
- }
- ]
- }
-
- makeMeuns() {
- return this
- .menuLink
- .map((item, index) =>
-
- {item.name}
- );
- }
- componentDidUpdate() {
- let id = Qs.parse(this.props.location.search.replace(/^\?/, '')).pid;
- this.props.store.updateActive(id)
- }
- render() {
- let listsItem = this.makeMeuns();
-
- return (
-
- )
- }
-}
-
-export default Left
\ No newline at end of file
diff --git a/static/src/components/Left/left.less b/static/src/components/Left/left.less
deleted file mode 100644
index 74ce624..0000000
--- a/static/src/components/Left/left.less
+++ /dev/null
@@ -1,39 +0,0 @@
-.is-active {
- .link {
- color: #48576a;
- }
-}
-
-.meun {
- background: #eef1f6;
- li {
- display: block;
- height: 56px;
- line-height: 56px;
- font-size: 14px;
- color: #48576a;
- padding: 0 20px;
- cursor: pointer;
- position: relative;
- transition: border-color .3s, background-color .3s, color .3s;
- box-sizing: border-box;
- white-space: nowrap;
- .link {
- display: block;
- height: 56px;
- line-height: 56px;
- color: #48576a;
- i {
- margin-right: 5px;
- width: 24px;
- text-align: center;
- }
- }
- .link-actvie {
- color: #20a0ff;
- i {
- color: #20a0ff;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/static/src/components/LineChartComponent/index.js b/static/src/components/LineChartComponent/index.tsx
similarity index 60%
rename from static/src/components/LineChartComponent/index.js
rename to static/src/components/LineChartComponent/index.tsx
index 054ea98..04d7fff 100644
--- a/static/src/components/LineChartComponent/index.js
+++ b/static/src/components/LineChartComponent/index.tsx
@@ -1,5 +1,5 @@
-import React, {Component} from 'react';
-import echarts from 'echarts/lib/echarts';
+import * as React from "react";
+import * as echarts from 'echarts/lib/echarts';
import theme from '../../utils/charts/theme'
@@ -12,16 +12,20 @@ import 'echarts/lib/chart/line';
-class LineChart extends Component {
- constructor(props) {
+class LineChart extends React.Component {
+ ID:any;
+ lineRef:any
+ constructor(props:any) {
super(props);
console.log('LineChart-Component');
+ this.lineRef = React.createRef();
this.init = this.init.bind(this);
echarts.registerTheme('myTheme',theme);
}
init() {
const { option={} } = this.props;
- let myChart = echarts.init(this.ID,'myTheme',{renderer: 'svg'})
+ // let myChart = echarts.init(this.ID,'myTheme',{renderer: 'svg'});
+ let myChart = echarts.init(this.lineRef.current,'myTheme',{renderer: 'svg'});
myChart.setOption(option)
window.onresize = function() {
myChart.resize()
@@ -35,7 +39,7 @@ class LineChart extends Component {
componentDidUpdate() {
this.init()
}
- componentWillUnmount = () => {
+ componentWillUnmount(){
this.setState = (state,callback)=>{
return;
};
@@ -43,7 +47,8 @@ class LineChart extends Component {
render() {
const { width="100%", height="300px" } = this.props
return (
- this.ID = ID} style={{width, height}}>
+ // this.ID = ID} style={{width, height}}>
+
)
}
}
diff --git a/static/src/components/Loading/Loading.js b/static/src/components/Loading/Loading.tsx
similarity index 56%
rename from static/src/components/Loading/Loading.js
rename to static/src/components/Loading/Loading.tsx
index eb67c99..b7bbf5c 100644
--- a/static/src/components/Loading/Loading.js
+++ b/static/src/components/Loading/Loading.tsx
@@ -1,11 +1,12 @@
-import React from 'react';
+import * as React from "react";
+import {Loading as Loaded} from 'element-react';
-export default function Loading(props) {
+export default function Loading(props:any) {
if (props.isLoading) {
if (props.timedOut) {
return Loader timed out!
;
} else if (props.pastDelay) {
- return Loading...
;
+ return ;
} else {
return null;
}
diff --git a/static/src/components/PieChartComponent/index.js b/static/src/components/PieChartComponent/index.tsx
similarity index 60%
rename from static/src/components/PieChartComponent/index.js
rename to static/src/components/PieChartComponent/index.tsx
index 9cdfa76..14c42bf 100644
--- a/static/src/components/PieChartComponent/index.js
+++ b/static/src/components/PieChartComponent/index.tsx
@@ -1,5 +1,5 @@
-import React, {Component} from 'react';
-import echarts from 'echarts/lib/echarts';
+import * as React from "react";
+import * as echarts from 'echarts/lib/echarts';
import theme from '../../utils/charts/theme'
@@ -12,16 +12,20 @@ import 'echarts/lib/chart/pie';
-class PieChart extends Component {
- constructor(props) {
+class PieChart extends React.Component {
+ ID:any
+ pieRef:any
+ constructor(props:any) {
super(props);
console.log('PieChart-Component');
+ this.pieRef = React.createRef();
this.init = this.init.bind(this);
echarts.registerTheme('myTheme',theme);
}
init() {
const { option={} } = this.props;
- let myChart = echarts.init(this.ID,'myTheme',{renderer: 'svg'})
+ // let myChart = echarts.init(this.ID,'myTheme',{renderer: 'svg'});
+ let myChart = echarts.init(this.pieRef.current,'myTheme',{renderer: 'svg'})
myChart.setOption(option)
window.onresize = function() {
myChart.resize()
@@ -35,7 +39,7 @@ class PieChart extends Component {
componentDidUpdate() {
this.init()
}
- componentWillUnmount = () => {
+ componentWillUnmount() {
this.setState = (state,callback)=>{
return;
};
@@ -43,7 +47,8 @@ class PieChart extends Component {
render() {
const { width="100%", height="300px" } = this.props;
return (
- this.ID = ID} style={{width, height}}>
+ // this.ID = ID} style={{width, height}}>
+
)
}
}
diff --git a/static/src/components/SearchComponent/index.js b/static/src/components/SearchComponent/index.tsx
similarity index 66%
rename from static/src/components/SearchComponent/index.js
rename to static/src/components/SearchComponent/index.tsx
index 9118f72..424857c 100644
--- a/static/src/components/SearchComponent/index.js
+++ b/static/src/components/SearchComponent/index.tsx
@@ -1,14 +1,18 @@
-import React, {Component} from 'react';
+import * as React from "react";
import {observer, inject} from 'mobx-react';
import { DateRangePicker} from 'element-react';
-import {withRouter} from 'react-router-dom';
+
import dateFormat from '../../utils/Date';
-@withRouter
+interface states {
+ value: any[]
+}
+
@inject('store')
@observer
-class Searchs extends Component {
- constructor(props) {
+class Searchs extends React.Component {
+ paras:any = {}
+ constructor(props:any) {
super(props);
// console.log(this.props.handleData, 'Searchs')
this.props = props;
@@ -20,21 +24,12 @@ class Searchs extends Component {
};
this.paras = {};
}
- componentWillUnmount = () => {
+ componentWillUnmount() {
this.setState = (state,callback)=>{
return;
};
}
- componentWillReceiveProps(nextProps) {
- if (nextProps.location.pathname !== this.props.location.pathname || nextProps.location.search !== this.props.location.search) {
- console.log('Searchs-update-nextProps')
- let {startTime,endTime} = this.props.store.projectTime;
- let start_time = startTime?new Date(startTime):null;
- let end_time = endTime?new Date(endTime):null;
- this.setState({value: [start_time,end_time]})
- }
- }
- changeDate(date) {
+ changeDate(date:any) {
// console.log('DateRangePicker1 changed: ', date)
if(date.length>0) {
this.paras.start_time = dateFormat(date[0]);
diff --git a/static/src/components/Top/index.js b/static/src/components/Top/index.tsx
similarity index 76%
rename from static/src/components/Top/index.js
rename to static/src/components/Top/index.tsx
index b6476d5..2d60be7 100644
--- a/static/src/components/Top/index.js
+++ b/static/src/components/Top/index.tsx
@@ -1,20 +1,31 @@
-import React, {Component} from 'react'
+import * as React from "react";
import {observer, inject} from 'mobx-react';
-import {withRouter} from 'react-router-dom'
+import {withRouter} from 'react-router-dom';
import {Layout,Select,Message,Icon} from 'element-react';
-import Qs from 'qs';
+import * as Qs from 'qs';
import {getBase} from '../../utils/httpServers';
-import Searchs from '../SearchComponent'
+import Searchs from '../SearchComponent/index'
import './index.less'
-
-@withRouter
+interface states {
+ path: any,
+ type: any,
+ showTimeDialog:any,
+ pv: any,
+ uv: any,
+ comment: any,
+ like: any,
+ point: any,
+ options: any[],
+ value: any
+}
+// @withRouter
@inject('store')
@observer
-class Top extends Component {
- constructor(props) {
+class Top extends React.Component {
+ constructor(props:any) {
super(props);
- console.log('Top-Component')
+ console.log('Top-Component');
this.props = props;
// let isLogin = props.store.isLogin; if(!isLogin) {
// this.props.history.push(`/login`) }
@@ -36,18 +47,17 @@ class Top extends Component {
}],
value: '0'
}
- this.setUrlParamsToStore();
}
componentWillMount() {
this.handleData();
}
- componentWillReceiveProps(nextProps) {
- if (nextProps.location.pathname !== this.props.location.pathname || nextProps.location.search !== this.props.location.search) {
- console.log('top-update-nextProps')
- this.handleData();
- }
- }
- componentWillUnmount = () => {
+ // componentWillReceiveProps(nextProps:any) {
+ // if (nextProps.location.pathname !== this.props.location.pathname || nextProps.location.search !== this.props.location.search) {
+ // console.log('top-update-nextProps')
+ // this.handleData();
+ // }
+ // }
+ componentWillUnmount() {
this.setState = (state, callback) => {
return;
};
@@ -56,7 +66,7 @@ class Top extends Component {
const request = this.formatParams();
this.getBase(request);
}
- getBase(data) {
+ getBase(data:any) {
getBase(data).then((res) => {
if (res.status === 200 && res.data.status.code === 200) {
this.assignBase(res.data.data);
@@ -65,18 +75,18 @@ class Top extends Component {
}
})
}
- assignBase(data) {
+ assignBase(data:any) {
const {pv,uv,like,comment,point} = data;
this.setState({pv,uv,like,comment,point})
}
- onChange(value) {
+ onChange(value:any) {
this.props.store.updateActive(value);
this.props.history.push({
pathname: '/overview/list',
search: '?'+Qs.stringify(this.formatParams())
})
}
- linkTo(path) {
+ linkTo(path:any) {
// console.log(this.props.location.pathname,'this.props.location.pathname ');
let pathname = this.props.location.pathname;
let linkPath = '/overview/'+path;
@@ -89,7 +99,7 @@ class Top extends Component {
search: '?' + Qs.stringify(this.formatParams())
})
}
- showTime(date) {
+ showTime(date:any) {
// console.log(date,'date')
this.props.store.updateProjectTime({
startTime:date.start_time,
@@ -100,31 +110,14 @@ class Top extends Component {
});
}
formatParams() {
- const res = {};
+ const res:any = {};
res.pid = this.props.store.actived;
if(this.props.store.projectTime.startTime) res.start_time = this.props.store.projectTime.startTime;
if(this.props.store.projectTime.endTime) res.end_time = this.props.store.projectTime.endTime;
return res;
}
- setUrlParamsToStore() {
- let urlParams = Qs.parse(this.props.location.search.replace(/^\?/, ''));
- if(urlParams&&urlParams.pid) {
- if(urlParams.pid !== this.props.store.actived) this.props.store.updateActive(urlParams.pid);
- if(urlParams.start_time&&urlParams.end_time) {
- this.props.store.updateProjectTime({
- startTime:urlParams.start_time,
- endTime:urlParams.end_time
- });
- }
- } else {
- this.props.history.push({
- pathname: '/overview/list',
- search: '?'+ Qs.stringify(this.formatParams())
- });
- }
- }
render() {
- const {pv,uv,like,comment,point} = this.state;
+ const {pv,uv,like,comment,point,options} = this.state;
return (
@@ -132,7 +125,7 @@ class Top extends Component {
{
- this.state.options.map(el => {
+ options.map(el => {
return
})
}
@@ -180,4 +173,4 @@ class Top extends Component {
}
}
-export default Top
\ No newline at end of file
+export default withRouter(Top)
\ No newline at end of file
diff --git a/static/src/components/Uacomponent/index.js b/static/src/components/Uacomponent/index.tsx
similarity index 79%
rename from static/src/components/Uacomponent/index.js
rename to static/src/components/Uacomponent/index.tsx
index ff5e636..f3ad816 100644
--- a/static/src/components/Uacomponent/index.js
+++ b/static/src/components/Uacomponent/index.tsx
@@ -1,8 +1,8 @@
-import React, {Component} from 'react'
+import * as React from "react";
import {observer, inject} from 'mobx-react';
import {Message,Layout} from 'element-react';
-import {withRouter} from 'react-router-dom';
-import uaParser from 'ua-parser-js'
+// import {withRouter} from 'react-router-dom';
+import * as uaParser from 'ua-parser-js'
import {getBaseUa} from '../../utils/httpServers';
import PieOptions from '../../utils/charts/makePie'
import './index.less';
@@ -11,11 +11,11 @@ import asyncComponent from '../../components/asyncComponent/asyncComponent';
const PieChart = asyncComponent(() => import('../../components/PieChartComponent'));
-@withRouter
+// @withRouter
@inject('store')
@observer
-class Ua extends Component {
- constructor(props) {
+class Ua extends React.Component {
+ constructor(props:any) {
super(props)
console.log('Ua-Component')
this.state = {
@@ -26,14 +26,14 @@ class Ua extends Component {
componentWillMount() {
this.handleData();
}
- componentWillUnmount = () => {
+ componentWillUnmount(){
this.setState = (state,callback)=>{
return;
};
}
- handleData(data) {
+ handleData() {
const pid = this.props.store.actived;
- const request = {};
+ const request:any = {};
request.pid = pid;
if(this.props.urlConfig) {
request.url = this.props.urlConfig.url;
@@ -42,7 +42,7 @@ class Ua extends Component {
// request.version = 1;
this.getPoint(request);
}
- getPoint(data) {
+ getPoint(data:any) {
getBaseUa(data).then(res=>{
if (res.status === 200 && res.data.status.code === 200) {
// console.log(res.data.data)
@@ -53,16 +53,21 @@ class Ua extends Component {
})
}
- assignPoint(data) {
+ assignPoint(data:any) {
const uaBrowserSet = new Set();
const uaOsSet = new Set();
- const uaList = [];
- let browserList = [];
- let osList = [];
+ const uaList:any = [];
+ let browserList:any = [];
+ let osList:any = [];
// let uaBrowserList = Object.keys(data.detail);
// console.log(uaBrowserList.length)
- data.forEach(item => {
- let ua = uaParser(item);
+ data.forEach((item:any) => {
+ // console.log(uaParser,'uaParser')
+ let ua = uaParser['default'](item);
+ // console.log(uas,'uas')
+ // let ua:any = {}
+ // ua.browser = uas.browser;
+ // ua.os = uas.os();
// console.log(ua.browser.name,ua.browser.version)
if(ua.browser.name==='ie') ua.browser.name = 'IE';
if(ua.browser.name==='qq'|| ua.browser.name==='qqbrowser') ua.browser.name = 'QQ';
@@ -85,10 +90,10 @@ class Ua extends Component {
});
// console.log([...uaBrowserSet].sort(),'uaBrowserSet');
// console.log(uaOsSet,'uaOsSet');
-
- [...uaBrowserSet].sort().forEach(item => {
- let list = [];
- uaList.forEach(element => {
+ let uaBrowserSets = Array.from(uaBrowserSet);
+ uaBrowserSets.sort().forEach(item => {
+ let list:any = [];
+ uaList.forEach((element:any) => {
if(element.browser.name===item) {
list.push(element)
}
@@ -99,8 +104,8 @@ class Ua extends Component {
});
});
uaOsSet.forEach(item => {
- let list = [];
- uaList.forEach(element => {
+ let list:any = [];
+ uaList.forEach((element:any) => {
if(element.os.name===item) {
list.push(element)
}
diff --git a/static/src/components/asyncComponent/asyncComponent.js b/static/src/components/asyncComponent/asyncComponent.tsx
similarity index 71%
rename from static/src/components/asyncComponent/asyncComponent.js
rename to static/src/components/asyncComponent/asyncComponent.tsx
index ac553e0..fc9a8df 100644
--- a/static/src/components/asyncComponent/asyncComponent.js
+++ b/static/src/components/asyncComponent/asyncComponent.tsx
@@ -1,8 +1,8 @@
-import React, { Component } from 'react'
+import * as React from "react";
-export default function asyncComponent(importComponent) {
- class AsyncComponent extends Component {
- constructor(props) {
+export default function asyncComponent(importComponent:any) {
+ class AsyncComponent extends React.Component {
+ constructor(props:any) {
super(props)
this.state = {
diff --git a/static/src/index.js b/static/src/index.js
deleted file mode 100644
index 06df8f2..0000000
--- a/static/src/index.js
+++ /dev/null
@@ -1,14 +0,0 @@
-import React from 'react';
-import ReactDOM from 'react-dom';
-import {Provider} from 'mobx-react'
-// import App from './App';
-import App from './AppStatic';
-import store from './store'
-// import registerServiceWorker from './registerServiceWorker';
-import './assets/css/reset.css'
-import 'element-theme-default';
-
-ReactDOM.render((
-
-), document.getElementById('root'))
-// registerServiceWorker();
\ No newline at end of file
diff --git a/static/src/index.tsx b/static/src/index.tsx
new file mode 100644
index 0000000..8704d91
--- /dev/null
+++ b/static/src/index.tsx
@@ -0,0 +1,17 @@
+import * as React from "react";
+import * as ReactDOM from "react-dom";
+import {HashRouter} from 'react-router-dom';
+import {Provider} from 'mobx-react';
+
+import App from './AppStatic';
+import store from './store';
+
+import './assets/css/reset.css'
+import 'element-theme-default';
+
+ReactDOM.render((
+
+
+
+), document.getElementById('root'));
+// registerServiceWorker();
\ No newline at end of file
diff --git a/static/src/pages/Content/content.js b/static/src/pages/Content/content.tsx
similarity index 57%
rename from static/src/pages/Content/content.js
rename to static/src/pages/Content/content.tsx
index ac65666..de66922 100644
--- a/static/src/pages/Content/content.js
+++ b/static/src/pages/Content/content.tsx
@@ -1,14 +1,13 @@
-import React, {Component} from 'react'
-import Loadable from 'react-loadable';
+import * as React from "react";
+import * as Loadable from 'react-loadable';
import Loading from '../../components/Loading/Loading'
-
-const LoadableComponent = Loadable({
+const LoadableComponent = Loadable['default']({
loader: () => import('./index'),
loading: Loading
})
-class Content extends Component {
+class Content extends React.Component {
render() {
return (
diff --git a/static/src/pages/Content/index.js b/static/src/pages/Content/index.js
deleted file mode 100644
index 0adec2c..0000000
--- a/static/src/pages/Content/index.js
+++ /dev/null
@@ -1,36 +0,0 @@
-import React, {Component} from 'react'
-import {Layout} from 'element-react';
-import {observer, inject} from 'mobx-react';
-import {withRouter} from 'react-router-dom'
-import { renderRoutes } from 'react-router-config'
-import Left from '../../components/Left'
-import Top from '../../components/Top'
-import './index.less'
-
-@withRouter
-@inject('store')
-@observer
-class Content extends Component {
- constructor(props) {
- super(props)
- // console.log(this.props, 'Content-props')
- console.log('Content-Component')
- }
- componentWillUnmount = () => {
- this.setState = (state,callback)=>{
- return;
- };
- }
- render() {
- return (
-
-
-
- {renderRoutes(this.props.route.routes)}
-
-
- )
- }
-}
-
-export default Content
\ No newline at end of file
diff --git a/static/src/pages/Content/index.less b/static/src/pages/Content/index.less
index c5d502a..a32e171 100644
--- a/static/src/pages/Content/index.less
+++ b/static/src/pages/Content/index.less
@@ -1,5 +1,6 @@
.info {
padding: 0 20px;
+ // background: red;
.table-title {
font-size: 24px;
line-height: 40px;
diff --git a/static/src/pages/Content/index.tsx b/static/src/pages/Content/index.tsx
new file mode 100644
index 0000000..e7a8809
--- /dev/null
+++ b/static/src/pages/Content/index.tsx
@@ -0,0 +1,39 @@
+import * as React from "react";
+import {observer, inject} from 'mobx-react';
+import {withRouter} from 'react-router-dom';
+import { renderRoutes} from 'react-router-config';
+import Top from '../../components/Top/index';
+import './index.less';
+import { Props ,Routes} from "../../utils/interface/index";
+
+interface props extends Props,Routes {
+
+}
+
+@inject('store')
+@observer
+class Content extends React.Component {
+ constructor(props:any) {
+ super(props)
+ console.log('Content-Component')
+ }
+ componentWillUnmount() {
+ console.log('Content-componentWillUnmount')
+ this.setState = (state,callback)=>{
+ return;
+ };
+ }
+
+ render() {
+ return (
+
+
+
+ {renderRoutes(this.props.route.routes)}
+
+
+ )
+ }
+}
+// export default Content
+export default withRouter(Content)
\ No newline at end of file
diff --git a/static/src/pages/ContentComment/contentComment.js b/static/src/pages/ContentComment/contentComment.tsx
similarity index 56%
rename from static/src/pages/ContentComment/contentComment.js
rename to static/src/pages/ContentComment/contentComment.tsx
index 74595c7..c570014 100644
--- a/static/src/pages/ContentComment/contentComment.js
+++ b/static/src/pages/ContentComment/contentComment.tsx
@@ -1,14 +1,14 @@
-import React, {Component} from 'react'
-import Loadable from 'react-loadable';
+import * as React from "react";
+import * as Loadable from 'react-loadable';
import Loading from '../../components/Loading/Loading'
-const LoadableComponent = Loadable({
+const LoadableComponent = Loadable['default']({
loader: () => import('./index'),
loading: Loading
})
-class ContentComment extends Component {
+class ContentComment extends React.Component {
render() {
return (
diff --git a/static/src/pages/ContentComment/index.js b/static/src/pages/ContentComment/index.tsx
similarity index 77%
rename from static/src/pages/ContentComment/index.js
rename to static/src/pages/ContentComment/index.tsx
index 015ba91..15b275c 100644
--- a/static/src/pages/ContentComment/index.js
+++ b/static/src/pages/ContentComment/index.tsx
@@ -1,15 +1,27 @@
-import React, {Component} from 'react'
+import * as React from "react";
import {observer, inject} from 'mobx-react';
import {Message,Table,Loading,Button,Dialog} from 'element-react';
import {withRouter} from 'react-router-dom'
import {getComment} from '../../utils/httpServers';
import './index.less'
+import { Props,UrlConfig} from "../../utils/interface/index";
-@withRouter
+interface props extends Props {
+ urlConfig:UrlConfig;
+}
+
+interface States {
+ showDialog: boolean,
+ loading:boolean,
+ columns: any[],
+ data: any[],
+ dialogData:any[],
+ dialogColumns:any[]
+}
@inject('store')
@observer
-class ContentComment extends Component {
- constructor(props) {
+class ContentComment extends React.Component {
+ constructor(props:any) {
super(props)
console.log('ContentComment-Component')
this.state = {
@@ -22,7 +34,7 @@ class ContentComment extends Component {
},{
label: '酒店名称',
// prop: 'hotel',
- render:(data)=>{
+ render:(data:any)=>{
const hotel = data.hotel;
return (
{
@@ -51,23 +63,23 @@ class ContentComment extends Component {
componentWillMount() {
this.handleData();
}
- componentWillUnmount = () => {
+ componentWillUnmount(){
this.setState = (state,callback)=>{
return;
};
}
- makeHotel(hotel,data){
- const arr = [];
+ makeHotel(hotel:any,data:any){
+ const arr:any[] = [];
if(!hotel.size) return arr;
- hotel.forEach((item, index) => {
+ hotel.forEach((item:any, index:number) => {
arr.push(
{item} )
})
return arr;
}
- showUsers(data,item) {
- console.log('showUsers',data)
- const detail = [];
- data.detail.forEach(el => {
+ showUsers(data:any,item:any) {
+ // console.log('showUsers',data)
+ const detail:any[] = [];
+ data.detail.forEach((el:any) => {
if(el.htl_name===item) {
detail.push(el);
}
@@ -77,20 +89,20 @@ class ContentComment extends Component {
dialogData:detail
})
}
- handleDetail(data) {
- data.forEach((item) => {
+ handleDetail(data:any) {
+ data.forEach((item:any) => {
const dataSet = new Set();
if(item.detail&&item.detail.length>0) {
- item.detail.forEach((detail) => {
+ item.detail.forEach((detail:any) => {
dataSet.add(detail.htl_name)
});
}
item.hotel = dataSet;
});
}
- handleData(data) {
+ handleData() {
const pid = this.props.store.actived;
- const request = {};
+ const request:any = {};
request.pid = pid;
if(this.props.urlConfig) {
request.url = this.props.urlConfig.url;
@@ -99,7 +111,7 @@ class ContentComment extends Component {
// request.version = 1;
this.getLike(request);
}
- getLike(data) {
+ getLike(data:any) {
getComment(data).then(res=>{
if (res.status === 200 && res.data.status.code === 200) {
this.assignLike(res.data.data);
@@ -108,7 +120,7 @@ class ContentComment extends Component {
}
})
}
- assignLike(data) {
+ assignLike(data:any) {
this.handleDetail(data);
this.setState({
data:data,
@@ -153,4 +165,5 @@ class ContentComment extends Component {
}
}
-export default ContentComment
\ No newline at end of file
+export default withRouter(ContentComment)
+// export default ContentComment
\ No newline at end of file
diff --git a/static/src/pages/ContentDetail/contentDetail.js b/static/src/pages/ContentDetail/contentDetail.tsx
similarity index 56%
rename from static/src/pages/ContentDetail/contentDetail.js
rename to static/src/pages/ContentDetail/contentDetail.tsx
index dec33ca..a83c0bc 100644
--- a/static/src/pages/ContentDetail/contentDetail.js
+++ b/static/src/pages/ContentDetail/contentDetail.tsx
@@ -1,14 +1,14 @@
-import React, {Component} from 'react'
-import Loadable from 'react-loadable';
+import * as React from "react";
+import * as Loadable from 'react-loadable';
import Loading from '../../components/Loading/Loading'
-const LoadableComponent = Loadable({
+const LoadableComponent = Loadable['default']({
loader: () => import('./index'),
loading: Loading
})
-class ContentDetail extends Component {
+class ContentDetail extends React.Component {
render() {
return (
diff --git a/static/src/pages/ContentDetail/index.js b/static/src/pages/ContentDetail/index.tsx
similarity index 79%
rename from static/src/pages/ContentDetail/index.js
rename to static/src/pages/ContentDetail/index.tsx
index 29ba165..9bf9d2e 100644
--- a/static/src/pages/ContentDetail/index.js
+++ b/static/src/pages/ContentDetail/index.tsx
@@ -1,19 +1,23 @@
-import React, {Component} from 'react'
+import * as React from "react";
import {observer, inject} from 'mobx-react';
import {Table,Message,Loading} from 'element-react';
import {withRouter} from 'react-router-dom';
-import Qs from 'qs';
+import * as Qs from 'qs';
import {getBasePage} from '../../utils/httpServers';
import ContentLike from '../ContentLike/index';
import ContentComment from '../ContentComment/index';
import ContentPoint from '../ContentPoint/index';
import './index.less'
+import { Props,UrlConfig} from "../../utils/interface/index";
-@withRouter
+
+// @withRouter
@inject('store')
@observer
-class ContentDetail extends Component {
- constructor(props) {
+class ContentDetail extends React.Component
{
+ urlConfig:UrlConfig;
+ UrlConfig:any={}
+ constructor(props:any) {
super(props)
// console.log(this.props, 'ContentDetail-props')
console.log('ContentDetail-Component')
@@ -48,6 +52,7 @@ class ContentDetail extends Component {
url:urls[0],
router:urls[1]
}
+ this.UrlConfig.urlConfig = this.urlConfig;
}
componentWillMount() {
const state = this.props.location.state;
@@ -64,13 +69,13 @@ class ContentDetail extends Component {
// router:this.urlConfig.router
// })
}
- tranformData(data) {
- const res = [];
+ tranformData(data:any) {
+ const res:any[] = [];
const url = data.url;
const referrer = data.info.referrer;
const referrerKeys = Object.keys(referrer);
referrerKeys.forEach((key) => {
- const obj = {};
+ const obj:any = {};
obj.url = url;
obj.title = referrer[key].title;
obj.referrerUrl = key;
@@ -82,12 +87,12 @@ class ContentDetail extends Component {
loading:false
});
}
- componentWillUnmount = () => {
+ componentWillUnmount(){
this.setState = (state,callback)=>{
return;
};
}
- getBasePage(data) {
+ getBasePage(data:any) {
getBasePage(data).then(res=>{
if (res.status === 200 && res.data.status.code === 200) {
this.filterData(res.data.data)
@@ -96,16 +101,16 @@ class ContentDetail extends Component {
}
})
}
- filterData(data) {
+ filterData(data:any) {
let res;
- data.forEach((item)=>{
+ data.forEach((item:any)=>{
if(item.url===this.urlConfig.urls) {
res = item;
}
});
this.tranformData(res);
}
- render() {
+ public render() {
return (
@@ -121,12 +126,13 @@ class ContentDetail extends Component {
stripe={true}/>
-
-
-
+
+
+
+
)
}
}
-export default ContentDetail
\ No newline at end of file
+export default withRouter(ContentDetail)
\ No newline at end of file
diff --git a/static/src/pages/ContentLike/contentLike.js b/static/src/pages/ContentLike/contentLike.tsx
similarity index 57%
rename from static/src/pages/ContentLike/contentLike.js
rename to static/src/pages/ContentLike/contentLike.tsx
index 5925947..a82c0f8 100644
--- a/static/src/pages/ContentLike/contentLike.js
+++ b/static/src/pages/ContentLike/contentLike.tsx
@@ -1,14 +1,14 @@
-import React, {Component} from 'react'
-import Loadable from 'react-loadable';
+import * as React from "react";
+import * as Loadable from 'react-loadable';
import Loading from '../../components/Loading/Loading'
-const LoadableComponent = Loadable({
+const LoadableComponent = Loadable['default']({
loader: () => import('./index'),
loading: Loading
})
-class ContentLike extends Component {
+class ContentLike extends React.Component {
render() {
return (
diff --git a/static/src/pages/ContentLike/index.js b/static/src/pages/ContentLike/index.tsx
similarity index 75%
rename from static/src/pages/ContentLike/index.js
rename to static/src/pages/ContentLike/index.tsx
index 0b95c0d..a3cd471 100644
--- a/static/src/pages/ContentLike/index.js
+++ b/static/src/pages/ContentLike/index.tsx
@@ -1,17 +1,33 @@
-import React, {Component} from 'react'
+import * as React from "react";
import {observer, inject} from 'mobx-react';
import {Message,Table,Loading,Button,Dialog} from 'element-react';
-import {withRouter} from 'react-router-dom'
+import {withRouter} from 'react-router-dom';
+// import {store} from '../../store/index';
import {getLike} from '../../utils/httpServers';
import './index.less'
-@withRouter
+import { Props} from "../../utils/interface/index";
+
+interface props extends Props {
+ urlConfig? : any;
+}
+interface States {
+ showDialog: boolean,
+ showDialogTitle:string,
+ loading:boolean,
+ columns: any[],
+ data: any[],
+ dialogData: any[],
+ dialogColumns: any[]
+}
+
+// @withRouter
@inject('store')
@observer
-class ContentLike extends Component {
- constructor(props) {
+class ContentLike extends React.Component{
+ constructor(props:any) {
super(props)
- console.log('ContentLike-Component')
+ console.log('ContentLike-Component');
this.state = {
showDialog: false,
showDialogTitle:'',
@@ -25,7 +41,7 @@ class ContentLike extends Component {
{
label: '酒店名称',
// prop: 'hotel',
- render:(data)=>{
+ render:(data:any)=>{
const hotel = data.hotel;
return (
{
@@ -50,20 +66,19 @@ class ContentLike extends Component {
prop: 'update_time',
}]
}
- // console.log(this.props.urlConfig,'urlConfig')
}
- makeHotel(hotel,data){
- const arr = [];
+ makeHotel(hotel:any,data:any){
+ const arr:any[] = [];
if(!hotel.size) return arr;
- hotel.forEach((item, index) => {
+ hotel.forEach((item:any, index:number) => {
arr.push(
{item} )
})
return arr;
}
- showUsers(data,item) {
+ showUsers(data:any,item:any) {
// console.log('showUsers',data)
- const detail = [];
- data.detail.forEach(el => {
+ const detail:any[] = [];
+ data.detail.forEach((el:any) => {
if(el.htl_name===item) {
detail.push(el);
}
@@ -77,14 +92,14 @@ class ContentLike extends Component {
componentWillMount() {
this.handleData();
}
- componentWillUnmount = () => {
+ componentWillUnmount() {
this.setState = (state,callback)=>{
return;
};
}
- handleData(data) {
+ handleData() {
const pid = this.props.store.actived;
- const request = {};
+ const request:any = {};
request.pid = pid;
if(this.props.urlConfig) {
request.url = this.props.urlConfig.url;
@@ -93,7 +108,7 @@ class ContentLike extends Component {
// request.version = 1;
this.getLike(request);
}
- getLike(data) {
+ getLike(data:any) {
getLike(data).then(res=>{
if (res.status === 200 && res.data.status.code === 200) {
this.assignLike(res.data.data);
@@ -102,18 +117,18 @@ class ContentLike extends Component {
}
})
}
- handleDetail(data) {
- data.forEach((item) => {
+ handleDetail(data:any) {
+ data.forEach((item:any) => {
const dataSet = new Set();
if(item.detail&&item.detail.length>0) {
- item.detail.forEach((detail) => {
+ item.detail.forEach((detail:any) => {
dataSet.add(detail.htl_name)
});
}
item.hotel = dataSet;
});
}
- assignLike(data) {
+ assignLike(data:any) {
this.handleDetail(data);
this.setState({
data:data,
@@ -158,4 +173,5 @@ class ContentLike extends Component {
}
}
-export default ContentLike
\ No newline at end of file
+export default withRouter(ContentLike)
+// export default ContentLike
\ No newline at end of file
diff --git a/static/src/pages/ContentList/contentList.js b/static/src/pages/ContentList/contentList.tsx
similarity index 57%
rename from static/src/pages/ContentList/contentList.js
rename to static/src/pages/ContentList/contentList.tsx
index 59afe26..23d912b 100644
--- a/static/src/pages/ContentList/contentList.js
+++ b/static/src/pages/ContentList/contentList.tsx
@@ -1,14 +1,14 @@
-import React, {Component} from 'react'
-import Loadable from 'react-loadable';
+import * as React from "react";
+import * as Loadable from 'react-loadable';
import Loading from '../../components/Loading/Loading'
-const LoadableComponent = Loadable({
+const LoadableComponent = Loadable['default']({
loader: () => import('./index'),
loading: Loading
})
-class ContentList extends Component {
+class ContentList extends React.Component {
render() {
return (
diff --git a/static/src/pages/ContentList/index.js b/static/src/pages/ContentList/index.tsx
similarity index 84%
rename from static/src/pages/ContentList/index.js
rename to static/src/pages/ContentList/index.tsx
index 66bb118..da912c3 100644
--- a/static/src/pages/ContentList/index.js
+++ b/static/src/pages/ContentList/index.tsx
@@ -1,25 +1,37 @@
-import React, {Component} from 'react'
+import * as React from "react";
import {Message, Progress, Table, Button,Loading} from 'element-react';
import {observer, inject} from 'mobx-react';
import {withRouter} from 'react-router-dom';
import {getBasePage,getTime} from '../../utils/httpServers';
import makeLine from '../../utils/charts/makeLine';
-import './index.less'
+import './index.less';
// import ReactHighcharts from 'react-highcharts';
import asyncComponent from '../../components/asyncComponent/asyncComponent';
+import { Props} from "../../utils/interface/index";
+
const LineChart = asyncComponent(() => import('../../components/LineChartComponent'));
const UaComponent = asyncComponent(() => import('../../components/Uacomponent'));
-
-@withRouter
+interface states {
+ option:{},
+ loading:boolean,
+ columns: any[],
+ data: any[]
+}
+interface baseParams {
+ pid:string,
+ start_time:string,
+ end_time:string
+}
+// @withRouter
@inject('store')
@observer
-class ContentList extends Component {
- constructor(props) {
+class ContentList extends React.Component
{
+ constructor(props:any) {
super(props)
console.log('ContentList-Component')
this.state = {
@@ -53,8 +65,8 @@ class ContentList extends Component {
label: '转化率',
prop: 'transfer',
width: 100,
- render:(data)=>{
- let transfer = (+data.transfer * 100).toFixed(2);
+ render:(data:any)=>{
+ let transfer = +(+data.transfer * 100).toFixed(2);
// transfer = transfer>100?100:transfer;
return (
@@ -66,7 +78,7 @@ class ContentList extends Component {
}, {
label: '操作',
width: 100,
- render: (data) => {
+ render: (data:any) => {
return (
{data.transfer
@@ -88,13 +100,13 @@ class ContentList extends Component {
componentWillMount() {
this.handleData();
}
- handleData(data) {
+ handleData() {
const request = this.formatParams();
this.getBasePage(request);
this.getTime({pid:request.pid});
}
- getBasePage(data) {
+ getBasePage(data:baseParams) {
getBasePage(data).then(res=>{
if (res.status === 200 && res.data.status.code === 200) {
this.assignBasePage(res.data.data);
@@ -103,7 +115,7 @@ class ContentList extends Component {
}
})
}
- getTime(data) {
+ getTime(data:any) {
getTime(data).then(res=>{
if (res.status === 200 && res.data.status.code === 200) {
this.assignTimeData(res.data.data);
@@ -113,28 +125,28 @@ class ContentList extends Component {
})
}
- assignBasePage(data) {
+ assignBasePage(data:any) {
this.setState({data: data,loading:false})
}
- assignTimeData(data) {
+ assignTimeData(data:any) {
const res = makeLine(data);
this.setState({
option:res
})
}
- componentWillUnmount = () => {
+ componentWillUnmount(){
this.setState = (state, callback) => {
return;
};
}
- componentWillReceiveProps(nextProps) {
+ componentWillReceiveProps(nextProps:Props) {
if (nextProps.location.pathname !== this.props.location.pathname || nextProps.location.search !== this.props.location.search) {
console.log('-------------')
console.log('update-list-content')
this.handleData();
}
}
- detail(data) {
+ detail(data:any) {
// console.log(data,'detail');
this
.props
@@ -146,7 +158,7 @@ class ContentList extends Component {
})
}
formatParams() {
- const res = {};
+ const res = {} as baseParams;
res.pid = this.props.store.actived;
if(this.props.store.projectTime.startTime) res.start_time = this.props.store.projectTime.startTime;
if(this.props.store.projectTime.endTime) res.end_time = this.props.store.projectTime.endTime;
@@ -179,4 +191,4 @@ class ContentList extends Component {
}
}
-export default ContentList
\ No newline at end of file
+export default withRouter(ContentList)
\ No newline at end of file
diff --git a/static/src/pages/ContentPoint/contentPoint.js b/static/src/pages/ContentPoint/contentPoint.tsx
similarity index 56%
rename from static/src/pages/ContentPoint/contentPoint.js
rename to static/src/pages/ContentPoint/contentPoint.tsx
index 0dc20d2..a39c2ae 100644
--- a/static/src/pages/ContentPoint/contentPoint.js
+++ b/static/src/pages/ContentPoint/contentPoint.tsx
@@ -1,14 +1,14 @@
-import React, {Component} from 'react'
-import Loadable from 'react-loadable';
+import * as React from "react";
+import * as Loadable from 'react-loadable';
import Loading from '../../components/Loading/Loading'
-const LoadableComponent = Loadable({
+const LoadableComponent = Loadable['default']({
loader: () => import('./index'),
loading: Loading
})
-class ContentPoint extends Component {
+class ContentPoint extends React.Component {
render() {
return (
diff --git a/static/src/pages/ContentPoint/index.js b/static/src/pages/ContentPoint/index.tsx
similarity index 84%
rename from static/src/pages/ContentPoint/index.js
rename to static/src/pages/ContentPoint/index.tsx
index 6c8f423..ed5109d 100644
--- a/static/src/pages/ContentPoint/index.js
+++ b/static/src/pages/ContentPoint/index.tsx
@@ -1,16 +1,29 @@
-import React, {Component} from 'react'
+import * as React from "react";
import {observer, inject} from 'mobx-react';
import {Message,Loading,Table,Button,Dialog} from 'element-react';
import {withRouter} from 'react-router-dom';
import {getPointHotel} from '../../utils/httpServers';
import './index.less';
+import { Props} from "../../utils/interface/index";
-@withRouter
+interface props extends Props {
+ urlConfig? : any;
+}
+interface States {
+ loading:boolean,
+ showDialog: boolean,
+ columns: any[],
+ data: any[],
+ dialogData: any[],
+ dialogColumns: any[]
+}
+
+// @withRouter
@inject('store')
@observer
-class ContentPoint extends Component {
- constructor(props) {
+class ContentPoint extends React.Component
{
+ constructor(props:any) {
super(props)
console.log('ContentPoint-Component')
this.state = {
@@ -27,7 +40,7 @@ class ContentPoint extends Component {
}, {
label: '操作',
width: 150,
- render: (data) => {
+ render: (data:any) => {
return (
{data.mens.length>0
@@ -62,19 +75,19 @@ class ContentPoint extends Component {
componentWillMount() {
this.handleData();
}
- componentWillUnmount = () => {
+ componentWillUnmount(){
this.setState = (state,callback)=>{
return;
};
}
- componentWillReceiveProps(nextProps) {
+ componentWillReceiveProps(nextProps:any) {
if (nextProps.location.pathname !== this.props.location.pathname || nextProps.location.search !== this.props.location.search) {
console.log('point-update-nextProps')
this.handleData();
}
}
- handleData(data) {
- const request = this.formatParams();
+ handleData() {
+ const request:any = this.formatParams();
if(this.props.urlConfig) {
request.url = this.props.urlConfig.url;
request.router = this.props.urlConfig.router;
@@ -83,7 +96,7 @@ class ContentPoint extends Component {
// request.version = 1;
this.getPoint(request);
}
- getPoint(data) {
+ getPoint(data:any) {
getPointHotel(data).then(res=>{
if (res.status === 200 && res.data.status.code === 200) {
this.assignPoint(res.data.data);
@@ -93,13 +106,13 @@ class ContentPoint extends Component {
})
}
- assignPoint(data) {
+ assignPoint(data:any) {
this.setState({
data:data,
loading:false
});
}
- detail(data) {
+ detail(data:any) {
// console.log(data,'data')
this.setState({
showDialog:true,
@@ -107,7 +120,7 @@ class ContentPoint extends Component {
})
}
formatParams() {
- const res = {};
+ const res:any = {};
res.pid = this.props.store.actived;
if(this.props.store.projectTime.startTime) res.start_time = this.props.store.projectTime.startTime;
if(this.props.store.projectTime.endTime) res.end_time = this.props.store.projectTime.endTime;
@@ -151,4 +164,4 @@ class ContentPoint extends Component {
}
}
-export default ContentPoint
\ No newline at end of file
+export default withRouter(ContentPoint)
\ No newline at end of file
diff --git a/static/src/pages/List/index.js b/static/src/pages/List/index.js
deleted file mode 100644
index 17a9499..0000000
--- a/static/src/pages/List/index.js
+++ /dev/null
@@ -1,115 +0,0 @@
-import React, {Component} from 'react'
-import {Layout, Table, Pagination, Loading} from 'element-react';
-import {observer, inject} from 'mobx-react';
-import Left from '../../components/Left'
-import Top from '../../components/Top'
-import Searchs from '../../components/SearchComponent'
-// import {getBase} from '../../utils/httpServers'
-import './index.less'
-
-@inject('store')
-@observer
-class List extends Component {
- constructor(props) {
- super(props);
- console.log(props, 'props-list-index')
- // console.log(props.match.params, 'params') if(!props.match.params.type) {
- // this.props.history.push(`/content`) }
- this.state = {
- columns: [
- {
- label: "日期",
- prop: "date",
- width: 180
- }, {
- label: "姓名",
- prop: "name",
- width: 180
- }, {
- label: "地址",
- prop: "address"
- }
- ],
- data: [
- {
- date: '2016-05-02',
- name: '王小虎',
- address: '上海市普陀区金沙江路 1518 弄'
- }, {
- date: '2016-05-04',
- name: '王小虎',
- address: '上海市普陀区金沙江路 1517 弄'
- }, {
- date: '2016-05-01',
- name: '王小虎',
- address: '上海市普陀区金沙江路 1519 弄'
- }, {
- date: '2016-05-03',
- name: '王小虎',
- address: '上海市普陀区金沙江路 1516 弄'
- }
- ],
- fullscreen: false
- }
- // this.showLoading();
- }
- showLoading() {
- clearTimeout(this.timeout);
-
- this.timeout = setTimeout(() => {
- this.setState({fullscreen: false});
- }, 3000);
- }
- handleData(data) {
- const pid = this.props.store.actived;
- console.log(data,'data');
- // getBase({
- // pid:pid,
- // start_time:data.start_time,
- // end_time:data.end_time
- // }).then((res)=> {
- // console.log(res);
- // })
- }
- componentWillReceiveProps(nextProps) {
- console.log('nextProps',nextProps.location.pathname)
- console.log('nowProps',this.props.location.pathname)
- if (nextProps.location.pathname != this.props.location.pathname) {
- console.log('ipdate')
- }
- }
- // componentDidUpdate() {
- // console.log('componentDidUpdate-list')
- // }
- render() {
- return (
-
-
-
-
-
-
-
-
-
- {this.state.fullscreen &&
}
-
-
-
-
-
-
-
- )
- }
-}
-
-export default List
\ No newline at end of file
diff --git a/static/src/pages/List/index.less b/static/src/pages/List/index.less
deleted file mode 100644
index 8318fe5..0000000
--- a/static/src/pages/List/index.less
+++ /dev/null
@@ -1,10 +0,0 @@
-.pages {
- padding: 30px;
- text-align: center;
-}
-.container {
- padding: 0 10px;
- .table-info {
- padding: 0 10px 0 20px;;
- }
-}
\ No newline at end of file
diff --git a/static/src/pages/List/list.js b/static/src/pages/List/list.js
deleted file mode 100644
index 7c8150a..0000000
--- a/static/src/pages/List/list.js
+++ /dev/null
@@ -1,22 +0,0 @@
-import React, {Component} from 'react'
-import Loadable from 'react-loadable';
-import Loading from '../../components/Loading/Loading'
-
-
-const LoadableComponent = Loadable({
- loader: () => import('./index'),
- loading: Loading
-})
-
-class List extends Component {
- constructor(props) {
- super(props);
- console.log('list',props)
- }
- render() {
- return (
-
- );
- }
-}
-export default List
\ No newline at end of file
diff --git a/static/src/pages/Login/index.less b/static/src/pages/Login/index.less
deleted file mode 100644
index af937cf..0000000
--- a/static/src/pages/Login/index.less
+++ /dev/null
@@ -1,3 +0,0 @@
-.ptop50 {
- padding-top: 50px;
-}
\ No newline at end of file
diff --git a/static/src/pages/Login/login.js b/static/src/pages/Login/login.js
deleted file mode 100644
index c8757bd..0000000
--- a/static/src/pages/Login/login.js
+++ /dev/null
@@ -1,18 +0,0 @@
-import React, {Component} from 'react'
-import Loadable from 'react-loadable';
-import Loading from '../../components/Loading/Loading'
-
-
-const LoadableComponent = Loadable({
- loader: () => import('./index'),
- loading: Loading
-})
-
-class Logins extends Component {
- render() {
- return (
-
- );
- }
-}
-export default Logins
\ No newline at end of file
diff --git a/static/src/pages/Logins/app.less b/static/src/pages/Logins/app.less
new file mode 100644
index 0000000..531dfc5
--- /dev/null
+++ b/static/src/pages/Logins/app.less
@@ -0,0 +1,10 @@
+.login-box {
+ padding: 30px;
+ .login-title {
+ text-align: center;
+ font-size: 24px;
+ line-height: 40px;
+ padding-bottom: 20px;
+ }
+}
+
diff --git a/static/src/pages/Login/index.js b/static/src/pages/Logins/index.tsx
similarity index 65%
rename from static/src/pages/Login/index.js
rename to static/src/pages/Logins/index.tsx
index f5c1d7d..04806e0 100644
--- a/static/src/pages/Login/index.js
+++ b/static/src/pages/Logins/index.tsx
@@ -1,16 +1,16 @@
-import React, {Component} from 'react'
-import {Form, Input, Button} from 'element-react';
+import * as React from 'react';
import {observer, inject} from 'mobx-react';
-import {withRouter} from 'react-router-dom'
-import './index.less'
+import {withRouter} from 'react-router-dom';
+import {Form, Input, Button} from 'element-react';
+import './app.less';
+import { Props} from "../../utils/interface/index";
-@withRouter
@inject('store')
@observer
-class Login extends Component {
- constructor(props) {
+class Login extends React.Component {
+ constructor(props:Props) {
super(props);
- console.log(2222)
+ console.log('Login');
this.state = {
form: {
userName: '',
@@ -34,46 +34,42 @@ class Login extends Component {
}
}
}
- handleSubmit(e) {
+ handleSubmit(e:Event) {
e.preventDefault();
-
- this
- .refs
- .form
- .validate((valid) => {
- if (valid) {
- this
- .props
- .store
- .login()
- .then(res => {
- this
- .props
- .history
- .push(`/`)
- })
- } else {
- console.log('error submit!!');
- return false;
- }
- });
+ let form:any = this.refs.form;
+ form.validate((valid:any) => {
+ if(valid) {
+ this.props.store.login().then((res:any) => {
+ this.props.history.push(`/overview/list?pid=${this.props.store.actived}`);
+ })
+ return null;
+ } else {
+ console.log('error submit!!');
+ return false;
+ }
+ });
}
- handleReset(e) {
+ handleReset(e:Event) {
e.preventDefault();
- this
- .refs
- .form
- .resetFields();
+ let form:any = this.refs.form;
+ form.resetFields();
+ this.setState({
+ form: {
+ userName: '',
+ passWord: ''
+ }
+ });
}
- onChange(key, value) {
+ onChange(key:any, value:any) {
this.setState({
form: Object.assign({}, this.state.form, {[key]: value})
});
}
render() {
return (
-
+
+
登录
-
import('./index'),
+ loading: Loading
+})
+
+class Logins extends React.Component {
+ render() {
+ return (
+
+ );
+ }
+}
+export default Logins
\ No newline at end of file
diff --git a/static/src/pages/Overview/index.js b/static/src/pages/Overview/index.js
deleted file mode 100644
index 5c7dd7c..0000000
--- a/static/src/pages/Overview/index.js
+++ /dev/null
@@ -1,17 +0,0 @@
-import React, {Component} from 'react'
-// import {observer,inject} from 'mobx-react';
-import Top from '../../components/Top'
-// @inject('store')
-// @observer
-class Overview extends Component {
- render() {
- return (
-
-
- welcome123
-
- )
- }
-}
-
-export default Overview
\ No newline at end of file
diff --git a/static/src/pages/Overview/overview.js b/static/src/pages/Overview/overview.js
deleted file mode 100644
index 44ee44a..0000000
--- a/static/src/pages/Overview/overview.js
+++ /dev/null
@@ -1,18 +0,0 @@
-import React, {Component} from 'react'
-import Loadable from 'react-loadable';
-import Loading from '../../components/Loading/Loading'
-
-
-const LoadableComponent = Loadable({
- loader: () => import('./index'),
- loading: Loading
-})
-
-class Overview extends Component {
- render() {
- return (
-
- );
- }
-}
-export default Overview
\ No newline at end of file
diff --git a/static/src/registerServiceWorker.js b/static/src/registerServiceWorker.js
new file mode 100644
index 0000000..a3e6c0c
--- /dev/null
+++ b/static/src/registerServiceWorker.js
@@ -0,0 +1,117 @@
+// In production, we register a service worker to serve assets from local cache.
+
+// This lets the app load faster on subsequent visits in production, and gives
+// it offline capabilities. However, it also means that developers (and users)
+// will only see deployed updates on the "N+1" visit to a page, since previously
+// cached resources are updated in the background.
+
+// To learn more about the benefits of this model, read https://goo.gl/KwvDNy.
+// This link also includes instructions on opting out of this behavior.
+
+const isLocalhost = Boolean(
+ window.location.hostname === 'localhost' ||
+ // [::1] is the IPv6 localhost address.
+ window.location.hostname === '[::1]' ||
+ // 127.0.0.1/8 is considered localhost for IPv4.
+ window.location.hostname.match(
+ /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
+ )
+);
+
+export default function register() {
+ if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
+ // The URL constructor is available in all browsers that support SW.
+ const publicUrl = new URL(process.env.PUBLIC_URL, window.location);
+ if (publicUrl.origin !== window.location.origin) {
+ // Our service worker won't work if PUBLIC_URL is on a different origin
+ // from what our page is served on. This might happen if a CDN is used to
+ // serve assets; see https://github.com/facebookincubator/create-react-app/issues/2374
+ return;
+ }
+
+ window.addEventListener('load', () => {
+ const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
+
+ if (isLocalhost) {
+ // This is running on localhost. Lets check if a service worker still exists or not.
+ checkValidServiceWorker(swUrl);
+
+ // Add some additional logging to localhost, pointing developers to the
+ // service worker/PWA documentation.
+ navigator.serviceWorker.ready.then(() => {
+ console.log(
+ 'This web app is being served cache-first by a service ' +
+ 'worker. To learn more, visit https://goo.gl/SC7cgQ'
+ );
+ });
+ } else {
+ // Is not local host. Just register service worker
+ registerValidSW(swUrl);
+ }
+ });
+ }
+}
+
+function registerValidSW(swUrl) {
+ navigator.serviceWorker
+ .register(swUrl)
+ .then(registration => {
+ registration.onupdatefound = () => {
+ const installingWorker = registration.installing;
+ installingWorker.onstatechange = () => {
+ if (installingWorker.state === 'installed') {
+ if (navigator.serviceWorker.controller) {
+ // At this point, the old content will have been purged and
+ // the fresh content will have been added to the cache.
+ // It's the perfect time to display a "New content is
+ // available; please refresh." message in your web app.
+ console.log('New content is available; please refresh.');
+ } else {
+ // At this point, everything has been precached.
+ // It's the perfect time to display a
+ // "Content is cached for offline use." message.
+ console.log('Content is cached for offline use.');
+ }
+ }
+ };
+ };
+ })
+ .catch(error => {
+ console.error('Error during service worker registration:', error);
+ });
+}
+
+function checkValidServiceWorker(swUrl) {
+ // Check if the service worker can be found. If it can't reload the page.
+ fetch(swUrl)
+ .then(response => {
+ // Ensure service worker exists, and that we really are getting a JS file.
+ if (
+ response.status === 404 ||
+ response.headers.get('content-type').indexOf('javascript') === -1
+ ) {
+ // No service worker found. Probably a different app. Reload the page.
+ navigator.serviceWorker.ready.then(registration => {
+ registration.unregister().then(() => {
+ window.location.reload();
+ });
+ });
+ } else {
+ // Service worker found. Proceed as normal.
+ registerValidSW(swUrl);
+ }
+ })
+ .catch(() => {
+ console.log(
+ 'No internet connection found. App is running in offline mode.'
+ );
+ });
+}
+
+export function unregister() {
+ if ('serviceWorker' in navigator) {
+ navigator.serviceWorker.ready.then(registration => {
+ registration.unregister();
+ });
+ }
+}
diff --git a/static/src/routerStatic.js b/static/src/routerStatic.ts
similarity index 69%
rename from static/src/routerStatic.js
rename to static/src/routerStatic.ts
index 1051840..52f91d5 100644
--- a/static/src/routerStatic.js
+++ b/static/src/routerStatic.ts
@@ -1,25 +1,26 @@
-// import asyncComponent from './components/asyncComponent/asyncComponent'
-// import overview from './pages/Overview/index';
-import Login from './pages/Login/login';
import Content from './pages/Content/content';
import ContentList from './pages/ContentList/contentList';
import ContentDetail from './pages/ContentDetail/contentDetail';
import ContentLike from './pages/ContentLike/contentLike';
import ContentComment from './pages/ContentComment/contentComment';
-import ContentPoint from './pages/ContentPoint/contentPoint'
-import List from './pages/List/list';
+import ContentPoint from './pages/ContentPoint/contentPoint';
+import Logins from './pages/Logins/logins';
+// import Logins from './pages/Login/login';
-export default[
+export default [
{
path : '/',
exact : true,
component : Content,
- routes : []
- }, {
+ routes : [
+
+ ]
+ },{
path : '/login',
- component : Login
- }, {
+ // exact: true,
+ component : Logins
+ },{
path : '/overview',
component : Content,
routes : [
@@ -27,7 +28,8 @@ export default[
path: '/overview/list',
exact: true,
component: ContentList
- }, {
+ },
+ {
path: '/overview/detail',
exact: true,
component: ContentDetail
@@ -39,14 +41,11 @@ export default[
path: '/overview/comment',
exact: true,
component: ContentComment
- },{
+ }, {
path: '/overview/point',
exact: true,
component: ContentPoint
- }
+ },
]
- }, {
- path : '/action/:type/',
- component : List
- }
+ },
]
\ No newline at end of file
diff --git a/static/src/store/index.js b/static/src/store/index.js
deleted file mode 100644
index e3b0d00..0000000
--- a/static/src/store/index.js
+++ /dev/null
@@ -1,41 +0,0 @@
-import {observable, action} from 'mobx'
-
-class Store {
- @observable isLogin = false;
- @action login = () => {
- this.isLogin = true;
- return Promise.resolve(true);
- }
- @action loginOut = () => {
- this.isLogin = false;
- }
-
- @observable actived = '0';
- @action updateActive = (id) => {
- this.actived = id;
- }
-
- @observable projectList = [
- {
- name: '项目一',
- id: '0'
- }, {
- name: '项目二',
- id: '1'
- }
- ]
- @action updateProjectList = (arr) => {
- this.projectList = [].concat(arr);
- }
-
- @observable projectTime = {
- startTime: null,
- endTime: null
- }
- @action updateProjectTime = ({startTime, endTime}) => {
- this.projectTime.startTime = startTime;
- this.projectTime.endTime = endTime;
- }
-}
-
-export default new Store()
\ No newline at end of file
diff --git a/static/src/store/index.ts b/static/src/store/index.ts
new file mode 100644
index 0000000..666fb24
--- /dev/null
+++ b/static/src/store/index.ts
@@ -0,0 +1,60 @@
+import {observable, action} from 'mobx';
+
+interface Stores {
+ actived: string,
+ updateActive: (id: string) => void,
+ projectList: any[],
+ updateProjectList : (arr:any[]) => void,
+ projectTime: ProjectTime,
+ updateProjectTime: ({startTime, endTime}:any) => void,
+ isLogin:boolean,
+ login:() => Promise
+}
+interface ProjectTime{
+ startTime: any,
+ endTime: any
+}
+export interface store {
+ store:Stores
+}
+
+class Store {
+ @observable isLogin = false;
+ @action login = () => {
+ this.isLogin = true;
+ return Promise.resolve(true);
+ }
+ @action loginOut = () => {
+ this.isLogin = false;
+ }
+
+ @observable actived = '0';
+ @action updateActive = (id:string) => {
+ this.actived = id;
+ }
+
+ @observable projectList:any[] = [
+ {
+ name: '项目一',
+ id: '0'
+ }, {
+ name: '项目二',
+ id: '1'
+ }
+ ]
+ @action updateProjectList = (arr:any[]) => {
+ let res:any[] = [];
+ this.projectList = res.concat(arr);
+ }
+
+ @observable projectTime:ProjectTime = {
+ startTime: null,
+ endTime: null
+ }
+ @action updateProjectTime = ({startTime, endTime}:any) => {
+ this.projectTime.startTime = startTime;
+ this.projectTime.endTime = endTime;
+ }
+}
+
+export default new Store()
\ No newline at end of file
diff --git a/static/src/texts/common.js b/static/src/texts/common.js
deleted file mode 100644
index 404dcf8..0000000
--- a/static/src/texts/common.js
+++ /dev/null
@@ -1,7 +0,0 @@
-const common = {
- BTN_SUBMIT_NAME: '确定',
-
- NO_LOGIN: '未登录',
-}
-
-export default common
\ No newline at end of file
diff --git a/static/src/texts/user-text.js b/static/src/texts/user-text.js
deleted file mode 100644
index 128b6d4..0000000
--- a/static/src/texts/user-text.js
+++ /dev/null
@@ -1,23 +0,0 @@
-const UserText = {
-
- USER_INFO_LABEL_NAME: '用户名称',
-
- USER_INFO_LABEL_EMAIL: '用户邮件',
-
- USER_INFO_LABEL_PASSWORD: '密码',
-
- USER_INFO_LABEL_CONFIRM_PASSWORD: '确认密码',
-
- USER_INFO_PLACEHOLDER_NAME: '请输入用户名称',
-
- USER_INFO_PLACEHOLDER_EMAIL: '请输入邮箱地址',
-
- USER_INFO_PLACEHOLDER_PASSWORD: '请输入密码',
-
- USER_INFO_PLACEHOLDER_CONFIRM_PASSWORD: '请再次输入密码确认',
-
- USER_INFO_BTN_SUBMIT: '确认',
-
-}
-
-export default UserText
\ No newline at end of file
diff --git a/static/src/utils/Date.js b/static/src/utils/Date.ts
similarity index 74%
rename from static/src/utils/Date.js
rename to static/src/utils/Date.ts
index d043c51..bed689e 100644
--- a/static/src/utils/Date.js
+++ b/static/src/utils/Date.ts
@@ -1,9 +1,9 @@
-export default function (date,format='yyyy-MM-dd hh:mm:ss') {
+export default function (date:Date,format='yyyy-MM-dd hh:mm:ss') {
// const date = new Date(format)
/*
* format='yyyy-MM-dd hh:mm:ss';
*/
- var o = {
+ const o = {
'M+': date.getMonth() + 1,
'd+': date.getDate(),
'h+': date.getHours(),
@@ -18,7 +18,7 @@ export default function (date,format='yyyy-MM-dd hh:mm:ss') {
- RegExp.$1.length));
}
- for (var k in o) {
+ for (let k in o) {
if (new RegExp('(' + k + ')').test(format)) {
format = format.replace(RegExp.$1, RegExp.$1.length === 1
? o[k]
@@ -26,4 +26,13 @@ export default function (date,format='yyyy-MM-dd hh:mm:ss') {
}
}
return format;
+}
+interface Format {
+ 'M+': any,
+ 'd+': any,
+ 'h+': any,
+ 'm+': any,
+ 's+': any,
+ 'q+': any,
+ 'S': any
}
\ No newline at end of file
diff --git a/static/src/utils/charts/makeLine.js b/static/src/utils/charts/makeLine.ts
similarity index 60%
rename from static/src/utils/charts/makeLine.js
rename to static/src/utils/charts/makeLine.ts
index 67ac7d4..2ee29b3 100644
--- a/static/src/utils/charts/makeLine.js
+++ b/static/src/utils/charts/makeLine.ts
@@ -1,4 +1,6 @@
-const lineOption = {
+// import { inflate } from "zlib";
+
+const lineOption:any = {
title: {
text: '时间点击分布图'
},
@@ -8,7 +10,7 @@ const lineOption = {
legend: {
data: ['小时']
},
- grid : {
+ grid: {
top: '100',
right: '100',
bottom: '60',
@@ -17,17 +19,15 @@ const lineOption = {
xAxis: [
{
type: 'category',
- offset:10,
+ offset: 10,
boundaryGap: false,
- data: [
-
- ]
+ data: []
}
],
yAxis: [
{
type: 'value',
- axisLabel:{
+ axisLabel: {
formatter: '{value} 次'
}
}
@@ -36,26 +36,24 @@ const lineOption = {
{
name: '小时',
type: 'line',
- data: [
- ]
+ data: []
}
]
};
-function tranformHour(val) {
- return val>9?(val+':00'):('0'+val+':00')
+function tranformHour(val:number) {
+ return val > 9
+ ? (val + ':00')
+ : ('0' + val + ':00')
}
-export default function (data) {
- const seriesData = [];
- const xAxisData = [];
- data.forEach((item) => {
+export default function (data:any) {
+ const seriesData:any = [];
+ const xAxisData:any = [];
+ data.forEach((item:any) => {
seriesData.push(item.count);
xAxisData.push(tranformHour(item.hour));
});
lineOption.xAxis[0].data = xAxisData;
lineOption.series[0].data = seriesData;
return lineOption;
- // return {
- // seriesData,
- // xAxisData
- // }
-}
+ // return { seriesData, xAxisData }
+}
\ No newline at end of file
diff --git a/static/src/utils/charts/makePie.js b/static/src/utils/charts/makePie.ts
similarity index 90%
rename from static/src/utils/charts/makePie.js
rename to static/src/utils/charts/makePie.ts
index 2cef707..08f80b7 100644
--- a/static/src/utils/charts/makePie.js
+++ b/static/src/utils/charts/makePie.ts
@@ -1,4 +1,5 @@
export default class {
+ pieOption:any;
constructor() {
this.pieOption = {
title: {
@@ -36,9 +37,9 @@ export default class {
};
// this.make(data,title);
}
- make(data,title) {
- const legendData = [];
- data.forEach((item) => {
+ make(data:any,title:any) {
+ const legendData:any = [];
+ data.forEach((item:any) => {
legendData.push(item.name);
});
this.pieOption.legend.data = legendData;
diff --git a/static/src/utils/charts/theme.js b/static/src/utils/charts/theme.ts
similarity index 100%
rename from static/src/utils/charts/theme.js
rename to static/src/utils/charts/theme.ts
diff --git a/static/src/utils/http.js b/static/src/utils/http.ts
similarity index 100%
rename from static/src/utils/http.js
rename to static/src/utils/http.ts
diff --git a/static/src/utils/httpServers.js b/static/src/utils/httpServers.js
deleted file mode 100644
index 30f0273..0000000
--- a/static/src/utils/httpServers.js
+++ /dev/null
@@ -1,75 +0,0 @@
-import axios from './http';
-import {Time, Base,Like,Point} from './resetApi';
-import Qs from 'qs'
-
-// export function postOverview(params) {
-// return axios.post(ACTION.overview,
-// params); }
-function tranformParas(params) {
- return (params)=>{
- return Qs.stringify(params).replace(/%3A/g, ':')
- }
-}
-export function getTime(params) {
- return axios.get(Time.Time, {params: params});
-}
-
-export function getBase(params) {
- return axios.get(Base.Base, {
- params: params,
- paramsSerializer: tranformParas(params)
- });
-}
-
-export function getBasePage(params) {
- return axios.get(Base.BasePage, {
- params: params,
- paramsSerializer: tranformParas(params)
- });
-}
-export function getBasetTransfer(params) {
- return axios.get(Base.BasetTransfer, {
- params: params,
- paramsSerializer: tranformParas(params)
- });
-}
-export function getTransfers(funs) {
- return new Promise((resolve, reject)=>{
- axios.all(funs).then(axios.spread((basePage, basetTransfer)=>{
- const arr = [];
- arr.push(basePage);
- arr.push(basetTransfer);
- resolve(arr);
- }));
- })
-}
-
-export function getBaseUa(params) {
- return axios.get(Base.BaseUa, {
- params: params
- });
-}
-
-export function getLike(params) {
- return axios.get(Like.Like, {
- params: params
- });
-}
-export function getComment(params) {
- return axios.get(Like.Comment, {
- params: params
- });
-}
-
-export function getPoint(params) {
- return axios.get(Point.Point, {
- params: params,
- paramsSerializer: tranformParas(params)
- });
-}
-export function getPointHotel(params) {
- return axios.get(Point.PointHotel, {
- params: params,
- paramsSerializer: tranformParas(params)
- });
-}
\ No newline at end of file
diff --git a/static/src/utils/httpServers.ts b/static/src/utils/httpServers.ts
new file mode 100644
index 0000000..6906b86
--- /dev/null
+++ b/static/src/utils/httpServers.ts
@@ -0,0 +1,78 @@
+import axios from './http';
+import {Time, Base,Like,Point} from './resetApi';
+import * as Qs from 'qs'
+
+interface Params {
+ pid:string,
+}
+interface ParamsBasePage extends Params {
+ start_time:string,
+ end_time:string
+}
+
+interface ParamsBase extends ParamsBasePage {
+ groupType:number
+}
+
+interface Likes extends Params{
+ version:string,
+ url:string,
+ router:string
+}
+
+interface Points extends Likes,ParamsBasePage{
+
+}
+
+function tranformParas(params:any) {
+ return (params:any)=>{
+ return Qs.stringify(params).replace(/%3A/g, ':')
+ }
+}
+export function getTime(params:any) {
+ return axios.get(Time.Time, {params: params});
+}
+
+export function getBase(params:ParamsBase) {
+ return axios.get(Base.Base, {
+ params: params,
+ paramsSerializer: tranformParas(params)
+ });
+}
+
+export function getBasePage(params:ParamsBasePage) {
+ return axios.get(Base.BasePage, {
+ params: params,
+ paramsSerializer: tranformParas(params)
+ });
+}
+
+export function getBaseUa(params:Params) {
+ return axios.get(Base.BaseUa, {
+ params: params
+ });
+}
+
+export function getLike(params:Likes) {
+ return axios.get(Like.Like, {
+ params: params
+ });
+}
+export function getComment(params:Likes) {
+ return axios.get(Like.Comment, {
+ params: params
+ });
+}
+
+export function getPoint(params:Points) {
+ return axios.get(Point.Point, {
+ params: params,
+ paramsSerializer: tranformParas(params)
+ });
+}
+export function getPointHotel(params:Points) {
+ return axios.get(Point.PointHotel, {
+ params: params,
+ paramsSerializer: tranformParas(params)
+ });
+}
\ No newline at end of file
diff --git a/static/src/utils/interface/index.tsx b/static/src/utils/interface/index.tsx
new file mode 100644
index 0000000..32cb16f
--- /dev/null
+++ b/static/src/utils/interface/index.tsx
@@ -0,0 +1,23 @@
+import {RouteComponentProps} from 'react-router-dom';
+import { store } from "../../store";
+
+export interface RouteConfig {
+ path?: string;
+ exact?: boolean;
+ strict?: boolean;
+ routes?: RouteConfig[];
+}
+export interface Routes {
+ route: RouteConfig;
+}
+
+export interface Props extends RouteComponentProps,store {
+
+}
+
+export interface UrlConfig {
+ pid:string,
+ urls:string,
+ url:string,
+ router:string
+}
diff --git a/static/src/utils/resetApi.js b/static/src/utils/resetApi.ts
similarity index 80%
rename from static/src/utils/resetApi.js
rename to static/src/utils/resetApi.ts
index 8d74454..5ba7b36 100644
--- a/static/src/utils/resetApi.js
+++ b/static/src/utils/resetApi.ts
@@ -1,11 +1,9 @@
// 接口
+
// Base
export const Base = {
- // 获取基础信息
Base: '/api/base',
- // 获取分页信息
BasePage: '/api/base/page',
- BasetTransfer:'/api/base/transfer',
BaseUa: '/api/base/ua'
};
// Time
diff --git a/tsconfig.json b/tsconfig.json
new file mode 100644
index 0000000..0039eed
--- /dev/null
+++ b/tsconfig.json
@@ -0,0 +1,29 @@
+{
+ "compilerOptions": {
+ "module": "esnext",
+ "target": "es5",
+ "lib": [
+ "es6",
+ "dom"
+ ],
+ "outDir": "./static/build/",
+ "sourceMap": true,
+ "noImplicitAny": true,
+ "jsx": "react",
+ "experimentalDecorators": true,
+ "skipLibCheck": true,
+ "moduleResolution": "node",
+ "forceConsistentCasingInFileNames": true,
+ "noImplicitReturns": true,
+ "noImplicitThis": true,
+ "strictNullChecks": true,
+ "suppressImplicitAnyIndexErrors": true,
+ "noUnusedLocals": true
+ },
+ "include": [
+ "./static/src/**/*"
+ ],
+ "exclude": [
+ "node_modules"
+ ]
+}
\ No newline at end of file