Ver Fonte

online && private分支融合

wjj há 4 anos atrás
pai
commit
17f096a1a0
10 ficheiros alterados com 135 adições e 13 exclusões
  1. 2 2
      build/build.js
  2. 8 2
      build/utils.js
  3. 96 0
      build/webpack.private.conf.js
  4. 1 0
      config/index.js
  5. 4 2
      package.json
  6. 4 4
      src/App.vue
  7. 2 2
      src/main.js
  8. 2 1
      src/style/main.scss
  9. 0 0
      src/style/online.scss
  10. 16 0
      src/style/private.scss

+ 2 - 2
build/build.js

@@ -1,7 +1,7 @@
 'use strict'
 require('./check-versions')()
-
-process.env.NODE_ENV = 'production'
+console.log(process.env.NODE_ENV);
+// process.env.NODE_ENV = 'production'
 
 const ora = require('ora')
 const rm = require('rimraf')

+ 8 - 2
build/utils.js

@@ -3,6 +3,8 @@ const path = require('path')
 const config = require('../config')
 const ExtractTextPlugin = require('extract-text-webpack-plugin')
 const packageConfig = require('../package.json')
+// console.log(process.env.NODE_ENV)
+let themeConfig = process.env.NODE_ENV === 'private' ? `@import "~@/style/private.scss";` : `@import "~@/style/online.scss";`;
 
 exports.assetsPath = function (_path) {
   const assetsSubDirectory = process.env.NODE_ENV === 'production'
@@ -60,8 +62,12 @@ exports.cssLoaders = function (options) {
     css: generateLoaders(),
     postcss: generateLoaders(),
     less: generateLoaders('less'),
-    sass: generateLoaders('sass', { indentedSyntax: true }),
-    scss: generateLoaders('sass'),
+    sass: generateLoaders('sass', {
+      indentedSyntax: true ,
+      data: themeConfig}),
+    scss: generateLoaders('sass', {
+      data: themeConfig,
+    }),
     stylus: generateLoaders('stylus'),
     styl: generateLoaders('stylus')
   }

+ 96 - 0
build/webpack.private.conf.js

@@ -0,0 +1,96 @@
+'use strict'
+const utils = require('./utils')
+const webpack = require('webpack')
+const config = require('../config')
+const merge = require('webpack-merge')
+const path = require('path')
+const baseWebpackConfig = require('./webpack.base.conf')
+const CopyWebpackPlugin = require('copy-webpack-plugin')
+const HtmlWebpackPlugin = require('html-webpack-plugin')
+const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
+const portfinder = require('portfinder')
+console.log(require('../config/private.env'));
+const HOST = process.env.HOST
+const PORT = process.env.PORT && Number(process.env.PORT)
+console.log(process.env.NODE_ENV);
+const devWebpackConfig = merge(baseWebpackConfig, {
+  module: {
+    rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true })
+  },
+  // cheap-module-eval-source-map is faster for development
+  devtool: config.dev.devtool,
+
+  // these devServer options should be customized in /config/index.js
+  devServer: {
+    clientLogLevel: 'warning',
+    historyApiFallback: {
+      rewrites: [
+        { from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'index.html') },
+      ],
+    },
+    hot: true,
+    contentBase: false, // since we use CopyWebpackPlugin.
+    compress: true,
+    host: HOST || config.dev.host,
+    port: PORT || config.dev.port,
+    open: config.dev.autoOpenBrowser,
+    overlay: config.dev.errorOverlay
+      ? { warnings: false, errors: true }
+      : false,
+    publicPath: config.dev.assetsPublicPath,
+    proxy: config.dev.proxyTable,
+    quiet: true, // necessary for FriendlyErrorsPlugin
+    watchOptions: {
+      poll: config.dev.poll,
+    },
+    disableHostCheck: true, //  开发环境使用true方便开发,生产环境使用false
+  },
+  plugins: [
+    new webpack.DefinePlugin({
+      'process.env': require('../config/private.env')
+    }),
+    new webpack.HotModuleReplacementPlugin(),
+    new webpack.NamedModulesPlugin(), // HMR shows correct file names in console on update.
+    new webpack.NoEmitOnErrorsPlugin(),
+    // https://github.com/ampedandwired/html-webpack-plugin
+    new HtmlWebpackPlugin({
+      filename: 'index.html',
+      template: 'index.html',
+      inject: true
+    }),
+    // copy custom static assets
+    new CopyWebpackPlugin([
+      {
+        from: path.resolve(__dirname, '../static'),
+        to: config.dev.assetsSubDirectory,
+        ignore: ['.*']
+      }
+    ])
+  ]
+})
+
+module.exports = new Promise((resolve, reject) => {
+  portfinder.basePort = process.env.PORT || config.dev.port
+  portfinder.getPort((err, port) => {
+    if (err) {
+      reject(err)
+    } else {
+      // publish the new Port, necessary for e2e tests
+      process.env.PORT = port
+      // add port to devServer config
+      devWebpackConfig.devServer.port = port
+
+      // Add FriendlyErrorsPlugin
+      devWebpackConfig.plugins.push(new FriendlyErrorsPlugin({
+        compilationSuccessInfo: {
+          messages: [`Your application is running here: http://${devWebpackConfig.devServer.host}:${port}`],
+        },
+        onErrors: config.dev.notifyOnErrors
+        ? utils.createNotifierCallback()
+        : undefined
+      }))
+
+      resolve(devWebpackConfig)
+    }
+  })
+})

