Преглед на файлове

更新 tabText渲染逻辑

wzh преди 4 години
родител
ревизия
b98c5f9800
променени са 2 файла, в които са добавени 11 реда и са изтрити 13 реда
  1. 9 8
      src/components/Header.vue
  2. 2 5
      src/main.js

+ 9 - 8
src/components/Header.vue

@@ -38,18 +38,19 @@ import { ref, onMounted } from "vue";
 export default {
   setup() {
     let tabs = ref([
-      { path: 0, tabText: "运输安全管理中心" },
-      { path: 0, tabText: "智能交易中心" },
-      { path: 0, tabText: "环境中心" },
+      { path: "/transportationSafetyCenter", tabText: "运输安全管理中心" },
+      { path: "/transportationSafetyCenter", tabText: "智能交易中心" },
+      { path: "/transportationSafetyCenter", tabText: "环境中心" },
       { path: "/digitalEmpowermentCenter", tabText: "数字化赋能中心" },
     ]);
     function changeTab(item) {
       store.commit("changeTab", item.tabText);
-      if (item.path) {
-        router.push(item.path);
-      } else {
-        router.push("/transportationSafetyCenter");
-      }
+      router.push({
+        path: item.path,
+        query: {
+          tabText: item.tabText,
+        },
+      });
     }
     async function logOut() {
       let res = await store.dispatch("LogOut");

+ 2 - 5
src/main.js

@@ -65,11 +65,8 @@ router.beforeEach(async (to, from, next) => {
   }
 });
 router.afterEach((to, from) => {
-  let { title } = to.meta;
-  if (to.meta == "数字化赋能中心") {
-    store.commit("changeTab", to.meta);
-  }
-  document.title = title;
+  store.commit("changeTab", to.query.tabText);
+  document.title = to.query.tabText;
 });
 
 app.use(router).use(ElementPlus).use(store).mount("#app");