Răsfoiți Sursa

Merge branch 'http_test' into insist

qinzhipeng_v@didiglobal.com 4 ani în urmă
părinte
comite
e88da05aa2

+ 1 - 1
package.json

@@ -93,7 +93,7 @@
     "mockjs": "1.0.1-beta3",
     "node-sass": "^4.14.1",
     "runjs": "^4.3.2",
-    "sass-loader": "^7.3.1",
+    "sass-loader": "^8.0.0",
     "script-ext-html-webpack-plugin": "2.1.3",
     "script-loader": "^0.7.2",
     "serve-static": "^1.13.2",

+ 0 - 1
src/main.js

@@ -16,7 +16,6 @@ import store from './store'
 import router from './router'
 
 import '@/icons' // icon
-// import '@/permission' // permission control/
 import htmlToPdf from '@/utils/htmlToPdf'
 Vue.use(htmlToPdf)
 

+ 0 - 66
src/permission.js

@@ -1,66 +0,0 @@
-import router from './router'
-import store from './store'
-import { Message } from 'element-ui'
-import NProgress from 'nprogress' // progress bar
-import 'nprogress/nprogress.css' // progress bar style
-import { getToken } from '@/utils/auth' // get token from cookie
-import getPageTitle from '@/utils/get-page-title'
-
-NProgress.configure({ showSpinner: false }) // NProgress Configuration
-
-const whiteList = ['/login'] // no redirect whitelist
-
-router.beforeEach(async(to, from, next) => {
-  // start progress bar
-  NProgress.start()
-
-  // set page title
-  document.title = getPageTitle(to.meta.title)
-
-  // determine whether the user has logged in
-  const hasToken = getToken()
-
-  if (hasToken) {
-    if (to.path === '/login') {
-      // if is logged in, redirect to the home page
-      next({ path: '/' })
-      NProgress.done()
-    } else {
-      const hasGetUserInfo = store.getters.name
-      if (hasGetUserInfo) {
-        next()
-      } else {
-        try {
-          // get user info
-          await store.dispatch('user/getInfo')
-
-          next()
-        } catch (error) {
-          // remove token and go to login page to re-login
-          await store.dispatch('user/resetToken')
-          Message.error(error || 'Has Error')
-          next(`/login?redirect=${to.path}`)
-          NProgress.done()
-        }
-      }
-    }
-  } else {
-    /* has no token*/
-
-    // var mock_url = '/mock/interface/'
-    // if (whiteList.indexOf(to.path) !== -1) {
-    if (whiteList.length > 0) {
-      // in the free login whitelist, go directly
-      next()
-    } else {
-      // other pages that do not have permission to access are redirected to the login page.
-      next(`/login?redirect=${to.path}`)
-      NProgress.done()
-    }
-  }
-})
-
-router.afterEach(() => {
-  // finish progress bar
-  NProgress.done()
-})

+ 0 - 2
src/store/index.js

@@ -3,7 +3,6 @@ import Vuex from 'vuex'
 import getters from './getters'
 import app from './modules/app'
 import settings from './modules/settings'
-import user from './modules/user'
 import data from './modules/data'
 import project from './modules/project'
 
