This commit is contained in:
喻希里 2017-09-29 14:11:15 +08:00
commit a3a99ada2b
27 changed files with 68 additions and 27449 deletions

View File

@ -1,4 +1,5 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Route, BrowserRouter as Router } from 'react-router-dom'; import { Route, BrowserRouter as Router } from 'react-router-dom';
@ -7,6 +8,7 @@ import User from './containers/User/User.js';
import Header from './components/Header/Header'; import Header from './components/Header/Header';
import Footer from './components/Footer/Footer'; import Footer from './components/Footer/Footer';
import Loading from './components/Loading/Loading'; import Loading from './components/Loading/Loading';
import MyPopConfirm from './components/MyPopConfirm/MyPopConfirm';
import { checkLoginState } from './reducer/modules/user'; import { checkLoginState } from './reducer/modules/user';
import { requireAuthentication } from './components/AuthenticatedComponent'; import { requireAuthentication } from './components/AuthenticatedComponent';
@ -46,7 +48,13 @@ export default class App extends Component {
return <Loading visible />; return <Loading visible />;
} else { } else {
r = ( r = (
<Router > <Router getUserConfirmation={(msg, callback) => {
let container = document.createElement('div');
document.body.appendChild(container);
ReactDOM.render((
<MyPopConfirm msg={msg} callback={callback} />
), container);
}}>
<div className="g-main"> <div className="g-main">
<div className="router-main"> <div className="router-main">
{this.props.loginState !== 1 ? <Header /> : null} {this.props.loginState !== 1 ? <Header /> : null}

View File

@ -0,0 +1,50 @@
import React, { Component } from 'react';
import { Modal, Button } from 'antd';
import PropTypes from 'prop-types';
// 嵌入到 BrowserRouter 内部,覆盖掉默认的 window.confirm
// http://reacttraining.cn/web/api/BrowserRouter/getUserConfirmation-func
class MyPopConfirm extends Component {
constructor(props) {
super(props);
this.state = {
visible: true
};
}
static propTypes = {
msg: PropTypes.string,
callback: PropTypes.func
};
yes = () => {
this.props.callback(true);
this.setState({ visible: false });
}
no = () => {
this.props.callback(false);
this.setState({ visible: false });
}
componentWillReceiveProps() {
this.setState({ visible: true });
}
render() {
if (!this.state.visible) {
return null;
}
return (<Modal
title="你即将离开编辑页面"
visible={this.state.visible}
footer={[
<Button key="back" onClick={this.no}> </Button>,
<Button key="submit" onClick={this.yes}> </Button>
]}
>
<p>{this.props.msg}</p>
</Modal>);
}
}
export default MyPopConfirm;

View File

@ -135,7 +135,8 @@ class Content extends Component {
<Prompt <Prompt
when={this.state.curtab === 'edit' && this.props.editStatus ? true : false} when={this.state.curtab === 'edit' && this.props.editStatus ? true : false}
message={() => { message={() => {
this.showModal(); // this.showModal();
console.log('e');
return '离开页面会丢失当前编辑的内容,确定要离开吗?'; return '离开页面会丢失当前编辑的内容,确定要离开吗?';
}} }}
/> />

View File

@ -1 +1 @@
window.WEBPACK_ASSETS = {"index.js":{"js":"index@726f0c05be8ee7a1b257.js","css":"index@726f0c05be8ee7a1b257.css"},"lib":{"js":"lib@70933cf119a409aca1f2.js"},"lib2":{"js":"lib2@2536ef5c4b4711cf085a.js"},"manifest":{"js":"manifest@b67af9f8b578904e66c5.js"}} window.WEBPACK_ASSETS = {"index.js":{"js":"index@86c2b0ce829f6e441377.js","css":"index@86c2b0ce829f6e441377.css"},"lib":{"js":"lib@0fe1d0abd11fbb8ef3d6.js"},"lib2":{"js":"lib2@980bff89a8e0841fa293.js"},"manifest":{"js":"manifest@b67af9f8b578904e66c5.js"}}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -1,94 +0,0 @@
/******/ (function(modules) { // webpackBootstrap
/******/ // install a JSONP callback for chunk loading
/******/ var parentJsonpFunction = window["webpackJsonp"];
/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules) {
/******/ // add "moreModules" to the modules object,
/******/ // then flag all "chunkIds" as loaded and fire callback
/******/ var moduleId, chunkId, i = 0, callbacks = [];
/******/ for(;i < chunkIds.length; i++) {
/******/ chunkId = chunkIds[i];
/******/ if(installedChunks[chunkId])
/******/ callbacks.push.apply(callbacks, installedChunks[chunkId]);
/******/ installedChunks[chunkId] = 0;
/******/ }
/******/ for(moduleId in moreModules) {
/******/ modules[moduleId] = moreModules[moduleId];
/******/ }
/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules);
/******/ while(callbacks.length)
/******/ callbacks.shift().call(null, __webpack_require__);
/******/ if(moreModules[0]) {
/******/ installedModules[0] = 0;
/******/ return __webpack_require__(0);
/******/ }
/******/ };
/******/ // The module cache
/******/ var installedModules = {};
/******/ // object to store loaded and loading chunks
/******/ // "0" means "already loaded"
/******/ // Array means "loading", array contains callbacks
/******/ var installedChunks = {
/******/ 3:0
/******/ };
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/ // This file contains only the entry chunk.
/******/ // The chunk loading function for additional chunks
/******/ __webpack_require__.e = function requireEnsure(chunkId, callback) {
/******/ // "0" is the signal for "already loaded"
/******/ if(installedChunks[chunkId] === 0)
/******/ return callback.call(null, __webpack_require__);
/******/ // an array means "currently loading".
/******/ if(installedChunks[chunkId] !== undefined) {
/******/ installedChunks[chunkId].push(callback);
/******/ } else {
/******/ // start chunk loading
/******/ installedChunks[chunkId] = [callback];
/******/ var head = document.getElementsByTagName('head')[0];
/******/ var script = document.createElement('script');
/******/ script.type = 'text/javascript';
/******/ script.charset = 'utf-8';
/******/ script.async = true;
/******/ script.src = __webpack_require__.p + "" + chunkId + ".chunk.js";
/******/ head.appendChild(script);
/******/ }
/******/ };
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/ })
/************************************************************************/
/******/ ([]);

View File

@ -36,6 +36,8 @@ function initPlugins(){
}) })
scripts = "module.exports = {" + scripts.join(",") + "}"; scripts = "module.exports = {" + scripts.join(",") + "}";
fs.writeFileSync('client/plugin-module.js', scripts); fs.writeFileSync('client/plugin-module.js', scripts);
}else{
fs.writeFileSync('client/plugin-module.js', 'module.exports = {}');
} }
} }