Authored by huangyi

优化结构

import httpService from '../../../../common/httpService'
import httpService from '../../../common/httpService'
import config from '../config'
let collectApi = (param) => httpService.postJson(config.domain + '/api/guochao/addFav', param);
... ...
import Loadable from "react-loadable";
import React from 'react';
const guochaoHome = Loadable({
loader: () => import(/* webpackChunkName: "guochaoHome" */'./view/guochaoHome'),
loading(){
return <div></div>
},
})
const top40 = Loadable({
loader: () => import(/* webpackChunkName: "top40" */'./view/top40'),
loading(){
return <div></div>
},
})
module.exports = {
guochaoHome,
top40
}
... ...
import React from 'react';
import {render} from 'react-dom';
import config from './config';
import {BrowserRouter, Route,Switch,HashRouter,hashHistory,browserHistory} from 'react-router-dom';
// import guochaoHome from './view/guochaoHome';
// import top40 from './view/top40';
import Loadable from 'react-loadable';
const guochaoHome = Loadable({
loader: () => import(/* webpackChunkName: "guochaoHome" */'./view/guochaoHome'),
loading(){
return <div></div>
},
});
const top40 = Loadable({
loader: () => import(/* webpackChunkName: "top40" */'./view/top40'),
loading(){
return <div></div>
},
});
const SliderComponent = () => (
<Switch>
<Route exact path={config.routerPath+'/guochao.html'} component={guochaoHome} />
<Route path={config.routerPath+'/top40.html'} component={top40} />
</Switch>
);
render(
<BrowserRouter history={browserHistory}>
<SliderComponent/>
</BrowserRouter>,
document.querySelector("#root")
);
\ No newline at end of file
module.exports = {
guochaoHome:'中西碰撞 潮流无界',
top40:'中西碰撞 潮流无界'
}
\ No newline at end of file
... ...
import React, {PureComponent} from 'react';
import './index.scss'
import {collectApi, checkFavApi} from '../../api/guochaoApi'
import {getQueryObj, linkToMiniApp, invokeMethod, parseUrl} from '../../../../../common/utils';
import wxshare from '../../../../../common/wxshare'
import {getQueryObj, linkToMiniApp, invokeMethod, parseUrl} from '../../../../common/utils';
import wxshare from '../../../../common/wxshare'
import wx from 'weixin-js-sdk';
import config from '../../config';
import cookie from 'react-cookies';
... ...
import React, {PureComponent} from 'react';
import './index.scss'
import {guochaoListApi} from '../../api/guochaoApi'
import {getEnv, linkToMiniApp, invokeMethod} from "../../../../../common/utils";
import { Link } from 'react-router-dom'
import {linkToMiniApp, invokeMethod} from "../../../../common/utils";
import wx from "weixin-js-sdk";
import config from "../../config";
import wxshare from "../../../../../common/wxshare";
import wxshare from "../../../../common/wxshare";
export default class top40 extends PureComponent {
... ...
import webpack, {DefinePlugin} from 'webpack';
import merge from 'webpack-merge';
import baseConfig from '../../webpack.public.config';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import config from './src/config';
export default merge(baseConfig, {
//项目入口js文件
entry: ['./app/guoChao/src/index.js'],
devServer:{
publicPath: config.routerPath
},
plugins: [
// new HtmlWebpackPlugin({
// filename: 'index.html',
// template: './app/guoChao/index.html',
// }),
new HtmlWebpackPlugin({
filename: 'top40.html',
template: './app/guoChao/index.ejs',
title:"中西碰撞 潮流无界",
inject: true,
minify: {
removeComments: true,
collapseWhitespace: true,
removeAttributeQuotes: true
}
}),
new HtmlWebpackPlugin({
filename: 'guochao.html',
template: './app/guoChao/index.ejs',
title:"中西碰撞 潮流无界",
inject: true,
minify: {
removeComments: true,
collapseWhitespace: true,
removeAttributeQuotes: true
}
}),
]
});
import React from 'react';
import {render} from 'react-dom';
import config from '../config';
import {BrowserRouter, Route, Switch, HashRouter, hashHistory, browserHistory} from 'react-router-dom';
const router = require('./' + config.currentApp +'/router');
const routers = () => {
let arr = [];
Object.keys(router).forEach((key,index)=> {
if(index === 0){
arr.push(<Route key={index} exact path={config.routerPath[config.currentApp] + '/'+key+'.html'} component={router[key]}/>)
}else{
arr.push(<Route key={index} path={config.routerPath[config.currentApp] + '/'+key+'.html'} component={ router[key]}/>)
}
})
return arr;
}
const SliderComponent = () => (
<Switch>
{routers()}
</Switch>
);
render(
<BrowserRouter history={browserHistory}>
<Switch>
<SliderComponent/>
</Switch>
</BrowserRouter>,
document.querySelector("#root")
);
\ No newline at end of file
... ...