zhaomiao %!s(int64=3) %!d(string=hai) anos
pai
achega
7a0ac082df

+ 1 - 1
src/api/axios.js

@@ -78,7 +78,7 @@ export function requestData (options) {
           window.location.reload();
           // window.__STATICVUE__.$router.replace('/login');
         }, 1000);
-      } else if (response.code === 200) { // 请求成功 code
+      } else if (response.data.code === 200) { // 请求成功 code
         options.success && options.success(response.data);
         resolve(response);
       } else { // 其他code

+ 5 - 11
src/assets/js/login.js

@@ -26,17 +26,11 @@ export default {
           const { data, code } = res;
           if (code == 200) {
             this.SET_TOKEN({ "token": data, "username": this.loginForm.username });
-            debugger
-            var digital1 = new URLSearchParams();
-            digital1.append('authToken', localStorage.getItem('authToken'));
-            this.API.post("admin/usermenu", digital1).then((res) => {
-                console.log(res + "1111111111111")
-                this.$router.push('/'); // 跳转到首页
-                this.$message({
-                  message: '登陆成功',
-                  type: 'success'
-                });
-              }).catch(console.log("3333333333333333333"));
+            this.$router.push('/'); // 跳转到首页
+            this.$message({
+              message: '登陆成功',
+              type: 'success'
+            });
           }
           else {
             this.$message.error('登录失败');// ui弹窗提示

+ 3 - 3
src/components/common/menu.vue

@@ -2,14 +2,14 @@
   <el-menu v-if="menuIndex !== undefined" :default-active="menuIndex" background-color="#545c64" text-color="#fff"
     active-text-color="#ffd04b" class="el-menu-demo" mode="horizontal">
     <template v-for="(item, i) in menu">
-      <el-menu-item :key="i" v-if="item.children.length === 0" :index="(i+1)+''" @click="menuC(item)">{{item.name}}</el-menu-item>
+      <el-menu-item :key="i" v-if="!item.children" :index="(i+1)+''" @click="menuC(item)">{{item.label}}</el-menu-item>
       <menuZj :key="i" v-else :obj="item" :fIndex="(i+1)+''"></menuZj>
     </template>
   </el-menu>
   <el-submenu v-else :index="fIndex" :popper-append-to-body="false">
-    <template slot="title">{{obj.name}}</template>
+    <template slot="title">{{obj.label}}</template>
     <template v-for="(item, i) in obj.children">
-      <el-menu-item :key="i" v-if="item.children.length === 0" :index="fIndex+'-'+(i+1)" @click="menuC(item)">{{item.name}}</el-menu-item>
+      <el-menu-item :key="i" v-if="!item.children" :index="fIndex+'-'+(i+1)" @click="menuC(item)">{{item.label}}</el-menu-item>
       <menuZj :key="i" v-else :obj="item" :fIndex="fIndex+'-'+(i+1)"></menuZj>
     </template>
   </el-submenu>

+ 17 - 9
src/layout/header.vue

@@ -43,7 +43,7 @@ export default {
   mounted() {
     window.onload=function() {
        this.name = localStorage.getItem('username');
-    },
+    }
     this.getMenu();
   },
   computed: {
@@ -54,14 +54,22 @@ export default {
     ...mapMutations("user", ["SET_NAME"]),
     // 获取菜单
     getMenu() {
-      //   this.API.requestData({
-      //     subUrl: "admin/usermenu",
-      //     success (res) {
-      //       console.log("getMenu", res);
-      //     }
-      //   });
-      //   return;
-      this.menu = menuData.menu;
+            var digital1 = new URLSearchParams();
+            digital1.append('authToken', localStorage.getItem('authToken'));
+            this.API.get("admin/usermenu", digital1).then((res) => {
+              let { children } = res.data[0];
+              let menu = [];
+              for (let i = 0; i < Object.keys(children).length; i++) {
+                menu.push(children[i]);
+              }
+              this.$store.commit('setMenu', menu);
+              this.menu = this.$store.getters.menu;
+            }).catch(console.log("3333333333333333333"));
+      //this.menu = menuData.menu;
+      //this.menu = localStorage.getItem('menu')
+      //this.$store.commit('setMenu', )
+
+     
       this.API.get("/powercompare/windfarmAjax").then((res) => {
         console.log(res);
         if (res.code === 200) {

+ 3 - 0
src/layout/vueapp.vue

@@ -36,6 +36,9 @@ export default {
     mains,
   },
   methods: {},
+   created() {
+      
+    },
 };
 </script>
 <style lang="scss">

+ 1 - 0
src/store/getters.js

@@ -7,5 +7,6 @@ const getters = {
   asidez: state => state.z,
   mainy: state => state.y,
   login: state => state.login,
+  menu: state => state.menu,
 }
 export default getters

+ 14 - 0
vue.config.js

@@ -3,6 +3,9 @@ const path = require('path');
 const IS_PROD = ['production', 'prod'].includes(process.env.NODE_ENV);
 const resolve = (dir) => path.join(__dirname, dir);
 const UglifyJsPlugin = require("uglifyjs-webpack-plugin"); // 去掉 console.log
+//打包分析
+const BundleAnalyzerPlugin = require("webpack-bundle-analyzer")
+  .BundleAnalyzerPlugin;
 module.exports = {
   publicPath: "./", // 默认'/',部署应用包时的基本 URL
   indexPath: 'index.html', // 相对于打包路径index.html的路径
@@ -82,6 +85,17 @@ module.exports = {
       }
     },
     open: true, // 是否打开浏览器
+  },
+  //打包分析
+  chainWebpack: config => {
+    // 打包分析
+    if (IS_PROD) {
+      config.plugin("webpack-report").use(BundleAnalyzerPlugin, [
+        {
+          analyzerMode: "static"
+        }
+      ]);
+    }
   }
 
 }