Merge remote-tracking branch 'origin/master'

dev_forum
杨树明 6 years ago
commit d6755bb8ec

113
.gitignore vendored

@ -1,56 +1,57 @@
# See https://help.github.com/articles/ignoring-files for more about ignoring files. # See https://help.github.com/articles/ignoring-files for more about ignoring files.
# #
# If you find yourself ignoring temporary files generated by your text editor # If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead: # or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global' # git config --global core.excludesfile '~/.gitignore_global'
# Ignore bundler config. # Ignore bundler config.
/.bundle /.bundle
# mac # mac
*.DS_Store *.DS_Store
# Ignore all logfiles and tempfiles. # Ignore all logfiles and tempfiles.
/log/* /log/*
/tmp/* /tmp/*
!/log/.keep !/log/.keep
!/tmp/.keep !/tmp/.keep
# Ignore uploaded files in development # Ignore uploaded files in development
/storage/* /storage/*
/node_modules /node_modules
/yarn-error.log /yarn-error.log
# /public/assets # /public/assets
.byebug_history .byebug_history
# Ignore master key for decrypting credentials and more. # Ignore master key for decrypting credentials and more.
/config/master.key /config/master.key
/config/database.yml /config/database.yml
/.idea/* /.idea/*
# Ignore react node_modules # Ignore react node_modules
/public/react/build /public/react/build
/public/react/build/ /public/react/build/
/public/react/node_modules/ /public/react/.cache
/public/react/config/stats.json /public/react/node_modules/
/public/react/stats.json /public/react/config/stats.json
/public/react/stats.json
/public/npm-debug.log
/public/npm-debug.log
# avatars
/public/images/avatars # avatars
/public/images/avatars
/config/secrets.yml
/files/archiveZip/* /config/secrets.yml
/files/cache_store/* /files/archiveZip/*
public/upload.html /files/cache_store/*
/config/configuration.yml public/upload.html
/config/initializers/gitlab_config.rb /config/configuration.yml
/db/schema.rb /config/initializers/gitlab_config.rb
.vscode/ /db/schema.rb
vendor/bundle/ .vscode/
.ruby-version vendor/bundle/
.ruby-gemset .ruby-version
.ruby-gemset

@ -9,6 +9,7 @@ const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin'); const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
const eslintFormatter = require('react-dev-utils/eslintFormatter'); const eslintFormatter = require('react-dev-utils/eslintFormatter');
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin'); const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
const ParallelUglifyPlugin = require('webpack-parallel-uglify-plugin');
// const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin'); // const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
const getClientEnvironment = require('./env'); const getClientEnvironment = require('./env');
const paths = require('./paths'); const paths = require('./paths');
@ -249,6 +250,46 @@ module.exports = {
// https://github.com/jmblog/how-to-optimize-momentjs-with-webpack // https://github.com/jmblog/how-to-optimize-momentjs-with-webpack
// You can remove this if you don't use Moment.js: // You can remove this if you don't use Moment.js:
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/), new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new ParallelUglifyPlugin({
// 传递给 UglifyJS的参数如下
uglifyJS: {
output: {
/*
是否输出可读性较强的代码即会保留空格和制表符默认为输出为了达到更好的压缩效果
可以设置为false
*/
beautify: false,
/*
是否保留代码中的注释默认为保留为了达到更好的压缩效果可以设置为false
*/
comments: false
},
compress: {
/*
是否在UglifyJS删除没有用到的代码时输出警告信息默认为输出可以设置为false关闭这些作用
不大的警告
*/
warnings: false,
/*
是否删除代码中所有的console语句默认为不删除开启后会删除所有的console语句
*/
drop_console: false,
/*
是否内嵌虽然已经定义了但是只用到一次的变量比如将 var x = 1; y = x, 转换成 y = 5, 默认为不
转换为了达到更好的压缩效果可以设置为false
*/
collapse_vars: false,
/*
是否提取出现了多次但是没有定义成变量去引用的静态值比如将 x = 'xxx'; y = 'xxx' 转换成
var a = 'xxxx'; x = a; y = a; 默认为不转换为了达到更好的压缩效果可以设置为false
*/
reduce_vars: false
}
}
}),
], ],
// Some libraries import Node modules but don't use them in the browser. // Some libraries import Node modules but don't use them in the browser.
// Tell Webpack to provide empty mocks for them so importing them works. // Tell Webpack to provide empty mocks for them so importing them works.

