Просмотр исходного кода

管理端,增加npm run trial,打包给测试环境

theo 3 лет назад
Родитель
Сommit
ef8cb6bfcb

+ 0 - 17
backendApi/web/index.php

@@ -1,17 +0,0 @@
-<?php
-ini_set('display_errors', 'On');
-error_reporting(E_ALL);
-defined('YII_DEBUG') or define('YII_DEBUG', true);
-defined('YII_ENV') or define('YII_ENV', 'prod');
-
-require __DIR__ . '/../../vendor/autoload.php';
-require __DIR__ . '/../../vendor/yiisoft/yii2/Yii.php';
-require __DIR__ . '/../../common/config/bootstrap.php';
-require __DIR__ . '/../config/bootstrap.php';
-
-$config = yii\helpers\ArrayHelper::merge(
-    require __DIR__ . '/../../common/config/main.php',
-    require __DIR__ . '/../config/main.php'
-);
-
-(new yii\web\Application($config))->run();

+ 41 - 0
backendEle/build/trial.js

@@ -0,0 +1,41 @@
+'use strict'
+require('./check-versions')()
+
+process.env.NODE_ENV = 'trial'
+
+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.trial.conf')
+
+const spinner = ora('building for trial...')
+spinner.start()
+
+rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
+  if (err) throw err
+  webpack(webpackConfig, (err, stats) => {
+    spinner.stop()
+    if (err) throw err
+    process.stdout.write(stats.toString({
+      colors: true,
+      modules: false,
+      children: false, // If you are using ts-loader, setting this to true will make TypeScript errors show up during build.
+      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'
+    ))
+  })
+})

+ 150 - 0
backendEle/build/webpack.trial.conf.js

