hjm 5 years ago
commit 2168c0821a

@ -0,0 +1,268 @@
'use strict';
const autoprefixer = require('autoprefixer');
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
const eslintFormatter = require('react-dev-utils/eslintFormatter');
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
// const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
const getClientEnvironment = require('./env');
const paths = require('./paths');
// Webpack uses `publicPath` to determine where the app is being served from.
// In development, we always serve from the root. This makes config easier.
const publicPath = '/';
// `publicUrl` is just like `publicPath`, but we will provide it to our app
// as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
// Omit trailing slash as %PUBLIC_PATH%/xyz looks better than %PUBLIC_PATH%xyz.
const publicUrl = '';
// Get environment variables to inject into our app.
const env = getClientEnvironment(publicUrl);
// This is the development configuration.
// It is focused on developer experience and fast rebuilds.
// The production configuration is different and lives in a separate file.
module.exports = {
// You may want 'eval' instead if you prefer to see the compiled output in DevTools.
// See the discussion in https://github.com/facebookincubator/create-react-app/issues/343.
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.
// The first two entry points enable "hot" CSS and auto-refreshes for JS.
entry: [
// We ship a few polyfills by default:
require.resolve('./polyfills'),
// 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
// of CSS changes), or refresh the page (in case of JS changes). When you
// make a syntax error, this client will display a syntax error overlay.
// Note: instead of the default WebpackDevServer client, we use a custom one
// to bring better experience for Create React App users. You can replace
// 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'),
require.resolve('react-dev-utils/webpackHotDevClient'),
// Finally, this is your app's code:
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/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.
publicPath: publicPath,
// Point sourcemap entries to original disk location (format as URL on Windows)
devtoolModuleFilenameTemplate: info =>
path.resolve(info.absoluteResourcePath).replace(/\\/g, '/'),
},
resolve: {
// 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"
// if there are any conflicts. This matches Node resolution mechanism.
// https://github.com/facebookincubator/create-react-app/issues/253
modules: ['node_modules', paths.appNodeModules].concat(
// It is guaranteed to exist because we tweak it in `env.js`
process.env.NODE_PATH.split(path.delimiter).filter(Boolean)
),
// These are the reasonable defaults supported by the Node ecosystem.
// We also include JSX as a common component filename extension to support
// some tools, although we do not recommend using it, see:
// https://github.com/facebookincubator/create-react-app/issues/290
// `web` extension prefixes have been added for better support
// for React Native Web.
extensions: ['.web.js', '.mjs', '.js', '.json', '.web.jsx', '.jsx'],
alias: {
"educoder": __dirname + "/../src/common/educoder.js",
// Support React Native Web
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
'react-native': 'react-native-web',
},
plugins: [
// 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.
// To fix this, we prevent you from importing files out of src/ -- if you'd like to,
// 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]),
// MonacoEditor
// https://github.com/Microsoft/monaco-editor/blob/master/docs/integrate-esm.md
// https://github.com/Microsoft/monaco-editor-webpack-plugin/issues/56
// new MonacoWebpackPlugin(),
],
},
module: {
strictExportPresence: true,
rules: [
// 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.
// { parser: { requireEnsure: false } },
// First, run the linter.
// It's important to do this before Babel processes the JS.
// {
// test: /\.(js|jsx|mjs)$/,
// enforce: 'pre',
// use: [
// {
// options: {
// formatter: eslintFormatter,
// eslintPath: require.resolve('eslint'),
//
// },
// loader: require.resolve('eslint-loader'),
// },
// ],
// 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: [
// "url" loader works like "file" loader except that it embeds assets
// smaller than specified limit in bytes as data URLs to avoid requests.
// A missing `test` is equivalent to a match.
{
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
loader: require.resolve('url-loader'),
options: {
limit: 10000,
name: 'static/media/[name].[hash:8].[ext]',
},
},
// Process JS with Babel.
{
test: /\.(js|jsx|mjs)$/,
include: paths.appSrc,
loader: require.resolve('babel-loader'),
options: {
// This is a feature of `babel-loader` for webpack (not Babel itself).
// It enables caching results in ./node_modules/.cache/babel-loader/
// directory for faster rebuilds.
cacheDirectory: true,
},
},
// "postcss" loader applies autoprefixer to our CSS.
// "css" loader resolves paths in CSS and adds assets as dependencies.
// "style" loader turns CSS into JS modules that inject <style> tags.
// In production, we use a plugin to extract that CSS to a file, but
// in development "style" loader enables hot editing of CSS.
{
test: /\.css$/,
use: [
require.resolve('style-loader'),
{
loader: require.resolve('css-loader'),
options: {
importLoaders: 1,
},
},
{
loader: require.resolve('postcss-loader'),
options: {
// Necessary for external CSS imports to work
// https://github.com/facebookincubator/create-react-app/issues/2677
ident: 'postcss',
plugins: () => [
require('postcss-flexbugs-fixes'),
autoprefixer({
browsers: [
'>1%',
'last 4 versions',
'Firefox ESR',
'not ie < 9', // React doesn't support IE8 anyway
],
flexbox: 'no-2009',
}),
],
},
},
],
},
// "file" loader makes sure those assets get served by WebpackDevServer.
// When you `import` an asset, you get its (virtual) filename.
// In production, they would get copied to the `build` folder.
// This loader doesn't use a "test" so it will catch all modules
// that fall through the other loaders.
{
// Exclude `js` files to keep "css" loader working as it injects
// its runtime that would otherwise processed through "file" loader.
// Also exclude `html` and `json` extensions so they get processed
// by webpacks internal loaders.
exclude: [/\.(js|jsx|mjs)$/, /\.html$/, /\.json$/],
loader: require.resolve('file-loader'),
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.
],
},
plugins: [
// 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">
// In development, this will be an empty string.
new InterpolateHtmlPlugin(env.raw),
// Generates an `index.html` file with the <script> injected.
new HtmlWebpackPlugin({
inject: true,
template: paths.appHtml,
}),
// Add module names to factory functions so they appear in browser profiler.
new webpack.NamedModulesPlugin(),
// Makes some environment variables available to the JS code, for example:
// if (process.env.NODE_ENV === 'development') { ... }. See `./env.js`.
new webpack.DefinePlugin(env.stringified),
// This is necessary to emit hot updates (currently CSS only):
new webpack.HotModuleReplacementPlugin(),
// Watcher doesn't work well if you mistype casing in a path so we use
// a plugin that prints an error when you attempt to do this.
// See https://github.com/facebookincubator/create-react-app/issues/240
new CaseSensitivePathsPlugin(),
// If you require a missing module and then `npm install` it, you still have
// to restart the development server for Webpack to discover it. This plugin
// makes the discovery automatic so you don't have to restart.
// See https://github.com/facebookincubator/create-react-app/issues/186
new WatchMissingNodeModulesPlugin(paths.appNodeModules),
// 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',
},
// Turn off performance hints during development because we don't do any
// splitting or minification in interest of speed. These warnings become
// cumbersome.
performance: {
hints: false,
},
};

@ -0,0 +1,365 @@
'use strict';
const autoprefixer = require('autoprefixer');
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const ManifestPlugin = require('webpack-manifest-plugin');
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
const eslintFormatter = require('react-dev-utils/eslintFormatter');
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
const ParallelUglifyPlugin = require('webpack-parallel-uglify-plugin');
const paths = require('./paths');
const getClientEnvironment = require('./env');
// Webpack uses `publicPath` to determine where the app is being served from.
// It requires a trailing slash, or the file assets will get an incorrect path.
const publicPath = paths.servedPath;
// Some apps do not use client-side routing with pushState.
// For these, "homepage" can be set to "." to enable relative asset paths.
const shouldUseRelativeAssetPaths = publicPath === './';
// Source maps are resource heavy and can cause out of memory issue for large source files.
const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false';
// `publicUrl` is just like `publicPath`, but we will provide it to our app
// as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
// Omit trailing slash as %PUBLIC_URL%/xyz looks better than %PUBLIC_URL%xyz.
const publicUrl = publicPath.slice(0, -1);
// Get environment variables to inject into our app.
const env = getClientEnvironment(publicUrl);
// Assert this just to be safe.
// 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';
// ExtractTextPlugin expects the build output to be flat.
// (See https://github.com/webpack-contrib/extract-text-webpack-plugin/issues/27)
// However, our output is structured with css, js and media folders.
// To have this structure working with relative paths, we have to use custom options.
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.
// console.log('publicPath ', publicPath)
module.exports = {
// Don't attempt to continue if there are any errors.
bail: true,
// We generate sourcemaps in production. This is slow but gives good results.
// You can exclude the *.map files from the build during deployment.
// devtool: shouldUseSourceMap ? 'nosources-source-map' : false, //正式版
devtool: shouldUseSourceMap ? 'source-map' : false,//测试版
// In production, we only want to load the polyfills and the app code.
entry: [require.resolve('./polyfills'), paths.appIndexJs],
output: {
// The build folder.
path: paths.appBuild,
// Generated JS file names (with nested folders).
// There will be one main bundle, and one file per asynchronous chunk.
// We don't currently advertise code splitting but Webpack supports it.
filename: './static/js/[name].[chunkhash:8].js',
chunkFilename: './static/js/[name].[chunkhash:8].chunk.js',
// We inferred the "public path" (such as / or /my-project) from homepage.
// cdn
// 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
publicPath: '/react/build/', //publicPath, https://cdn.educoder.net
// Point sourcemap entries to original disk location (format as URL on Windows)
devtoolModuleFilenameTemplate: info =>
path
.relative(paths.appSrc, info.absoluteResourcePath)
.replace(/\\/g, '/'),
},
resolve: {
// 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"
// if there are any conflicts. This matches Node resolution mechanism.
// https://github.com/facebookincubator/create-react-app/issues/253
modules: ['node_modules', paths.appNodeModules].concat(
// It is guaranteed to exist because we tweak it in `env.js`
process.env.NODE_PATH.split(path.delimiter).filter(Boolean)
),
// These are the reasonable defaults supported by the Node ecosystem.
// We also include JSX as a common component filename extension to support
// some tools, although we do not recommend using it, see:
// https://github.com/facebookincubator/create-react-app/issues/290
// `web` extension prefixes have been added for better support
// for React Native Web.
extensions: ['.web.js', '.mjs', '.js', '.json', '.web.jsx', '.jsx'],
alias: {
"educoder": __dirname + "/../src/common/educoder.js",
// Support React Native Web
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
'react-native': 'react-native-web',
},
plugins: [
// 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.
// To fix this, we prevent you from importing files out of src/ -- if you'd like to,
// 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: [
// 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.
// { parser: { requireEnsure: false } },
// First, run the linter.
// It's important to do this before Babel processes the JS.
// {
// test: /\.(js|jsx|mjs)$/,
// enforce: 'pre',
// use: [
// {
// options: {
// formatter: eslintFormatter,
// eslintPath: require.resolve('eslint'),
//
// },
// loader: require.resolve('eslint-loader'),
// },
// ],
// 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: [
// "url" loader works just like "file" loader but it also embeds
// assets smaller than specified size as data URLs to avoid requests.
{
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
loader: require.resolve('url-loader'),
options: {
limit: 10000,
name: 'static/media/[name].[hash:8].[ext]',
},
},
// Process JS with Babel.
{
test: /\.(js|jsx|mjs)$/,
include: paths.appSrc,
loader: require.resolve('babel-loader'),
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.
// "style" loader normally turns CSS into JS modules injecting <style>,
// but unlike in development configuration, we do something different.
// `ExtractTextPlugin` first applies the "postcss" and "css" loaders
// (second argument), then grabs the result CSS and puts it into a
// separate file in our build process. This way we actually ship
// a single CSS file in production instead of JS code injecting <style>
// 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
// in the main CSS file.
{
test: /\.css$/,
loader: ExtractTextPlugin.extract(
Object.assign(
{
fallback: {
loader: require.resolve('style-loader'),
options: {
hmr: false,
},
},
use: [
{
loader: require.resolve('css-loader'),
options: {
importLoaders: 1,
minimize: true,
sourceMap: shouldUseSourceMap,
},
},
{
loader: require.resolve('postcss-loader'),
options: {
// Necessary for external CSS imports to work
// https://github.com/facebookincubator/create-react-app/issues/2677
ident: 'postcss',
plugins: () => [
require('postcss-flexbugs-fixes'),
autoprefixer({
browsers: [
'>1%',
'last 4 versions',
'Firefox ESR',
'not ie < 9', // React doesn't support IE8 anyway
],
flexbox: 'no-2009',
}),
],
},
},
],
},
extractTextPluginOptions
)
),
// Note: this won't work without `new ExtractTextPlugin()` in `plugins`.
},
// "file" loader makes sure assets end up in the `build` folder.
// When you `import` an asset, you get its filename.
// This loader doesn't use a "test" so it will catch all modules
// that fall through the other loaders.
{
loader: require.resolve('file-loader'),
// Exclude `js` files to keep "css" loader working as it injects
// it's runtime that would otherwise processed through "file" loader.
// Also exclude `html` and `json` extensions so they get processed
// by webpacks internal loaders.
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.
],
},
],
},
plugins: [
// 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">
// In production, it will be an empty string unless you specify "homepage"
// in `package.json`, in which case it will be the pathname of that URL.
new InterpolateHtmlPlugin(env.raw),
// Generates an `index.html` file with the <script> injected.
new HtmlWebpackPlugin({
inject: true,
template: paths.appHtml,
minify: {
removeComments: true,
collapseWhitespace: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeStyleLinkTypeAttributes: true,
keepClosingSlash: 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.
// Otherwise React will be compiled in the very slow development mode.
new webpack.DefinePlugin(env.stringified),
// Minify the code.
// new webpack.optimize.UglifyJsPlugin({
// compress: {
// warnings: false,
// // Disabled because of an issue with Uglify breaking seemingly valid code:
// // https://github.com/facebookincubator/create-react-app/issues/2376
// // Pending further investigation:
// // https://github.com/mishoo/UglifyJS2/issues/2011
// comparisons: false,
// },
// mangle: {
// safari10: true,
// },
// output: {
// comments: false,
// // Turned on because emoji and regex is not minified properly using default
// // https://github.com/facebookincubator/create-react-app/issues/2488
// ascii_only: true,
// },
// sourceMap: shouldUseSourceMap,
// }),
//正式版上线后打开去掉debuger和console
new ParallelUglifyPlugin({
cacheDir: '.cache/',
uglifyJS:{
output: {
comments: false
},
warnings: false,
compress: {
drop_debugger: false,
drop_console: false
}
}
}),
// Note: this won't work without ExtractTextPlugin.extract(..) in `loaders`.
new ExtractTextPlugin({
filename: cssFilename,
}),
// Generate a manifest file which contains a mapping of all asset filenames
// to their corresponding output file so that tools can pick it up without
// having to parse `index.html`.
new ManifestPlugin({
fileName: 'asset-manifest.json',
}),
// Generate a service worker script that will precache, and keep up to date,
// the HTML & assets that are part of the Webpack build.
new SWPrecacheWebpackPlugin({
// 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.
dontCacheBustUrlsMatching: /\.\w{8}\./,
filename: 'service-worker.js',
logger(message) {
if (message.indexOf('Total precache size is') === 0) {
// This message occurs for every build and is a bit too noisy.
return;
}
if (message.indexOf('Skipping static resource') === 0) {
// This message obscures real errors so we ignore it.
// https://github.com/facebookincubator/create-react-app/issues/2612
return;
}
// console.log(message);
},
minify: true,
// For unknown URLs, fallback to the index page
navigateFallback: publicUrl + '/index.html',
// Ignores URLs starting from /__ (useful for Firebase):
// https://github.com/facebookincubator/create-react-app/issues/2237#issuecomment-302693219
navigateFallbackWhitelist: [/^(?!\/__).*/],
// Don't precache sourcemaps (they're large) and build asset manifest:
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',
},
};

@ -8,7 +8,7 @@ class Loading extends Component {
render() {
// Loading
return (
<div className="App" style={{minHeight: '800px'}}>
<div className="App" style={{minHeight: '800px',width:"100%"}}>
<style>
{
`

@ -8,7 +8,7 @@ import './pollStyle.css'
import update from 'immutability-helper'
import axios from 'axios'
const map={1:"单选题",2:"多选题",3:"主观题"}
const map={1:"单选题",2:"多选题",3:"主观题",4:"主观题"}
class PollDetailTabSecond extends Component{
constructor(props){
super(props);

@ -753,7 +753,7 @@ submittojoinclass=(value)=>{
<li><Link to={`/users/${this.props.current_user===undefined?"":this.props.current_user.login}/shixuns`}>我的实训</Link></li>
<li><Link to={`/users/${this.props.current_user===undefined?"":this.props.current_user.login}/paths`}>我的实践课程</Link></li>
<li><Link to={`/users/${this.props.current_user===undefined?"":this.props.current_user.login}/projects`}>我的项目</Link></li>
<li><a href={this.props.Headertop===undefined?"":this.props.Headertop.account_manager_url}>账号管理</a></li>
<li><a href={`/account/basic`}>账号管理</a></li>
{/*<li><a onClick={()=>this.educoderlogin()} >登入测试接口</a></li>*/}
{/*<li><a onClick={()=>this.trialapplications()} >试用申请</a> </li>*/}
{/*<li><Link to={`/interest`}>兴趣页</Link></li>*/}

@ -54,12 +54,12 @@ class AccountPage extends Component {
let url=`/users/accounts/${login || this.props.current_user.login}.json`;
axios.get(url).then((result)=>{
if(result.data){
this.setState({
basicInfo: Object.assign({}, {...result.data}, { avatar_url: `${result.data.avatar_url}?t=${new Date().getTime()}`})
})
if(result.data && result.data.base_info_completed == false){
this.props.history.push(`/account/basic/edit`);
}
this.setState({
basicInfo: Object.assign({}, {...result.data}, { avatar_url: `${result.data.avatar_url}?t=${new Date().getTime()}`})
})
}
}).catch((error)=>{
console.log(error);

@ -21,40 +21,45 @@ class AccountNav extends Component {
const isSecure = path.indexOf('secure') != -1
return (
<div className="accountNav fl">
<div className="accountInfo">
<AccountImg src={basicInfo && basicInfo.avatar_url} {...this.props}></AccountImg>
<span className="name">{basicInfo && basicInfo.name}</span>
<span className="role">{basicInfo && basicInfo.technical_title}</span>
</div>
{
basicInfo &&
<React.Fragment>
<div className="accountInfo">
<AccountImg src={basicInfo.avatar_url} {...this.props}></AccountImg>
<span className="name">{basicInfo.name}</span>
<span className="role">{basicInfo.technical_title}</span>
</div>
<div className="accountManagement">
<div className="title">账号管理</div>
<ul>
<li className={`navItem ${isBasic ? 'active' : ''}`} onClick={this.toBasic}>
<i className="iconfont icon-jibenxinxi color-grey-9 font-16"></i>
基本信息
{
basicInfo && (basicInfo.authentication == 'uncertified' || basicInfo.authentication == 'applying') &&
<i className="status fr iconfont icon-tishi color-red font-16"></i>
}
{
basicInfo && basicInfo.authentication == 'certified' &&
<i className="status fr iconfont icon-wancheng color-green-light font-16"></i>
}
</li>
<li className={`navItem ${isCertification ? 'active' : ''}`} onClick={this.toCertification}>
<i className="iconfont icon-renzhengxinxi color-grey-9 font-16"></i>
{
basicInfo && basicInfo.professional_certification == 'certified' && basicInfo.authentication == 'certified' ?
<i className="status fr iconfont icon-wancheng color-green-light font-16"></i>:
<i className="status fr iconfont icon-tishi color-red font-16"></i>
}
</li>
<li className={`navItem ${isSecure ? 'active' : ''}`} onClick={this.toSecure}>
<i className="iconfont icon-anquanshezhi color-grey-9 font-16"></i>
</li>
</ul>
</div>
<div className="accountManagement">
<div className="title">账号管理</div>
<ul>
<li className={`navItem ${isBasic ? 'active' : ''}`} onClick={this.toBasic}>
<i className="iconfont icon-jibenxinxi color-grey-9 font-16"></i>
基本信息
{
(basicInfo.authentication == 'uncertified' || basicInfo.authentication == 'applying') &&
<i className="status fr iconfont icon-tishi color-red font-16"></i>
}
{
basicInfo.authentication == 'certified' &&
<i className="status fr iconfont icon-wancheng color-green-light font-16"></i>
}
</li>
<li className={`navItem ${isCertification ? 'active' : ''}`} onClick={this.toCertification}>
<i className="iconfont icon-renzhengxinxi color-grey-9 font-16"></i>
{
basicInfo.professional_certification == 'certified' && basicInfo.authentication == 'certified' ?
<i className="status fr iconfont icon-wancheng color-green-light font-16"></i>:
<i className="status fr iconfont icon-tishi color-red font-16"></i>
}
</li>
<li className={`navItem ${isSecure ? 'active' : ''}`} onClick={this.toSecure}>
<i className="iconfont icon-anquanshezhi color-grey-9 font-16"></i>
</li>
</ul>
</div>
</React.Fragment>
}
</div>
);
}

@ -27,20 +27,72 @@ class AccountSecure extends Component {
constructor (props) {
super(props)
this.state = {
updating: ''
updating: '',
secondsFlag:false,
seconds:60
}
}
// 获取验证码倒计时
remainTime=()=>{
this.timer = setInterval(() => {
let { seconds } =this.state;
let s = parseInt(seconds)-1;
if(s > -1){
this.setState({
seconds:s
})
}else{
this.setState({
secondsFlag:false
})
clearInterval(this.timer);
}
},1000)
}
// 获取验证码
getCode=(index)=>{
let url=`/account/get_verification_code.json`
let login = '';
let values=this.props.form.getFieldsValue();
if(index == 3){
//绑定手机号码
let values=this.props.form.getFieldsValue();
console.log(values);
login=values.phone;
let reg=/^1\d{10}$/;
if(reg.test(login)==false){
this.props.showNotification(`请先输入正确的手机号码`);
return;
}
}else if(index == 4){
// 绑定邮箱
login=values.email;
let reg=/^[a-zA-Z0-9]+([.\-_\\]*[a-zA-Z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/;
if(reg.test(login)==false){
this.props.showNotification(`请先输入正确的邮箱地址`);
return;
}
}
let type = index;
if(!login){
this.props.showNotification(`请先输入${index==3?"手机号码":"邮箱地址"}`);
return;
}
axios.get((url),{params:{
login,type
}}).then((result)=>{
if(result){
// 倒计时
this.setState({
secondsFlag:true
})
this.remainTime();
}
}).catch((error)=>{
console.log(error);
})
}
// 绑定手机
onPhoneSubmit = () => {
this.props.form.validateFieldsAndScroll((err, values) => {
if (!err) {
@ -68,17 +120,62 @@ class AccountSecure extends Component {
}
})
}
// 绑定邮箱
onEmailSubmit = () => {
this.props.form.validateFieldsAndScroll((err, values) => {
if (!err) {
let {login}=this.props.current_user;
let reg=/^[a-zA-Z0-9]+([.\-_\\]*[a-zA-Z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/;
if(reg.test(values.email)){
let url=`/users/accounts/${login}/email_bind.json`
axios.post((url),{
email:values.email,
code:values.emailValidateCode
}).then((result)=>{
if(result){
this.props.showNotification("邮箱地址绑定成功!");
this.setState({
updating:''
})
this.props.getBasicInfo();
}
}).catch((error)=>{
console.log(error);
})
}else{
this.props.showNotification("请输入正确的邮箱地址");
}
}
})
}
onPasswordSubmit = () => {
this.props.form.validateFieldsAndScroll((err, values) => {
if (!err) {
if(values.p_old == values.p_new){
this.props.showNotification("新密码不能与旧密码相同!");
return;
}
if(values.p_again != values.p_new){
this.props.showNotification("两次输入的新密码必须一致!");
return;
}
let {login}=this.props.current_user;
let url=`/users/accounts/${login}/password.json`;
axios.put((url),{
old_password:values.p_old,
password:values.p_new
}).then((result)=>{
if(result){
this.props.showNotification("密码更新成功!");
this.setState({
updating:''
})
this.props.getBasicInfo();
}
}).catch((error)=>{
console.log(error);
})
}
})
}
@ -90,13 +187,31 @@ class AccountSecure extends Component {
})
}
// 修改密码-判断规则
comfirmNewPassword=(rule,value,callback)=>{
const { form } = this.props;
if (value != form.getFieldsValue().p_new) {
callback("两次输入的新密码必须一致!");
}else {
callback();
}
}
InputNewPassword=(rule,value,callback)=>{
const { form } = this.props;
if (value.length<8 || value.length>12) {
callback("请输入8-12个字符的新密码区分大小写");
}else {
callback();
}
}
render() {
let {basicInfo}=this.props;
const { getFieldDecorator } = this.props.form;
const { updating } = this.state
const { updating,seconds,secondsFlag } = this.state
return (
<div className="basicFormWrap">
<div className="basicForm settingForm">
<style>{`
@ -116,7 +231,7 @@ class AccountSecure extends Component {
color: #CDCDCD;
}
.description span {
margin-right: 8px;
margin-right: 20px;
color: #05101A;
}
.flexRow .status {
@ -210,7 +325,9 @@ class AccountSecure extends Component {
})(
<Input placeholder="请输入手机获取的验证码" className="validateInput"></Input>
)}
<Button type="primary" onClick={()=>this.getCode(3)}>获取验证码</Button>
<Button type="primary" disabled={ secondsFlag } onClick={()=>this.getCode(3)}>
{ !secondsFlag ? "获取验证码":`重新发送${seconds}s`}
</Button>
</Form.Item>
<div className="mb20" style={{ marginLeft: '118px' }}>
@ -248,14 +365,14 @@ class AccountSecure extends Component {
label="邮箱地址"
className="formItemInline hideRequireTag mb20"
>
{getFieldDecorator('phone', {
{getFieldDecorator('email', {
rules: [{
// initialValue: this.state.cityDefaultValue,
required: true,
message: '请输入要更换的新邮箱地址',
message: basicInfo && basicInfo.mail ?'请输入要更换的新邮箱地址':'请输入邮箱地址',
}],
})(
<Input placeholder="请输入要更换的新邮箱地址"></Input>
<Input placeholder={`${basicInfo && basicInfo.mail ?'请输入要更换的新邮箱地址':'请输入邮箱地址'}`}></Input>
)}
</Form.Item>
@ -263,7 +380,7 @@ class AccountSecure extends Component {
label="邮箱验证码"
className="mb20 formItemInline hideRequireTag"
>
{getFieldDecorator('phoneValidateCode', {
{getFieldDecorator('emailValidateCode', {
rules: [{
// initialValue: this.state.cityDefaultValue,
required: true,
@ -272,7 +389,8 @@ class AccountSecure extends Component {
})(
<Input placeholder="请输入邮箱收到的验证码" className="validateInput"></Input>
)}
<Button type="primary">获取验证码</Button>
<Button type="primary" disabled={ secondsFlag } onClick={()=>this.getCode(4)}>
{ !secondsFlag ? "获取验证码":`重新发送${seconds}s`}</Button>
</Form.Item>
<div className="mb20" style={{ marginLeft: '118px' }}>
@ -314,7 +432,7 @@ class AccountSecure extends Component {
message: '请设置816位密码区分大小写',
}],
})(
<Input type="password" placeholder="请设置816位密码区分大小写"></Input>
<Input type="password" placeholder="请设置816位密码区分大小写" autoComplete="new-password"></Input>
)}
</Form.Item>
@ -326,10 +444,12 @@ class AccountSecure extends Component {
rules: [{
// initialValue: this.state.cityDefaultValue,
required: true,
message: '请设置816位密码区分大小写',
message: '请输入816位的新密码区分大小写',
},{
validator:this.InputNewPassword
}],
})(
<Input type="password" placeholder="请设置816位密码区分大小写" className="validateInput"></Input>
<Input type="password" placeholder="请输入816位的新密码区分大小写" autoComplete="new-password"></Input>
)}
</Form.Item>
@ -342,9 +462,11 @@ class AccountSecure extends Component {
// initialValue: this.state.cityDefaultValue,
required: true,
message: '请再次输入新密码',
},{
validator:this.comfirmNewPassword
}],
})(
<Input type="password" placeholder="请再次输入新密码" className="validateInput"></Input>
<Input type="password" placeholder="请再次输入新密码" autoComplete="new-password"></Input>
)}
</Form.Item>

@ -46,8 +46,42 @@ class RealNameCertificationModal extends Component{
console.log(values);
if(!err){
let{imageUrl2}=this.state;
let{current_user,basicInfo}=this.props;
if(imageUrl2){
let { certification } = this.props;
if(certification == 1){
// 实名认证
let url = `/users/accounts/${current_user && current_user.login}/authentication_apply.json`
axios.post((url),{
name:basicInfo.name,
id_number:values.credentials
}).then((result)=>{
if(result){
this.props.showNotification("申请已提交,请等待审核!");
this.props.getBasicInfo();
this.setVisible(false);
}
}).catch((error)=>{
console.log(error);
})
}else{
// 职业认证
let url = `/users/accounts/${current_user && current_user.login}/professional_auth_apply.json`
axios.post((url),{
school_id:basicInfo && basicInfo.school_id,
department_id:basicInfo && basicInfo.department_id,
identity:basicInfo && basicInfo.identity,
extra:basicInfo && basicInfo.identity == "student" ? basicInfo.student_id:basicInfo.technical_title
}).then((result)=>{
if(result){
this.props.showNotification("申请已提交,请等待审核!");
this.props.getBasicInfo();
this.setVisible(false);
}
}).catch((error)=>{
console.log(error);
})
}
}else{
this.props.showNotification("请先上传照片!");
}
@ -261,7 +295,7 @@ class RealNameCertificationModal extends Component{
</span>
<Dragger {...uploadProps2}>
{imageUrl2 ?
<a href={imageUrl2} target="_blank">
<a href={imageUrl2} target="_blank" title="点击重新上传图片">
<img src={imageUrl2} alt="avatar" style={{ maxHeight: '110px'}}/>
</a> :
<React.Fragment>

Loading…
Cancel
Save