diff --git a/oj/.babelrc b/.babelrc
similarity index 100%
rename from oj/.babelrc
rename to .babelrc
diff --git a/admin/.editorconfig b/.editorconfig
similarity index 100%
rename from admin/.editorconfig
rename to .editorconfig
diff --git a/admin/.eslintignore b/.eslintignore
similarity index 100%
rename from admin/.eslintignore
rename to .eslintignore
diff --git a/oj/.eslintrc.js b/.eslintrc.js
similarity index 100%
rename from oj/.eslintrc.js
rename to .eslintrc.js
diff --git a/.gitignore b/.gitignore
index 77c1ac8..52061c5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,10 +1,70 @@
-.DS_Store
-node_modules/
+# Logs
+logs
+*.log
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+
+# Runtime data
+pids
+*.pid
+*.seed
+*.pid.lock
+
+# Directory for instrumented libs generated by jscoverage/JSCover
+lib-cov
+
+# Coverage directory used by tools like istanbul
+coverage
+
+# nyc test coverage
+.nyc_output
+
+# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
+.grunt
+
+# Bower dependency directory (https://bower.io/)
+bower_components
+
+# node-waf configuration
+.lock-wscript
+
+# Compiled binary addons (http://nodejs.org/api/addons.html)
dist/
-npm-debug.log
-npm-debug.log.*
-test/unit/coverage
-test/e2e/reports
-selenium-debug.log
-.idea/
-stat.json
+
+# Dependency directories
+node_modules/
+jspm_packages/
+
+# Typescript v1 declaration files
+typings/
+
+# Optional npm cache directory
+.npm
+
+# Optional eslint cache
+.eslintcache
+
+# Optional REPL history
+.node_repl_history
+
+# Output of 'npm pack'
+*.tgz
+
+# Yarn Integrity file
+.yarn-integrity
+
+# dotenv environment variables file
+.env
+
+# editor
+.vscode
+.idea
+
+# test_code
+test.vue
+
+# build
+vendor-manifest.json
+vendor.dll.js
+
diff --git a/oj/.postcssrc.js b/.postcssrc.js
similarity index 100%
rename from oj/.postcssrc.js
rename to .postcssrc.js
diff --git a/admin/.babelrc b/admin/.babelrc
deleted file mode 100644
index c06df4d..0000000
--- a/admin/.babelrc
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "presets": [
- ["env", {
- "modules": false,
- "targets": {
- "browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
- }
- }],
- "stage-2"
- ],
- "plugins": ["transform-runtime"],
- "env": {
- "test": {
- "presets": ["env", "stage-2"],
- "plugins": ["istanbul"]
- }
- }
-}
diff --git a/admin/.eslintrc.js b/admin/.eslintrc.js
deleted file mode 100644
index 8e6549e..0000000
--- a/admin/.eslintrc.js
+++ /dev/null
@@ -1,22 +0,0 @@
-module.exports = {
- root: true,
- parser: 'babel-eslint',
- parserOptions: {
- sourceType: 'module'
- },
- // https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
- extends: 'standard',
- // required to lint *.vue files
- plugins: [
- 'html'
- ],
- // add your custom rules here
- 'rules': {
- // allow paren-less arrow functions
- 'arrow-parens': 0,
- // allow async-await
- 'generator-star-spacing': 0,
- // allow debugger during development
- 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
- }
-}
diff --git a/admin/build/dev-server.js b/admin/build/dev-server.js
deleted file mode 100644
index a503b51..0000000
--- a/admin/build/dev-server.js
+++ /dev/null
@@ -1,105 +0,0 @@
-'use strict'
-require('./check-versions')()
-
-const config = require('../config')
-if (!process.env.NODE_ENV) {
- process.env.NODE_ENV = JSON.parse(config.dev.env.NODE_ENV)
-}
-
-const opn = require('opn')
-const path = require('path')
-const express = require('express')
-const webpack = require('webpack')
-const proxyMiddleware = require('http-proxy-middleware')
-const webpackConfig = require('./webpack.dev.conf')
-
-// default port where dev server listens for incoming traffic
-const port = process.env.PORT || config.dev.port
-// automatically open browser, if not set will be false
-const autoOpenBrowser = !!config.dev.autoOpenBrowser
-// Define HTTP proxies to your custom API backend
-// https://github.com/chimurai/http-proxy-middleware
-const proxyTable = config.dev.proxyTable
-
-const app = express()
-const compiler = webpack(webpackConfig)
-
-const devMiddleware = require('webpack-dev-middleware')(compiler, {
- publicPath: webpackConfig.output.publicPath,
- quiet: true
-})
-
-const hotMiddleware = require('webpack-hot-middleware')(compiler, {
- log: false,
- heartbeat: 2000
-})
-// force page reload when html-webpack-plugin template changes
-// currently disabled until this is resolved:
-// https://github.com/jantimon/html-webpack-plugin/issues/680
-// compiler.plugin('compilation', function (compilation) {
-// compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {
-// hotMiddleware.publish({ action: 'reload' })
-// cb()
-// })
-// })
-
-// enable hot-reload and state-preserving
-// compilation error display
-app.use(hotMiddleware)
-
-// proxy api requests
-Object.keys(proxyTable).forEach(function (context) {
- let options = proxyTable[context]
- if (typeof options === 'string') {
- options = { target: options }
- }
- app.use(proxyMiddleware(options.filter || context, options))
-})
-
-// handle fallback for HTML5 history API
-app.use(require('connect-history-api-fallback')())
-
-// serve webpack bundle output
-app.use(devMiddleware)
-
-// serve pure static assets
-const staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory)
-app.use(staticPath, express.static('./static'))
-
-const uri = 'http://localhost:' + port
-
-var _resolve
-var _reject
-var readyPromise = new Promise((resolve, reject) => {
- _resolve = resolve
- _reject = reject
-})
-
-var server
-var portfinder = require('portfinder')
-portfinder.basePort = port
-
-console.log('> Starting dev server...')
-devMiddleware.waitUntilValid(() => {
- portfinder.getPort((err, port) => {
- if (err) {
- _reject(err)
- }
- process.env.PORT = port
- var uri = 'http://localhost:' + port
- console.log('> Listening at ' + uri + '\n')
- // when env is testing, don't need open it
- if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') {
- opn(uri)
- }
- server = app.listen(port)
- _resolve()
- })
-})
-
-module.exports = {
- ready: readyPromise,
- close: () => {
- server.close()
- }
-}
diff --git a/admin/build/utils.js b/admin/build/utils.js
deleted file mode 100644
index 4ac71cb..0000000
--- a/admin/build/utils.js
+++ /dev/null
@@ -1,72 +0,0 @@
-'use strict'
-const path = require('path')
-const config = require('../config')
-const ExtractTextPlugin = require('extract-text-webpack-plugin')
-
-exports.assetsPath = function (_path) {
- const assetsSubDirectory = process.env.NODE_ENV === 'production'
- ? config.build.assetsSubDirectory
- : config.dev.assetsSubDirectory
- return path.posix.join(assetsSubDirectory, _path)
-}
-
-exports.cssLoaders = function (options) {
- options = options || {}
-
- const cssLoader = {
- loader: 'css-loader',
- options: {
- minimize: process.env.NODE_ENV === 'production',
- sourceMap: options.sourceMap
- }
- }
-
- // generate loader string to be used with extract text plugin
- function generateLoaders (loader, loaderOptions) {
- const loaders = [cssLoader]
- if (loader) {
- loaders.push({
- loader: loader + '-loader',
- options: Object.assign({}, loaderOptions, {
- sourceMap: options.sourceMap
- })
- })
- }
-
- // Extract CSS when that option is specified
- // (which is the case during production build)
- if (options.extract) {
- return ExtractTextPlugin.extract({
- use: loaders,
- fallback: 'vue-style-loader'
- })
- } else {
- return ['vue-style-loader'].concat(loaders)
- }
- }
-
- // https://vue-loader.vuejs.org/en/configurations/extract-css.html
- return {
- css: generateLoaders(),
- postcss: generateLoaders(),
- less: generateLoaders('less'),
- sass: generateLoaders('sass', { indentedSyntax: true }),
- scss: generateLoaders('sass'),
- stylus: generateLoaders('stylus'),
- styl: generateLoaders('stylus')
- }
-}
-
-// Generate loaders for standalone style files (outside of .vue)
-exports.styleLoaders = function (options) {
- const output = []
- const loaders = exports.cssLoaders(options)
- for (const extension in loaders) {
- const loader = loaders[extension]
- output.push({
- test: new RegExp('\\.' + extension + '$'),
- use: loader
- })
- }
- return output
-}
diff --git a/admin/build/webpack.base.conf.js b/admin/build/webpack.base.conf.js
deleted file mode 100644
index 8380237..0000000
--- a/admin/build/webpack.base.conf.js
+++ /dev/null
@@ -1,75 +0,0 @@
-'use strict'
-const path = require('path')
-const utils = require('./utils')
-const config = require('../config')
-const vueLoaderConfig = require('./vue-loader.conf')
-
-function resolve (dir) {
- return path.join(__dirname, '..', dir)
-}
-
-module.exports = {
- entry: {
- app: './src/main.js'
- },
- output: {
- path: config.build.assetsRoot,
- filename: '[name].js',
- publicPath: process.env.NODE_ENV === 'production'
- ? config.build.assetsPublicPath
- : config.dev.assetsPublicPath
- },
- resolve: {
- extensions: ['.js', '.vue', '.json'],
- alias: {
- '@': resolve('src'),
- }
- },
- module: {
- rules: [
- {
- test: /\.(js|vue)$/,
- loader: 'eslint-loader',
- enforce: 'pre',
- include: [resolve('src'), resolve('test')],
- options: {
- formatter: require('eslint-friendly-formatter')
- }
- },
- {
- test: /\.vue$/,
- loader: 'vue-loader',
- options: vueLoaderConfig
- },
- {
- test: /\.js$/,
- loader: 'babel-loader',
- include: [resolve('src'), resolve('test')]
- },
- {
- test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
- loader: 'url-loader',
- options: {
- limit: 10000,
- name: utils.assetsPath('img/[name].[hash:7].[ext]')
- }
- },
- {
- test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
- loader: 'url-loader',
- options: {
- limit: 10000,
- name: utils.assetsPath('media/[name].[hash:7].[ext]')
- }
- },
- {
- test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
- loader: 'url-loader',
- options: {
- limit: 10000,
- name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
- }
- }
- ]
- }
-}
diff --git a/admin/build/webpack.dev.conf.js b/admin/build/webpack.dev.conf.js
deleted file mode 100644
index 6f25d63..0000000
--- a/admin/build/webpack.dev.conf.js
+++ /dev/null
@@ -1,36 +0,0 @@
-'use strict'
-const utils = require('./utils')
-const webpack = require('webpack')
-const config = require('../config')
-const merge = require('webpack-merge')
-const baseWebpackConfig = require('./webpack.base.conf')
-const HtmlWebpackPlugin = require('html-webpack-plugin')
-const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
-
-// add hot-reload related code to entry chunks
-Object.keys(baseWebpackConfig.entry).forEach(function (name) {
- baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name])
-})
-
-module.exports = merge(baseWebpackConfig, {
- module: {
- rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap })
- },
- // cheap-module-eval-source-map is faster for development
- devtool: '#cheap-module-eval-source-map',
- plugins: [
- new webpack.DefinePlugin({
- 'process.env': config.dev.env
- }),
- // https://github.com/glenjamin/webpack-hot-middleware#installation--usage
- new webpack.HotModuleReplacementPlugin(),
- new webpack.NoEmitOnErrorsPlugin(),
- // https://github.com/ampedandwired/html-webpack-plugin
- new HtmlWebpackPlugin({
- filename: 'index.html',
- template: 'index.html',
- inject: true
- }),
- new FriendlyErrorsPlugin()
- ]
-})
diff --git a/admin/build/webpack.prod.conf.js b/admin/build/webpack.prod.conf.js
deleted file mode 100644
index dcb239d..0000000
--- a/admin/build/webpack.prod.conf.js
+++ /dev/null
@@ -1,124 +0,0 @@
-'use strict'
-const path = require('path')
-const utils = require('./utils')
-const webpack = require('webpack')
-const config = require('../config')
-const merge = require('webpack-merge')
-const baseWebpackConfig = require('./webpack.base.conf')
-const CopyWebpackPlugin = require('copy-webpack-plugin')
-const HtmlWebpackPlugin = require('html-webpack-plugin')
-const ExtractTextPlugin = require('extract-text-webpack-plugin')
-const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
-
-const env = config.build.env
-
-const webpackConfig = merge(baseWebpackConfig, {
- module: {
- rules: utils.styleLoaders({
- sourceMap: config.build.productionSourceMap,
- extract: true
- })
- },
- devtool: config.build.productionSourceMap ? '#source-map' : false,
- output: {
- path: config.build.assetsRoot,
- filename: utils.assetsPath('js/[name].[chunkhash].js'),
- chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
- },
- plugins: [
- // http://vuejs.github.io/vue-loader/en/workflow/production.html
- new webpack.DefinePlugin({
- 'process.env': env
- }),
- // UglifyJs do not support ES6+, you can also use babel-minify for better treeshaking: https://github.com/babel/minify
- new webpack.optimize.UglifyJsPlugin({
- compress: {
- warnings: false
- },
- sourceMap: true
- }),
- // extract css into its own file
- new ExtractTextPlugin({
- filename: utils.assetsPath('css/[name].[contenthash].css')
- }),
- // Compress extracted CSS. We are using this plugin so that possible
- // duplicated CSS from different components can be deduped.
- new OptimizeCSSPlugin({
- cssProcessorOptions: {
- safe: true
- }
- }),
- // generate dist index.html with correct asset hash for caching.
- // you can customize output by editing /index.html
- // see https://github.com/ampedandwired/html-webpack-plugin
- new HtmlWebpackPlugin({
- filename: config.build.index,
- template: 'index.html',
- inject: true,
- minify: {
- removeComments: true,
- collapseWhitespace: true,
- removeAttributeQuotes: true
- // more options:
- // https://github.com/kangax/html-minifier#options-quick-reference
- },
- // necessary to consistently work with multiple chunks via CommonsChunkPlugin
- chunksSortMode: 'dependency'
- }),
- // keep module.id stable when vender modules does not change
- new webpack.HashedModuleIdsPlugin(),
- // split vendor js into its own file
- new webpack.optimize.CommonsChunkPlugin({
- name: 'vendor',
- minChunks: function (module) {
- // any required modules inside node_modules are extracted to vendor
- return (
- module.resource &&
- /\.js$/.test(module.resource) &&
- module.resource.indexOf(
- path.join(__dirname, '../node_modules')
- ) === 0
- )
- }
- }),
- // extract webpack runtime and module manifest to its own file in order to
- // prevent vendor hash from being updated whenever app bundle is updated
- new webpack.optimize.CommonsChunkPlugin({
- name: 'manifest',
- chunks: ['vendor']
- }),
- // copy custom static assets
- new CopyWebpackPlugin([
- {
- from: path.resolve(__dirname, '../static'),
- to: config.build.assetsSubDirectory,
- ignore: ['.*']
- }
- ])
- ]
-})
-
-if (config.build.productionGzip) {
- const CompressionWebpackPlugin = require('compression-webpack-plugin')
-
- webpackConfig.plugins.push(
- new CompressionWebpackPlugin({
- asset: '[path].gz[query]',
- algorithm: 'gzip',
- test: new RegExp(
- '\\.(' +
- config.build.productionGzipExtensions.join('|') +
- ')$'
- ),
- threshold: 10240,
- minRatio: 0.8
- })
- )
-}
-
-if (config.build.bundleAnalyzerReport) {
- const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
- webpackConfig.plugins.push(new BundleAnalyzerPlugin())
-}
-
-module.exports = webpackConfig
diff --git a/admin/config/dev.env.js b/admin/config/dev.env.js
deleted file mode 100644
index 1e22973..0000000
--- a/admin/config/dev.env.js
+++ /dev/null
@@ -1,7 +0,0 @@
-'use strict'
-const merge = require('webpack-merge')
-const prodEnv = require('./prod.env')
-
-module.exports = merge(prodEnv, {
- NODE_ENV: '"development"'
-})
diff --git a/admin/config/index.js b/admin/config/index.js
deleted file mode 100644
index 8a34349..0000000
--- a/admin/config/index.js
+++ /dev/null
@@ -1,51 +0,0 @@
-
-'use strict'
-// Template version: 1.1.3
-// see http://vuejs-templates.github.io/webpack for documentation.
-
-const path = require('path')
-
-module.exports = {
- build: {
- env: require('./prod.env'),
- index: path.resolve(__dirname, '../dist/index.html'),
- assetsRoot: path.resolve(__dirname, '../dist'),
- assetsSubDirectory: 'static',
- assetsPublicPath: '/admin/',
- productionSourceMap: true,
- // Gzip off by default as many popular static hosts such as
- // Surge or Netlify already gzip all static assets for you.
- // Before setting to `true`, make sure to:
- // npm install --save-dev compression-webpack-plugin
- productionGzip: false,
- productionGzipExtensions: ['js', 'css'],
- // Run the build command with an extra argument to
- // View the bundle analyzer report after build finishes:
- // `npm run build --report`
- // Set to `true` or `false` to always turn it on or off
- bundleAnalyzerReport: process.env.npm_config_report
- },
- dev: {
- env: require('./dev.env'),
- port: 8010,
- autoOpenBrowser: true,
- assetsSubDirectory: 'static',
- assetsPublicPath: '/',
- proxyTable: {
- "/api": {
- target: process.env.TARGET,
- changeOrigin: true
- },
- "/static/upload": {
- target: process.env.TARGET,
- changeOrigin: true
- }
- },
- // CSS Sourcemaps off by default because relative paths are "buggy"
- // with this option, according to the CSS-Loader README
- // (https://github.com/webpack/css-loader#sourcemaps)
- // In our experience, they generally work as expected,
- // just be aware of this issue when enabling this option.
- cssSourceMap: false
- }
-}
diff --git a/admin/config/prod.env.js b/admin/config/prod.env.js
deleted file mode 100644
index 300657e..0000000
--- a/admin/config/prod.env.js
+++ /dev/null
@@ -1,10 +0,0 @@
-let date = require('moment')().format('YYYYMMDD')
-let commit = require('child_process').execSync('git rev-parse HEAD').toString().slice(0, 5)
-let version = `"${date}-${commit}"`
-
-console.log(`current version is ${version}`)
-
-module.exports = {
- NODE_ENV: '"production"',
- VERSION: version
-}
diff --git a/admin/index.html b/admin/index.html
deleted file mode 100644
index 18bc0e6..0000000
--- a/admin/index.html
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
- OnlineJudge Admin
-
-
-
-
-
-
-
-
diff --git a/admin/package.json b/admin/package.json
deleted file mode 100644
index df964f2..0000000
--- a/admin/package.json
+++ /dev/null
@@ -1,82 +0,0 @@
-{
- "name": "oj_admin",
- "version": "1.0.0",
- "description": "onlinejudge admin",
- "author": "zemal ",
- "private": true,
- "scripts": {
- "dev": "node build/dev-server.js",
- "start": "npm run dev",
- "build": "node build/build.js",
- "lint": "eslint --ext .js,.vue src"
- },
- "dependencies": {
- "axios": "^0.17.0",
- "element-ui": "^1.4.9",
- "font-awesome": "^4.7.0",
- "moment": "^2.19.1",
- "simditor": "^2.3.6",
- "simditor-markdown": "^1.1.2",
- "vue": "^2.5.3",
- "vue-codemirror": "^3.1.8",
- "vue-i18n": "^7.3.2",
- "vue-router": "^2.8.1"
- },
- "devDependencies": {
- "autoprefixer": "^7.1.2",
- "babel-core": "^6.22.1",
- "babel-eslint": "^7.1.1",
- "babel-loader": "^7.1.1",
- "babel-plugin-transform-runtime": "^6.22.0",
- "babel-preset-env": "^1.3.2",
- "babel-preset-stage-2": "^6.22.0",
- "babel-register": "^6.22.0",
- "chalk": "^2.0.1",
- "connect-history-api-fallback": "^1.3.0",
- "copy-webpack-plugin": "^4.0.1",
- "css-loader": "^0.28.0",
- "eslint": "^3.19.0",
- "eslint-config-standard": "^10.2.1",
- "eslint-friendly-formatter": "^3.0.0",
- "eslint-loader": "^1.7.1",
- "eslint-plugin-html": "^3.0.0",
- "eslint-plugin-import": "^2.7.0",
- "eslint-plugin-node": "^5.2.0",
- "eslint-plugin-promise": "^3.4.0",
- "eslint-plugin-standard": "^3.0.1",
- "eventsource-polyfill": "^0.9.6",
- "express": "^4.14.1",
- "extract-text-webpack-plugin": "^3.0.0",
- "file-loader": "^1.1.4",
- "friendly-errors-webpack-plugin": "^1.6.1",
- "html-webpack-plugin": "^2.30.1",
- "http-proxy-middleware": "^0.17.3",
- "less": "^2.7.2",
- "less-loader": "^4.0.5",
- "opn": "^5.1.0",
- "optimize-css-assets-webpack-plugin": "^3.2.0",
- "ora": "^1.2.0",
- "portfinder": "^1.0.13",
- "rimraf": "^2.6.0",
- "semver": "^5.3.0",
- "shelljs": "^0.7.6",
- "url-loader": "^0.5.8",
- "vue-loader": "^13.5.0",
- "vue-style-loader": "^3.0.1",
- "vue-template-compiler": "^2.5.3",
- "webpack": "^3.6.0",
- "webpack-bundle-analyzer": "^2.9.0",
- "webpack-dev-middleware": "^1.12.0",
- "webpack-hot-middleware": "^2.18.2",
- "webpack-merge": "^4.1.0"
- },
- "engines": {
- "node": ">= 4.0.0",
- "npm": ">= 3.0.0"
- },
- "browserslist": [
- "> 1%",
- "last 2 versions",
- "not ie <= 8"
- ]
-}
diff --git a/admin/src/utils/constants.js b/admin/src/utils/constants.js
deleted file mode 100644
index 7dabab2..0000000
--- a/admin/src/utils/constants.js
+++ /dev/null
@@ -1,5 +0,0 @@
-export const CONTEST_STATUS_REVERSE = {
- '-1': 'Ended',
- '0': 'Underway',
- '1': 'Not Started'
-}
diff --git a/admin/src/utils/filters.js b/admin/src/utils/filters.js
deleted file mode 100644
index 5d98d87..0000000
--- a/admin/src/utils/filters.js
+++ /dev/null
@@ -1,25 +0,0 @@
-import moment from 'moment'
-
-// 友好显示时间
-export function fromNow (time) {
- return moment(time * 3).fromNow()
-}
-
-// 只显示日期
-export function onlyDate (time) {
- const d = new Date(time * 1000)
- return d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate()
-}
-
-function localtime (utcTime, format = 'YYYY-M-D HH:mm:ss') {
- let m = moment.utc(utcTime)
- if (m.isValid()) {
- return m.local().format(format)
- } else {
- return ''
- }
-}
-
-export default {
- localtime: localtime
-}
diff --git a/admin/static/.gitkeep b/admin/static/.gitkeep
deleted file mode 100644
index e69de29..0000000
diff --git a/admin/build/build.js b/build/build.js
similarity index 100%
rename from admin/build/build.js
rename to build/build.js
diff --git a/admin/build/check-versions.js b/build/check-versions.js
similarity index 100%
rename from admin/build/check-versions.js
rename to build/check-versions.js
diff --git a/admin/build/dev-client.js b/build/dev-client.js
similarity index 100%
rename from admin/build/dev-client.js
rename to build/dev-client.js
diff --git a/oj/build/dev-server.js b/build/dev-server.js
similarity index 92%
rename from oj/build/dev-server.js
rename to build/dev-server.js
index a503b51..9234ddd 100644
--- a/oj/build/dev-server.js
+++ b/build/dev-server.js
@@ -57,7 +57,14 @@ Object.keys(proxyTable).forEach(function (context) {
})
// handle fallback for HTML5 history API
-app.use(require('connect-history-api-fallback')())
+const rewrites = {
+ rewrites: [{
+ from: '/admin/', // 正则或者字符串
+ to: '/admin/index.html', // 字符串或者函数
+ }]
+}
+const historyMiddleware = require('connect-history-api-fallback')(rewrites);
+app.use(historyMiddleware)
// serve webpack bundle output
app.use(devMiddleware)
diff --git a/oj/build/utils.js b/build/utils.js
similarity index 100%
rename from oj/build/utils.js
rename to build/utils.js
diff --git a/admin/build/vue-loader.conf.js b/build/vue-loader.conf.js
similarity index 100%
rename from admin/build/vue-loader.conf.js
rename to build/vue-loader.conf.js
diff --git a/oj/build/webpack.base.conf.js b/build/webpack.base.conf.js
similarity index 78%
rename from oj/build/webpack.base.conf.js
rename to build/webpack.base.conf.js
index 82a141f..ca378f6 100644
--- a/oj/build/webpack.base.conf.js
+++ b/build/webpack.base.conf.js
@@ -4,6 +4,7 @@ const webpack = require('webpack')
const utils = require('./utils')
const config = require('../config')
const vueLoaderConfig = require('./vue-loader.conf')
+const HtmlWebpackIncludeAssetsPlugin = require('html-webpack-include-assets-plugin')
function resolve (dir) {
return path.join(__dirname, '..', dir)
@@ -11,7 +12,8 @@ function resolve (dir) {
module.exports = {
entry: {
- 'admin': './src/pages/oj/index.js'
+ 'oj': './src/pages/oj/index.js',
+ 'admin': './src/pages/admin/index.js'
},
output: {
path: config.build.assetsRoot,
@@ -37,7 +39,7 @@ module.exports = {
test: /\.(js|vue)$/,
loader: 'eslint-loader',
enforce: 'pre',
- include: [resolve('src'), resolve('test')],
+ include: [resolve('src')],
options: {
formatter: require('eslint-friendly-formatter')
}
@@ -80,6 +82,16 @@ module.exports = {
]
},
plugins: [
- new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /zh-cn/)
+ new webpack.DllReferencePlugin({
+ name: 'vendor_dll',
+ context: __dirname,
+ manifest: require('./vendor-manifest.json')
+ }),
+ new HtmlWebpackIncludeAssetsPlugin({
+ assets: ['static/js/vendor.dll.js'],
+ files: ['index.html', 'admin/index.html'],
+ append: false,
+ hash: true
+ }),
]
}
diff --git a/oj/build/webpack.dev.conf.js b/build/webpack.dev.conf.js
similarity index 87%
rename from oj/build/webpack.dev.conf.js
rename to build/webpack.dev.conf.js
index 8508d87..c08ae56 100644
--- a/oj/build/webpack.dev.conf.js
+++ b/build/webpack.dev.conf.js
@@ -30,6 +30,12 @@ module.exports = merge(baseWebpackConfig, {
new HtmlWebpackPlugin({
filename: config.build.ojIndex,
template: config.build.ojTemplate,
+ chunks: ['manifest', 'vendor', 'oj'],
+ inject: true
+ }),
+ new HtmlWebpackPlugin({
+ filename: config.build.adminIndex,
+ template: config.build.adminTemplate,
chunks: ['manifest', 'vendor', 'admin'],
inject: true
}),
diff --git a/build/webpack.dll.conf.js b/build/webpack.dll.conf.js
new file mode 100644
index 0000000..9684b20
--- /dev/null
+++ b/build/webpack.dll.conf.js
@@ -0,0 +1,43 @@
+const webpack = require('webpack');
+const path = require('path');
+const UglifyJsParallelPlugin = require('webpack-uglify-parallel');
+const os = require('os');
+
+const vendors = [
+ 'vue/dist/vue.esm.js',
+ 'vue-router',
+ 'vuex',
+ 'axios',
+ 'moment'
+];
+
+module.exports = {
+ entry: {
+ "vendor": vendors,
+ },
+ output: {
+ path: path.join(__dirname, '../static/js'),
+ filename: '[name].dll.js',
+ library: '[name]_dll',
+ },
+ plugins: [
+ new webpack.optimize.ModuleConcatenationPlugin(),
+ new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /zh-cn/),
+ new UglifyJsParallelPlugin({
+ workers: os.cpus().length,
+ mangle: true,
+ exclude: /\.min\.js$/,
+ output: {comments: false},
+ compressor: {
+ warnings: false,
+ drop_console: true,
+ drop_debugger: true
+ }
+ }),
+ new webpack.DllPlugin({
+ context: __dirname,
+ path: path.join(__dirname, '[name]-manifest.json'),
+ name: '[name]_dll',
+ })
+ ]
+};
diff --git a/oj/build/webpack.prod.conf.js b/build/webpack.prod.conf.js
similarity index 73%
rename from oj/build/webpack.prod.conf.js
rename to build/webpack.prod.conf.js
index 553810a..97f4237 100644
--- a/oj/build/webpack.prod.conf.js
+++ b/build/webpack.prod.conf.js
@@ -1,4 +1,5 @@
'use strict'
+const os = require('os');
const path = require('path')
const utils = require('./utils')
const webpack = require('webpack')
@@ -9,6 +10,7 @@ const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
+const UglifyJsParallelPlugin = require('webpack-uglify-parallel');
const env = config.build.env
@@ -31,11 +33,16 @@ const webpackConfig = merge(baseWebpackConfig, {
'process.env': env
}),
// UglifyJs do not support ES6+, you can also use babel-minify for better treeshaking: https://github.com/babel/minify
- new webpack.optimize.UglifyJsPlugin({
- compress: {
- warnings: false
- },
- sourceMap: true
+ new UglifyJsParallelPlugin({
+ workers: os.cpus().length,
+ mangle: true,
+ exclude: /\.min\.js$/,
+ output: {comments: false},
+ compressor: {
+ warnings: false,
+ drop_console: true,
+ drop_debugger: true
+ }
}),
// extract css into its own file
new ExtractTextPlugin({
@@ -52,6 +59,7 @@ const webpackConfig = merge(baseWebpackConfig, {
// generate dist index.html with correct asset hash for caching.
// you can customize output by editing /index.html
// see https://github.com/ampedandwired/html-webpack-plugin
+ // oj
new HtmlWebpackPlugin({
filename: config.build.ojIndex,
template: config.build.ojTemplate,
@@ -66,28 +74,45 @@ const webpackConfig = merge(baseWebpackConfig, {
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
chunksSortMode: 'dependency'
}),
+ // admin
+ new HtmlWebpackPlugin({
+ filename: config.build.adminIndex,
+ template: config.build.adminTemplate,
+ inject: true,
+ minify: {
+ removeComments: true,
+ collapseWhitespace: true,
+ removeAttributeQuotes: true
+ // more options:
+ // https://github.com/kangax/html-minifier#options-quick-reference
+ },
+ // necessary to consistently work with multiple chunks via CommonsChunkPlugin
+ chunksSortMode: 'dependency'
+ }),
// keep module.id stable when vender modules does not change
new webpack.HashedModuleIdsPlugin(),
// split vendor js into its own file
new webpack.optimize.CommonsChunkPlugin({
- name: 'vendor',
- minChunks: function (module) {
- // any required modules inside node_modules are extracted to vendor
- return (
- module.resource &&
- /\.js$/.test(module.resource) &&
- module.resource.indexOf(
- path.join(__dirname, '../node_modules')
- ) === 0
- )
- }
+ name: 'common',
+ chunks: ['oj', 'admin'],
+ minChunks: 2
+ // minChunks: function (module) {
+ // // any required modules inside node_modules are extracted to vendor
+ // return (
+ // module.resource &&
+ // /\.js$/.test(module.resource) &&
+ // module.resource.indexOf(
+ // path.join(__dirname, '../node_modules')
+ // ) === 0
+ // )
+ // }
}),
// extract webpack runtime and module manifest to its own file in order to
// prevent vendor hash from being updated whenever app bundle is updated
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest',
- chunks: ['vendor']
+ chunks: ['common']
}),
// copy custom static assets
new CopyWebpackPlugin([
diff --git a/oj/config/dev.env.js b/config/dev.env.js
similarity index 100%
rename from oj/config/dev.env.js
rename to config/dev.env.js
diff --git a/oj/config/index.js b/config/index.js
similarity index 100%
rename from oj/config/index.js
rename to config/index.js
diff --git a/oj/config/prod.env.js b/config/prod.env.js
similarity index 100%
rename from oj/config/prod.env.js
rename to config/prod.env.js
diff --git a/oj/.editorconfig b/oj/.editorconfig
deleted file mode 100644
index 9d08a1a..0000000
--- a/oj/.editorconfig
+++ /dev/null
@@ -1,9 +0,0 @@
-root = true
-
-[*]
-charset = utf-8
-indent_style = space
-indent_size = 2
-end_of_line = lf
-insert_final_newline = true
-trim_trailing_whitespace = true
diff --git a/oj/.eslintignore b/oj/.eslintignore
deleted file mode 100644
index 34af377..0000000
--- a/oj/.eslintignore
+++ /dev/null
@@ -1,2 +0,0 @@
-build/*.js
-config/*.js
diff --git a/oj/.gitignore b/oj/.gitignore
deleted file mode 100644
index bb8272a..0000000
--- a/oj/.gitignore
+++ /dev/null
@@ -1,64 +0,0 @@
-# Logs
-logs
-*.log
-npm-debug.log*
-yarn-debug.log*
-yarn-error.log*
-
-# Runtime data
-pids
-*.pid
-*.seed
-*.pid.lock
-
-# Directory for instrumented libs generated by jscoverage/JSCover
-lib-cov
-
-# Coverage directory used by tools like istanbul
-coverage
-
-# nyc test coverage
-.nyc_output
-
-# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
-.grunt
-
-# Bower dependency directory (https://bower.io/)
-bower_components
-
-# node-waf configuration
-.lock-wscript
-
-# Compiled binary addons (http://nodejs.org/api/addons.html)
-build/Release
-
-# Dependency directories
-node_modules/
-jspm_packages/
-
-# Typescript v1 declaration files
-typings/
-
-# Optional npm cache directory
-.npm
-
-# Optional eslint cache
-.eslintcache
-
-# Optional REPL history
-.node_repl_history
-
-# Output of 'npm pack'
-*.tgz
-
-# Yarn Integrity file
-.yarn-integrity
-
-# dotenv environment variables file
-.env
-
-# vscode
-.vscode
-
-# test_code
-test.vue
diff --git a/oj/build/build.js b/oj/build/build.js
deleted file mode 100644
index 30f036a..0000000
--- a/oj/build/build.js
+++ /dev/null
@@ -1,41 +0,0 @@
-'use strict'
-require('./check-versions')()
-
-process.env.NODE_ENV = 'production'
-
-const ora = require('ora')
-const rm = require('rimraf')
-const path = require('path')
-const chalk = require('chalk')
-const webpack = require('webpack')
-const config = require('../config')
-const webpackConfig = require('./webpack.prod.conf')
-
-const spinner = ora('building for production...')
-spinner.start()
-
-rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
- if (err) throw err
- webpack(webpackConfig, function (err, stats) {
- spinner.stop()
- if (err) throw err
- process.stdout.write(stats.toString({
- colors: true,
- modules: false,
- children: false,
- chunks: false,
- chunkModules: false
- }) + '\n\n')
-
- if (stats.hasErrors()) {
- console.log(chalk.red(' Build failed with errors.\n'))
- process.exit(1)
- }
-
- console.log(chalk.cyan(' Build complete.\n'))
- console.log(chalk.yellow(
- ' Tip: built files are meant to be served over an HTTP server.\n' +
- ' Opening index.html over file:// won\'t work.\n'
- ))
- })
-})
diff --git a/oj/build/check-versions.js b/oj/build/check-versions.js
deleted file mode 100644
index ca407bb..0000000
--- a/oj/build/check-versions.js
+++ /dev/null
@@ -1,49 +0,0 @@
-'use strict'
-const chalk = require('chalk')
-const semver = require('semver')
-const packageConfig = require('../package.json')
-const shell = require('shelljs')
-function exec (cmd) {
- return require('child_process').execSync(cmd).toString().trim()
-}
-
-const versionRequirements = [
- {
- name: 'node',
- currentVersion: semver.clean(process.version),
- versionRequirement: packageConfig.engines.node
- }
-]
-
-if (shell.which('npm')) {
- versionRequirements.push({
- name: 'npm',
- currentVersion: exec('npm --version'),
- versionRequirement: packageConfig.engines.npm
- })
-}
-
-module.exports = function () {
- const warnings = []
- for (let i = 0; i < versionRequirements.length; i++) {
- const mod = versionRequirements[i]
- if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
- warnings.push(mod.name + ': ' +
- chalk.red(mod.currentVersion) + ' should be ' +
- chalk.green(mod.versionRequirement)
- )
- }
- }
-
- if (warnings.length) {
- console.log('')
- console.log(chalk.yellow('To use this template, you must update following to modules:'))
- console.log()
- for (let i = 0; i < warnings.length; i++) {
- const warning = warnings[i]
- console.log(' ' + warning)
- }
- console.log()
- process.exit(1)
- }
-}
diff --git a/oj/build/dev-client.js b/oj/build/dev-client.js
deleted file mode 100644
index 2f75dd5..0000000
--- a/oj/build/dev-client.js
+++ /dev/null
@@ -1,10 +0,0 @@
-/* eslint-disable */
-'use strict'
-require('eventsource-polyfill')
-var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')
-
-hotClient.subscribe(function (event) {
- if (event.action === 'reload') {
- window.location.reload()
- }
-})
diff --git a/oj/build/vue-loader.conf.js b/oj/build/vue-loader.conf.js
deleted file mode 100644
index eece58f..0000000
--- a/oj/build/vue-loader.conf.js
+++ /dev/null
@@ -1,19 +0,0 @@
-'use strict'
-const utils = require('./utils')
-const config = require('../config')
-const isProduction = process.env.NODE_ENV === 'production'
-
-module.exports = {
- loaders: utils.cssLoaders({
- sourceMap: isProduction
- ? config.build.productionSourceMap
- : config.dev.cssSourceMap,
- extract: isProduction
- }),
- transformToRequire: {
- video: 'src',
- source: 'src',
- img: 'src',
- image: 'xlink:href'
- }
-}
diff --git a/oj/src/assets/logo.svg b/oj/src/assets/logo.svg
deleted file mode 100644
index ac954e6..0000000
--- a/oj/src/assets/logo.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/oj/package.json b/package.json
similarity index 89%
rename from oj/package.json
rename to package.json
index a571dc6..96bbf56 100644
--- a/oj/package.json
+++ b/package.json
@@ -8,15 +8,20 @@
"dev": "node build/dev-server.js",
"start": "npm run dev",
"build": "node build/build.js",
+ "build:dll": "webpack --config=build/webpack.dll.conf.js",
"lint": "eslint --ext .js,.vue src"
},
"dependencies": {
"axios": "^0.17.0",
"browser-detect": "^0.2.18",
"echarts": "^3.8.3",
+ "element-ui": "^1.4.9",
+ "font-awesome": "^4.7.0",
"highlight.js": "^9.12.0",
"iview": "^2.6.0",
"moment": "^2.19.1",
+ "simditor": "^2.3.6",
+ "simditor-markdown": "^1.1.2",
"vue": "^2.5.3",
"vue-clipboard2": "0.0.7",
"vue-codemirror-lite": "^1.0.2",
@@ -54,6 +59,7 @@
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^1.1.4",
"friendly-errors-webpack-plugin": "^1.6.1",
+ "html-webpack-include-assets-plugin": "^1.0.2",
"html-webpack-plugin": "^2.30.1",
"http-proxy-middleware": "^0.17.3",
"less": "^2.7.3",
@@ -73,7 +79,8 @@
"webpack-bundle-analyzer": "^2.9.0",
"webpack-dev-middleware": "^1.12.0",
"webpack-hot-middleware": "^2.18.2",
- "webpack-merge": "^4.1.0"
+ "webpack-merge": "^4.1.0",
+ "webpack-uglify-parallel": "^0.1.4"
},
"engines": {
"node": ">= 4.0.0",
diff --git a/oj/src/assets/Cup.png b/src/assets/Cup.png
similarity index 100%
rename from oj/src/assets/Cup.png
rename to src/assets/Cup.png
diff --git a/admin/src/assets/logo.svg b/src/assets/logo.svg
similarity index 100%
rename from admin/src/assets/logo.svg
rename to src/assets/logo.svg
diff --git a/admin/src/App.vue b/src/pages/admin/App.vue
similarity index 100%
rename from admin/src/App.vue
rename to src/pages/admin/App.vue
diff --git a/admin/src/api.js b/src/pages/admin/api.js
similarity index 100%
rename from admin/src/api.js
rename to src/pages/admin/api.js
diff --git a/admin/src/components/Accordion.vue b/src/pages/admin/components/Accordion.vue
similarity index 100%
rename from admin/src/components/Accordion.vue
rename to src/pages/admin/components/Accordion.vue
diff --git a/admin/src/components/CodeMirror.vue b/src/pages/admin/components/CodeMirror.vue
similarity index 100%
rename from admin/src/components/CodeMirror.vue
rename to src/pages/admin/components/CodeMirror.vue
diff --git a/admin/src/components/Panel.vue b/src/pages/admin/components/Panel.vue
similarity index 100%
rename from admin/src/components/Panel.vue
rename to src/pages/admin/components/Panel.vue
diff --git a/admin/src/components/SideMenu.vue b/src/pages/admin/components/SideMenu.vue
similarity index 96%
rename from admin/src/components/SideMenu.vue
rename to src/pages/admin/components/SideMenu.vue
index 41d9121..a2ce8a7 100644
--- a/admin/src/components/SideMenu.vue
+++ b/src/pages/admin/components/SideMenu.vue
@@ -1,7 +1,7 @@