修改文件的新建和编辑

This commit is contained in:
sylor_huang@126.com 2020-05-27 17:07:36 +08:00
parent d3ba91983d
commit 4b2cfb21fd
13 changed files with 807 additions and 612 deletions

View File

@ -1,24 +1,26 @@
'use strict';
"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 ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
const getClientEnvironment = require('./env');
const paths = require('./paths');
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 ModuleScopePlugin = require("react-dev-utils/ModuleScopePlugin");
const MonacoWebpackPlugin = require("monaco-editor-webpack-plugin");
const publicPath = '/';
const env = getClientEnvironment('/');
const getClientEnvironment = require("./env");
const paths = require("./paths");
const publicPath = "/";
const env = getClientEnvironment("/");
module.exports = {
optimization: {
splitChunks: {
chunks: 'async',
chunks: "async",
// 大于30KB才单独分离成chunk
minSize: 30000,
maxAsyncRequests: 5,
@ -30,16 +32,16 @@ module.exports = {
reuseExistingChunk: true,
},
vendors: {
name: 'vendors',
name: "vendors",
test: /[\\/]node_modules[\\/]/,
priority: -10,
chunks: "all"
}
}
chunks: "all",
},
runtimeChunk: true
},
mode: 'development',
},
runtimeChunk: true,
},
mode: "development",
// 开启调试
devtool: "source-map", // 开启调试
// These are the "entry points" to our application.
@ -47,7 +49,7 @@ module.exports = {
// The first two entry points enable "hot" CSS and auto-refreshes for JS.
entry: [
// We ship a few polyfills by default:
require.resolve('./polyfills'),
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
@ -58,7 +60,7 @@ module.exports = {
// the line below with these two lines if you prefer the stock client:
// require.resolve('webpack-dev-server/client') + '?/',
// require.resolve('webpack/hot/dev-server'),
require.resolve('react-dev-utils/webpackHotDevClient'),
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
@ -68,25 +70,25 @@ module.exports = {
output: {
// Add /* filename */ comments to generated require()s in the output.
pathinfo: true,
globalObject: 'this',
globalObject: "this",
// 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',
filename: "static/js/bundle.js",
// There are also additional JS chunk files if you use code splitting.
chunkFilename: 'static/js/[name].chunk.js',
chunkFilename: "static/js/[name].chunk.js",
// This is the URL that app is served from. We use "/" in development.
publicPath,
// Point sourcemap entries to original disk location (format as URL on Windows)
devtoolModuleFilenameTemplate: info =>
path.resolve(info.absoluteResourcePath).replace(/\\/g, '/'),
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(
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)
),
@ -96,13 +98,12 @@ module.exports = {
// 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'],
extensions: [".web.js", ".mjs", ".js", ".json", ".web.jsx", ".jsx"],
alias: {
"educoder": __dirname + "/../src/common/educoder.js",
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',
"react-native": "react-native-web",
},
plugins: [
// Prevents users from importing files from outside of src/ (or node_modules/).
@ -126,10 +127,10 @@ module.exports = {
// A missing `test` is equivalent to a match.
{
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
loader: require.resolve('url-loader'),
loader: require.resolve("url-loader"),
options: {
limit: 10000,
name: 'static/media/[name].[hash:8].[ext]',
name: "static/media/[name].[hash:8].[ext]",
},
},
// Process JS with Babel.
@ -137,19 +138,22 @@ module.exports = {
test: /\.(js|jsx|mjs)$/,
include: paths.appSrc,
exclude: /node_modules/,
loader: require.resolve('babel-loader'),
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,
"plugins": [
["import", {
"libraryName": "antd",
"libraryDirectory": "es",
"style": "css"
}]
]
plugins: [
[
"import",
{
libraryName: "antd",
libraryDirectory: "es",
style: "css",
},
],
],
},
},
// "postcss" loader applies autoprefixer to our CSS.
@ -160,29 +164,29 @@ module.exports = {
{
test: /\.css$/,
use: [
require.resolve('style-loader'),
require.resolve("style-loader"),
{
loader: require.resolve('css-loader'),
loader: require.resolve("css-loader"),
options: {
importLoaders: 1,
},
},
{
loader: require.resolve('postcss-loader'),
loader: require.resolve("postcss-loader"),
options: {
// Necessary for external CSS imports to work
// https://github.com/facebookincubator/create-react-app/issues/2677
ident: 'postcss',
ident: "postcss",
plugins: () => [
require('postcss-flexbugs-fixes'),
require("postcss-flexbugs-fixes"),
autoprefixer({
browsers: [
'>1%',
'last 4 versions',
'Firefox ESR',
'not ie < 9', // React doesn't support IE8 anyway
">1%",
"last 4 versions",
"Firefox ESR",
"not ie < 9", // React doesn't support IE8 anyway
],
flexbox: 'no-2009',
flexbox: "no-2009",
}),
],
},
@ -192,7 +196,7 @@ module.exports = {
{
test: /\.scss$/,
use: [
require.resolve('style-loader'),
require.resolve("style-loader"),
{
loader: require.resolve("css-loader"),
options: {
@ -200,8 +204,8 @@ module.exports = {
},
},
{
loader: require.resolve("sass-loader")
}
loader: require.resolve("sass-loader"),
},
],
},
// "file" loader makes sure those assets get served by WebpackDevServer.
@ -215,9 +219,9 @@ module.exports = {
// 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'),
loader: require.resolve("file-loader"),
options: {
name: 'static/media/[name].[hash:8].[ext]',
name: "static/media/[name].[hash:8].[ext]",
},
},
],
@ -261,17 +265,18 @@ module.exports = {
// You can remove this if you don't use Moment.js:
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new MonacoWebpackPlugin({
features: ['!gotoSymbol'],
})
features: ["coreCommands", "find"],
languages: ['plaintext','apex', 'azcli', 'bat', 'clojure', 'coffee', 'cpp', 'csharp', 'csp', 'css', 'dockerfile', 'fsharp', 'go', 'handlebars', 'html', 'ini', 'java', 'javascript', 'json', 'less', 'lua', 'markdown', 'msdax', 'mysql', 'objective', 'perl', 'pgsql', 'php', 'postiats', 'powerquery', 'powershell', 'pug', 'python', 'r', 'razor', 'redis', 'redshift', 'ruby', 'rust', 'sb', 'scheme', 'scss', 'shell', 'solidity', 'sql', 'st', 'swift', 'typescript', 'vb', 'xml', 'yaml']
}),
],
// 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',
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

View File

@ -1,25 +1,25 @@
'use strict';
const autoprefixer = require('autoprefixer');
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-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 MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
"use strict";
const autoprefixer = require("autoprefixer");
const path = require("path");
const webpack = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-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 MonacoWebpackPlugin = require("monaco-editor-webpack-plugin");
const TerserJSPlugin = require('terser-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const TerserJSPlugin = require("terser-webpack-plugin");
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const paths = require('./paths');
const getClientEnvironment = require('./env');
const paths = require("./paths");
const getClientEnvironment = require("./env");
// Some apps do not use client-side routing with pushState.
// For these, "homepage" can be set to "." to enable relative asset paths.
let publicPath = '/react/build/';
let publicPath = "/react/build/";
// let nodeEnv = process.env.NODE_ENV
// if (nodeEnv === 'testBuild') {
// publicPath = 'https://testforgeplus.trustie.net/react/build/';
@ -28,7 +28,7 @@ let publicPath = '/react/build/';
// publicPath = 'https://forgeplus.trustie.net/react/build/';
// }
const publicUrl = publicPath.slice(0, -1);
const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false';
const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== "false";
const env = getClientEnvironment(publicPath);
// This is the production configuration.
@ -39,7 +39,7 @@ module.exports = {
optimization: {
minimizer: [new TerserJSPlugin({}), new OptimizeCSSAssetsPlugin({})],
splitChunks: {
chunks: 'async',
chunks: "async",
// 大于30KB才单独分离成chunk
minSize: 30000,
maxAsyncRequests: 5,
@ -57,33 +57,33 @@ module.exports = {
// priority: -10,
// chunks: "all"
// }
}
},
runtimeChunk: true
},
runtimeChunk: true,
},
bail: true,
mode: 'production',
mode: "production",
devtool: false, //测试版
entry: [require.resolve('./polyfills'), paths.appIndexJs],
entry: [require.resolve("./polyfills"), paths.appIndexJs],
output: {
path: paths.appBuild,
globalObject: 'this',
filename: './static/js/[name].[contenthash:8].js',
chunkFilename: './static/js/[name].[contenthash:8].chunk.js',
globalObject: "this",
filename: "./static/js/[name].[contenthash:8].js",
chunkFilename: "./static/js/[name].[contenthash:8].chunk.js",
publicPath,
// Point sourcemap entries to original disk location (format as URL on Windows)
devtoolModuleFilenameTemplate: info =>
devtoolModuleFilenameTemplate: (info) =>
path
.relative(paths.appSrc, info.absoluteResourcePath)
.replace(/\\/g, '/'),
.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(
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)
),
@ -93,12 +93,12 @@ module.exports = {
// 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'],
extensions: [".web.js", ".mjs", ".js", ".json", ".web.jsx", ".jsx"],
alias: {
"educoder": __dirname + "/../src/common/educoder.js",
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',
"react-native": "react-native-web",
},
plugins: [
// Prevents users from importing files from outside of src/ (or node_modules/).
@ -114,15 +114,14 @@ module.exports = {
rules: [
{
test: /\.(js|jsx|mjs)$/,
enforce: 'pre',
enforce: "pre",
use: [
{
options: {
formatter: eslintFormatter,
eslintPath: require.resolve('eslint'),
eslintPath: require.resolve("eslint"),
},
loader: require.resolve('eslint-loader'),
loader: require.resolve("eslint-loader"),
},
],
include: paths.appSrc,
@ -136,10 +135,10 @@ module.exports = {
// assets smaller than specified size as data URLs to avoid requests.
{
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
loader: require.resolve('url-loader'),
loader: require.resolve("url-loader"),
options: {
limit: 10000,
name: 'static/media/[name].[hash:8].[ext]',
name: "static/media/[name].[hash:8].[ext]",
},
},
// Process JS with Babel.
@ -147,26 +146,30 @@ module.exports = {
test: /\.(js|jsx|mjs)$/,
include: paths.appSrc,
exclude: /node_modules/,
loader: require.resolve('babel-loader'),
loader: require.resolve("babel-loader"),
options: {
compact: true,
"plugins": [
["import", {
"libraryName": "antd",
"libraryDirectory": "es",
"style": "css"
}]
]
plugins: [
[
"import",
{
libraryName: "antd",
libraryDirectory: "es",
style: "css",
},
],
],
},
},
{
test: /\.css$/,
use: [{
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
publicPath
publicPath,
},
},
{
@ -177,31 +180,32 @@ module.exports = {
},
},
{
loader: require.resolve('postcss-loader'),
loader: require.resolve("postcss-loader"),
options: {
ident: 'postcss',
ident: "postcss",
plugins: () => [
require('postcss-flexbugs-fixes'),
require("postcss-flexbugs-fixes"),
autoprefixer({
browsers: [
'>1%',
'last 4 versions',
'Firefox ESR',
'not ie < 9', // React doesn't support IE8 anyway
">1%",
"last 4 versions",
"Firefox ESR",
"not ie < 9", // React doesn't support IE8 anyway
],
flexbox: 'no-2009',
flexbox: "no-2009",
}),
],
},
}
]
},
],
},
{
test: /\.scss$/,
use: [{
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
publicPath
publicPath,
},
},
{
@ -212,8 +216,8 @@ module.exports = {
},
},
{
loader: require.resolve("sass-loader")
}
loader: require.resolve("sass-loader"),
},
],
},
// "file" loader makes sure assets end up in the `build` folder.
@ -221,14 +225,14 @@ module.exports = {
// This loader doesn't use a "test" so it will catch all modules
// that fall through the other loaders.
{
loader: require.resolve('file-loader'),
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].[contenthash:8].[ext]',
name: "static/media/[name].[contenthash:8].[ext]",
},
},
// ** STOP ** Are you adding a new loader?
@ -268,14 +272,14 @@ module.exports = {
new webpack.DefinePlugin(env.stringified),
new MiniCssExtractPlugin({
filename: 'static/css/[name].[contenthash:8].css',
chunkFilename: 'static/css/[name].[contenthash:8].chunk.css',
filename: "static/css/[name].[contenthash:8].css",
chunkFilename: "static/css/[name].[contenthash:8].chunk.css",
}),
// 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',
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.
@ -285,13 +289,13 @@ module.exports = {
// 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',
filename: "service-worker.js",
logger(message) {
if (message.indexOf('Total precache size is') === 0) {
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) {
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;
@ -300,7 +304,7 @@ module.exports = {
},
minify: true,
// For unknown URLs, fallback to the index page
navigateFallback: publicUrl + '/index.html',
navigateFallback: publicUrl + "/index.html",
// Ignores URLs starting from /__ (useful for Firebase):
// https://github.com/facebookincubator/create-react-app/issues/2237#issuecomment-302693219
navigateFallbackWhitelist: [/^(?!\/__).*/],
@ -314,18 +318,19 @@ module.exports = {
// You can remove this if you don't use Moment.js:
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new MonacoWebpackPlugin({
features: ['!gotoSymbol'],
features: ["coreCommands", "find"],
languages: ['plaintext','apex', 'azcli', 'bat', 'clojure', 'coffee', 'cpp', 'csharp', 'csp', 'css', 'dockerfile', 'fsharp', 'go', 'handlebars', 'html', 'ini', 'java', 'javascript', 'json', 'less', 'lua', 'markdown', 'msdax', 'mysql', 'objective', 'perl', 'pgsql', 'php', 'postiats', 'powerquery', 'powershell', 'pug', 'python', 'r', 'razor', 'redis', 'redshift', 'ruby', 'rust', 'sb', 'scheme', 'scss', 'shell', 'solidity', 'sql', 'st', 'swift', 'typescript', 'vb', 'xml', 'yaml']
}),
new webpack.NamedChunksPlugin(),
new webpack.HashedModuleIdsPlugin()
new webpack.HashedModuleIdsPlugin(),
],
// 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',
dgram: "empty",
fs: "empty",
net: "empty",
tls: "empty",
child_process: "empty",
},
};

17
package-lock.json generated
View File

@ -14904,20 +14904,13 @@
}
},
"react-monaco-editor": {
"version": "0.25.1",
"resolved": "https://registry.npmjs.org/react-monaco-editor/-/react-monaco-editor-0.25.1.tgz",
"integrity": "sha512-VLksQjt8fmeIZoET9fQgmR0sdCCBFaiss92MwW5JvgO3JfrnhHtrLBqrSQRjtbUmef1EmEKi4gZp5Mh0oidvVg==",
"version": "0.36.0",
"resolved": "https://registry.npmjs.org/react-monaco-editor/-/react-monaco-editor-0.36.0.tgz",
"integrity": "sha512-JVA5SZhOoYZ0DCdTwYgagtRb3jHo4KN7TVFiJauG+ZBAJWfDSTzavPIrwzWbgu8ahhDqDk4jUcYlOJL2BC/0UA==",
"requires": {
"@types/react": "*",
"monaco-editor": "^0.16.0",
"@types/react": "^16.x",
"monaco-editor": "*",
"prop-types": "^15.7.2"
},
"dependencies": {
"monaco-editor": {
"version": "0.16.2",
"resolved": "https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.16.2.tgz",
"integrity": "sha512-NtGrFzf54jADe7qsWh3lazhS7Kj0XHkJUGBq9fA/Jbwc+sgVcyfsYF6z2AQ7hPqDC+JmdOt/OwFjBnRwqXtx6w=="
}
}
},
"react-onclickoutside": {

View File

@ -47,8 +47,8 @@
"katex": "^0.11.1",
"lodash": "^4.17.15",
"loglevel": "^1.6.8",
"material-ui": "^1.0.0-beta.40",
"marked": "^1.0.0",
"material-ui": "^1.0.0-beta.40",
"md5": "^2.2.1",
"mini-css-extract-plugin": "^0.9.0",
"moment": "^2.23.0",
@ -72,10 +72,10 @@
"rc-tree": "^1.15.3",
"rc-upload": "^2.9.4",
"react": "^16.13.1",
"react-color": "^2.18.0",
"react-beautiful-dnd": "^10.0.4",
"react-codemirror": "^1.0.0",
"react-codemirror2": "^6.0.1",
"react-color": "^2.18.0",
"react-content-loader": "^3.1.1",
"react-cookies": "^0.1.1",
"react-datepicker": "^2.14.1",
@ -84,7 +84,7 @@
"react-hot-loader": "^4.12.20",
"react-infinite-scroller": "^1.2.4",
"react-loadable": "^5.3.1",
"react-monaco-editor": "^0.25.1",
"react-monaco-editor": "0.36",
"react-player": "^1.15.3",
"react-redux": "5.0.7",
"react-router": "^4.2.0",

View File

@ -98,9 +98,9 @@ export function initAxiosInterceptors(props) {
// TODO 避免重复的请求 https://github.com/axios/axios#cancellation
// TODO 读取到package.json中的配置
var proxy = "http://localhost:3000"
proxy = "https://pre-newweb.educoder.net"
proxy = "https://testforgeplus.trustie.net/"
// var proxy = "http://localhost:3000"
// proxy = "https://pre-newweb.educoder.net"
var proxy = "https://testforgeplus.trustie.net/"
// 在这里使用requestMap控制避免用户通过双击等操作发出重复的请求
// 如果需要支持重复的请求考虑config里面自定义一个allowRepeat参考来控制

View File

@ -1,23 +1,24 @@
import React, { Component } from "react";
import { Popconfirm } from 'antd';
import './list.css';
import axios from 'axios';
import Meditor from "../Newfile/m_editor"
import { Popconfirm, Select } from "antd";
import "./list.css";
import axios from "axios";
import Meditor from "../Newfile/m_editor";
function bytesToSize(bytes) {
if (bytes === 0) return '0 B';
if (bytes === 0) return "0 B";
let k = 1024,
sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
sizes = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"],
i = Math.floor(Math.log(bytes) / Math.log(k));
return (bytes / Math.pow(k, i)). toFixed(2) + ' ' + sizes[i];
return (bytes / Math.pow(k, i)).toFixed(2) + " " + sizes[i];
}
class CoderRootFileDetail extends Component {
constructor(props) {
super(props);
this.state = {
readOnly: true,
value:undefined
}
value: undefined,
language: undefined,
};
}
componentDidMount = () => {
@ -25,51 +26,57 @@ class CoderRootFileDetail extends Component{
this.setState({
value: detail.content,
readOnly: readOnly
})
}
readOnly: readOnly,
});
};
select_language = (e) => {
console.log(e);
this.setState({
language: e,
});
};
EditFile = () => {
this.setState({
readOnly:false
})
}
readOnly: false,
});
};
CancelEdit = () => {
this.setState({
readOnly:true
})
}
readOnly: true,
});
};
// 编辑文件
changeMmirror = (e, e1, value) => {
this.setState({
value
})
}
value,
});
};
deleteFile = () => {
const { branch, detail } = this.props;
const { projectsId } = this.props.match.params;
const url = `/repositories/${projectsId}/delete_file.json`;
axios.delete(url,{
axios
.delete(url, {
params: {
filepath: detail.path,
branch,
sha:detail.sha
}
}).then(result=>{
sha: detail.sha,
},
})
.then((result) => {
if (result) {
this.props.showNotification("删除成功!");
this.props.history.push(`/projects/${projectsId}`);
}
}).catch(error=>{
console.log(error);
})
}
.catch((error) => {
console.log(error);
});
};
// // 确认修改文件
// UpdateFile=()=>{
@ -97,66 +104,140 @@ class CoderRootFileDetail extends Component{
this.setState({
value,
});
}
};
render() {
const { detail, current_user, isManager, isDeveloper } = this.props;
const { readOnly } = this.state;
const { readOnly, language } = this.state;
let flag = current_user && current_user.login && (isManager || isDeveloper);
// var options = {
// lineNumbers: true,
// mode: 'javascript',
// readOnly:readOnly?'nocursor':false,
// autofocus:readOnly?false:true,
// styleActiveLine:true
// };
const Option = Select.Option;
const languages = [
"apex",
"azcli",
"bat",
"clojure",
"coffee",
"cpp",
"csharp",
"csp",
"css",
"dockerfile",
"fsharp",
"go",
"handlebars",
"html",
"ini",
"java",
"javascript",
"json",
"less",
"lua",
"markdown",
"msdax",
"mysql",
"objective",
"perl",
"pgsql",
"php",
"postiats",
"powerquery",
"powershell",
"pug",
"python",
"r",
"razor",
"redis",
"redshift",
"ruby",
"rust",
"sb",
"scheme",
"scss",
"shell",
"solidity",
"sql",
"st",
"swift",
"typescript",
"vb",
"xml",
"yaml",
];
return (
<div className="mb20">
<div className="">
<p className="branchTitle f-wrap-alignCenter f-wrap-between">
<span>{bytesToSize(detail && detail.size)}</span>
{
flag &&
<span>
{
readOnly ?
<a onClick={this.EditFile} className="ml20"><i className="iconfont icon-bianji1 font-15 color-grey-6"></i></a>
:
<div className="grid-item branchTitle">
<div className="grid-item">
<span className="ml20 color-grey-6 font-16">{bytesToSize(detail && detail.size)}</span>
</div>
<p className="text-right">
{flag && (
<div>
{readOnly ? (
<a onClick={this.EditFile} className="ml20">
<i className="iconfont icon-bianji1 font-15 color-grey-6"></i>
</a>
) : (
<React.Fragment>
<button type="button" className="ant-btn ant-btn-sm mr10" onClick={this.CancelEdit}><span> </span>
<Select
showSearch={true}
placeholder={"请选择文本语言"}
style={{ width: 200 }}
value={language}
onChange={this.select_language}
>
<Option value={undefined}>请选择文本语言</Option>
{languages.map((item, key) => {
return <Option value={item}>{item}</Option>;
})}
</Select>
<button
type="button"
className="ant-btn ant-btn-sm ml20"
onClick={this.CancelEdit}
>
<span> </span>
</button>
{/* <button type="button" className="ant-btn ant-btn-primary ant-btn-sm" onClick={this.UpdateFile}><span> </span>
</button> */}
</React.Fragment>
}
)}
<Popconfirm title="确认删除这个文件?" className="ml20" okText="确定" cancelText="取消" onConfirm={this.deleteFile}>
<a><i className="iconfont icon-shanchu font-15 color-grey-6"></i></a>
<Popconfirm
title="确认删除这个文件?"
className="ml20"
okText="确定"
cancelText="取消"
onConfirm={this.deleteFile}
>
<a>
<i className="iconfont icon-shanchu font-15 color-grey-6"></i>
</a>
</Popconfirm>
</span>
}
</div>
)}
</p>
</div>
<div>
{
detail.direct_download ?
{detail.direct_download ? (
<div className="text-center">
<a href={detail.download_url} className="color-blue font-15">下载原始文件</a>
<a href={detail.download_url} className="color-blue font-15">
下载原始文件
</a>
</div>
:
) : (
<Meditor
{...this.props}
{...this.state}
language={language ? language : "javascript"}
filepath={`/${detail.path}`}
content={detail.content}
readOnly={readOnly}
editorType="update"
>
</Meditor>
}
></Meditor>
)}
</div>
</div>
)
);
}
}

