diff --git a/UI/.babelrc b/UI/.babelrc new file mode 100644 index 0000000000000000000000000000000000000000..eb8642707fc28a66831c6be3ac03f56db19c20e7 --- /dev/null +++ b/UI/.babelrc @@ -0,0 +1,9 @@ +{ + "presets": [ + ["env", { "modules": false }], + "stage-2" + // "es2015" + ], + "plugins": ["transform-runtime"], + "comments": false +} diff --git a/UI/.editorconfig b/UI/.editorconfig new file mode 100644 index 0000000000000000000000000000000000000000..ea6e20f5b2e79f76a0032c30d99b9fcd346232fd --- /dev/null +++ b/UI/.editorconfig @@ -0,0 +1,14 @@ +# http://editorconfig.org +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +insert_final_newline = false +trim_trailing_whitespace = false diff --git a/UI/.eslintignore b/UI/.eslintignore new file mode 100644 index 0000000000000000000000000000000000000000..e3a4037e479f58286a5de99b95107183d71ffcf9 --- /dev/null +++ b/UI/.eslintignore @@ -0,0 +1,3 @@ +build/*.js +config/*.js +src/assets diff --git a/UI/.eslintrc.js b/UI/.eslintrc.js new file mode 100644 index 0000000000000000000000000000000000000000..20ae9e58231b446fb16fae75b23e4dc2396c2eca --- /dev/null +++ b/UI/.eslintrc.js @@ -0,0 +1,318 @@ +module.exports = { + root: true, + parser: 'babel-eslint', + parserOptions: { + sourceType: 'module' + }, + env: { + browser: true, + node: true + }, + extends: 'eslint:recommended', + // required to lint *.vue files + plugins: [ + 'html' + ], + // check if imports actually resolve + 'settings': { + 'import/resolver': { + 'webpack': { + 'config': 'build/webpack.base.conf.js' + } + } + }, + // add your custom rules here + 'rules': { + // don't require .vue extension when importing + // 'import/extensions': ['error', 'always', { + // 'js': 'never', + // 'vue': 'never' + // }], + // allow debugger during development + 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0, + /* + * Possible Errors + */ + + // disallow unnecessary parentheses + 'no-extra-parens': ['error', 'all', {'nestedBinaryExpressions': false}], + + // disallow negating the left operand of relational operators + 'no-unsafe-negation': 'error', + + // enforce valid JSDoc comments + 'valid-jsdoc': 'off', + + /* + * Best Practices + */ + + // enforce return statements in callbacks of array methods + 'array-callback-return': 'error', + + // enforce consistent brace style for all control statements + curly: ['error', 'multi-line'], + + // enforce consistent newlines before and after dots + 'dot-location': ['error', 'property'], + + // enforce dot notation whenever possible + 'dot-notation': 'error', + + // require the use of === and !== + 'eqeqeq': ['error', 'smart'], + + // disallow the use of arguments.caller or arguments.callee + 'no-caller': 'error', + + // disallow empty functions + 'no-empty-function': 'error', + + // disallow unnecessary calls to .bind() + 'no-extra-bind': 'error', + + // disallow unnecessary labels + 'no-extra-label': 'error', + + // disallow leading or trailing decimal points in numeric literals + 'no-floating-decimal': 'error', + + // disallow assignments to native objects or read-only global variables + 'no-global-assign': 'error', + + // disallow the use of eval()-like methods + 'no-implied-eval': 'error', + + // disallow the use of the __iterator__ property + 'no-iterator': 'error', + + // disallow unnecessary nested blocks + 'no-lone-blocks': 'error', + + // disallow multiple spaces + 'no-multi-spaces': 'error', + + // disallow new operators with the String, Number, and Boolean objects + 'no-new-wrappers': 'error', + + // disallow octal escape sequences in string literals + 'no-octal-escape': 'error', + + // disallow the use of the __proto__ property + 'no-proto': 'error', + + // disallow comparisons where both sides are exactly the same + 'no-self-compare': 'error', + + // disallow throwing literals as exceptions + 'no-throw-literal': 'error', + + // disallow unused expressions + 'no-unused-expressions': 'error', + + // disallow unnecessary calls to .call() and .apply() + 'no-useless-call': 'error', + + // disallow unnecessary concatenation of literals or template literals + 'no-useless-concat': 'error', + + // disallow unnecessary escape characters + 'no-useless-escape': 'error', + + // disallow void operators + 'no-void': 'error', + + // require parentheses around immediate function invocations + 'wrap-iife': 'error', + + // require or disallow “Yoda” conditions + yoda: 'error', + + /* + * Variables + */ + + // disallow labels that share a name with a variable + 'no-label-var': 'error', + + // disallow initializing variables to undefined + 'no-undef-init': 'error', + 'no-undef': 'off', + // disallow the use of variables before they are defined + 'no-use-before-define': 'error', + + /* + * Node.js and CommonJS + */ + + // disallow new operators with calls to require + 'no-new-require': 'error', + + /* + * Stylistic Issues + */ + + // enforce consistent spacing inside array brackets + 'array-bracket-spacing': 'error', + + // enforce consistent spacing inside single-line blocks + 'block-spacing': 'error', + + // enforce consistent brace style for blocks + 'brace-style': ['error', '1tbs', {'allowSingleLine': true}], + + // require or disallow trailing commas + 'comma-dangle': 'error', + + // enforce consistent spacing before and after commas + 'comma-spacing': 'error', + + // enforce consistent comma style + 'comma-style': 'error', + + // enforce consistent spacing inside computed property brackets + 'computed-property-spacing': 'error', + + // require or disallow spacing between function identifiers and their invocations + 'func-call-spacing': 'error', + + // enforce consistent indentation + indent: ['error', 2, {SwitchCase: 1}], + + // enforce the consistent use of either double or single quotes in JSX attributes + 'jsx-quotes': 'error', + + // enforce consistent spacing between keys and values in object literal properties + 'key-spacing': 'error', + + // enforce consistent spacing before and after keywords + 'keyword-spacing': 'error', + + // enforce consistent linebreak style + 'linebreak-style': 'error', + + // require or disallow newlines around directives + 'lines-around-directive': 'error', + + // require constructor names to begin with a capital letter + 'new-cap': 'off', + + // require parentheses when invoking a constructor with no arguments + 'new-parens': 'error', + + // disallow Array constructors + 'no-array-constructor': 'error', + + // disallow Object constructors + 'no-new-object': 'error', + + // disallow trailing whitespace at the end of lines + 'no-trailing-spaces': 'error', + + // disallow ternary operators when simpler alternatives exist + 'no-unneeded-ternary': 'error', + + // disallow whitespace before properties + 'no-whitespace-before-property': 'error', + + // enforce consistent spacing inside braces + 'object-curly-spacing': ['error', 'always'], + + // require or disallow padding within blocks + 'padded-blocks': ['error', 'never'], + + // require quotes around object literal property names + 'quote-props': ['error', 'as-needed'], + + // enforce the consistent use of either backticks, double, or single quotes + quotes: ['error', 'single'], + + // enforce consistent spacing before and after semicolons + 'semi-spacing': 'error', + + // require or disallow semicolons instead of ASI + // semi: ['error', 'never'], + + // enforce consistent spacing before blocks + 'space-before-blocks': 'error', + + 'no-console': 'off', + + // enforce consistent spacing before function definition opening parenthesis + 'space-before-function-paren': ['error', 'never'], + + // enforce consistent spacing inside parentheses + 'space-in-parens': 'error', + + // require spacing around infix operators + 'space-infix-ops': 'error', + + // enforce consistent spacing before or after unary operators + 'space-unary-ops': 'error', + + // enforce consistent spacing after the // or /* in a comment + 'spaced-comment': 'error', + + // require or disallow Unicode byte order mark (BOM) + 'unicode-bom': 'error', + + + /* + * ECMAScript 6 + */ + + // require braces around arrow function bodies + 'arrow-body-style': 'error', + + // require parentheses around arrow function arguments + 'arrow-parens': ['error', 'as-needed'], + + // enforce consistent spacing before and after the arrow in arrow functions + 'arrow-spacing': 'error', + + // enforce consistent spacing around * operators in generator functions + 'generator-star-spacing': ['error', 'after'], + + // disallow duplicate module imports + 'no-duplicate-imports': 'error', + + // disallow unnecessary computed property keys in object literals + 'no-useless-computed-key': 'error', + + // disallow unnecessary constructors + 'no-useless-constructor': 'error', + + // disallow renaming import, export, and destructured assignments to the same name + 'no-useless-rename': 'error', + + // require let or const instead of var + 'no-var': 'error', + + // require or disallow method and property shorthand syntax for object literals + 'object-shorthand': 'error', + + // require arrow functions as callbacks + 'prefer-arrow-callback': 'error', + + // require const declarations for variables that are never reassigned after declared + 'prefer-const': 'error', + + // disallow parseInt() in favor of binary, octal, and hexadecimal literals + 'prefer-numeric-literals': 'error', + + // require rest parameters instead of arguments + 'prefer-rest-params': 'error', + + // require spread operators instead of .apply() + 'prefer-spread': 'error', + + // enforce spacing between rest and spread operators and their expressions + 'rest-spread-spacing': 'error', + + // require or disallow spacing around embedded expressions of template strings + 'template-curly-spacing': 'error', + + // require or disallow spacing around the * in yield* expressions + 'yield-star-spacing': 'error' + } +} diff --git a/UI/.eslintrc.json b/UI/.eslintrc.json new file mode 100644 index 0000000000000000000000000000000000000000..7db57548c6204a1458aac25218c418cd29344091 --- /dev/null +++ b/UI/.eslintrc.json @@ -0,0 +1,23 @@ +{ + "env": { + "browser": true, + "commonjs": true, + "es6": true, + "node": true + }, + "parserOptions": { + "ecmaFeatures": { + "jsx": true + }, + "sourceType": "module" + }, + "rules": { + "no-const-assign": "warn", + "no-this-before-super": "warn", + "no-undef": "warn", + "no-unreachable": "warn", + "no-unused-vars": "warn", + "constructor-super": "warn", + "valid-typeof": "warn" + } +} \ No newline at end of file diff --git a/UI/.gitignore b/UI/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4aa016eb8e6d549ce4d93fc3936c7a22bf216cde --- /dev/null +++ b/UI/.gitignore @@ -0,0 +1,11 @@ +.DS_Store +node_modules/ +dist/ +static/ckeditor +gifs/ +npm-debug.log +test/unit/coverage +test/e2e/reports +selenium-debug.log +.idea +node_modules diff --git a/UI/.postcssrc.js b/UI/.postcssrc.js new file mode 100644 index 0000000000000000000000000000000000000000..ea9a5ab8752c93dc8bc2849afdfae95d56378c17 --- /dev/null +++ b/UI/.postcssrc.js @@ -0,0 +1,8 @@ +// https://github.com/michael-ciniawsky/postcss-load-config + +module.exports = { + "plugins": { + // to edit target browsers: use "browserlist" field in package.json + "autoprefixer": {} + } +} diff --git a/UI/Dockerfile b/UI/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d4340df1372c662087fd2bad0b207c5aae292dce --- /dev/null +++ b/UI/Dockerfile @@ -0,0 +1,11 @@ +#Dockerfile文件 +FROM registry.gz.cvte.cn/library/node:8.9.3 +# Create app directory +RUN mkdir -p /home/Service +WORKDIR /home/Service +# Bundle app source +COPY . /home/Service +RUN npm install +EXPOSE 3000 +CMD [ "npm", "run dev" ] + diff --git a/UI/README.md b/UI/README.md new file mode 100644 index 0000000000000000000000000000000000000000..34872265a428cd295a04646e5fab3d24b04de546 --- /dev/null +++ b/UI/README.md @@ -0,0 +1,79 @@ +# 健康状态监测系统 +## 准备工作 +- node.js环境(npm包管理器) +- vue-cli 脚手架构建工具 +- npm npm的淘宝镜像 +- yarn 不需要镜像,使用npm install -g yarn 进行安装 + +## 开发运行 +```bash + # 安装依赖 + npm install + npm install --registry=https://registry.npm.taobao.org + + //or 不需要依赖,比npm速度快 + yarn install || yarn 可以用yarn代替npm 速度较快 + # 本地开发 开启服务 + npm run dev +``` + +## 发布 +```bash + # 发布测试环境 带webpack ananalyzer + npm run build:sit-preview + + # 构建生成环境 + npm run build:prod +``` +### 部署nginx配置参考 +``` + location / { + # 指向我们打包后上传的前端文件 + root /opt/nginx/dist; + index index.html; + } + location /jwt/ { + # 转发请求到后端服务网关 + proxy_pass http://127.0.0.1:8765/jwt/; + } + location /api/ { + proxy_pass http://127.0.0.1:8765/api/; + } +``` + +## 目录结构 +```shell +├── build // 构建相关 +├── config // 配置相关 +├── dist // 打包文件 +├── src // 源代码 +│ ├── api // 所有请求 +│ ├── assets // 主题 字体等静态资源 +│ ├── components // 全局公用组件 +│ ├── directive // 全局指令 +│ ├── filters // 全局filter +│ ├── mock // mock数据 +│ ├── router // 路由 +│ ├── store // 全局store管理 +│ ├── styles // 全局样式 +│ ├── utils // 全局公用方法 +│ ├── view // view +│ ├── App.vue // 入口页面 +│ └── main.js // 入口 加载组件 初始化等 +├── static // 第三方不打包资源 +│ ├── +│ └── Tinymce // 富文本 +├── .babelrc // babel-loader 配置 +├── eslintrc.js // eslint 配置项 +├── .gitignore // git 忽略项 +├── favicon.ico // favicon图标 +├── index.html // html模板 +└── package.json // package.json + +``` + +## 状态管理 +后台只有user和app配置相关状态使用vuex存在全局,其它数据都由每个业务页面自己管理。 + +## License +Apache License Version 1.0 diff --git a/UI/build/build.js b/UI/build/build.js new file mode 100644 index 0000000000000000000000000000000000000000..da9522a10f069f88aa1cd2fe9fb30e519ba56b83 --- /dev/null +++ b/UI/build/build.js @@ -0,0 +1,41 @@ +require('./check-versions')(); +var server = require('pushstate-server'); +var opn = require('opn') +var ora = require('ora') +var rm = require('rimraf') +var path = require('path') +var chalk = require('chalk') +var webpack = require('webpack'); +var config = require('../config'); +var webpackConfig = require('./webpack.prod.conf'); + +console.log(process.env.NODE_ENV) + +var spinner = ora('building for ' + process.env.NODE_ENV + '...') +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') + + console.log(chalk.cyan(' Build complete.\n')) + if(process.env.npm_config_preview){ + server.start({ + port: 9528, + directory: './dist', + file: '/index.html' + }); + console.log('> Listening at ' + 'http://localhost:9528' + '\n') + } + }) +}) diff --git a/UI/build/check-versions.js b/UI/build/check-versions.js new file mode 100644 index 0000000000000000000000000000000000000000..3a1dda61e98f9ee7c67088a0ccb952333829ff85 --- /dev/null +++ b/UI/build/check-versions.js @@ -0,0 +1,45 @@ +var chalk = require('chalk') +var semver = require('semver') +var packageConfig = require('../package.json') + +function exec(cmd) { + return require('child_process').execSync(cmd).toString().trim() +} + +var versionRequirements = [ + { + name: 'node', + currentVersion: semver.clean(process.version), + versionRequirement: packageConfig.engines.node + }, + { + name: 'npm', + currentVersion: exec('npm --version'), + versionRequirement: packageConfig.engines.npm + } +] + +module.exports = function () { + var warnings = [] + for (var i = 0; i < versionRequirements.length; i++) { + var 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 (var i = 0; i < warnings.length; i++) { + var warning = warnings[i] + console.log(' ' + warning) + } + console.log() + process.exit(1) + } +} diff --git a/UI/build/dev-client.js b/UI/build/dev-client.js new file mode 100644 index 0000000000000000000000000000000000000000..18aa1e21952b9468dd5a7e603eb9966d037d2f1a --- /dev/null +++ b/UI/build/dev-client.js @@ -0,0 +1,9 @@ +/* eslint-disable */ +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/UI/build/dev-server.js b/UI/build/dev-server.js new file mode 100644 index 0000000000000000000000000000000000000000..34c32b3c348e710a917f8beb66d412bb3a18e350 --- /dev/null +++ b/UI/build/dev-server.js @@ -0,0 +1,84 @@ +require('./check-versions')(); // 检查 Node 和 npm 版本 +var config = require('../config'); +if (!process.env.NODE_ENV) { + process.env.NODE_ENV = JSON.parse(config.dev.env.NODE_ENV) +} + +var opn = require('opn') +var path = require('path'); +var express = require('express'); +var webpack = require('webpack'); +var proxyMiddleware = require('http-proxy-middleware'); +var webpackConfig = require('./webpack.dev.conf'); + +// default port where dev server listens for incoming traffic +var port = process.env.PORT || config.dev.port; +// automatically open browser, if not set will be false +var autoOpenBrowser = !!config.dev.autoOpenBrowser; +// Define HTTP proxies to your custom API backend +// https://github.com/chimurai/http-proxy-middleware +var proxyTable = config.dev.proxyTable; + +var app = express(); +var compiler = webpack(webpackConfig); + +var devMiddleware = require('webpack-dev-middleware')(compiler, { + publicPath: webpackConfig.output.publicPath, + quiet: true +}); + +var hotMiddleware = require('webpack-hot-middleware')(compiler, { + log: () => { + } +}); + +// force page reload when html-webpack-plugin template changes +compiler.plugin('compilation', function (compilation) { + compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) { + hotMiddleware.publish({action: 'reload'}); + cb() + }) +}); + +// compiler.apply(new DashboardPlugin()); + +// proxy api requests +Object.keys(proxyTable).forEach(function (context) { + var 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); + +// enable hot-reload and state-preserving +// compilation error display +app.use(hotMiddleware); + +// serve pure static assets +var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory); +app.use(staticPath, express.static('./static')); + +var uri = 'http://localhost:' + port + +devMiddleware.waitUntilValid(function () { + console.log('> Listening at ' + uri + '\n') +}); + +module.exports = app.listen(port, function (err) { + if (err) { + console.log(err); + return + } + + // when env is testing, don't need open it + if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') { + opn(uri) + } +}); diff --git a/UI/build/utils.js b/UI/build/utils.js new file mode 100644 index 0000000000000000000000000000000000000000..7323e5d5715990d974b51ccc067bf54e094615cb --- /dev/null +++ b/UI/build/utils.js @@ -0,0 +1,72 @@ +var path = require('path') +var config = require('../config') +var ExtractTextPlugin = require('extract-text-webpack-plugin') + +exports.assetsPath = function (_path) { + var assetsSubDirectory = process.env.NODE_ENV === 'production' + ? config.build.assetsSubDirectory + : config.dev.assetsSubDirectory + return path.posix.join(assetsSubDirectory, _path) +} + +exports.cssLoaders = function (options) { + options = options || {} + + var 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) { + var 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', + publicPath:'../../' + }) + } 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) { + var output = [] + var loaders = exports.cssLoaders(options) + for (var extension in loaders) { + var loader = loaders[extension] + output.push({ + test: new RegExp('\\.' + extension + '$'), + use: loader + }) + } + return output +} diff --git a/UI/build/vue-loader.conf.js b/UI/build/vue-loader.conf.js new file mode 100644 index 0000000000000000000000000000000000000000..d7df7e57270ac94e6361180f61d4998a32a662d9 --- /dev/null +++ b/UI/build/vue-loader.conf.js @@ -0,0 +1,12 @@ +var utils = require('./utils') +var config = require('../config') +var isProduction = process.env.NODE_ENV === 'production' + +module.exports = { + loaders: utils.cssLoaders({ + sourceMap: isProduction + ? config.build.productionSourceMap + : config.dev.cssSourceMap, + extract: isProduction + }) +} diff --git a/UI/build/webpack.base.conf.js b/UI/build/webpack.base.conf.js new file mode 100644 index 0000000000000000000000000000000000000000..6c8dcfd3fa3dcc69f3e7283fbb599f8af3e3763a --- /dev/null +++ b/UI/build/webpack.base.conf.js @@ -0,0 +1,89 @@ +var path = require('path') +var utils = require('./utils') +var config = require('../config') +var vueLoaderConfig = require('./vue-loader.conf') + +function resolve(dir) { + return path.join(__dirname, '..', dir) +} + +module.exports = { + entry: { + app: ["babel-polyfill", "./src/main.js"] + }, + output: { + path: config.build.assetsRoot, + filename: '[name].js', + publicPath: process.env.NODE_ENV !== 'development' ? config.build.assetsPublicPath : config.dev.assetsPublicPath + }, + resolve: { + extensions: ['.js', '.vue', '.json'], + alias: { + 'vue$': 'vue/dist/vue.esm.js', + '@': resolve('src'), + 'src': path.resolve(__dirname, '../src'), + 'assets': path.resolve(__dirname, '../src/assets'), + 'components': path.resolve(__dirname, '../src/components'), + 'views': path.resolve(__dirname, '../src/views'), + 'styles': path.resolve(__dirname, '../src/styles'), + 'api': path.resolve(__dirname, '../src/api'), + 'utils': path.resolve(__dirname, '../src/utils'), + 'store': path.resolve(__dirname, '../src/store'), + 'router': path.resolve(__dirname, '../src/router'), + 'mock': path.resolve(__dirname, '../src/mock'), + 'vendor': path.resolve(__dirname, '../src/vendor'), + 'static': path.resolve(__dirname, '../static') + } + }, + externals: { + 'jquery': 'jQuery' + }, + 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?cacheDirectory', + // options: { + // presets:['es2015'] + // }, + include: [resolve('src'), resolve('test')] + }, + { + test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, + loader: 'url-loader', + query: { + limit: 10000, + name: utils.assetsPath('img/[name].[hash:7].[ext]') + } + }, + { + test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, + loader: 'url-loader', + query: { + limit: 10000, + name: utils.assetsPath('fonts/[name].[hash:7].[ext]') + } + } + ] + }, + //注入全局mixin + // sassResources: path.join(__dirname, '../src/styles/mixin.scss'), + // sassLoader: { + // data: path.join(__dirname, '../src/styles/index.scss') + // }, +} + diff --git a/UI/build/webpack.dev.conf.js b/UI/build/webpack.dev.conf.js new file mode 100644 index 0000000000000000000000000000000000000000..c75747abf0b39f02b6597ff8a18f310b41d45683 --- /dev/null +++ b/UI/build/webpack.dev.conf.js @@ -0,0 +1,50 @@ +var utils = require('./utils') +var path = require('path') +var webpack = require('webpack') +var config = require('../config') +var merge = require('webpack-merge') +var baseWebpackConfig = require('./webpack.base.conf') +var HtmlWebpackPlugin = require('html-webpack-plugin') +var 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]) +}) + +function resolveApp(relativePath) { + return path.resolve(relativePath); +} + +module.exports = merge(baseWebpackConfig, { + module: { + rules: utils.styleLoaders({ + sourceMap: config.dev.cssSourceMap + }) + }, + // cheap-source-map is faster for development + devtool: '#cheap-source-map', + cache: true, + plugins: [ + new webpack.DefinePlugin({ + 'process.env': config.dev.env + }), + new webpack.ProvidePlugin({ + $: 'jquery', + 'jQuery': 'jquery' + }), + // 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', + favicon: resolveApp('favicon.ico'), + inject: true, + path: config.dev.assetsPublicPath + config.dev.assetsSubDirectory + }), + new FriendlyErrorsPlugin() + ] +}) + diff --git a/UI/build/webpack.prod.conf.js b/UI/build/webpack.prod.conf.js new file mode 100644 index 0000000000000000000000000000000000000000..a38ea83ce85fe5cf53f0dc2db74e76b32bedae9b --- /dev/null +++ b/UI/build/webpack.prod.conf.js @@ -0,0 +1,121 @@ +var path = require('path') +var utils = require('./utils') +var webpack = require('webpack') +var config = require('../config') +var merge = require('webpack-merge') +var baseWebpackConfig = require('./webpack.base.conf') +var CopyWebpackPlugin = require('copy-webpack-plugin') +var HtmlWebpackPlugin = require('html-webpack-plugin') +var ExtractTextPlugin = require('extract-text-webpack-plugin') +var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin') + +var env = process.env.NODE_ENV === 'production' ? config.build.prodEnv : config.build.sitEnv + +function resolveApp(relativePath) { + return path.resolve(relativePath); +} + +var 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'), + publicPath: config.build.assetsPublicPath + }, + plugins: [ + // http://vuejs.github.io/vue-loader/en/workflow/production.html + new webpack.DefinePlugin({ + 'process.env': env + }), + 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(), + // 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: 'index.html', + template: 'index.html', + inject: true, + favicon: resolveApp('favicon.ico'), + minify: { + removeComments: true, + collapseWhitespace: true, + removeRedundantAttributes: true, + useShortDoctype: true, + removeEmptyAttributes: true, + removeStyleLinkTypeAttributes: true, + keepClosingSlash: true, + minifyJS: true, + minifyCSS: true, + minifyURLs: true + }, + path: config.build.assetsPublicPath + config.build.assetsSubDirectory, + // necessary to consistently work with multiple chunks via CommonsChunkPlugin + chunksSortMode: 'dependency' + }), + // cache Module Identifiers + new webpack.HashedModuleIdsPlugin(), + // split vendor js into its own file + new webpack.optimize.CommonsChunkPlugin({ + name: 'vendor', + minChunks: function (module, count) { + // 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 + ) + } + }), + // split echarts into its own file + new webpack.optimize.CommonsChunkPlugin({ + async: 'echarts', + minChunks(module) { + var context = module.context; + return context && (context.indexOf('echarts') >= 0 || context.indexOf('zrender') >= 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: ['.*'] + }]), + new webpack.ProvidePlugin({ + $: 'jquery', + 'jQuery': 'jquery' + }) + ] +}) +if (config.build.bundleAnalyzerReport) { + var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin + webpackConfig.plugins.push(new BundleAnalyzerPlugin()) +} +module.exports = webpackConfig + diff --git a/UI/config/dev.env.js b/UI/config/dev.env.js new file mode 100644 index 0000000000000000000000000000000000000000..c6bd3ac17a0ea9c74eddc08880d043a43c61827c --- /dev/null +++ b/UI/config/dev.env.js @@ -0,0 +1,4 @@ +module.exports = { + NODE_ENV: '"development"', + BASE_API: '"http://127.0.0.1:8766"', +} diff --git a/UI/config/index.js b/UI/config/index.js new file mode 100644 index 0000000000000000000000000000000000000000..b4fb9771678f1bc46799107ef818853489802a00 --- /dev/null +++ b/UI/config/index.js @@ -0,0 +1,37 @@ +const path = require('path') + +function resolve(dir) { + return path.join(__dirname, dir) +} +module.exports = { + build: { + sitEnv: require('./sit.env'), + prodEnv: require('./prod.env'), + index: path.resolve(__dirname, '../dist/index.html'), + assetsRoot: path.resolve(__dirname, '../dist'), + assetsSubDirectory: 'static', + assetsPublicPath: '/', //请根据自己路径配置更改 + productionSourceMap: false, + productionGzip: false, + productionGzipExtensions: ['js', 'css'], + bundleAnalyzerReport: process.env.npm_config_report + }, + dev: { + env: require('./dev.env'), + port: 8888, + host: '0.0.0.0', + autoOpenBrowser: true, + assetsSubDirectory: 'static', + assetsPublicPath: '/', + proxyTable: { + '/api': { + target: 'http://47.116.106.242:8871', //后端接口地址 + changeOrigin: true,//是否允许跨越 + pathRewrite: { + '^/api': '/' + } + }, + }, + cssSourceMap: false + }, +} diff --git a/UI/config/prod.env.js b/UI/config/prod.env.js new file mode 100644 index 0000000000000000000000000000000000000000..58094789c690051cf4c03f257074121d96c5700d --- /dev/null +++ b/UI/config/prod.env.js @@ -0,0 +1,4 @@ +module.exports = { + NODE_ENV: '"production"', + BASE_API: '"https://api-prod"', +}; diff --git a/UI/config/sit.env.js b/UI/config/sit.env.js new file mode 100644 index 0000000000000000000000000000000000000000..deb8eff7e722b7e46d4f5c4f64119c9767965c9d --- /dev/null +++ b/UI/config/sit.env.js @@ -0,0 +1,4 @@ +module.exports = { + NODE_ENV: '"production"', + BASE_API: '"https://api-sit"', +}; diff --git a/UI/dump.rdb b/UI/dump.rdb new file mode 100644 index 0000000000000000000000000000000000000000..2669c07fdaf2ffc0bc6b2a21103debe8d24c679e Binary files /dev/null and b/UI/dump.rdb differ diff --git a/UI/favicon.ico b/UI/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..41390329381a833f2542e1f2e8b93456db6b159e Binary files /dev/null and b/UI/favicon.ico differ diff --git a/UI/index.html b/UI/index.html new file mode 100644 index 0000000000000000000000000000000000000000..b82c9743d7ea89b85c2407fc6b578ab762640068 --- /dev/null +++ b/UI/index.html @@ -0,0 +1,211 @@ + + +
+ + + + +