+ 1 - 0
config/index.js

@@ -46,6 +46,7 @@ module.exports = {
   build: {
     devEnv: require('./dev.env'),
     testEnv: require('./test.env'),
+    privateEnv: require('./private.env'),
     prodEnv: require('./prod.env'),
     // Template for index.html
     index: path.resolve(__dirname, '../dist/index.html'),

+ 4 - 2
package.json

@@ -5,12 +5,14 @@
   "author": "yuinii1215 <qi1215e_mail@163.com>",
   "private": true,
   "scripts": {
-    "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
+    "dev": "NODE_ENV=development webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
     "start": "npm run dev",
+    "private": "NODE_ENV=private webpack-dev-server --inline --progress --config build/webpack.private.conf.js",
     "lint": "eslint --ext .js,.vue src",
     "build--dev": "NODE_ENV=production env_config=dev node build/build.js",
     "build--test": "NODE_ENV=production env_config=test node build/build.js",
-    "build--prod": "NODE_ENV=production env_config=prod node build/build.js"
+    "build--prod": "NODE_ENV=production env_config=prod node build/build.js",
+    "build--private": "NODE_ENV=private env_config=private node build/build.js"
   },
   "dependencies": {
     "axios": "^0.21.1",

+ 4 - 4
src/App.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="body-content">
-    <home-slice v-if="showSlice && slice_type === 1"/>
-    <home-slice-online v-if="showSlice && slice_type === 0"/>
+    <home-slice v-if="showSlice && this.$env === 'private'"/>
+    <home-slice-online v-else/>
     <header-container/>
     <div class="container-wrapper">
       <slot>
@@ -30,7 +30,6 @@ export default {
   data(){
     return {
       // showSlice:false
-      slice_type
     }
   },
   methods: {
@@ -84,7 +83,8 @@ export default {
 }
 </script>
 
-<style>
+<style lang="scss">
+
   .body-content{
     width:100%;
     min-width: 1300px;

+ 2 - 2
src/main.js

@@ -207,8 +207,8 @@ Vue.prototype.$notify = Notification
 Vue.prototype.$message = Message
 
 Vue.config.productionTip = false
-
-
+Vue.prototype.$env = process.env.NODE_ENV
+// console.log(process.env);
 Http.get('/api/common/configuration').then((res) => {
   let config = res.data&&res.data.configurationList;
   let configData = configToJson(config);

+ 2 - 1
src/style/main.scss

@@ -1,4 +1,5 @@
-@import "./basic";
+//@import "online";
+//@import "private";
 
 /* 改变主题色变量 */
 $--color-primary: $color-primary;

+ 0 - 0
src/style/basic.scss → src/style/online.scss


+ 16 - 0
src/style/private.scss

@@ -0,0 +1,16 @@
+//配置主题色
+$color-primary: #B80000;
+//配置浅色主题背景色
+$color-primary-background:#FDD2D2;
+//配置发布按钮背景色
+$color-publish-background:#FFE400;
+//配置参与按钮背景色
+$color-participate-background:#FF1800;
+//配置slice title文本颜色
+$color-title-color:#FFFFFF;
+//配置footer灰色背景色
+$color-footer-background:#2f3030;
+
+.el-input-group__append {
+  border-radius: 0 !important;
+}