@ -1,349 +1,365 @@
'use strict'; 'use strict';
const autoprefixer = require('autoprefixer'); const autoprefixer = require('autoprefixer');
const path = require('path'); const path = require('path');
const webpack = require('webpack'); const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin'); const ExtractTextPlugin = require('extract-text-webpack-plugin');
const ManifestPlugin = require('webpack-manifest-plugin'); const ManifestPlugin = require('webpack-manifest-plugin');
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin'); const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin'); const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
const eslintFormatter = require('react-dev-utils/eslintFormatter'); const eslintFormatter = require('react-dev-utils/eslintFormatter');
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin'); const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
const paths = require('./paths'); const ParallelUglifyPlugin = require('webpack-parallel-uglify-plugin');
const getClientEnvironment = require('./env');
const paths = require('./paths');
// Webpack uses `publicPath` to determine where the app is being served from. const getClientEnvironment = require('./env');
// It requires a trailing slash, or the file assets will get an incorrect path.
const publicPath = paths.servedPath; // Webpack uses `publicPath` to determine where the app is being served from.
// Some apps do not use client-side routing with pushState. // It requires a trailing slash, or the file assets will get an incorrect path.
// For these, "homepage" can be set to "." to enable relative asset paths. const publicPath = paths.servedPath;
const shouldUseRelativeAssetPaths = publicPath === './'; // Some apps do not use client-side routing with pushState.
// Source maps are resource heavy and can cause out of memory issue for large source files. // For these, "homepage" can be set to "." to enable relative asset paths.
const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false'; const shouldUseRelativeAssetPaths = publicPath === './';
// `publicUrl` is just like `publicPath`, but we will provide it to our app // Source maps are resource heavy and can cause out of memory issue for large source files.
// as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript. const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false';
// Omit trailing slash as %PUBLIC_URL%/xyz looks better than %PUBLIC_URL%xyz. // `publicUrl` is just like `publicPath`, but we will provide it to our app
const publicUrl = publicPath.slice(0, -1); // as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
// Get environment variables to inject into our app. // Omit trailing slash as %PUBLIC_URL%/xyz looks better than %PUBLIC_URL%xyz.
const env = getClientEnvironment(publicUrl); const publicUrl = publicPath.slice(0, -1);
// Get environment variables to inject into our app.
// Assert this just to be safe. const env = getClientEnvironment(publicUrl);
// Development builds of React are slow and not intended for production.
if (env.stringified['process.env'].NODE_ENV !== '"production"') { // Assert this just to be safe.
throw new Error('Production builds must have NODE_ENV=production.'); // Development builds of React are slow and not intended for production.
} if (env.stringified['process.env'].NODE_ENV !== '"production"') {
throw new Error('Production builds must have NODE_ENV=production.');
// Note: defined here because it will be used more than once. }
const cssFilename = './static/css/[name].[contenthash:8].css';
// Note: defined here because it will be used more than once.
// ExtractTextPlugin expects the build output to be flat. const cssFilename = './static/css/[name].[contenthash:8].css';
// (See https://github.com/webpack-contrib/extract-text-webpack-plugin/issues/27)
// However, our output is structured with css, js and media folders. // ExtractTextPlugin expects the build output to be flat.
// To have this structure working with relative paths, we have to use custom options. // (See https://github.com/webpack-contrib/extract-text-webpack-plugin/issues/27)
const extractTextPluginOptions = shouldUseRelativeAssetPaths // However, our output is structured with css, js and media folders.
? // Making sure that the publicPath goes back to to build folder. // To have this structure working with relative paths, we have to use custom options.
{ publicPath: Array(cssFilename.split('/').length).join('../') } const extractTextPluginOptions = shouldUseRelativeAssetPaths
: {}; ? // Making sure that the publicPath goes back to to build folder.
{ publicPath: Array(cssFilename.split('/').length).join('../') }
// This is the production configuration. : {};
// It compiles slowly and is focused on producing a fast and minimal bundle.
// The development configuration is different and lives in a separate file. // This is the production configuration.
// It compiles slowly and is focused on producing a fast and minimal bundle.
// console.log('publicPath ', publicPath) // The development configuration is different and lives in a separate file.
module.exports = {
// Don't attempt to continue if there are any errors. // console.log('publicPath ', publicPath)
bail: true, module.exports = {
// We generate sourcemaps in production. This is slow but gives good results. // Don't attempt to continue if there are any errors.
// You can exclude the *.map files from the build during deployment. bail: true,
devtool: shouldUseSourceMap ? 'nosources-source-map' : false, //正式版 // We generate sourcemaps in production. This is slow but gives good results.
// devtool: shouldUseSourceMap ? 'source-map' : false,//测试版 // You can exclude the *.map files from the build during deployment.
// In production, we only want to load the polyfills and the app code. // devtool: shouldUseSourceMap ? 'nosources-source-map' : false, //正式版
entry: [require.resolve('./polyfills'), paths.appIndexJs], devtool: shouldUseSourceMap ? 'source-map' : false,//测试版
output: { // In production, we only want to load the polyfills and the app code.
// The build folder. entry: [require.resolve('./polyfills'), paths.appIndexJs],
path: paths.appBuild, output: {
// Generated JS file names (with nested folders). // The build folder.
// There will be one main bundle, and one file per asynchronous chunk. path: paths.appBuild,
// We don't currently advertise code splitting but Webpack supports it. // Generated JS file names (with nested folders).
filename: './static/js/[name].[chunkhash:8].js', // There will be one main bundle, and one file per asynchronous chunk.
chunkFilename: './static/js/[name].[chunkhash:8].chunk.js', // We don't currently advertise code splitting but Webpack supports it.
// We inferred the "public path" (such as / or /my-project) from homepage. filename: './static/js/[name].[chunkhash:8].js',
// cdn chunkFilename: './static/js/[name].[chunkhash:8].chunk.js',
// publicPath: 'https://shixun.educoder.net/react/build/', //publicPath, https://cdn.educoder.net // We inferred the "public path" (such as / or /my-project) from homepage.
// publicPath: 'https://cdn-testeduplus2.educoder.net/react/build/', //publicPath, https://cdn.educoder.net // cdn
publicPath: '/react/build/', //publicPath, https://cdn.educoder.net // publicPath: 'https://shixun.educoder.net/react/build/', //publicPath, https://cdn.educoder.net
// publicPath: 'https://cdn-testeduplus2.educoder.net/react/build/', //publicPath, https://cdn.educoder.net
// Point sourcemap entries to original disk location (format as URL on Windows) publicPath: '/react/build/', //publicPath, https://cdn.educoder.net
devtoolModuleFilenameTemplate: info =>
path // Point sourcemap entries to original disk location (format as URL on Windows)
.relative(paths.appSrc, info.absoluteResourcePath) devtoolModuleFilenameTemplate: info =>
.replace(/\\/g, '/'), path
}, .relative(paths.appSrc, info.absoluteResourcePath)
resolve: { .replace(/\\/g, '/'),
// This allows you to set a fallback for where Webpack should look for modules. },
// We placed these paths second because we want `node_modules` to "win" resolve: {
// if there are any conflicts. This matches Node resolution mechanism. // This allows you to set a fallback for where Webpack should look for modules.
// https://github.com/facebookincubator/create-react-app/issues/253 // We placed these paths second because we want `node_modules` to "win"
modules: ['node_modules', paths.appNodeModules].concat( // if there are any conflicts. This matches Node resolution mechanism.
// It is guaranteed to exist because we tweak it in `env.js` // https://github.com/facebookincubator/create-react-app/issues/253
process.env.NODE_PATH.split(path.delimiter).filter(Boolean) modules: ['node_modules', paths.appNodeModules].concat(
), // It is guaranteed to exist because we tweak it in `env.js`
// These are the reasonable defaults supported by the Node ecosystem. process.env.NODE_PATH.split(path.delimiter).filter(Boolean)
// We also include JSX as a common component filename extension to support ),
// some tools, although we do not recommend using it, see: // These are the reasonable defaults supported by the Node ecosystem.
// https://github.com/facebookincubator/create-react-app/issues/290 // We also include JSX as a common component filename extension to support
// `web` extension prefixes have been added for better support // some tools, although we do not recommend using it, see:
// for React Native Web. // https://github.com/facebookincubator/create-react-app/issues/290
extensions: ['.web.js', '.mjs', '.js', '.json', '.web.jsx', '.jsx'], // `web` extension prefixes have been added for better support
alias: { // for React Native Web.
"educoder": __dirname + "/../src/common/educoder.js", extensions: ['.web.js', '.mjs', '.js', '.json', '.web.jsx', '.jsx'],
// Support React Native Web alias: {
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/ "educoder": __dirname + "/../src/common/educoder.js",
'react-native': 'react-native-web', // Support React Native Web
}, // https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
plugins: [ 'react-native': 'react-native-web',
// Prevents users from importing files from outside of src/ (or node_modules/). },
// This often causes confusion because we only process files within src/ with babel. plugins: [
// To fix this, we prevent you from importing files out of src/ -- if you'd like to, // Prevents users from importing files from outside of src/ (or node_modules/).
// please link the files into your node_modules/ and let module-resolution kick in. // This often causes confusion because we only process files within src/ with babel.
// Make sure your source files are compiled, as they will not be processed in any way. // To fix this, we prevent you from importing files out of src/ -- if you'd like to,
new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]), // please link the files into your node_modules/ and let module-resolution kick in.
], // Make sure your source files are compiled, as they will not be processed in any way.
}, new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]),
module: { ],
strictExportPresence: true, },
rules: [ module: {
// TODO: Disable require.ensure as it's not a standard language feature. strictExportPresence: true,
// We are waiting for https://github.com/facebookincubator/create-react-app/issues/2176. rules: [
// { parser: { requireEnsure: false } }, // TODO: Disable require.ensure as it's not a standard language feature.
// We are waiting for https://github.com/facebookincubator/create-react-app/issues/2176.
// First, run the linter. // { parser: { requireEnsure: false } },
// It's important to do this before Babel processes the JS.
// { // First, run the linter.
// test: /\.(js|jsx|mjs)$/, // It's important to do this before Babel processes the JS.
// enforce: 'pre', // {
// use: [ // test: /\.(js|jsx|mjs)$/,
// { // enforce: 'pre',
// options: { // use: [
// formatter: eslintFormatter, // {
// eslintPath: require.resolve('eslint'), // options: {
// // formatter: eslintFormatter,
// }, // eslintPath: require.resolve('eslint'),
// loader: require.resolve('eslint-loader'), //
// }, // },
// ], // loader: require.resolve('eslint-loader'),
// include: paths.appSrc, // },
// }, // ],
{ // include: paths.appSrc,
// "oneOf" will traverse all following loaders until one will // },
// match the requirements. When no loader matches it will fall {
// back to the "file" loader at the end of the loader list. // "oneOf" will traverse all following loaders until one will
oneOf: [ // match the requirements. When no loader matches it will fall
// "url" loader works just like "file" loader but it also embeds // back to the "file" loader at the end of the loader list.
// assets smaller than specified size as data URLs to avoid requests. oneOf: [
{ // "url" loader works just like "file" loader but it also embeds
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/], // assets smaller than specified size as data URLs to avoid requests.
loader: require.resolve('url-loader'), {
options: { test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
limit: 10000, loader: require.resolve('url-loader'),
name: 'static/media/[name].[hash:8].[ext]', options: {
}, limit: 10000,
}, name: 'static/media/[name].[hash:8].[ext]',
// Process JS with Babel. },
{ },
test: /\.(js|jsx|mjs)$/, // Process JS with Babel.
include: paths.appSrc, {
loader: require.resolve('babel-loader'), test: /\.(js|jsx|mjs)$/,
options: { include: paths.appSrc,
loader: require.resolve('babel-loader'),
compact: true, options: {
},
}, compact: true,
// The notation here is somewhat confusing. },
// "postcss" loader applies autoprefixer to our CSS. },
// "css" loader resolves paths in CSS and adds assets as dependencies. // The notation here is somewhat confusing.
// "style" loader normally turns CSS into JS modules injecting <style>, // "postcss" loader applies autoprefixer to our CSS.
// but unlike in development configuration, we do something different. // "css" loader resolves paths in CSS and adds assets as dependencies.
// `ExtractTextPlugin` first applies the "postcss" and "css" loaders // "style" loader normally turns CSS into JS modules injecting <style>,
// (second argument), then grabs the result CSS and puts it into a // but unlike in development configuration, we do something different.
// separate file in our build process. This way we actually ship // `ExtractTextPlugin` first applies the "postcss" and "css" loaders
// a single CSS file in production instead of JS code injecting <style> // (second argument), then grabs the result CSS and puts it into a
// tags. If you use code splitting, however, any async bundles will still // separate file in our build process. This way we actually ship
// use the "style" loader inside the async code so CSS from them won't be // a single CSS file in production instead of JS code injecting <style>
// in the main CSS file. // tags. If you use code splitting, however, any async bundles will still
{ // use the "style" loader inside the async code so CSS from them won't be
test: /\.css$/, // in the main CSS file.
loader: ExtractTextPlugin.extract( {
Object.assign( test: /\.css$/,
{ loader: ExtractTextPlugin.extract(
fallback: { Object.assign(
loader: require.resolve('style-loader'), {
options: { fallback: {
hmr: false, loader: require.resolve('style-loader'),
}, options: {
}, hmr: false,
use: [ },
{ },
loader: require.resolve('css-loader'), use: [
options: { {
importLoaders: 1, loader: require.resolve('css-loader'),
minimize: true, options: {
sourceMap: shouldUseSourceMap, importLoaders: 1,
}, minimize: true,
}, sourceMap: shouldUseSourceMap,
{ },
loader: require.resolve('postcss-loader'), },
options: { {
// Necessary for external CSS imports to work loader: require.resolve('postcss-loader'),
// https://github.com/facebookincubator/create-react-app/issues/2677 options: {
ident: 'postcss', // Necessary for external CSS imports to work
plugins: () => [ // https://github.com/facebookincubator/create-react-app/issues/2677
require('postcss-flexbugs-fixes'), ident: 'postcss',
autoprefixer({ plugins: () => [
browsers: [ require('postcss-flexbugs-fixes'),
'>1%', autoprefixer({
'last 4 versions', browsers: [
'Firefox ESR', '>1%',
'not ie < 9', // React doesn't support IE8 anyway 'last 4 versions',
], 'Firefox ESR',
flexbox: 'no-2009', 'not ie < 9', // React doesn't support IE8 anyway
}), ],
], flexbox: 'no-2009',
}, }),
}, ],
], },
}, },
extractTextPluginOptions ],
) },
), extractTextPluginOptions
// Note: this won't work without `new ExtractTextPlugin()` in `plugins`. )
}, ),
// "file" loader makes sure assets end up in the `build` folder. // Note: this won't work without `new ExtractTextPlugin()` in `plugins`.
// When you `import` an asset, you get its filename. },
// This loader doesn't use a "test" so it will catch all modules // "file" loader makes sure assets end up in the `build` folder.
// that fall through the other loaders. // When you `import` an asset, you get its filename.
{ // This loader doesn't use a "test" so it will catch all modules
loader: require.resolve('file-loader'), // that fall through the other loaders.
// Exclude `js` files to keep "css" loader working as it injects {
// it's runtime that would otherwise processed through "file" loader. loader: require.resolve('file-loader'),
// Also exclude `html` and `json` extensions so they get processed // Exclude `js` files to keep "css" loader working as it injects
// by webpacks internal loaders. // it's runtime that would otherwise processed through "file" loader.
exclude: [/\.(js|jsx|mjs)$/, /\.html$/, /\.json$/], // Also exclude `html` and `json` extensions so they get processed
options: { // by webpacks internal loaders.
name: 'static/media/[name].[hash:8].[ext]', exclude: [/\.(js|jsx|mjs)$/, /\.html$/, /\.json$/],
}, options: {
}, name: 'static/media/[name].[hash:8].[ext]',
// ** STOP ** Are you adding a new loader? },
// Make sure to add the new loader(s) before the "file" loader. },
], // ** STOP ** Are you adding a new loader?
}, // Make sure to add the new loader(s) before the "file" loader.
], ],
}, },
plugins: [ ],
// Makes some environment variables available in index.html. },
// The public URL is available as %PUBLIC_URL% in index.html, e.g.: plugins: [
// <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico"> // Makes some environment variables available in index.html.
// In production, it will be an empty string unless you specify "homepage" // The public URL is available as %PUBLIC_URL% in index.html, e.g.:
// in `package.json`, in which case it will be the pathname of that URL. // <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
new InterpolateHtmlPlugin(env.raw), // In production, it will be an empty string unless you specify "homepage"
// Generates an `index.html` file with the <script> injected. // in `package.json`, in which case it will be the pathname of that URL.
new HtmlWebpackPlugin({ new InterpolateHtmlPlugin(env.raw),
inject: true, // Generates an `index.html` file with the <script> injected.
template: paths.appHtml, new HtmlWebpackPlugin({
minify: { inject: true,
removeComments: true, template: paths.appHtml,
collapseWhitespace: true, minify: {
removeRedundantAttributes: true, removeComments: true,
useShortDoctype: true, collapseWhitespace: true,
removeEmptyAttributes: true, removeRedundantAttributes: true,
removeStyleLinkTypeAttributes: true, useShortDoctype: true,
keepClosingSlash: true, removeEmptyAttributes: true,
minifyJS: true, removeStyleLinkTypeAttributes: true,
minifyCSS: true, keepClosingSlash: true,
minifyURLs: true, minifyJS: true,
}, minifyCSS: true,
}), minifyURLs: true,
// Makes some environment variables available to the JS code, for example: },
// if (process.env.NODE_ENV === 'production') { ... }. See `./env.js`. }),
// It is absolutely essential that NODE_ENV was set to production here. // Makes some environment variables available to the JS code, for example:
// Otherwise React will be compiled in the very slow development mode. // if (process.env.NODE_ENV === 'production') { ... }. See `./env.js`.
new webpack.DefinePlugin(env.stringified), // It is absolutely essential that NODE_ENV was set to production here.
// Minify the code. // Otherwise React will be compiled in the very slow development mode.
new webpack.optimize.UglifyJsPlugin({ new webpack.DefinePlugin(env.stringified),
compress: { // Minify the code.
warnings: false, // new webpack.optimize.UglifyJsPlugin({
// Disabled because of an issue with Uglify breaking seemingly valid code: // compress: {
// https://github.com/facebookincubator/create-react-app/issues/2376 // warnings: false,
// Pending further investigation: // // Disabled because of an issue with Uglify breaking seemingly valid code:
// https://github.com/mishoo/UglifyJS2/issues/2011 // // https://github.com/facebookincubator/create-react-app/issues/2376
comparisons: false, // // Pending further investigation:
}, // // https://github.com/mishoo/UglifyJS2/issues/2011
mangle: { // comparisons: false,
safari10: true, // },
}, // mangle: {
output: { // safari10: true,
comments: false, // },
// Turned on because emoji and regex is not minified properly using default // output: {
// https://github.com/facebookincubator/create-react-app/issues/2488 // comments: false,
ascii_only: true, // // Turned on because emoji and regex is not minified properly using default
}, // // https://github.com/facebookincubator/create-react-app/issues/2488
sourceMap: shouldUseSourceMap, // ascii_only: true,
}), // },
// Note: this won't work without ExtractTextPlugin.extract(..) in `loaders`. // sourceMap: shouldUseSourceMap,
new ExtractTextPlugin({ // }),
filename: cssFilename, //正式版上线后打开去掉debuger和console
}), new ParallelUglifyPlugin({
// Generate a manifest file which contains a mapping of all asset filenames cacheDir: '.cache/',
// to their corresponding output file so that tools can pick it up without uglifyJS:{
// having to parse `index.html`. output: {
new ManifestPlugin({ comments: false
fileName: 'asset-manifest.json', },
}), warnings: false,
// Generate a service worker script that will precache, and keep up to date, compress: {
// the HTML & assets that are part of the Webpack build. drop_debugger: false,
new SWPrecacheWebpackPlugin({ drop_console: false
// By default, a cache-busting query parameter is appended to requests }
// used to populate the caches, to ensure the responses are fresh. }
// If a URL is already hashed by Webpack, then there is no concern }),
// about it being stale, and the cache-busting can be skipped. // Note: this won't work without ExtractTextPlugin.extract(..) in `loaders`.
dontCacheBustUrlsMatching: /\.\w{8}\./, new ExtractTextPlugin({
filename: 'service-worker.js', filename: cssFilename,
logger(message) { }),
if (message.indexOf('Total precache size is') === 0) { // Generate a manifest file which contains a mapping of all asset filenames
// This message occurs for every build and is a bit too noisy. // to their corresponding output file so that tools can pick it up without
return; // having to parse `index.html`.
} new ManifestPlugin({
if (message.indexOf('Skipping static resource') === 0) { fileName: 'asset-manifest.json',
// This message obscures real errors so we ignore it. }),
// https://github.com/facebookincubator/create-react-app/issues/2612 // Generate a service worker script that will precache, and keep up to date,
return; // the HTML & assets that are part of the Webpack build.
} new SWPrecacheWebpackPlugin({
// console.log(message); // By default, a cache-busting query parameter is appended to requests
}, // used to populate the caches, to ensure the responses are fresh.
minify: true, // If a URL is already hashed by Webpack, then there is no concern
// For unknown URLs, fallback to the index page // about it being stale, and the cache-busting can be skipped.
navigateFallback: publicUrl + '/index.html', dontCacheBustUrlsMatching: /\.\w{8}\./,
// Ignores URLs starting from /__ (useful for Firebase): filename: 'service-worker.js',
// https://github.com/facebookincubator/create-react-app/issues/2237#issuecomment-302693219 logger(message) {
navigateFallbackWhitelist: [/^(?!\/__).*/], if (message.indexOf('Total precache size is') === 0) {
// Don't precache sourcemaps (they're large) and build asset manifest: // This message occurs for every build and is a bit too noisy.
staticFileGlobsIgnorePatterns: [/\.map$/, /asset-manifest\.json$/], return;
}), }
// Moment.js is an extremely popular library that bundles large locale files if (message.indexOf('Skipping static resource') === 0) {
// by default due to how Webpack interprets its code. This is a practical // This message obscures real errors so we ignore it.
// solution that requires the user to opt into importing specific locales. // https://github.com/facebookincubator/create-react-app/issues/2612
// https://github.com/jmblog/how-to-optimize-momentjs-with-webpack return;
// You can remove this if you don't use Moment.js: }
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/), // console.log(message);
], },
// Some libraries import Node modules but don't use them in the browser. minify: true,
// Tell Webpack to provide empty mocks for them so importing them works. // For unknown URLs, fallback to the index page
node: { navigateFallback: publicUrl + '/index.html',
dgram: 'empty', // Ignores URLs starting from /__ (useful for Firebase):
fs: 'empty', // https://github.com/facebookincubator/create-react-app/issues/2237#issuecomment-302693219
net: 'empty', navigateFallbackWhitelist: [/^(?!\/__).*/],
tls: 'empty', // Don't precache sourcemaps (they're large) and build asset manifest:
child_process: 'empty', staticFileGlobsIgnorePatterns: [/\.map$/, /asset-manifest\.json$/],
}, }),
}; // Moment.js is an extremely popular library that bundles large locale files
// by default due to how Webpack interprets its code. This is a practical
// solution that requires the user to opt into importing specific locales.
// https://github.com/jmblog/how-to-optimize-momentjs-with-webpack
// You can remove this if you don't use Moment.js:
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
],
// Some libraries import Node modules but don't use them in the browser.
// Tell Webpack to provide empty mocks for them so importing them works.
node: {
dgram: 'empty',
fs: 'empty',
net: 'empty',
tls: 'empty',
child_process: 'empty',
},
};

@ -224,7 +224,12 @@ class App extends Component {
componentDidMount() { componentDidMount() {
// force an update if the URL changes // force an update if the URL changes
history.listen(() => this.forceUpdate()); history.listen(() => {
this.forceUpdate()
const $ = window.$
// https://www.trustie.net/issues/21919 可能会有问题
$("html").animate({ scrollTop: $('html').scrollTop() - 0 })
});
initAxiosInterceptors(this.props) initAxiosInterceptors(this.props)

@ -6,27 +6,8 @@ const $ = window.$
let _url_origin = getUrl2() let _url_origin = getUrl2()
// let _url_origin = `http://47.96.87.25:48080`; // let _url_origin = `http://47.96.87.25:48080`;
if (!window.Cropper) {
$.ajaxSetup({
cache: true
});
$('head').append($('<link rel="stylesheet" type="text/css" />')
.attr('href', `${_url_origin}/react/public/js/cropper/cropper.min.css`));
$.getScript(
`${_url_origin}/react/public/js/cropper/cropper.js`,
(data, textStatus, jqxhr) => {
});
$.getScript(
`${_url_origin}/react/public/js/cropper/html2canvas.min.js`,
(data, textStatus, jqxhr) => {
});
}
function save_avatar(){ function save_avatar(){
// if($(img_lg).html().trim() == ""){ // if($(img_lg).html().trim() == ""){
@ -93,9 +74,30 @@ class Cropper extends Component {
// console.log(event.detail.scaleX); // console.log(event.detail.scaleX);
// console.log(event.detail.scaleY); // console.log(event.detail.scaleY);
}, },
preview: this.props.previewId ? `#${this.props.previewId}` : '.img-preview', preview: this.props.previewId ? `#${this.props.previewId}` : '.img-preview',
} }
if (!window.Cropper) {
$.ajaxSetup({
cache: true
});
$('head').append($('<link rel="stylesheet" type="text/css" />')
.attr('href', `${_url_origin}/react/public/js/cropper/cropper.min.css`));
$.getScript(
`${_url_origin}/react/public/js/cropper/cropper.js`,
(data, textStatus, jqxhr) => {
});
$.getScript(
`${_url_origin}/react/public/js/cropper/html2canvas.min.js`,
(data, textStatus, jqxhr) => {
});
}
setTimeout(() => { setTimeout(() => {
const image = document.getElementById(this.props.imageId || '__image'); const image = document.getElementById(this.props.imageId || '__image');
this.cropper = new window.Cropper(image, this.options); this.cropper = new window.Cropper(image, this.options);

@ -401,7 +401,7 @@ class commonWork extends Component{
} }
secondRowLeft={ secondRowLeft={
<div style={{"display":"inline-block", "marginTop": "22px"}}> <div style={{"display":"inline-block", "marginTop": "22px"}}>
<span> {mainList&&mainList.all_count} 作业</span> <span> {mainList&&mainList.all_count} {moduleChineseName}</span>
<span style={{"marginLeft":"16px"}}>已发布{published_count}</span> <span style={{"marginLeft":"16px"}}>已发布{published_count}</span>
{/* {this.props.isAdmin()?:""} */} {/* {this.props.isAdmin()?:""} */}
<span style={{"marginLeft":"16px"}}>未发布{unpublished_count}</span> <span style={{"marginLeft":"16px"}}>未发布{unpublished_count}</span>

@ -77,7 +77,7 @@ class GraduationTasksappraiseReplyChild extends Component{
{this.props.ultimate===true ? "": isAdmin && <GraduationTasksappraiseMainEditor {...this.props} {this.props.ultimate===true ? "": isAdmin && <GraduationTasksappraiseMainEditor {...this.props}
addSuccess={() => this.props.addSuccess()} addSuccess={() => this.props.addSuccess()}
showSameScore={true} showSameScore={this.props.task_type == 2}
></GraduationTasksappraiseMainEditor> } ></GraduationTasksappraiseMainEditor> }
</div> </div>

Loading…
Cancel
Save