Merge branch 'master' of https://bdgit.educoder.net/Hjqreturn/educoder
commit
d50af67946
@ -1,56 +1,57 @@
|
||||
# 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
|
||||
# or operating system, you probably want to add a global ignore instead:
|
||||
# git config --global core.excludesfile '~/.gitignore_global'
|
||||
|
||||
# Ignore bundler config.
|
||||
/.bundle
|
||||
|
||||
# mac
|
||||
*.DS_Store
|
||||
|
||||
# Ignore all logfiles and tempfiles.
|
||||
/log/*
|
||||
/tmp/*
|
||||
!/log/.keep
|
||||
!/tmp/.keep
|
||||
|
||||
# Ignore uploaded files in development
|
||||
/storage/*
|
||||
|
||||
/node_modules
|
||||
/yarn-error.log
|
||||
|
||||
# /public/assets
|
||||
.byebug_history
|
||||
|
||||
# Ignore master key for decrypting credentials and more.
|
||||
/config/master.key
|
||||
/config/database.yml
|
||||
/.idea/*
|
||||
|
||||
# Ignore react node_modules
|
||||
/public/react/build
|
||||
/public/react/build/
|
||||
/public/react/node_modules/
|
||||
/public/react/config/stats.json
|
||||
/public/react/stats.json
|
||||
|
||||
/public/npm-debug.log
|
||||
|
||||
# avatars
|
||||
/public/images/avatars
|
||||
|
||||
/config/secrets.yml
|
||||
/files/archiveZip/*
|
||||
/files/cache_store/*
|
||||
public/upload.html
|
||||
/config/configuration.yml
|
||||
/config/initializers/gitlab_config.rb
|
||||
/db/schema.rb
|
||||
.vscode/
|
||||
vendor/bundle/
|
||||
.ruby-version
|
||||
.ruby-gemset
|
||||
|
||||
# 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
|
||||
# or operating system, you probably want to add a global ignore instead:
|
||||
# git config --global core.excludesfile '~/.gitignore_global'
|
||||
|
||||
# Ignore bundler config.
|
||||
/.bundle
|
||||
|
||||
# mac
|
||||
*.DS_Store
|
||||
|
||||
# Ignore all logfiles and tempfiles.
|
||||
/log/*
|
||||
/tmp/*
|
||||
!/log/.keep
|
||||
!/tmp/.keep
|
||||
|
||||
# Ignore uploaded files in development
|
||||
/storage/*
|
||||
|
||||
/node_modules
|
||||
/yarn-error.log
|
||||
|
||||
# /public/assets
|
||||
.byebug_history
|
||||
|
||||
# Ignore master key for decrypting credentials and more.
|
||||
/config/master.key
|
||||
/config/database.yml
|
||||
/.idea/*
|
||||
|
||||
# Ignore react node_modules
|
||||
/public/react/build
|
||||
/public/react/build/
|
||||
/public/react/.cache
|
||||
/public/react/node_modules/
|
||||
/public/react/config/stats.json
|
||||
/public/react/stats.json
|
||||
|
||||
/public/npm-debug.log
|
||||
|
||||
# avatars
|
||||
/public/images/avatars
|
||||
|
||||
/config/secrets.yml
|
||||
/files/archiveZip/*
|
||||
/files/cache_store/*
|
||||
public/upload.html
|
||||
/config/configuration.yml
|
||||
/config/initializers/gitlab_config.rb
|
||||
/db/schema.rb
|
||||
.vscode/
|
||||
vendor/bundle/
|
||||
.ruby-version
|
||||
.ruby-gemset
|
||||
|
||||
|
@ -1,349 +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 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,
|
||||
}),
|
||||
// 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',
|
||||
},
|
||||
};
|
||||
'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',
|
||||
},
|
||||
};
|
||||
|
@ -1,205 +1,205 @@
|
||||
import React, { Component } from 'react';
|
||||
|
||||
import { BrowserRouter as Router, Route, Link } from "react-router-dom";
|
||||
|
||||
import axios from 'axios';
|
||||
|
||||
import { getImageUrl,} from "educoder";
|
||||
|
||||
import './TPMright.css';
|
||||
|
||||
import {Icon,Tooltip} from 'antd';
|
||||
|
||||
// import "antd/dist/antd.css";
|
||||
|
||||
class TPMRightSection extends Component {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
this.state = {
|
||||
|
||||
TPMRightSection:false,
|
||||
clickNewsubscripttype:false
|
||||
}
|
||||
}
|
||||
|
||||
// componentDidMount() {
|
||||
// let id=this.props.match.params.shixunId;
|
||||
//
|
||||
// let shixunsDetailsURL=`/shixuns/`+id+`/show_right.json`;
|
||||
//
|
||||
// axios.get(shixunsDetailsURL).then((response)=> {
|
||||
// if(response.status===200){
|
||||
// this.setState({
|
||||
// TPMRightSectionData: response.data
|
||||
// });
|
||||
// }
|
||||
// }).catch((error)=>{
|
||||
// console.log(error)
|
||||
// });
|
||||
// }
|
||||
|
||||
// shouldComponentUpdate(nextProps, nextState) {
|
||||
// return nextProps.TPMRightSectionData !== this.state.TPMRightSectionData
|
||||
// }
|
||||
clickNewsubscript=(val)=>{
|
||||
if(val===0){
|
||||
this.setState({
|
||||
TPMRightSection:true,
|
||||
clickNewsubscripttype:true
|
||||
})
|
||||
}else{
|
||||
this.setState({
|
||||
TPMRightSection:false,
|
||||
clickNewsubscripttype:false
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
render() {
|
||||
let {TPMRightSection,clickNewsubscripttype}=this.state;
|
||||
let {TPMRightSectionData}=this.props
|
||||
|
||||
return (
|
||||
<div>
|
||||
{
|
||||
TPMRightSectionData===undefined?"":
|
||||
<div>
|
||||
<div className="edu-back-white padding40-20 mb10">
|
||||
<p className="font-16 mb20">创建者</p>
|
||||
<div className="df">
|
||||
<a href={TPMRightSectionData===undefined?"":TPMRightSectionData.creator===undefined?"":TPMRightSectionData.creator.user_url}>
|
||||
<img alt="头像" className="radius mr10" height="80" src={getImageUrl(TPMRightSectionData===undefined?"":TPMRightSectionData.creator===undefined?"":'images/'+TPMRightSectionData.creator.image_url+"?1532489442")} width="80" />
|
||||
</a>
|
||||
<div className="flex1">
|
||||
|
||||
<p className="mb20">{TPMRightSectionData===undefined?"":TPMRightSectionData.creator===undefined?"":TPMRightSectionData.creator.name}</p>
|
||||
<div className="clearfix">
|
||||
<span>发布 {TPMRightSectionData.user_shixuns_count}</span>
|
||||
{/*<span className="ml20">粉丝 <span id="user_h_fan_count">{TPMRightSectionData.fans_count}</span></span>*/}
|
||||
{/* <a href="/watchers/unwatch?className=fr+user_watch_btn+edu-default-btn+edu-focus-btn&object_id=3039&object_type=user&shixun_id=61&target_id=3039" className="fr edu-default-btn user_watch_btn edu-focus-btn" data-method="post" data-remote="true" id="cancel_watch" rel="nofollow">取消关注</a> */}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{
|
||||
TPMRightSectionData === undefined ? "" :TPMRightSectionData.tags===undefined?"": TPMRightSectionData.tags.length === 0 ? "" :
|
||||
<div className="edu-back-white padding40-20 mb10 relative">
|
||||
<p className="font-16 mb20">技能标签 <span className="color-grey-c">{TPMRightSectionData.tags.length}</span></p>
|
||||
<div className={TPMRightSection===false?"newedbox newedboxheight":"newedbox newminheight"}>
|
||||
<div className="clearfix" id="boxheight">
|
||||
{ TPMRightSectionData.tags.map((item,key)=>{
|
||||
return(
|
||||
<span className={item.status===false?"newedu-filter-btn fl":"edu-filter-btn29BD8B fl"}
|
||||
style={{display:item.tag_name===" "||item.tag_name===""?"none":""}}
|
||||
key={key}>{item.tag_name}</span>
|
||||
)})
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div className={TPMRightSectionData.tags.length>15&&clickNewsubscripttype===false?"newsubscript mb9 color-grey-9":"newsubscript mb9 color-grey-9 none"}
|
||||
|
||||
data-tip-down="显示全部"
|
||||
onClick={()=>this.clickNewsubscript(0)}><span className="mr8">...</span><Icon type="caret-down" />
|
||||
</div>
|
||||
|
||||
|
||||
<div className={clickNewsubscripttype===false?"newsubscript mb9 color-grey-9 none":"newsubscript mb9 color-grey-9"}
|
||||
|
||||
data-tip-down="显示全部"
|
||||
onClick={()=>this.clickNewsubscript(1)}><Icon type="caret-up" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
}
|
||||
|
||||
<div className="padding20 edu-back-white"
|
||||
style={{
|
||||
display:
|
||||
TPMRightSectionData === undefined?"none":TPMRightSectionData.recommands===undefined?"none":TPMRightSectionData.recommands.length === 0 ? "none" : "block"
|
||||
}}
|
||||
>
|
||||
<p className="mb20 font-16 clearfix">推荐实训</p>
|
||||
<div className="recommend-list">
|
||||
{
|
||||
TPMRightSectionData===undefined?"":TPMRightSectionData.recommands===undefined?"":TPMRightSectionData.recommands.map((item,key)=>{
|
||||
return(
|
||||
<div className="recomments clearfix df" key={key}>
|
||||
<a href={"/shixuns/"+item.identifier+"/challenges"} target="_blank">
|
||||
<img alt="69?1526971094" height="96" src={item.pic} width="128"/>
|
||||
</a>
|
||||
<div className="ml10 flex1">
|
||||
<Tooltip placement="bottom" title={item.name}>
|
||||
<a href={"/shixuns/"+item.identifier+"/challenges"} target="_blank" className="color-grey-6 task-hide mb12 recomment-name">{item.name}</a>
|
||||
</Tooltip>
|
||||
<p className="clearfix mt8 font-12 color-grey-B4">
|
||||
{item.stu_num} 人学习
|
||||
</p>
|
||||
<p className="edu-txt-right color-orange pr10">{item.level}</p>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
})
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="padding20 edu-back-white mb10 mt10" style={{
|
||||
display: TPMRightSectionData === undefined?"none":TPMRightSectionData.paths===undefined?"":TPMRightSectionData.paths.length === 0 ? "none" : "block"
|
||||
}}>
|
||||
<p className="mb20 font-16 clearfix">相关实训课程</p>
|
||||
<div className="recommend-list" >
|
||||
{
|
||||
TPMRightSectionData===undefined?"":TPMRightSectionData.paths===undefined?"":TPMRightSectionData.paths.map((i,k)=>{
|
||||
|
||||
return(
|
||||
|
||||
<div className="recomments clearfix df" key={k}>
|
||||
|
||||
<a href={"/paths/"+i.id} height="96" width="128" target="_blank">
|
||||
<img alt="实训" height="96" src={i.image_url} width="128" />
|
||||
</a>
|
||||
|
||||
<div className="ml10 flex1">
|
||||
<a href={"/paths/"+i.id} target="_blank" data-tip-down={i.name} className="color-grey-6 task-hide mb12 recomment-name">{i.name}</a>
|
||||
<p className="clearfix mt8 font-12 color-grey-B4">
|
||||
|
||||
<Tooltip placement="bottom" title={"章节"}>
|
||||
<span className="mr10 fl squareIconSpan"><i className="iconfont icon-shixun fl mr3"></i>{i.stages_count}</span>
|
||||
</Tooltip>
|
||||
|
||||
{/*<Tooltip placement="bottom" title={"经验值"}>*/}
|
||||
{/*<span className="mr10 fl squareIconSpan"><i className="iconfont icon-jingyan fl mr3"></i>{i.score_count}</span>*/}
|
||||
{/*</Tooltip>*/}
|
||||
|
||||
<Tooltip placement="bottom" title={"学习人数"}>
|
||||
<span className="mr10 fl squareIconSpan"><i className="iconfont icon-chengyuan fl mr3"></i>{i.members_count}</span>
|
||||
</Tooltip>
|
||||
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
)
|
||||
})
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
)
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export default TPMRightSection;
|
||||
import React, { Component } from 'react';
|
||||
|
||||
import { BrowserRouter as Router, Route, Link } from "react-router-dom";
|
||||
|
||||
import axios from 'axios';
|
||||
|
||||
import { getImageUrl,} from "educoder";
|
||||
|
||||
import './TPMright.css';
|
||||
|
||||
import {Icon,Tooltip} from 'antd';
|
||||
|
||||
// import "antd/dist/antd.css";
|
||||
|
||||
class TPMRightSection extends Component {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
this.state = {
|
||||
|
||||
TPMRightSection:false,
|
||||
clickNewsubscripttype:false
|
||||
}
|
||||
}
|
||||
|
||||
// componentDidMount() {
|
||||
// let id=this.props.match.params.shixunId;
|
||||
//
|
||||
// let shixunsDetailsURL=`/shixuns/`+id+`/show_right.json`;
|
||||
//
|
||||
// axios.get(shixunsDetailsURL).then((response)=> {
|
||||
// if(response.status===200){
|
||||
// this.setState({
|
||||
// TPMRightSectionData: response.data
|
||||
// });
|
||||
// }
|
||||
// }).catch((error)=>{
|
||||
// console.log(error)
|
||||
// });
|
||||
// }
|
||||
|
||||
// shouldComponentUpdate(nextProps, nextState) {
|
||||
// return nextProps.TPMRightSectionData !== this.state.TPMRightSectionData
|
||||
// }
|
||||
clickNewsubscript=(val)=>{
|
||||
if(val===0){
|
||||
this.setState({
|
||||
TPMRightSection:true,
|
||||
clickNewsubscripttype:true
|
||||
})
|
||||
}else{
|
||||
this.setState({
|
||||
TPMRightSection:false,
|
||||
clickNewsubscripttype:false
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
render() {
|
||||
let {TPMRightSection,clickNewsubscripttype}=this.state;
|
||||
let {TPMRightSectionData}=this.props
|
||||
|
||||
return (
|
||||
<div>
|
||||
{
|
||||
TPMRightSectionData===undefined?"":
|
||||
<div>
|
||||
<div className="edu-back-white padding40-20 mb10">
|
||||
<p className="font-16 mb20">创建者</p>
|
||||
<div className="df">
|
||||
<a href={TPMRightSectionData===undefined?"":TPMRightSectionData.creator===undefined?"":TPMRightSectionData.creator.user_url}>
|
||||
<img alt="头像" className="radius mr10" height="80" src={getImageUrl(TPMRightSectionData===undefined?"":TPMRightSectionData.creator===undefined?"":'images/'+TPMRightSectionData.creator.image_url+"?1532489442")} width="80" />
|
||||
</a>
|
||||
<div className="flex1">
|
||||
|
||||
<p className="mb20">{TPMRightSectionData===undefined?"":TPMRightSectionData.creator===undefined?"":TPMRightSectionData.creator.name}</p>
|
||||
<div className="clearfix">
|
||||
<span>发布 {TPMRightSectionData.user_shixuns_count}</span>
|
||||
{/*<span className="ml20">粉丝 <span id="user_h_fan_count">{TPMRightSectionData.fans_count}</span></span>*/}
|
||||
{/* <a href="/watchers/unwatch?className=fr+user_watch_btn+edu-default-btn+edu-focus-btn&object_id=3039&object_type=user&shixun_id=61&target_id=3039" className="fr edu-default-btn user_watch_btn edu-focus-btn" data-method="post" data-remote="true" id="cancel_watch" rel="nofollow">取消关注</a> */}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{
|
||||
TPMRightSectionData === undefined ? "" :TPMRightSectionData.tags===undefined?"": TPMRightSectionData.tags.length === 0 ? "" :
|
||||
<div className="edu-back-white padding40-20 mb10 relative">
|
||||
<p className="font-16 mb20">技能标签 <span className="color-grey-c">{TPMRightSectionData.tags.length}</span></p>
|
||||
<div className={TPMRightSection===false?"newedbox newedboxheight":"newedbox newminheight"}>
|
||||
<div className="clearfix" id="boxheight">
|
||||
{ TPMRightSectionData.tags.map((item,key)=>{
|
||||
return(
|
||||
<span className={item.status===false?"newedu-filter-btn fl":"edu-filter-btn29BD8B fl"}
|
||||
style={{display:item.tag_name===" "||item.tag_name===""?"none":""}}
|
||||
key={key}>{item.tag_name}</span>
|
||||
)})
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div className={TPMRightSectionData.tags.length>15&&clickNewsubscripttype===false?"newsubscript mb9 color-grey-9":"newsubscript mb9 color-grey-9 none"}
|
||||
|
||||
data-tip-down="显示全部"
|
||||
onClick={()=>this.clickNewsubscript(0)}><span className="mr8">...</span><Icon type="caret-down" />
|
||||
</div>
|
||||
|
||||
|
||||
<div className={clickNewsubscripttype===false?"newsubscript mb9 color-grey-9 none":"newsubscript mb9 color-grey-9"}
|
||||
|
||||
data-tip-down="显示全部"
|
||||
onClick={()=>this.clickNewsubscript(1)}><Icon type="caret-up" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
}
|
||||
|
||||
<div className="padding20 edu-back-white"
|
||||
style={{
|
||||
display:
|
||||
TPMRightSectionData === undefined?"none":TPMRightSectionData.recommands===undefined?"none":TPMRightSectionData.recommands.length === 0 ? "none" : "block"
|
||||
}}
|
||||
>
|
||||
<p className="mb20 font-16 clearfix">推荐实训</p>
|
||||
<div className="recommend-list">
|
||||
{
|
||||
TPMRightSectionData===undefined?"":TPMRightSectionData.recommands===undefined?"":TPMRightSectionData.recommands.map((item,key)=>{
|
||||
return(
|
||||
<div className="recomments clearfix df" key={key}>
|
||||
<a href={"/shixuns/"+item.identifier+"/challenges"} target="_blank">
|
||||
<img alt="69?1526971094" height="96" src={item.pic} width="128"/>
|
||||
</a>
|
||||
<div className="ml10 flex1">
|
||||
<Tooltip placement="bottom" title={item.name}>
|
||||
<a href={"/shixuns/"+item.identifier+"/challenges"} target="_blank" className="color-grey-6 task-hide mb12 recomment-name">{item.name}</a>
|
||||
</Tooltip>
|
||||
<p className="clearfix mt8 font-12 color-grey-B4">
|
||||
{item.stu_num} 人学习
|
||||
</p>
|
||||
<p className="edu-txt-right color-orange pr10">{item.level}</p>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
})
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="padding20 edu-back-white mb10 mt10" style={{
|
||||
display: TPMRightSectionData === undefined?"none":TPMRightSectionData.paths===undefined?"":TPMRightSectionData.paths.length === 0 ? "none" : "block"
|
||||
}}>
|
||||
<p className="mb20 font-16 clearfix">相关实践课程</p>
|
||||
<div className="recommend-list" >
|
||||
{
|
||||
TPMRightSectionData===undefined?"":TPMRightSectionData.paths===undefined?"":TPMRightSectionData.paths.map((i,k)=>{
|
||||
|
||||
return(
|
||||
|
||||
<div className="recomments clearfix df" key={k}>
|
||||
|
||||
<a href={"/paths/"+i.id} height="96" width="128" target="_blank">
|
||||
<img alt="实训" height="96" src={i.image_url} width="128" />
|
||||
</a>
|
||||
|
||||
<div className="ml10 flex1">
|
||||
<a href={"/paths/"+i.id} target="_blank" data-tip-down={i.name} className="color-grey-6 task-hide mb12 recomment-name">{i.name}</a>
|
||||
<p className="clearfix mt8 font-12 color-grey-B4">
|
||||
|
||||
<Tooltip placement="bottom" title={"章节"}>
|
||||
<span className="mr10 fl squareIconSpan"><i className="iconfont icon-shixun fl mr3"></i>{i.stages_count}</span>
|
||||
</Tooltip>
|
||||
|
||||
{/*<Tooltip placement="bottom" title={"经验值"}>*/}
|
||||
{/*<span className="mr10 fl squareIconSpan"><i className="iconfont icon-jingyan fl mr3"></i>{i.score_count}</span>*/}
|
||||
{/*</Tooltip>*/}
|
||||
|
||||
<Tooltip placement="bottom" title={"学习人数"}>
|
||||
<span className="mr10 fl squareIconSpan"><i className="iconfont icon-chengyuan fl mr3"></i>{i.members_count}</span>
|
||||
</Tooltip>
|
||||
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
)
|
||||
})
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
)
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export default TPMRightSection;
|
||||
|
@ -1,391 +1,391 @@
|
||||
import React, { Component } from 'react';
|
||||
import { SnackbarHOC } from 'educoder';
|
||||
import {Link} from 'react-router-dom';
|
||||
import {Tooltip,Menu} from 'antd';
|
||||
import Loadable from 'react-loadable';
|
||||
import Loading from '../../../Loading';
|
||||
import {BrowserRouter as Router,Route,Switch} from 'react-router-dom';
|
||||
|
||||
import axios from 'axios';
|
||||
import {getImageUrl} from 'educoder';
|
||||
import { TPMIndexHOC } from '../../tpm/TPMIndexHOC';
|
||||
import { CNotificationHOC } from '../../courses/common/CNotificationHOC'
|
||||
import "./usersInfo.css"
|
||||
import "../../courses/css/members.css"
|
||||
import "../../courses/css/Courses.css"
|
||||
import update from 'immutability-helper'
|
||||
|
||||
import Trialapplication from '../../login/Trialapplication'
|
||||
|
||||
const InfosCourse = Loadable({
|
||||
loader: () => import('./InfosCourse'),
|
||||
loading:Loading,
|
||||
})
|
||||
const InfosShixun = Loadable({
|
||||
loader: () => import('./InfosShixun'),
|
||||
loading:Loading,
|
||||
})
|
||||
const InfosPath = Loadable({
|
||||
loader: () => import('./InfosPath'),
|
||||
loading:Loading,
|
||||
})
|
||||
const InfosProject = Loadable({
|
||||
loader: () => import('./InfosProject'),
|
||||
loading:Loading,
|
||||
})
|
||||
|
||||
const $ = window.$;
|
||||
class Infos extends Component{
|
||||
constructor(props){
|
||||
super(props);
|
||||
this.state={
|
||||
data:undefined,
|
||||
is_current:true,
|
||||
is_edit:false,
|
||||
sign:undefined,
|
||||
type:0,
|
||||
login:undefined,
|
||||
isRenders:false,
|
||||
moduleName:"courses",
|
||||
next_gold:undefined
|
||||
}
|
||||
}
|
||||
componentDidMount =()=>{
|
||||
this.getInfo(this.props.match.params.username);
|
||||
}
|
||||
//判断是否看的是当前用户的个人主页
|
||||
componentDidUpdate =(prevProps)=> {
|
||||
if(this.props.current_user && prevProps.current_user != this.props.current_user){
|
||||
console.log(this.props);
|
||||
if(this.props.current_user.login != this.props.match.params.username){
|
||||
this.setState({
|
||||
is_current:false,
|
||||
login:this.props.current_user.login
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//获取个人主页信息
|
||||
getInfo = (user_login) =>{
|
||||
let url =`/users/${user_login}/homepage_info.json`;
|
||||
axios.get(url).then((result)=>{
|
||||
if(result){
|
||||
this.setState({
|
||||
data:result.data,
|
||||
followed:result.data.followed,
|
||||
sign:result.data.brief_introduction,
|
||||
id:result.data.id,
|
||||
next_gold:result.data.tomorrow_attendance_gold
|
||||
})
|
||||
}
|
||||
}).catch((error)=>{
|
||||
console.log(error);
|
||||
})
|
||||
}
|
||||
|
||||
// 编辑签名
|
||||
editmysign=()=>{
|
||||
this.setState({
|
||||
is_edit:true
|
||||
},()=>{
|
||||
$("#mysign").focus();
|
||||
})
|
||||
}
|
||||
// 输入签名
|
||||
inputSign=(e)=>{
|
||||
this.setState({
|
||||
sign:e.target.value
|
||||
})
|
||||
}
|
||||
//取消编辑签名
|
||||
savemysign=()=>{
|
||||
let { sign } =this.state;
|
||||
let url=`/users/brief_introduction.json`;
|
||||
axios.post((url),{
|
||||
content:sign
|
||||
}).then((result)=>{
|
||||
if(result){
|
||||
this.setState({
|
||||
is_edit:false
|
||||
})
|
||||
}
|
||||
}).catch((error)=>{
|
||||
console.log(error)
|
||||
})
|
||||
|
||||
}
|
||||
changeType=(e)=>{
|
||||
this.setState({
|
||||
type:e.key
|
||||
})
|
||||
}
|
||||
turnTo=(url)=>{
|
||||
this.props.history.push(url);
|
||||
}
|
||||
|
||||
//签到
|
||||
signFor=()=>{
|
||||
let url=`/users/attendance.json`
|
||||
axios.post(url).then((result)=>{
|
||||
if(result){
|
||||
// this.setState(
|
||||
// (prevState) => ({
|
||||
// data : update(prevState.data, {attendance_signed: {$set: true} })
|
||||
// })
|
||||
// )
|
||||
// this.setState({
|
||||
// next_gold:result.data.next_gold
|
||||
// })
|
||||
this.getInfo(this.props.match.params.username);
|
||||
}
|
||||
}).catch((error)=>{
|
||||
console.log(error);
|
||||
})
|
||||
}
|
||||
|
||||
// 关注
|
||||
followPerson=()=>{
|
||||
let{followed,id}=this.state;
|
||||
let url=`/users/${id}/watch.json`;
|
||||
// 取消关注
|
||||
if(followed){
|
||||
axios.delete(url).then((result)=>{
|
||||
if(result){
|
||||
this.setState({
|
||||
followed:false
|
||||
})
|
||||
}
|
||||
}).catch((error)=>{
|
||||
console.log(error)
|
||||
})
|
||||
}else{
|
||||
// 关注
|
||||
axios.post(url).then((result)=>{
|
||||
if(result){
|
||||
this.setState({
|
||||
followed:true
|
||||
})
|
||||
}
|
||||
}).catch((error)=>{
|
||||
console.log(error);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 试用申请
|
||||
trialapplications =()=>{
|
||||
this.setState({
|
||||
isRenders: true,
|
||||
showTrial:true
|
||||
})
|
||||
}
|
||||
cancelModulationModels=()=>{
|
||||
this.setState({
|
||||
isRenders: false
|
||||
})
|
||||
}
|
||||
ToBank=(url)=>{
|
||||
window.location.href=url;
|
||||
}
|
||||
|
||||
render(){
|
||||
let {
|
||||
data ,
|
||||
is_current,
|
||||
is_edit,
|
||||
sign,
|
||||
type,
|
||||
followed,
|
||||
id,
|
||||
login,
|
||||
isRenders,
|
||||
moduleName,
|
||||
next_gold
|
||||
}=this.state;
|
||||
let {username}= this.props.match.params;
|
||||
|
||||
let {pathname}=this.props.location;
|
||||
moduleName=pathname.split("/")[3];
|
||||
return(
|
||||
<div className="newMain">
|
||||
{
|
||||
isRenders && <Trialapplication {...this.state} Cancel={() => this.cancelModulationModels()}/>
|
||||
}
|
||||
<div className="user-main-half">
|
||||
<div className="user-headImg"></div>
|
||||
<div className="user-headCon">
|
||||
<div className="pr" style={{"min-height": "465px"}}>
|
||||
<div className="educontent pt80 clearfix edu-txt-center">
|
||||
<div className="inline">
|
||||
<div className="fl headtab">
|
||||
<span>{is_current ? "我":"TA"}的经验值</span>
|
||||
<a href={`${this.props.Headertop && this.props.Headertop.old_url}/users/${username}/user_experience`}>{data && data.experience}</a>
|
||||
</div>
|
||||
<em className="v-h-line fl"></em>
|
||||
<div className="fl headtab">
|
||||
<span>{is_current ? "我":"TA"}的金币</span>
|
||||
<a href={`${this.props.Headertop && this.props.Headertop.old_url}/users/${username}/user_grade`} id="user_code">{data && data.grade}</a>
|
||||
</div>
|
||||
<div className="headphoto mt14">
|
||||
<img alt="头像" id="user_avatar_show" nhname="avatar_image" src={data && `${getImageUrl('images/'+data.avatar_url)}`}/>
|
||||
</div>
|
||||
<div className="fl headtab">
|
||||
<span>{is_current ? "我":"TA"}的粉丝</span>
|
||||
<a href={`${this.props.Headertop && this.props.Headertop.old_url}/users/${username}/user_fanslist`} id="user_h_fan_count">{data && data.fan_count}</a>
|
||||
</div>
|
||||
<em className="v-h-line fl"></em>
|
||||
<div className="fl headtab">
|
||||
<span>{is_current ? "我":"TA"}的关注</span>
|
||||
<a href={`${this.props.Headertop && this.props.Headertop.old_url}/users/${username}/user_watchlist`}>{data && data.follow_count}</a>
|
||||
</div>
|
||||
<span className="clearfix"></span>
|
||||
<span className="myName">{data && data.name}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="educontent mt10 clearfix edu-txt-center">
|
||||
<div className="inline">
|
||||
{
|
||||
data && is_current == false && data.identity =="学生" ? "" : <span className="mypost fl mr10">{data && data.identity}</span>
|
||||
}
|
||||
<a href={is_current ? `${this.props.Headertop && this.props.Headertop.old_url}/account/authentication` :"javascript:void(0)"} target="_blank" className={is_current ? "ringauto fl" :"ringauto fl cdefault"}>
|
||||
<Tooltip placement='bottom' title={ data && data.authentication ?"已实名认证":"未实名认证"}>
|
||||
<i className={ data && data.authentication ? "iconfont icon-shenfenrenzheng font-13 color-blue":"iconfont icon-shenfenrenzheng font-13 color-grey-9"}></i>
|
||||
</Tooltip>
|
||||
</a>
|
||||
<a href={is_current ? `${this.props.Headertop && this.props.Headertop.old_url}/account/professional_certification` :"javascript:void(0)"} target="_blank" className={is_current ? "ringauto fl" :"ringauto fl cdefault"}>
|
||||
<Tooltip placement='bottom' title={ data && data.professional_certification ?"已职业认证":"未职业认证"}>
|
||||
<i className={ data && data.professional_certification ? "iconfont icon-zhiyerenzheng font-13 color-blue":"iconfont icon-zhiyerenzheng font-13 color-grey-9"}></i>
|
||||
</Tooltip>
|
||||
</a>
|
||||
<a href={is_current ? `${this.props.Headertop && this.props.Headertop.old_url}/account/change_or_bind?type=phone` :"javascript:void(0)"} target="_blank" className={is_current ? "ringauto fl" :"ringauto fl cdefault"}>
|
||||
<Tooltip placement='bottom' title={ data && data.phone_binded ?"已手机认证":"未手机认证"}>
|
||||
<i className={ data && data.phone_binded ? "iconfont icon-shoujirenzheng font-13 color-blue":"iconfont icon-shoujirenzheng font-13 color-grey-9"}></i>
|
||||
</Tooltip>
|
||||
</a>
|
||||
<a href={is_current ? `${this.props.Headertop && this.props.Headertop.old_url}/my/account` :"javascript:void(0)"} target="_blank" className={is_current ? "ringauto fl" :"ringauto fl cdefault"}>
|
||||
<Tooltip placement='bottom' title={ data && data.email_binded ?"已邮箱认证":"未邮箱认证"}>
|
||||
<i className={ data && data.email_binded ? "iconfont icon-youxiangrenzheng font-13 color-blue":"iconfont icon-youxiangrenzheng font-13 color-grey-9"}></i>
|
||||
</Tooltip>
|
||||
</a>
|
||||
{/* <!--学院管理员身份--> */}
|
||||
{
|
||||
data && data.college_identifier &&
|
||||
<a href={`${this.props.Headertop && this.props.Headertop.old_url}/colleges/${data.college_identifier}/statistics`} target="_blank" className={is_current ? "ringauto fl" :"ringauto fl cdefault"}>
|
||||
<Tooltip placement='bottom' title="学院管理员">
|
||||
<i className="iconfont icon-chengyuanguanli font-12 color-blue" data-tip-down="学院管理员"></i>
|
||||
</Tooltip>
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt15 educontent clearfix edu-txt-center">
|
||||
<p className="mb20" style={{"height": "28px"}}>
|
||||
{
|
||||
is_edit && is_current ?
|
||||
<input type="text" id="mysign" class="mysign-input" placeholder="请输入您的个性签名" style={{height:"20px"}} value={sign} onInput={this.inputSign} onBlur={this.savemysign}/>
|
||||
:
|
||||
is_current ?
|
||||
<a className="mysign-span" onClick={this.editmysign} style={{"display": "block"}}>{sign || "这家伙很懒,什么都没留下~"}</a>
|
||||
:
|
||||
<span className="mysign-span" style={{"display": "block","cursor":"default"}}>{sign || "这家伙很懒,什么都没留下~"}</span>
|
||||
}
|
||||
</p>
|
||||
{
|
||||
is_current ?
|
||||
<div className="inline">
|
||||
{
|
||||
data && data.can_apply_trial == false ?
|
||||
data.attendance_signed ?
|
||||
<React.Fragment>
|
||||
<span className="user_default_btn user_grey_btn mb5">已签到</span>
|
||||
<p id="attendance_notice" className="none font-12 color-grey-6" style={{"display":"block"}}>明日签到 <font className="color-orange">+{next_gold}</font> 金币</p>
|
||||
</React.Fragment>
|
||||
:
|
||||
<a herf="javascript:void(0);" onClick={this.signFor} id="attendance" className="user_default_btn user_orange_btn fl mb15">签到</a>
|
||||
:
|
||||
<a herf="javascript:void(0);" onClick={this.trialapplications} id="authentication_apply" className="user_default_btn user_private_btn fl ml15">试用申请</a>
|
||||
}
|
||||
</div>
|
||||
:
|
||||
<div className="inline">
|
||||
<a href="javascript:void(0);" onClick={this.followPerson} className="user_default_btn user_watch_btn user_private_btn fl mr20">{followed ? "取消关注":"关注"}</a>
|
||||
<a href={`${this.props.Headertop && this.props.Headertop.old_url}/users/${login}/message_detail?user_id=${id}`} className="user_default_btn user_private_btn fl">私信</a>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div className="edu-txt-center navInfo">
|
||||
<div className="inline">
|
||||
<li className={`${moduleName == 'courses' ||moduleName == undefined ? 'active' : '' }`}>
|
||||
<Link
|
||||
onClick={() => this.setState({moduleName: 'courses'})}
|
||||
to={`/users/${username}/courses`}>课堂</Link>
|
||||
</li>
|
||||
<li className={`${moduleName == 'shixuns' ? 'active' : '' }`}>
|
||||
<Link
|
||||
onClick={() => this.setState({moduleName: 'shixuns'})}
|
||||
to={`/users/${username}/shixuns`}>实训</Link>
|
||||
</li>
|
||||
<li className={`${moduleName == 'paths' ? 'active' : '' }`}>
|
||||
<Link
|
||||
onClick={() => this.setState({moduleName: 'paths'})}
|
||||
to={`/users/${username}/paths`}>实训课程</Link>
|
||||
</li>
|
||||
<li className={`${moduleName == 'projects' ? 'active' : '' }`}>
|
||||
<Link
|
||||
onClick={() => this.setState({moduleName: 'projects'})}
|
||||
to={`/users/${username}/projects`}>项目</Link>
|
||||
</li>
|
||||
|
||||
{ data && data.identity!="学生" && <li> <a href={`${this.props.Headertop && this.props.Headertop.old_url}/users/${username}?type=m_bank`}>题库</a></li>}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<Switch {...this.props}>
|
||||
|
||||
{/* --------------------------------------------------------------------- */}
|
||||
|
||||
{/* 课堂 */}
|
||||
{/* http://localhost:3007/courses/1309/homework/9300/setting */}
|
||||
<Route exact path="/users/:username/courses"
|
||||
render={
|
||||
(props) => (<InfosCourse {...this.props} {...props} {...this.state} />)
|
||||
}
|
||||
></Route>
|
||||
|
||||
{/* 实训 */}
|
||||
<Route exact path="/users/:username/shixuns"
|
||||
render={
|
||||
(props) => (<InfosShixun {...this.props} {...props} {...this.state} />)
|
||||
}
|
||||
></Route>
|
||||
|
||||
{/* 实训课程 */}
|
||||
<Route exact path="/users/:username/paths"
|
||||
render={
|
||||
(props) => (<InfosPath {...this.props} {...props} {...this.state} />)
|
||||
}
|
||||
></Route>
|
||||
|
||||
{/* 项目 */}
|
||||
<Route exact path="/users/:username/projects"
|
||||
render={
|
||||
(props) => (<InfosProject {...this.props} {...props} {...this.state} />)
|
||||
}
|
||||
></Route>
|
||||
<Route exact path="/users/:username"
|
||||
render={
|
||||
(props) => (<InfosCourse {...this.props} {...props} {...this.state} />)
|
||||
}
|
||||
></Route>
|
||||
|
||||
</Switch>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
import React, { Component } from 'react';
|
||||
import { SnackbarHOC } from 'educoder';
|
||||
import {Link} from 'react-router-dom';
|
||||
import {Tooltip,Menu} from 'antd';
|
||||
import Loadable from 'react-loadable';
|
||||
import Loading from '../../../Loading';
|
||||
import {BrowserRouter as Router,Route,Switch} from 'react-router-dom';
|
||||
|
||||
import axios from 'axios';
|
||||
import {getImageUrl} from 'educoder';
|
||||
import { TPMIndexHOC } from '../../tpm/TPMIndexHOC';
|
||||
import { CNotificationHOC } from '../../courses/common/CNotificationHOC'
|
||||
import "./usersInfo.css"
|
||||
import "../../courses/css/members.css"
|
||||
import "../../courses/css/Courses.css"
|
||||
import update from 'immutability-helper'
|
||||
|
||||
import Trialapplication from '../../login/Trialapplication'
|
||||
|
||||
const InfosCourse = Loadable({
|
||||
loader: () => import('./InfosCourse'),
|
||||
loading:Loading,
|
||||
})
|
||||
const InfosShixun = Loadable({
|
||||
loader: () => import('./InfosShixun'),
|
||||
loading:Loading,
|
||||
})
|
||||
const InfosPath = Loadable({
|
||||
loader: () => import('./InfosPath'),
|
||||
loading:Loading,
|
||||
})
|
||||
const InfosProject = Loadable({
|
||||
loader: () => import('./InfosProject'),
|
||||
loading:Loading,
|
||||
})
|
||||
|
||||
const $ = window.$;
|
||||
class Infos extends Component{
|
||||
constructor(props){
|
||||
super(props);
|
||||
this.state={
|
||||
data:undefined,
|
||||
is_current:true,
|
||||
is_edit:false,
|
||||
sign:undefined,
|
||||
type:0,
|
||||
login:undefined,
|
||||
isRenders:false,
|
||||
moduleName:"courses",
|
||||
next_gold:undefined
|
||||
}
|
||||
}
|
||||
componentDidMount =()=>{
|
||||
this.getInfo(this.props.match.params.username);
|
||||
}
|
||||
//判断是否看的是当前用户的个人主页
|
||||
componentDidUpdate =(prevProps)=> {
|
||||
if(this.props.current_user && prevProps.current_user != this.props.current_user){
|
||||
console.log(this.props);
|
||||
if(this.props.current_user.login != this.props.match.params.username){
|
||||
this.setState({
|
||||
is_current:false,
|
||||
login:this.props.current_user.login
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//获取个人主页信息
|
||||
getInfo = (user_login) =>{
|
||||
let url =`/users/${user_login}/homepage_info.json`;
|
||||
axios.get(url).then((result)=>{
|
||||
if(result){
|
||||
this.setState({
|
||||
data:result.data,
|
||||
followed:result.data.followed,
|
||||
sign:result.data.brief_introduction,
|
||||
id:result.data.id,
|
||||
next_gold:result.data.tomorrow_attendance_gold
|
||||
})
|
||||
}
|
||||
}).catch((error)=>{
|
||||
console.log(error);
|
||||
})
|
||||
}
|
||||
|
||||
// 编辑签名
|
||||
editmysign=()=>{
|
||||
this.setState({
|
||||
is_edit:true
|
||||
},()=>{
|
||||
$("#mysign").focus();
|
||||
})
|
||||
}
|
||||
// 输入签名
|
||||
inputSign=(e)=>{
|
||||
this.setState({
|
||||
sign:e.target.value
|
||||
})
|
||||
}
|
||||
//取消编辑签名
|
||||
savemysign=()=>{
|
||||
let { sign } =this.state;
|
||||
let url=`/users/brief_introduction.json`;
|
||||
axios.post((url),{
|
||||
content:sign
|
||||
}).then((result)=>{
|
||||
if(result){
|
||||
this.setState({
|
||||
is_edit:false
|
||||
})
|
||||
}
|
||||
}).catch((error)=>{
|
||||
console.log(error)
|
||||
})
|
||||
|
||||
}
|
||||
changeType=(e)=>{
|
||||
this.setState({
|
||||
type:e.key
|
||||
})
|
||||
}
|
||||
turnTo=(url)=>{
|
||||
this.props.history.push(url);
|
||||
}
|
||||
|
||||
//签到
|
||||
signFor=()=>{
|
||||
let url=`/users/attendance.json`
|
||||
axios.post(url).then((result)=>{
|
||||
if(result){
|
||||
// this.setState(
|
||||
// (prevState) => ({
|
||||
// data : update(prevState.data, {attendance_signed: {$set: true} })
|
||||
// })
|
||||
// )
|
||||
// this.setState({
|
||||
// next_gold:result.data.next_gold
|
||||
// })
|
||||
this.getInfo(this.props.match.params.username);
|
||||
}
|
||||
}).catch((error)=>{
|
||||
console.log(error);
|
||||
})
|
||||
}
|
||||
|
||||
// 关注
|
||||
followPerson=()=>{
|
||||
let{followed,id}=this.state;
|
||||
let url=`/users/${id}/watch.json`;
|
||||
// 取消关注
|
||||
if(followed){
|
||||
axios.delete(url).then((result)=>{
|
||||
if(result){
|
||||
this.setState({
|
||||
followed:false
|
||||
})
|
||||
}
|
||||
}).catch((error)=>{
|
||||
console.log(error)
|
||||
})
|
||||
}else{
|
||||
// 关注
|
||||
axios.post(url).then((result)=>{
|
||||
if(result){
|
||||
this.setState({
|
||||
followed:true
|
||||
})
|
||||
}
|
||||
}).catch((error)=>{
|
||||
console.log(error);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 试用申请
|
||||
trialapplications =()=>{
|
||||
this.setState({
|
||||
isRenders: true,
|
||||
showTrial:true
|
||||
})
|
||||
}
|
||||
cancelModulationModels=()=>{
|
||||
this.setState({
|
||||
isRenders: false
|
||||
})
|
||||
}
|
||||
ToBank=(url)=>{
|
||||
window.location.href=url;
|
||||
}
|
||||
|
||||
render(){
|
||||
let {
|
||||
data ,
|
||||
is_current,
|
||||
is_edit,
|
||||
sign,
|
||||
type,
|
||||
followed,
|
||||
id,
|
||||
login,
|
||||
isRenders,
|
||||
moduleName,
|
||||
next_gold
|
||||
}=this.state;
|
||||
let {username}= this.props.match.params;
|
||||
|
||||
let {pathname}=this.props.location;
|
||||
moduleName=pathname.split("/")[3];
|
||||
return(
|
||||
<div className="newMain">
|
||||
{
|
||||
isRenders && <Trialapplication {...this.state} Cancel={() => this.cancelModulationModels()}/>
|
||||
}
|
||||
<div className="user-main-half">
|
||||
<div className="user-headImg"></div>
|
||||
<div className="user-headCon">
|
||||
<div className="pr" style={{"min-height": "465px"}}>
|
||||
<div className="educontent pt80 clearfix edu-txt-center">
|
||||
<div className="inline">
|
||||
<div className="fl headtab">
|
||||
<span>{is_current ? "我":"TA"}的经验值</span>
|
||||
<a href={`${this.props.Headertop && this.props.Headertop.old_url}/users/${username}/user_experience`}>{data && data.experience}</a>
|
||||
</div>
|
||||
<em className="v-h-line fl"></em>
|
||||
<div className="fl headtab">
|
||||
<span>{is_current ? "我":"TA"}的金币</span>
|
||||
<a href={`${this.props.Headertop && this.props.Headertop.old_url}/users/${username}/user_grade`} id="user_code">{data && data.grade}</a>
|
||||
</div>
|
||||
<div className="headphoto mt14">
|
||||
<img alt="头像" id="user_avatar_show" nhname="avatar_image" src={data && `${getImageUrl('images/'+data.avatar_url)}`}/>
|
||||
</div>
|
||||
<div className="fl headtab">
|
||||
<span>{is_current ? "我":"TA"}的粉丝</span>
|
||||
<a href={`${this.props.Headertop && this.props.Headertop.old_url}/users/${username}/user_fanslist`} id="user_h_fan_count">{data && data.fan_count}</a>
|
||||
</div>
|
||||
<em className="v-h-line fl"></em>
|
||||
<div className="fl headtab">
|
||||
<span>{is_current ? "我":"TA"}的关注</span>
|
||||
<a href={`${this.props.Headertop && this.props.Headertop.old_url}/users/${username}/user_watchlist`}>{data && data.follow_count}</a>
|
||||
</div>
|
||||
<span className="clearfix"></span>
|
||||
<span className="myName">{data && data.name}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="educontent mt10 clearfix edu-txt-center">
|
||||
<div className="inline">
|
||||
{
|
||||
data && is_current == false && data.identity =="学生" ? "" : <span className="mypost fl mr10">{data && data.identity}</span>
|
||||
}
|
||||
<a href={is_current ? `${this.props.Headertop && this.props.Headertop.old_url}/account/authentication` :"javascript:void(0)"} target="_blank" className={is_current ? "ringauto fl" :"ringauto fl cdefault"}>
|
||||
<Tooltip placement='bottom' title={ data && data.authentication ?"已实名认证":"未实名认证"}>
|
||||
<i className={ data && data.authentication ? "iconfont icon-shenfenrenzheng font-13 color-blue":"iconfont icon-shenfenrenzheng font-13 color-grey-9"}></i>
|
||||
</Tooltip>
|
||||
</a>
|
||||
<a href={is_current ? `${this.props.Headertop && this.props.Headertop.old_url}/account/professional_certification` :"javascript:void(0)"} target="_blank" className={is_current ? "ringauto fl" :"ringauto fl cdefault"}>
|
||||
<Tooltip placement='bottom' title={ data && data.professional_certification ?"已职业认证":"未职业认证"}>
|
||||
<i className={ data && data.professional_certification ? "iconfont icon-zhiyerenzheng font-13 color-blue":"iconfont icon-zhiyerenzheng font-13 color-grey-9"}></i>
|
||||
</Tooltip>
|
||||
</a>
|
||||
<a href={is_current ? `${this.props.Headertop && this.props.Headertop.old_url}/account/change_or_bind?type=phone` :"javascript:void(0)"} target="_blank" className={is_current ? "ringauto fl" :"ringauto fl cdefault"}>
|
||||
<Tooltip placement='bottom' title={ data && data.phone_binded ?"已手机认证":"未手机认证"}>
|
||||
<i className={ data && data.phone_binded ? "iconfont icon-shoujirenzheng font-13 color-blue":"iconfont icon-shoujirenzheng font-13 color-grey-9"}></i>
|
||||
</Tooltip>
|
||||
</a>
|
||||
<a href={is_current ? `${this.props.Headertop && this.props.Headertop.old_url}/my/account` :"javascript:void(0)"} target="_blank" className={is_current ? "ringauto fl" :"ringauto fl cdefault"}>
|
||||
<Tooltip placement='bottom' title={ data && data.email_binded ?"已邮箱认证":"未邮箱认证"}>
|
||||
<i className={ data && data.email_binded ? "iconfont icon-youxiangrenzheng font-13 color-blue":"iconfont icon-youxiangrenzheng font-13 color-grey-9"}></i>
|
||||
</Tooltip>
|
||||
</a>
|
||||
{/* <!--学院管理员身份--> */}
|
||||
{
|
||||
data && data.college_identifier &&
|
||||
<a href={`${this.props.Headertop && this.props.Headertop.old_url}/colleges/${data.college_identifier}/statistics`} target="_blank" className={is_current ? "ringauto fl" :"ringauto fl cdefault"}>
|
||||
<Tooltip placement='bottom' title="学院管理员">
|
||||
<i className="iconfont icon-chengyuanguanli font-12 color-blue" data-tip-down="学院管理员"></i>
|
||||
</Tooltip>
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt15 educontent clearfix edu-txt-center">
|
||||
<p className="mb20" style={{"height": "28px"}}>
|
||||
{
|
||||
is_edit && is_current ?
|
||||
<input type="text" id="mysign" class="mysign-input" placeholder="请输入您的个性签名" style={{height:"20px"}} value={sign} onInput={this.inputSign} onBlur={this.savemysign}/>
|
||||
:
|
||||
is_current ?
|
||||
<a className="mysign-span" onClick={this.editmysign} style={{"display": "block"}}>{sign || "这家伙很懒,什么都没留下~"}</a>
|
||||
:
|
||||
<span className="mysign-span" style={{"display": "block","cursor":"default"}}>{sign || "这家伙很懒,什么都没留下~"}</span>
|
||||
}
|
||||
</p>
|
||||
{
|
||||
is_current ?
|
||||
<div className="inline">
|
||||
{
|
||||
data && data.can_apply_trial == false ?
|
||||
data.attendance_signed ?
|
||||
<React.Fragment>
|
||||
<span className="user_default_btn user_grey_btn mb5">已签到</span>
|
||||
<p id="attendance_notice" className="none font-12 color-grey-6" style={{"display":"block"}}>明日签到 <font className="color-orange">+{next_gold}</font> 金币</p>
|
||||
</React.Fragment>
|
||||
:
|
||||
<a herf="javascript:void(0);" onClick={this.signFor} id="attendance" className="user_default_btn user_orange_btn fl mb15">签到</a>
|
||||
:
|
||||
<a herf="javascript:void(0);" onClick={this.trialapplications} id="authentication_apply" className="user_default_btn user_private_btn fl ml15">试用申请</a>
|
||||
}
|
||||
</div>
|
||||
:
|
||||
<div className="inline">
|
||||
<a href="javascript:void(0);" onClick={this.followPerson} className="user_default_btn user_watch_btn user_private_btn fl mr20">{followed ? "取消关注":"关注"}</a>
|
||||
<a href={`${this.props.Headertop && this.props.Headertop.old_url}/users/${login}/message_detail?user_id=${id}`} className="user_default_btn user_private_btn fl">私信</a>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div className="edu-txt-center navInfo">
|
||||
<div className="inline">
|
||||
<li className={`${moduleName == 'courses' ||moduleName == undefined ? 'active' : '' }`}>
|
||||
<Link
|
||||
onClick={() => this.setState({moduleName: 'courses'})}
|
||||
to={`/users/${username}/courses`}>课堂</Link>
|
||||
</li>
|
||||
<li className={`${moduleName == 'shixuns' ? 'active' : '' }`}>
|
||||
<Link
|
||||
onClick={() => this.setState({moduleName: 'shixuns'})}
|
||||
to={`/users/${username}/shixuns`}>实训</Link>
|
||||
</li>
|
||||
<li className={`${moduleName == 'paths' ? 'active' : '' }`}>
|
||||
<Link
|
||||
onClick={() => this.setState({moduleName: 'paths'})}
|
||||
to={`/users/${username}/paths`}>实践课程</Link>
|
||||
</li>
|
||||
<li className={`${moduleName == 'projects' ? 'active' : '' }`}>
|
||||
<Link
|
||||
onClick={() => this.setState({moduleName: 'projects'})}
|
||||
to={`/users/${username}/projects`}>项目</Link>
|
||||
</li>
|
||||
|
||||
{ data && data.identity!="学生" && <li> <a href={`${this.props.Headertop && this.props.Headertop.old_url}/users/${username}?type=m_bank`}>题库</a></li>}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<Switch {...this.props}>
|
||||
|
||||
{/* --------------------------------------------------------------------- */}
|
||||
|
||||
{/* 课堂 */}
|
||||
{/* http://localhost:3007/courses/1309/homework/9300/setting */}
|
||||
<Route exact path="/users/:username/courses"
|
||||
render={
|
||||
(props) => (<InfosCourse {...this.props} {...props} {...this.state} />)
|
||||
}
|
||||
></Route>
|
||||
|
||||
{/* 实训 */}
|
||||
<Route exact path="/users/:username/shixuns"
|
||||
render={
|
||||
(props) => (<InfosShixun {...this.props} {...props} {...this.state} />)
|
||||
}
|
||||
></Route>
|
||||
|
||||
{/* 实训课程 */}
|
||||
<Route exact path="/users/:username/paths"
|
||||
render={
|
||||
(props) => (<InfosPath {...this.props} {...props} {...this.state} />)
|
||||
}
|
||||
></Route>
|
||||
|
||||
{/* 项目 */}
|
||||
<Route exact path="/users/:username/projects"
|
||||
render={
|
||||
(props) => (<InfosProject {...this.props} {...props} {...this.state} />)
|
||||
}
|
||||
></Route>
|
||||
<Route exact path="/users/:username"
|
||||
render={
|
||||
(props) => (<InfosCourse {...this.props} {...props} {...this.state} />)
|
||||
}
|
||||
></Route>
|
||||
|
||||
</Switch>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
export default CNotificationHOC() ( SnackbarHOC() ( TPMIndexHOC(Infos) ));
|
@ -1,197 +1,197 @@
|
||||
import React, { Component } from 'react';
|
||||
import { SnackbarHOC } from 'educoder';
|
||||
import {BrowserRouter as Router,Route,Switch} from 'react-router-dom';
|
||||
import {Tooltip,Menu,Pagination, Spin} from 'antd';
|
||||
import Loadable from 'react-loadable';
|
||||
import Loading from '../../../Loading';
|
||||
import NoneData from '../../courses/coursesPublic/NoneData'
|
||||
import axios from 'axios';
|
||||
import {getImageUrl,setImagesUrl} from 'educoder';
|
||||
import { TPMIndexHOC } from '../../tpm/TPMIndexHOC';
|
||||
import { CNotificationHOC } from '../../courses/common/CNotificationHOC'
|
||||
import "./usersInfo.css"
|
||||
|
||||
import Create from './publicCreatNew'
|
||||
|
||||
class InfosPath extends Component{
|
||||
constructor(props){
|
||||
super(props);
|
||||
this.state={
|
||||
category:undefined,
|
||||
page:1,
|
||||
sort_by:'time',
|
||||
status:undefined,
|
||||
per_page:16,
|
||||
isSpin:false,
|
||||
|
||||
totalCount:undefined,
|
||||
data:undefined
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount=()=>{
|
||||
this.setState({
|
||||
isSpin:true
|
||||
})
|
||||
let{category,status,sort_by,page,per_page}=this.state;
|
||||
this.getCourses(category,status,sort_by,page,per_page);
|
||||
}
|
||||
|
||||
getCourses=(category,status,sort_by,page,per_page)=>{
|
||||
let url=`/users/${this.props.match.params.username}/subjects.json`;
|
||||
axios.get((url),{params:{
|
||||
category,
|
||||
status,
|
||||
sort_by,
|
||||
page,
|
||||
per_page:this.props.is_current && category && page ==1?17:16
|
||||
}}).then((result)=>{
|
||||
if(result){
|
||||
this.setState({
|
||||
totalCount:result.data.count,
|
||||
data:result.data,
|
||||
isSpin:false
|
||||
})
|
||||
}
|
||||
}).catch((error)=>{
|
||||
console.log(error);
|
||||
})
|
||||
}
|
||||
|
||||
//切换种类
|
||||
changeCategory=(cate)=>{
|
||||
this.setState({
|
||||
category:cate,
|
||||
status:undefined,
|
||||
page:1,
|
||||
isSpin:true
|
||||
})
|
||||
let{sort_by}=this.state;
|
||||
this.getCourses(cate,undefined,sort_by,1);
|
||||
}
|
||||
// 切换状态
|
||||
changeStatus=(status)=>{
|
||||
let{category,sort_by}=this.state;
|
||||
this.setState({
|
||||
status,
|
||||
page:1,
|
||||
isSpin:true
|
||||
})
|
||||
this.getCourses(category,status,sort_by,1);
|
||||
}
|
||||
//切换页数
|
||||
changePage=(page)=>{
|
||||
this.setState({
|
||||
page,
|
||||
isSpin:true
|
||||
})
|
||||
let{category,sort_by,status}=this.state;
|
||||
this.getCourses(category,status,sort_by,page);
|
||||
}
|
||||
|
||||
// 进入课堂
|
||||
turnToCourses=(url)=>{
|
||||
this.props.history.push(url);
|
||||
}
|
||||
|
||||
|
||||
// 切换排序方式
|
||||
changeOrder= (sort)=>{
|
||||
this.setState({
|
||||
sort_by:sort,
|
||||
isSpin:true
|
||||
})
|
||||
let{category,status,page}=this.state;
|
||||
this.getCourses(category,status,sort,page);
|
||||
}
|
||||
|
||||
render(){
|
||||
let{
|
||||
category,
|
||||
status,
|
||||
sort_by,
|
||||
page,
|
||||
data,
|
||||
totalCount,
|
||||
isSpin
|
||||
} = this.state;
|
||||
let isStudent = this.props.isStudent();
|
||||
let is_current=this.props.is_current;
|
||||
return(
|
||||
<div className="educontent">
|
||||
<Spin size="large" spinning={isSpin}>
|
||||
<div className="white-panel edu-back-white pt25 pb25 clearfix ">
|
||||
<li className={category ? "" : "active"}><a href="javascript:void(0)" onClick={()=>this.changeCategory()}>全部</a></li>
|
||||
<li className={category=="manage" ? "active" : ""}><a href="javascript:void(0)" onClick={()=>this.changeCategory("manage")}>{is_current ? "我":"TA"}管理的</a></li>
|
||||
<li className={category=="study" ? "active" : ""}><a href="javascript:void(0)" onClick={()=>this.changeCategory("study")}>{is_current ? "我":"TA"}学习的</a></li>
|
||||
</div>
|
||||
{
|
||||
category && category == "manage" && is_current &&
|
||||
<div className="edu-back-white padding20-30 clearfix secondNav bor-top-greyE">
|
||||
<li className={status ? "" : "active"}><a href="javascript:void(0)" onClick={()=>this.changeStatus()}>全部</a></li>
|
||||
<li className={status=="editing" ? "active" : ""}><a href="javascript:void(0)" onClick={()=>this.changeStatus("editing")}>编辑中</a></li>
|
||||
<li className={status=="applying" ? "active" : ""}><a href="javascript:void(0)" onClick={()=>this.changeStatus("applying")}>待审核</a></li>
|
||||
<li className={status=="published" ? "active" : ""}><a href="javascript:void(0)" onClick={()=>this.changeStatus("published")}>已发布</a></li>
|
||||
</div>
|
||||
}
|
||||
{
|
||||
category && category == "study" && is_current &&
|
||||
<div className="edu-back-white padding20-30 clearfix secondNav bor-top-greyE">
|
||||
<li className={status ? "" : "active"}><a href="javascript:void(0)" onClick={()=>this.changeStatus()}>全部</a></li>
|
||||
<li className={status=="unfinished" ? "active" : ""}><a href="javascript:void(0)" onClick={()=>this.changeStatus("unfinished")}>未完成</a></li>
|
||||
<li className={status=="finished" ? "active" : ""}><a href="javascript:void(0)" onClick={()=>this.changeStatus("finished")}>已完成</a></li>
|
||||
</div>
|
||||
}
|
||||
<div className="pl25 pr25 clearfix font-12 mb20 mt20">
|
||||
<span className="fl color-grey-9">共参与{totalCount}个{category?category=="manage"?"发布":"学习":"实训课程"}</span>
|
||||
<span className="fr color-grey-9">时间最新</span>
|
||||
</div>
|
||||
<div className="square-list clearfix">
|
||||
{
|
||||
!isStudent && page == 1 && !category && is_current &&
|
||||
<Create href={"/paths/new"} name={"新建实训课程"} index="3"></Create>
|
||||
}
|
||||
{
|
||||
(!data || data.subjects.length==0) && (isStudent || category) && <NoneData></NoneData>
|
||||
}
|
||||
{
|
||||
data && data.subjects && data.subjects.map((item,key)=>{
|
||||
return(
|
||||
<div className="square-Item" onClick={()=>this.turnToCourses(`/paths/${item.id}`)}>
|
||||
{
|
||||
item.tag && <div className="tag-green"><span className="tag-name">{item.tag}</span><img src={setImagesUrl("images/educoder/tag2.png")} className="fl"/></div>
|
||||
}
|
||||
<a href="javascript:void(0)" className="square-img"><img alt="Subject12" src={getImageUrl(`${item.image_url}`)}/></a>
|
||||
<div className="square-main">
|
||||
<p className="task-hide">
|
||||
<a href="javascript:void(0)" className="justify color-grey-name">{item.name}</a>
|
||||
</p>
|
||||
<div className="mt10">
|
||||
<p className="color-grey-6 clearfix">
|
||||
<a href="javascript:void(0)" className="fl color-grey-9">{item.owner_name}</a>
|
||||
<span className="fr squareIconSpan">
|
||||
<Tooltip placement='bottom' title="访问量">
|
||||
<i className="iconfont icon-liulanyan fl mr5"></i>
|
||||
</Tooltip>
|
||||
{item.visits_count}
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
})
|
||||
}
|
||||
</div>
|
||||
{
|
||||
totalCount > 15 &&
|
||||
<div className="mt30 mb50 edu-txt-center">
|
||||
<Pagination showQuickJumper total={totalCount} onChange={this.changePage} pageSize={16} current={page}/>
|
||||
</div>
|
||||
}
|
||||
</Spin>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
import React, { Component } from 'react';
|
||||
import { SnackbarHOC } from 'educoder';
|
||||
import {BrowserRouter as Router,Route,Switch} from 'react-router-dom';
|
||||
import {Tooltip,Menu,Pagination, Spin} from 'antd';
|
||||
import Loadable from 'react-loadable';
|
||||
import Loading from '../../../Loading';
|
||||
import NoneData from '../../courses/coursesPublic/NoneData'
|
||||
import axios from 'axios';
|
||||
import {getImageUrl,setImagesUrl} from 'educoder';
|
||||
import { TPMIndexHOC } from '../../tpm/TPMIndexHOC';
|
||||
import { CNotificationHOC } from '../../courses/common/CNotificationHOC'
|
||||
import "./usersInfo.css"
|
||||
|
||||
import Create from './publicCreatNew'
|
||||
|
||||
class InfosPath extends Component{
|
||||
constructor(props){
|
||||
super(props);
|
||||
this.state={
|
||||
category:undefined,
|
||||
page:1,
|
||||
sort_by:'time',
|
||||
status:undefined,
|
||||
per_page:16,
|
||||
isSpin:false,
|
||||
|
||||
totalCount:undefined,
|
||||
data:undefined
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount=()=>{
|
||||
this.setState({
|
||||
isSpin:true
|
||||
})
|
||||
let{category,status,sort_by,page,per_page}=this.state;
|
||||
this.getCourses(category,status,sort_by,page,per_page);
|
||||
}
|
||||
|
||||
getCourses=(category,status,sort_by,page,per_page)=>{
|
||||
let url=`/users/${this.props.match.params.username}/subjects.json`;
|
||||
axios.get((url),{params:{
|
||||
category,
|
||||
status,
|
||||
sort_by,
|
||||
page,
|
||||
per_page:this.props.is_current && category && page ==1?17:16
|
||||
}}).then((result)=>{
|
||||
if(result){
|
||||
this.setState({
|
||||
totalCount:result.data.count,
|
||||
data:result.data,
|
||||
isSpin:false
|
||||
})
|
||||
}
|
||||
}).catch((error)=>{
|
||||
console.log(error);
|
||||
})
|
||||
}
|
||||
|
||||
//切换种类
|
||||
changeCategory=(cate)=>{
|
||||
this.setState({
|
||||
category:cate,
|
||||
status:undefined,
|
||||
page:1,
|
||||
isSpin:true
|
||||
})
|
||||
let{sort_by}=this.state;
|
||||
this.getCourses(cate,undefined,sort_by,1);
|
||||
}
|
||||
// 切换状态
|
||||
changeStatus=(status)=>{
|
||||
let{category,sort_by}=this.state;
|
||||
this.setState({
|
||||
status,
|
||||
page:1,
|
||||
isSpin:true
|
||||
})
|
||||
this.getCourses(category,status,sort_by,1);
|
||||
}
|
||||
//切换页数
|
||||
changePage=(page)=>{
|
||||
this.setState({
|
||||
page,
|
||||
isSpin:true
|
||||
})
|
||||
let{category,sort_by,status}=this.state;
|
||||
this.getCourses(category,status,sort_by,page);
|
||||
}
|
||||
|
||||
// 进入课堂
|
||||
turnToCourses=(url)=>{
|
||||
this.props.history.push(url);
|
||||
}
|
||||
|
||||
|
||||
// 切换排序方式
|
||||
changeOrder= (sort)=>{
|
||||
this.setState({
|
||||
sort_by:sort,
|
||||
isSpin:true
|
||||
})
|
||||
let{category,status,page}=this.state;
|
||||
this.getCourses(category,status,sort,page);
|
||||
}
|
||||
|
||||
render(){
|
||||
let{
|
||||
category,
|
||||
status,
|
||||
sort_by,
|
||||
page,
|
||||
data,
|
||||
totalCount,
|
||||
isSpin
|
||||
} = this.state;
|
||||
let isStudent = this.props.isStudent();
|
||||
let is_current=this.props.is_current;
|
||||
return(
|
||||
<div className="educontent">
|
||||
<Spin size="large" spinning={isSpin}>
|
||||
<div className="white-panel edu-back-white pt25 pb25 clearfix ">
|
||||
<li className={category ? "" : "active"}><a href="javascript:void(0)" onClick={()=>this.changeCategory()}>全部</a></li>
|
||||
<li className={category=="manage" ? "active" : ""}><a href="javascript:void(0)" onClick={()=>this.changeCategory("manage")}>{is_current ? "我":"TA"}管理的</a></li>
|
||||
<li className={category=="study" ? "active" : ""}><a href="javascript:void(0)" onClick={()=>this.changeCategory("study")}>{is_current ? "我":"TA"}学习的</a></li>
|
||||
</div>
|
||||
{
|
||||
category && category == "manage" && is_current &&
|
||||
<div className="edu-back-white padding20-30 clearfix secondNav bor-top-greyE">
|
||||
<li className={status ? "" : "active"}><a href="javascript:void(0)" onClick={()=>this.changeStatus()}>全部</a></li>
|
||||
<li className={status=="editing" ? "active" : ""}><a href="javascript:void(0)" onClick={()=>this.changeStatus("editing")}>编辑中</a></li>
|
||||
<li className={status=="applying" ? "active" : ""}><a href="javascript:void(0)" onClick={()=>this.changeStatus("applying")}>待审核</a></li>
|
||||
<li className={status=="published" ? "active" : ""}><a href="javascript:void(0)" onClick={()=>this.changeStatus("published")}>已发布</a></li>
|
||||
</div>
|
||||
}
|
||||
{
|
||||
category && category == "study" && is_current &&
|
||||
<div className="edu-back-white padding20-30 clearfix secondNav bor-top-greyE">
|
||||
<li className={status ? "" : "active"}><a href="javascript:void(0)" onClick={()=>this.changeStatus()}>全部</a></li>
|
||||
<li className={status=="unfinished" ? "active" : ""}><a href="javascript:void(0)" onClick={()=>this.changeStatus("unfinished")}>未完成</a></li>
|
||||
<li className={status=="finished" ? "active" : ""}><a href="javascript:void(0)" onClick={()=>this.changeStatus("finished")}>已完成</a></li>
|
||||
</div>
|
||||
}
|
||||
<div className="pl25 pr25 clearfix font-12 mb20 mt20">
|
||||
<span className="fl color-grey-9">共参与{totalCount}个{category?category=="manage"?"发布":"学习":"实践课程"}</span>
|
||||
<span className="fr color-grey-9">时间最新</span>
|
||||
</div>
|
||||
<div className="square-list clearfix">
|
||||
{
|
||||
!isStudent && page == 1 && !category && is_current &&
|
||||
<Create href={"/paths/new"} name={"新建实践课程"} index="3"></Create>
|
||||
}
|
||||
{
|
||||
(!data || data.subjects.length==0) && (isStudent || category) && <NoneData></NoneData>
|
||||
}
|
||||
{
|
||||
data && data.subjects && data.subjects.map((item,key)=>{
|
||||
return(
|
||||
<div className="square-Item" onClick={()=>this.turnToCourses(`/paths/${item.id}`)}>
|
||||
{
|
||||
item.tag && <div className="tag-green"><span className="tag-name">{item.tag}</span><img src={setImagesUrl("images/educoder/tag2.png")} className="fl"/></div>
|
||||
}
|
||||
<a href="javascript:void(0)" className="square-img"><img alt="Subject12" src={getImageUrl(`${item.image_url}`)}/></a>
|
||||
<div className="square-main">
|
||||
<p className="task-hide">
|
||||
<a href="javascript:void(0)" className="justify color-grey-name">{item.name}</a>
|
||||
</p>
|
||||
<div className="mt10">
|
||||
<p className="color-grey-6 clearfix">
|
||||
<a href="javascript:void(0)" className="fl color-grey-9">{item.owner_name}</a>
|
||||
<span className="fr squareIconSpan">
|
||||
<Tooltip placement='bottom' title="访问量">
|
||||
<i className="iconfont icon-liulanyan fl mr5"></i>
|
||||
</Tooltip>
|
||||
{item.visits_count}
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
})
|
||||
}
|
||||
</div>
|
||||
{
|
||||
totalCount > 15 &&
|
||||
<div className="mt30 mb50 edu-txt-center">
|
||||
<Pagination showQuickJumper total={totalCount} onChange={this.changePage} pageSize={16} current={page}/>
|
||||
</div>
|
||||
}
|
||||
</Spin>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
export default InfosPath;
|
Loading…
Reference in new issue