瀏覽代碼

store文件挂载this

xiaohaizhao 10 月之前
父節點
當前提交
aa61abf657
共有 5 個文件被更改,包括 381 次插入734 次删除
  1. 322 687
      package-lock.json
  2. 48 43
      src/App.vue
  3. 2 1
      src/store/index.js
  4. 8 3
      src/utils/tool.js
  5. 1 0
      src/views/login/login.vue

文件差異過大導致無法顯示
+ 322 - 687
package-lock.json


+ 48 - 43
src/App.vue

@@ -1,63 +1,68 @@
 <template>
   <div id="app">
-    <router-view/>
+    <router-view />
   </div>
 </template>
 <script>
-  import {mapGetters} from 'vuex'
-  export default{
-    data () {
-      return {
-        system:null
-      }
-    },
-    computed:{
+import { mapGetters } from "vuex";
+export default {
+  data() {
+    return {
+      system: null,
+    };
+  },
+  computed: {
     ...mapGetters({
-      searchValue:'searchValue',
-      isRouterAlive:'isRouterAlive'
-    })
+      searchValue: "searchValue",
+      isRouterAlive: "isRouterAlive",
+    }),
   },
-    methods:{
-    },
-    created () {
-    },
-    watch: {
-      $route(val) {
-        this.system = JSON.parse(sessionStorage.getItem('module_info'))
-        this.system?this.system.forEach(sys => {
-          sys.modules.forEach(md=>{
-            md.apps.forEach(app=>{
-              if (val.name == app.name) {
-                sessionStorage.setItem('active_modules',JSON.stringify(md))
-                this.$store.dispatch('setActiveApp',{app:app,val:this.searchValue})
-                this.$store.dispatch('setSSystemModules',sys.modules)
-              }
-            })
+  methods: {},
+  created() {
+    store.state._this = this;
+  },
+  watch: {
+    $route(val) {
+      this.system = JSON.parse(sessionStorage.getItem("module_info"));
+      this.system
+        ? this.system.forEach((sys) => {
+            sys.modules.forEach((md) => {
+              md.apps.forEach((app) => {
+                if (val.name == app.name) {
+                  sessionStorage.setItem("active_modules", JSON.stringify(md));
+                  this.$store.dispatch("setActiveApp", {
+                    app: app,
+                    val: this.searchValue,
+                  });
+                  this.$store.dispatch("setSSystemModules", sys.modules);
+                }
+              });
+            });
           })
-        }):"";
-      }
-    }
-  }
+        : "";
+    },
+  },
+};
 </script>
 <style>
-
-body{
-  font:16px/1.5 Helvetica Neue,Helvetica,Arial,Microsoft Yahei,Hiragino Sans GB,Heiti SC,WenQuanYi Micro Hei,sans-serif;
+body {
+  font: 16px/1.5 Helvetica Neue, Helvetica, Arial, Microsoft Yahei,
+    Hiragino Sans GB, Heiti SC, WenQuanYi Micro Hei, sans-serif;
   font-family: "微软雅黑";
   min-width: 1200px;
 }
-.rightBar{
-  width:60px;
-  height:100vh;
-  background: rgba(255,255,255,.5);
+.rightBar {
+  width: 60px;
+  height: 100vh;
+  background: rgba(255, 255, 255, 0.5);
   box-shadow: 0 2px 5px rgb(0 0 0 / 10%);
 }
-.el-drawer__header{
+.el-drawer__header {
   padding: 10px !important;
   margin-bottom: 0 !important;
-  font-size: 16px  !important;
+  font-size: 16px !important;
   font-family: PingFang SC-Bold, PingFang SC;
-  font-weight: bold  !important;
-  color: #333333  !important;
+  font-weight: bold !important;
+  color: #333333 !important;
 }
 </style>

+ 2 - 1
src/store/index.js

@@ -29,7 +29,8 @@ export default new Vuex.Store({
     historyRouter:null,
     pageCache:[],
     svlistData:[],
-    fullScroll:false
+    fullScroll:false,
+    _this : null
   },
   getters: {
     siteinfo:state => state.siteinfo,

+ 8 - 3
src/utils/tool.js

@@ -1,5 +1,5 @@
-import Vue from 'vue'
 import { Message } from 'element-ui';
+import store from "../store/index";
 import router from '@/router';
 import api from '@/api/api';
 let timer = null
@@ -39,11 +39,16 @@ export default {
 
   // 操作响应提示
   showMessage (res,success) {
-    let message = res.msg || '操作成功'
+    let message = '操作成功'
     try {
-      message = Vue.prototype.$t(message)
+      message = res.msg || '操作成功'
     } catch (error) {
       
+    }
+
+    try {
+      message = store.state._this.$t(message)
+    } catch (error) {
     }
     if (res.code === 0)  return Message({
       message,

+ 1 - 0
src/views/login/login.vue

@@ -136,6 +136,7 @@ import Vue from "vue";
 import zhLocale from "element-ui/lib/locale/lang/zh-CN";
 import enLocale from "element-ui/lib/locale/lang/en";
 import ruLocale from "element-ui/lib/locale/lang/ru-RU";
+import store from "@/store";
 
 export default {
   data() {

部分文件因文件數量過多而無法顯示