@@ -13,7 +12,6 @@ const store = new Vuex.Store({
   modules: {
     app,
     settings,
-    user,
     data,
     project
   },

+ 0 - 90
src/store/modules/user.js

@@ -1,90 +0,0 @@
-import { login, logout, getInfo } from '@/api/user'
-import { getToken, setToken, removeToken } from '@/utils/auth'
-import { resetRouter } from '@/router'
-
-const state = {
-  token: getToken(),
-  name: '',
-  avatar: ''
-}
-
-const mutations = {
-  SET_TOKEN: (state, token) => {
-    state.token = token
-  },
-  SET_NAME: (state, name) => {
-    state.name = name
-  },
-  SET_AVATAR: (state, avatar) => {
-    state.avatar = avatar
-  }
-}
-
-const actions = {
-  // user login
-  login({ commit }, userInfo) {
-    const { username, password } = userInfo
-    return new Promise((resolve, reject) => {
-      login({ username: username.trim(), password: password }).then(response => {
-        const { data } = response
-        commit('SET_TOKEN', data.token)
-        setToken(data.token)
-        resolve()
-      }).catch(error => {
-        reject(error)
-      })
-    })
-  },
-
-  // get user info
-  getInfo({ commit, state }) {
-    return new Promise((resolve, reject) => {
-      getInfo(state.token).then(response => {
-        const { data } = response
-
-        if (!data) {
-          reject('Verification failed, please Login again.')
-        }
-
-        const { name, avatar } = data
-
-        commit('SET_NAME', name)
-        commit('SET_AVATAR', avatar)
-        resolve(data)
-      }).catch(error => {
-        reject(error)
-      })
-    })
-  },
-
-  // user logout
-  logout({ commit, state }) {
-    return new Promise((resolve, reject) => {
-      logout(state.token).then(() => {
-        commit('SET_TOKEN', '')
-        removeToken()
-        resetRouter()
-        resolve()
-      }).catch(error => {
-        reject(error)
-      })
-    })
-  },
-
-  // remove token
-  resetToken({ commit }) {
-    return new Promise(resolve => {
-      commit('SET_TOKEN', '')
-      removeToken()
-      resolve()
-    })
-  }
-}
-
-export default {
-  namespaced: true,
-  state,
-  mutations,
-  actions
-}
-

+ 2 - 1
src/views/mock/httprule.vue

@@ -238,7 +238,8 @@
 
 <script>
 const _ = require('lodash')
-import { fetchEnvInfo, queryById, fetchRuleList, createRule, updateRule, changeStatus, getHttpOp, getExpress, callbackQuery } from '@/api/httprule'
+import { queryById, fetchRuleList, createRule, updateRule, changeStatus, getHttpOp, getExpress, callbackQuery } from '@/api/httprule'
+import { fetchEnvInfo } from '@/api/interface'
 import waves from '@/directive/waves' // waves directive
 import { parseTime } from '@/utils'
 import Pagination from '@/components/Pagination' // secondary package based on el-pagination

+ 2 - 1
src/views/mock/interface.vue

@@ -224,7 +224,8 @@
 </style>
 
 <script>
-import { fetchEnvInfo, fetchServiceById, fetchServiceList, fetchConsumerList, createService, updateService, changeStatus } from '@/api/interface'
+import { fetchServiceById, fetchServiceList, fetchConsumerList, createService, updateService, changeStatus } from '@/api/interface'
+import { fetchEnvInfo } from '@/api/interface'
 import waves from '@/directive/waves' // waves directive
 import { parseTime } from '@/utils'
 import Pagination from '@/components/Pagination' // secondary package based on el-pagination

+ 2 - 1
src/views/mock/rule.vue

@@ -143,7 +143,8 @@
 </template>
 
 <script>
-import { fetchEnvInfo, fetchRuleById, fetchRuleList, createRule, updateRule, changeStatus } from '@/api/rule'
+import { fetchRuleById, fetchRuleList, createRule, updateRule, changeStatus } from '@/api/rule'
+import { fetchEnvInfo } from '@/api/interface'
 import waves from '@/directive/waves' // waves directive
 import { parseTime } from '@/utils'
 import Pagination from '@/components/Pagination' // secondary package based on el-pagination

+ 6 - 50
vue.config.js

@@ -1,27 +1,16 @@
 'use strict'
 const path = require('path')
 const defaultSettings = require('./src/settings.js')
-// const CompressionWebpackPlugin = require('compression-webpack-plugin')
 
 function resolve(dir) {
   return path.join(__dirname, dir)
 }
 
 const name = defaultSettings.title || 'vue Admin Template' // page title
-// If your port is set to 80,
-// use administrator privileges to execute the command line.
-// For example, Mac: sudo npm run
+
 const port = 9528 // dev port
 
-// All configuration item explanations can be find in https://cli.vuejs.org/config/
 module.exports = {
-  /**
-   * You will need to set publicPath if you plan to deploy your site under a sub path,
-   * for example GitHub Pages. If you plan to deploy your site to https://foo.github.io/bar/,
-   * then publicPath should be set to "/bar/".
-   * In most cases please use '/' !!!
-   * Detail: https://cli.vuejs.org/config/#publicpath
-   */
   publicPath: '/',
   outputDir: 'dist',
   assetsDir: 'static',
@@ -36,8 +25,6 @@ module.exports = {
     },
     disableHostCheck: true, // webpack4.0 开启热更新
     proxy: {
-      // change xxx-api/login => mock/login
-      // detail: https://cli.vuejs.org/config/#devserver-proxy
       [process.env.VUE_APP_BASE_API]: {
         target: `http://127.0.0.1:${port}/mock`,
         changeOrigin: true,
@@ -46,28 +33,24 @@ module.exports = {
         }
       }
     }
-    // after: require('./mock/mock-server.js')
   },
   configureWebpack: {
-    // provide the app's title in webpack's name field, so that
-    // it can be accessed in index.html to inject the correct title.
     name: name,
     resolve: {
       alias: {
         '@': resolve('src')
       }
+    },
+    performance: { // 性能设置
+      hints: 'warning',
+      maxEntrypointSize: 500000,
+      maxAssetSize: 300000
     }
-    // plugins: [
-    //   new CompressionWebpackPlugin({ // 构建压缩加速
-    //     test: /\.js$|\.html$|\.css/
-    //   })
-    // ]
   },
   chainWebpack(config) {
     config.plugins.delete('preload') // TODO: need test
     config.plugins.delete('prefetch') // TODO: need test
 
-    // set svg-sprite-loader
     config.module
       .rule('svg')
       .exclude.add(resolve('src/icons'))
@@ -84,7 +67,6 @@ module.exports = {
       })
       .end()
 
-    // set preserveWhitespace
     config.module
       .rule('vue')
       .use('vue-loader')
@@ -96,7 +78,6 @@ module.exports = {
       .end()
 
     config
-    // https://webpack.js.org/configuration/devtool/#development
       .when(process.env.NODE_ENV === 'development',
         config => config.devtool('cheap-source-map')
       )
@@ -108,7 +89,6 @@ module.exports = {
             .plugin('ScriptExtHtmlWebpackPlugin')
             .after('html')
             .use('script-ext-html-webpack-plugin', [{
-            // `runtime` must same as runtimeChunk name. default is `runtime`
               inline: /runtime\..*\.js$/
             }])
             .end()
@@ -121,30 +101,6 @@ module.exports = {
                   test: /[\\/]node_modules[\\/]/,
                   priority: -10,
                   chunks: 'initial' // only package third parties that are initially dependent
-                },
-                elementUI: {
-                  name: 'chunk-elementUI', // split elementUI into a single package
-                  priority: 15, // the weight needs to be larger than libs and app or it will be packaged into libs or app
-                  test: /[\\/]node_modules[\\/]element-ui[\\/]/, // in order to adapt to cnpm
-                  chunks: 'all',
-                  reuseExistingChunk: true,
-                  enforce: true
-                },
-                echarts: {
-                  name: 'chunk-echarts',
-                  test: /[\\/]node_modules[\\/]echarts[\\/]/,
-                  chunks: 'all',
-                  priority: 10,
-                  reuseExistingChunk: true,
-                  enforce: true
-                },
-                demo: {
-                  name: 'chunk-demo',
-                  test: /[\\/]src[\\/]views[\\/]/,
-                  chunks: 'all',
-                  priority: 20,
-                  reuseExistingChunk: true,
-                  enforce: true
                 }
               }
             })