Fix: 修复警告及webpack热加载

This commit is contained in:
HFO4 2019-11-26 19:27:41 +08:00
parent 5a77568a2c
commit 5d91aaf44d
14 changed files with 25 additions and 60 deletions

View File

@ -44,7 +44,7 @@ module.exports = {
appPath: resolveApp('.'),
appBuild: resolveApp('build'),
appPublic: resolveApp('public'),
appHtml: resolveApp('public/index.html'),
appHtml: resolveApp('public/member/login.html'),
appIndexJs: resolveApp('src/index.js'),
appPackageJson: resolveApp('package.json'),
appSrc: resolveApp('src'),

View File

@ -76,7 +76,7 @@ module.exports = {
devtool: 'cheap-module-source-map',
// These are the "entry points" to our application.
// This means they will be the "root" imports that are included in JS bundle.
entry: {
entry: [
// Include an alternative client for WebpackDevServer. A client's job is to
// connect to WebpackDevServer by a socket and get notified about changes.
// When you save a file, the client will either apply hot updates (in case
@ -87,21 +87,20 @@ module.exports = {
// the line below with these two lines if you prefer the stock client:
// require.resolve('webpack-dev-server/client') + '?/',
// require.resolve('webpack/hot/dev-server'),
hot:require.resolve('react-dev-utils/webpackHotDevClient'),
require.resolve('react-dev-utils/webpackHotDevClient'),
// Finally, this is your app's code:
index:'./src/index.js',
paths.appIndexJs,
// We include the app code last so that if there is a runtime error during
// initialization, it doesn't blow up the WebpackDevServer client, and
// changing JS code would still trigger a refresh.
},
],
output: {
// Add /* filename */ comments to generated require()s in the output.
pathinfo: true,
// This does not produce a real file. It's just the virtual path that is
// served by WebpackDevServer in development. This is the JS bundle
// containing code from all our entry points, and the Webpack runtime.
filename: 'static/js/[name].bundle.js',
filename: 'static/js/bundle.js',
// There are also additional JS chunk files if you use code splitting.
chunkFilename: 'static/js/[name].chunk.js',
// This is the URL that app is served from. We use "/" in development.
@ -178,7 +177,7 @@ module.exports = {
options: {
formatter: require.resolve('react-dev-utils/eslintFormatter'),
eslintPath: require.resolve('eslint'),
},
loader: require.resolve('eslint-loader'),
},
@ -211,7 +210,7 @@ module.exports = {
customize: require.resolve(
'babel-preset-react-app/webpack-overrides'
),
plugins: [
[
require.resolve('babel-plugin-named-asset-import'),
@ -251,7 +250,7 @@ module.exports = {
cacheDirectory: true,
// Don't waste time on Gzipping the cache
cacheCompression: false,
// If an error happens in a package, it's possible to be
// because it was compiled. Thus, we don't want the browser
// debugger to show the original code. Instead, the code
@ -331,11 +330,8 @@ module.exports = {
// Generates an `index.html` file with the <script> injected.
new HtmlWebpackPlugin({
inject: true,
filename:"index.html",
chunks:['index'],
template: './public/member/login.html',
template: paths.appHtml,
}),
// Makes some environment variables available in index.html.
// The public URL is available as %PUBLIC_URL% in index.html, e.g.:
// <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
@ -385,4 +381,4 @@ module.exports = {
// Turn off performance processing because we utilize
// our own hints via the FileSizeReporter
performance: false,
};
};

View File

@ -1,23 +0,0 @@
module.exports = {
"env": {
"browser": true,
"es6": true
},
"extends": "eslint:recommended",
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 2018,
"sourceType": "module"
},
"plugins": [
"react"
],
"rules": {
}
};

View File

@ -1,15 +1,13 @@
import React, { Component, Suspense } from "react";
import React, { Suspense } from "react";
import AuthRoute from "./middleware/AuthRoute";
import Navbar from "./component/Navbar.js";
import AlertBar from "./component/Snackbar";
import { createMuiTheme } from "@material-ui/core/styles";
import { connect, useSelector } from "react-redux";
import { useSelector } from "react-redux";
import {
BrowserRouter as Router,
Switch,
Route,
Link,
useParams,
Switch,
useRouteMatch
} from "react-router-dom";
@ -36,7 +34,7 @@ export default function App() {
const classes = useStyles();
let { path, url } = useRouteMatch();
let { path } = useRouteMatch();
return (
<React.Fragment>
<ThemeProvider theme={theme}>

View File

@ -29,7 +29,7 @@ class FileManager extends Component {
try {
eval(decode(this.image.current));
} catch (err) {
console.log(err)
}
if(window.upload_load===""){

View File

@ -71,8 +71,7 @@ class ImgPreviewCompoment extends Component {
}else{
items.push(newImg);
}
};
}
});
items.unshift(firstOne);
this.setState({

View File

@ -8,7 +8,6 @@ import {useHistory} from 'react-router-dom'
import API from "../../middleware/Api"
import Auth from "../../middleware/Auth"
import {
withStyles,
Button,
FormControl,
Divider,

View File

@ -527,19 +527,19 @@ class NavbarCompoment extends Component {
{(this.props.selected.length <=1 && !(!this.props.isMultiple&&this.props.withFile))&&
<Typography variant="h6" color="inherit" noWrap>
{pathHelper.isSharePage(this.props.location.pathname)&&window.pageId===""&&<FolderShared className={classes.folderShareIcon}/>}{this.props.title}
</Typography>
</Typography>
}
{(!this.props.isMultiple&&this.props.withFile&&!pathHelper.isMobile())&&
<Typography variant="h6" color="inherit" noWrap>
{this.props.selected[0].name} {(pathHelper.isHomePage(this.props.location.pathname)||pathHelper.isSharePage(this.props.location.pathname))&&"("+sizeToString(this.props.selected[0].size)+")"}
</Typography>
</Typography>
}
{(this.props.selected.length >1&&!pathHelper.isMobile())&&
<Typography variant="h6" color="inherit" noWrap>
{this.props.selected.length}个对象
</Typography>
</Typography>
}
{(this.props.selected.length <=1 && !(!this.props.isMultiple&&this.props.withFile))&&
<SezrchBar/>

View File

@ -2,7 +2,6 @@ import React, { Component } from 'react'
import PropTypes from 'prop-types';
import { connect } from 'react-redux'
import {
openResaveDialog,
setUserPopover
}from "../actions/index"

View File

@ -7,7 +7,6 @@ import { createStore } from "redux";
import App from "./App";
import cloureveApp from "./reducers";
import { InitSiteConfig, UpdateSiteConfig } from "./middleware/Init";
import Auth from "./middleware/Auth";
serviceWorker.register();
const defaultStatus = InitSiteConfig({

View File

@ -15,7 +15,7 @@ instance.interceptors.response.use(
// 登录过期
if (response.rawData.code == 401){
Auth.signout();
location.href="#/Login"
window.location.href="#/Login"
}
throw new Error(response.rawData.msg);
}

View File

@ -1,7 +1,6 @@
import React from "react";
import Auth from "./Auth"
import {
BrowserRouter as Router,
Route,
Redirect,
} from "react-router-dom";

View File

@ -165,8 +165,8 @@ const cloudreveApp = (state = [], action) => {
});
case 'NAVIGATOR_TO':
return doNavigate(action.path,state);
case 'TOGGLE_DAYLIGHT_MODE':
const copy = Object.assign({}, state);
case 'TOGGLE_DAYLIGHT_MODE':{
let copy = Object.assign({}, state);
if (copy.siteConfig.theme.palette.type === undefined || copy.siteConfig.theme.palette.type === "light"){
return {
...state,
@ -195,8 +195,7 @@ const cloudreveApp = (state = [], action) => {
},
},
};
return copy
}
case 'APPLY_THEME':
if (state.siteConfig.themes !== null){
let themes = JSON.parse(state.siteConfig.themes);
@ -209,6 +208,7 @@ const cloudreveApp = (state = [], action) => {
}),
});
}
break
case 'NAVIGATOR_UP':
var pathSplit = state.navigator.path.split("/");
pathSplit.pop();

View File

@ -22,7 +22,6 @@ export const setCookie = (name,value,days)=>{
export const setGetParameter = (paramName, paramValue) =>{
var url = window.location.href;
var hash = window.location.hash;
if (url.indexOf(paramName + "=") >= 0)
{