View File

@ -1,60 +1,145 @@
import React, { Component } from "react";
import Meditor from "./m_editor"
import Top from '../Main/DetailTop';
import './index.css';
import { Input } from 'antd';
import Meditor from "./m_editor";
import Top from "../Main/DetailTop";
import "./index.css";
import { Input, Select } from "antd";
class Index extends Component {
constructor(props) {
super(props);
this.state = {
editorValue: "",
filename:""
}
filename: "",
language: undefined
};
}
// 命名文件
changeFileName = (e) => {
this.setState({
filename:e.target.value
})
}
filename: e.target.value,
});
};
// 取消,弹框询问
CancelAddFile = () => {
this.props.history.goBack();
};
select_language = (e) => {
console.log(e)
this.setState({
language: e
})
}
render() {
const { pathname } = this.props.location;
const { filename } = this.state;
const { filename, language } = this.state;
const urlroot = pathname.split("newfile")[1];
const file_path = `${urlroot}/${filename}`
const file_path = `${urlroot}/${filename}`;
const { projectDetail } = this.props;
const Option = Select.Option;
const languages = [
"apex",
"azcli",
"bat",
"clojure",
"coffee",
"cpp",
"csharp",
"csp",
"css",
"dockerfile",
"fsharp",
"go",
"handlebars",
"html",
"ini",
"java",
"javascript",
"json",
"less",
"lua",
"markdown",
"msdax",
"mysql",
"objective",
"perl",
"pgsql",
"php",
"postiats",
"powerquery",
"powershell",
"pug",
"python",
"r",
"razor",
"redis",
"redshift",
"ruby",
"rust",
"sb",
"scheme",
"scss",
"shell",
"solidity",
"sql",
"st",
"swift",
"typescript",
"vb",
"xml",
"yaml",
];
return (
<React.Fragment>
<Top {...this.props} {...this.state} />
<div className="main">
<p className="pb15 bor-bottom-greyE font-16 color-grey-3 mb20">新建文件</p>
<p className="pb15 bor-bottom-greyE font-16 color-grey-3 mb20">
新建文件
</p>
<div>
<div className="f-wrap-alignCenter mb20">
<div className="grid-item mb20">
<div className="grid-item">
<div className="setInputAddon">
<Input addonBefore={`/${projectDetail && projectDetail.identifier}${urlroot}/`} value={filename} onChange={this.changeFileName} placeholder="命名文件..."/>
<Input
addonBefore={`/${
projectDetail && projectDetail.identifier
}${urlroot}/`}
value={filename}
onChange={this.changeFileName}
placeholder="命名文件..."
/>
</div>
<a onClick={this.CancelAddFile} className="color-blue">取消</a>
<a onClick={this.CancelAddFile} className="color-blue">
取消
</a>
</div>
<div className="text-right">
<Select showSearch={true} placeholder={"请选择文本语言"} style={{ width: 200 }} value={language} onChange={this.select_language}>
<Option value={undefined}>请选择文本语言</Option>
{languages.map((item, key) => {
return <Option value={item}>{item}</Option>;
})}
</Select>
</div>
</div>
<Meditor
{...this.props}
{...this.state}
filepath={`${file_path}`}
content={""}
language = {language}
content={undefined}
readOnly={false}
editorType="new"
>
</Meditor>
></Meditor>
</div>
</div>
</React.Fragment>
)
);
}
}
export default Index;