@@ -0,0 +1,150 @@
+'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 UglifyJsPlugin = require('uglifyjs-webpack-plugin')
+
+// const env = process.env.NODE_ENV === 'testing'
+//   ? require('../config/test.env')
+//   : require('../config/prod.env')
+const env = require('../config/trial.env')
+
+const webpackConfig = merge(baseWebpackConfig, {
+  module: {
+    rules: utils.styleLoaders({
+      sourceMap: config.trial.productionSourceMap,
+      extract: true,
+      usePostCSS: true
+    })
+  },
+  devtool: config.trial.productionSourceMap ? config.trial.devtool : false,
+  output: {
+    path: config.trial.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
+    }),
+    new UglifyJsPlugin({
+      uglifyOptions: {
+        compress: {
+          warnings: false
+        }
+      },
+      sourceMap: config.trial.productionSourceMap,
+      parallel: true
+    }),
+    // extract css into its own file
+    new ExtractTextPlugin({
+      filename: utils.assetsPath('css/[name].[contenthash].css'),
+      // Setting the following option to `false` will not extract CSS from codesplit chunks.
+      // Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack.
+      // It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`,
+      // increasing file size: https://github.com/vuejs-templates/webpack/issues/1110
+      allChunks: true,
+    }),
+    // Compress extracted CSS. We are using this plugin so that possible
+    // duplicated CSS from different components can be deduped.
+    new OptimizeCSSPlugin({
+      cssProcessorOptions: config.trial.productionSourceMap
+        ? { safe: true, map: { inline: false } }
+        : { 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: process.env.NODE_ENV === 'testing'
+        ? 'index.html'
+        : config.trial.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 vendor modules does not change
+    new webpack.HashedModuleIdsPlugin(),
+    // enable scope hoisting
+    new webpack.optimize.ModuleConcatenationPlugin(),
+    // split vendor js into its own file
+    new webpack.optimize.CommonsChunkPlugin({
+      name: 'vendor',
+      minChunks (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',
+      minChunks: Infinity
+    }),
+    // This instance extracts shared chunks from code splitted chunks and bundles them
+    // in a separate chunk, similar to the vendor chunk
+    // see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk
+    new webpack.optimize.CommonsChunkPlugin({
+      name: 'app',
+      async: 'vendor-async',
+      children: true,
+      minChunks: 3
+    }),
+
+    // copy custom static assets
+    new CopyWebpackPlugin([
+      {
+        from: path.resolve(__dirname, '../static'),
+        to: config.trial.assetsSubDirectory,
+        ignore: ['.*']
+      }
+    ])
+  ]
+})
+
+if (config.trial.productionGzip) {
+  const CompressionWebpackPlugin = require('compression-webpack-plugin')
+
+  webpackConfig.plugins.push(
+    new CompressionWebpackPlugin({
+      asset: '[path].gz[query]',
+      algorithm: 'gzip',
+      test: new RegExp(
+        '\\.(' +
+        config.trial.productionGzipExtensions.join('|') +
+        ')$'
+      ),
+      threshold: 10240,
+      minRatio: 0.8
+    })
+  )
+}
+
+if (config.trial.bundleAnalyzerReport) {
+  const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
+  webpackConfig.plugins.push(new BundleAnalyzerPlugin())
+}
+
+module.exports = webpackConfig

+ 4 - 0
backendEle/config/trial.env.js

@@ -0,0 +1,4 @@
+'use strict'
+module.exports = {
+  NODE_ENV: '"trial"'
+}

+ 2 - 1
backendEle/package.json

@@ -11,7 +11,8 @@
     "e2e": "node test/e2e/runner.js",
     "test": "npm run unit && npm run e2e",
     "lint": "eslint --ext .js,.vue src test/unit test/e2e/specs",
-    "build": "node build/build.js"
+    "build": "node build/build.js",
+    "trial": "node build/trial.js"
   },
   "dependencies": {
     "ajv": "^6.11.0",

+ 1 - 0
backendEle/src/router/_import_trial.js

@@ -0,0 +1 @@
+module.exports = file => () => import('@/views/' + file + '.vue')

+ 33 - 0
backendEle/src/utils/config_trial.js

@@ -0,0 +1,33 @@
+const APP_NAME = '奖金结算系统'
+const SERVER_API_DOMAIN = '16.163.228.151'
+const SERVER_API_HTTP_TYPE = 'http://'
+const SERVER_API_PORT = ':8025'  // ':8102'
+const SERVER_API_VERSION = 'v1'
+const REQUEST_URL = `${SERVER_API_HTTP_TYPE}${SERVER_API_DOMAIN}${SERVER_API_PORT}/${SERVER_API_VERSION}/`
+const WEBSOCKET_HOST = 'ws://127.0.0.1:9513'
+const BONUS_WEBSOCKET_HOST = 'ws://127.0.0.1:9513'
+const DEVICE_TYPE = 'pc'
+const ACCESS_TOKEN_PREFIX = 'Bearer '
+const CDN_BASE_URL = 'http://ng-upload.elken.com'
+const CDN_IMG_URL = `${CDN_BASE_URL}/cdn/`
+const PRICE_IS_ROUND = true
+const FRONTEND_SERVER = 'http://16.163.228.151:8028'
+const REGION_URL = `${CDN_BASE_URL}/cdn/jsdata/ar_region_data.js?ver=0.1`
+
+export {
+  APP_NAME,
+  SERVER_API_DOMAIN,
+  SERVER_API_HTTP_TYPE,
+  SERVER_API_PORT,
+  SERVER_API_VERSION,
+  REQUEST_URL,
+  WEBSOCKET_HOST,
+  BONUS_WEBSOCKET_HOST,
+  DEVICE_TYPE,
+  ACCESS_TOKEN_PREFIX,
+  CDN_BASE_URL,
+  CDN_IMG_URL,
+  PRICE_IS_ROUND,
+  FRONTEND_SERVER,
+  REGION_URL
+}

+ 0 - 107
common/config/config-product.php

@@ -1,107 +0,0 @@
-<?php
-/**
- * Created by PhpStorm.
- * User: leo
- * Date: 2018/2/23
- * Time: 下午3:53
- */
-return [
-    // 奖金结算系统主库
-    'db' => [
-        // 数据库连接
-        'dsn' => 'mysql:host=ngds-db-live.cdehazle30lc.ap-east-1.rds.amazonaws.com:4000;dbname=coco_milk_0524',
-        // 数据库用户名
-        'username' => 'babysbreath',
-        // 数据库密码
-        'password' => 'FV8%#$uFL4',
-        // 数据库字符集
-        'charset' => 'utf8',
-        // 数据表前缀
-        'tablePrefix' => 'AR_',
-    ],
-    // 日志库
-    'dbLog' => [
-        'dsn' => 'mongodb://192.168.0.9:27017/aikang_log_db',
-        'options' => [
-            "username" => "admin",
-            "password" => "123456"
-        ],
-    ],
-    // 奖金结算专属库(为不占用主库资源,不影响会员正常业务,该库专门用于奖金结算,可单独架设,需与主库做主从同步)
-    'dbCalc' => [
-        'dsn' => 'mysql:host=ngds-db-live.cdehazle30lc.ap-east-1.rds.amazonaws.com:4000;dbname=coco_milk_0524',
-        'username' => 'babysbreath',
-        'password' => 'FV8%#$uFL4',
-        'charset' => 'utf8',
-        'tablePrefix' => 'AR_',
-    ],
-    // 移动点位时专用的点位备份库(可用来查看各个时期的会员点位情况)
-    'dbNetPoint' => [
-        'dsn' => 'mysql:host=ngds-db-live.cdehazle30lc.ap-east-1.rds.amazonaws.com:4000;dbname=coco_milk_0524',
-        'username' => 'babysbreath',
-        'password' => 'FV8%#$uFL4',
-        'charset' => 'utf8',
-        'tablePrefix' => 'AR_',
-    ],
-    // 系统从库
-    'slavesDb' => [
-        'slaveConfig' => [
-            'username' => 'babysbreath',
-            'password' => 'FV8%#$uFL4',
-            'charset' => 'utf8',
-            'tablePrefix' => 'AR_',
-            'attributes' => [
-                PDO::ATTR_TIMEOUT => 10,  // 从库超时切换间隔时间
-            ],
-        ],
-        'slaves' => [
-            ['dsn' => 'mysql:host=ngds-db-live.cdehazle30lc.ap-east-1.rds.amazonaws.com:4000;dbname=coco_milk_0524'],
-            // 其他奖金结算系统的从库从下面继续添加配置
-        ],
-    ],
-    // Token专用 Redis 库
-    'tokenRedis' => [
-        // 服务器
-        'hostname' => '192.168.0.8',
-        // 端口
-        'port' => 6379,
-        // 密码
-        'password' => 'keli123456',
-        // 库索引
-        'database' => 13,
-    ],
-    // 缓存专用 Redis 库
-    'cacheRedis' => [
-        'hostname' => '192.168.0.8',
-        'port' => 6379,
-        'password' => 'keli123456',
-        'database' => 14,
-    ],
-    // 其他数据 Redis 库
-    'otherRedis' => [
-        'hostname' => '192.168.0.8',
-        'port' => 6379,
-        'password' => 'keli123456',
-        'database' => 15,
-    ],
-    // 远程静态上传服务器地址 @todo 明哥提供
-    'remoteUploadHost' => 'http://ng-upload.elken.com',
-    'idCardVerify' => [
-        'host' => 'http://121.40.238.29:20000',
-        'clientId' => '122371433052508160',
-    ],
-    // swoole异步服务器及端口
-    'swooleTimerConfig' => [
-        'host' => '127.0.0.1',
-        'port' => '9513',
-    ],
-    'swooleClientConfig' => [
-        'host' => '127.0.0.1',
-        'port' => '9513',
-    ],
-    // swoole奖金服务器及端口
-    'swooleBonusClientConfig' => [
-        'host' => '127.0.0.1',
-        'port' => '9513',
-    ],
-];

+ 0 - 15
frontendApi/web/index.php

@@ -1,15 +0,0 @@
-<?php
-defined('YII_DEBUG') or define('YII_DEBUG', true);
-defined('YII_ENV') or define('YII_ENV', 'prod');
-
-require __DIR__ . '/../../vendor/autoload.php';
-require __DIR__ . '/../../vendor/yiisoft/yii2/Yii.php';
-require __DIR__ . '/../../common/config/bootstrap.php';
-require __DIR__ . '/../config/bootstrap.php';
-
-$config = yii\helpers\ArrayHelper::merge(
-    require __DIR__ . '/../../common/config/main.php',
-    require __DIR__ . '/../config/main.php'
-);
-
-(new yii\web\Application($config))->run();

+ 0 - 22
yii

@@ -1,22 +0,0 @@
-#!/usr/bin/env php
-<?php
-/**
- * Yii console bootstrap file.
- */
-
-defined('YII_DEBUG') or define('YII_DEBUG', true);
-defined('YII_ENV') or define('YII_ENV', 'prod');
-
-require __DIR__ . '/vendor/autoload.php';
-require __DIR__ . '/vendor/yiisoft/yii2/Yii.php';
-require __DIR__ . '/common/config/bootstrap.php';
-require __DIR__ . '/console/config/bootstrap.php';
-
-$config = yii\helpers\ArrayHelper::merge(
-    require __DIR__ . '/common/config/main.php',
-    require __DIR__ . '/console/config/main.php'
-);
-
-$application = new yii\console\Application($config);
-$exitCode = $application->run();
-exit($exitCode);