View File

@ -10,7 +10,7 @@ class UserSubmitComponent extends Component {
constructor(props) {
super(props);
this.state = {
submitType: "0"
submitType: "0",
};
}
@ -52,7 +52,6 @@ class UserSubmitComponent extends Component {
});
};
// 确认修改文件
UpdateFile = () => {
const { branch, detail, content, filepath } = this.props;
@ -61,26 +60,32 @@ class UserSubmitComponent extends Component {
const url = `/repositories/${projectsId}/update_file.json`;
this.props.form.validateFieldsAndScroll((err, values) => {
if (!err) {
axios.put(url,{
axios
.put(url, {
filepath: detail.path,
branch: branch,
new_branch: submitType === "1" ? values.branchname : undefined,
content: content,
sha: detail.sha,
}).then(result=>{
if(result){
const url = `/projects/${projectsId}/coders?url=${detail.path.split("/")[0]}`;
message: values.desc,
})
.then((result) => {
if (result && result.data.status === 1) {
// const url = `/projects/${projectsId}/coders?url=${detail.path.split("/")[0]}`;
// this.props.history.push(url);
const url = values.branchname
? `/projects/${projectsId}/coders?branch=${values.branchname}`
: `/projects/${projectsId}/coders`;
this.props.history.push(url);
this.props.showNotification("修改成功!");
}
}).catch(error=>{
})
.catch((error) => {
console.log(error);
})
}
})
});
}
});
};
render() {
const { submitType } = this.state;
@ -89,7 +94,7 @@ class UserSubmitComponent extends Component {
const { branch, projectsId } = this.props.match.params;
const { current_user, filepath, projectDetail } = this.props;
const {editor_type} = this.props
const { editor_type } = this.props;
const changeSubmitBranch = () => {
if (submitType === "1") {
@ -128,7 +133,7 @@ class UserSubmitComponent extends Component {
alt=""
className="screwImg"
/>
<span className="color-grey-3">
<span className="color-grey-3 ver-middle">
{current_user && current_user.username}
</span>
</Link>
@ -138,7 +143,7 @@ class UserSubmitComponent extends Component {
<div className="userScrew">
<div className="screwPanel">
<Form>
<Form.Item>
<Form.Item style={{display: "none"}}>
{getFieldDecorator("path", {
rules: [],
})(
@ -155,12 +160,12 @@ class UserSubmitComponent extends Component {
rules: [
{
required: true,
message: "请输入合并请求的描述内容",
message: "请添加描述信息",
},
],
})(
<TextArea
placeholder={`请输入合并请求的描述,(必填)`}
placeholder={`必填,描述主要修改类型和内容`}
authSize={{ minRows: 3, maxRows: 5 }}
/>
)}
@ -181,7 +186,11 @@ class UserSubmitComponent extends Component {
</div>
</div>
<div className="mt50 text-center">
<Button type="primary" onClick={editor_type==="new" ? this.subMitFrom : this.UpdateFile} className="mr30">
<Button
type="primary"
onClick={editor_type === "new" ? this.subMitFrom : this.UpdateFile}
className="mr30"
>
提交变更
</Button>
<Button

View File

@ -5,4 +5,4 @@
.monaco-editor .margin-view-overlays .current-line{
background-color: rgba(48,232,132,0.15);
}
.branchTable .margin-view-overlays{width: 35px !important;}
.branchTable .margin-view-overlays{border-right: none !important; background-color: #fcfcfc !important;}

View File

@ -76,3 +76,5 @@
margin-right: 0px;
}
}
.grid-item{display: grid; align-items: center; grid-template-columns: max-content 1fr;}
.text-right{text-align: right;}

View File

@ -1,60 +1,72 @@
import React, { Component } from "react";
import Editor from "react-monaco-editor";
import UserSubmitComponent from './UserSubmitComponent';
import UserSubmitComponent from "./UserSubmitComponent";
import './index.css';
import "./editor.css"
import "./index.css";
import "./editor.css";
class m_editor extends Component {
constructor(props) {
super(props);
this.state = {
editorValue: this.props.content,
}
};
}
changeEditor = (editorValue) => {
this.setState({
editorValue
})
}
editorValue,
});
};
render() {
const { editorValue } = this.state;
const { readOnly, editorType } = this.props;
const { readOnly, editorType, language } = this.props;
const editor_options = {
lineNumbers: "on",
selectOnLineNumbers: true,
lineHeight: 24,
renderLineHighlight: "line",
revealHorizontalRightPadding: 5,
lineNumbersMinChars: 2,
readOnly: readOnly,
cursorStyle: readOnly ? "underline-thin" : "line"
}
cursorStyle: readOnly ? "underline-thin" : "line",
folding: true,
foldingStrategy: "indentation", // 代码可分小段折叠
automaticLayout: true, // 自适应布局
overviewRulerBorder: false, // 不要滚动条的边框
scrollBeyondLastLine: false, // 取消代码后面一大段空白
minimap: {
// 不要小地图
enabled: false,
},
};
return (
<React.Fragment>
<div>
<div className="branchTable">
<Editor
height="320px"
language={language ? language : "plaintext"}
theme={"vs-grey"}
defaultValue="请输入内容"
value={editorValue}
options={editor_options}
onChange={this.changeEditor}
editorWillMount={this.editorWillMount}
/>
</div>
{!readOnly && <UserSubmitComponent
{!readOnly && (
<UserSubmitComponent
{...this.props}
{...this.state}
filepath={`${this.props.filepath}`}
content={editorValue}
editor_type={editorType}
></UserSubmitComponent>
}
)}
</div>
</React.Fragment>
)
);
}
}
export default m_editor;

View File

@ -1,8 +1,8 @@
import React, { Component } from "react";
import { Input, Dropdown, Menu, Icon, Pagination, Spin, Button} from "antd";
import { Input, Dropdown, Menu, Icon, Pagination, Spin, Button, DatePicker } from "antd";
import "./order.css";
// const { RangePicker } = DatePicker;
const { RangePicker } = DatePicker;
import NoneData from "../Nodata";
import OrderItem from "./OrderItem";
@ -379,20 +379,20 @@ class order extends Component {
<div className="main">
<div className="topWrapper" style={{ borderBottom: "none", padding: "0" }}>
<div>
<span className="mr30">
<span className="mr40">
<span className="mr8 color-grey">所有:</span>
<Button size="small" type={status_type==="0" ? "primary" : ""} ghost={status_type==="0" ? true : false} onClick={() => this.openorder("0")}>{data && data.all_count}</Button>
<Button size="small">{data && data.all_count}</Button>
</span>
<span className="mr30">
<span className="mr40">
<span className="mr8 color-grey">开启中:</span>
<Button size="small" type={status_type==="1" ? "primary" : ""} ghost={status_type==="1" ? true : false} onClick={() => this.openorder("1")}>{data && data.open_count}</Button>
<Button size="small">{data && data.open_count}</Button>
</span>
<span>
<span className="mr8 color-grey">已关闭:</span>
<Button size="small" type={status_type==="2" ? "primary" : ""} ghost={status_type==="2" ? true : false} onClick={() => this.openorder("2")}>{data && data.close_count}</Button>
<Button size="small">{data && data.close_count}</Button>
</span>
</div>
<Button type="primary" onClick={() => this.islogin()} ghost><Icon type="plus" size="16"></Icon></Button>
<Button type="primary" onClick={() => this.islogin()}><Icon type="plus" size="16"></Icon></Button>
</div>
<div className="topWrapper" style={{ borderBottom: "none" }}>
@ -404,14 +404,14 @@ class order extends Component {
style={{ width: 350 }}
/>
</div>
{/* <DatePicker showTime onChange={onChange} onOk={onOk} /> */}
{/* <br /> */}
{/* <RangePicker
<DatePicker showTime onChange={onChange} onOk={onOk} />
<br />
<RangePicker
showTime={{ format: 'HH:mm' }}
format="YYYY-MM-DD HH:mm"
onChange={onChange}
onOk={onOk}
/> */}
/>
{/* <p className="topWrapper_type">
<li
className={status_type === "1" ? "active" : ""}

View File

@ -113,3 +113,6 @@ ul,ol,dl{
width: 100%;
}
}
.ver-middle{
vertical-align: middle;
}