ソースを参照

修改链接名称

Michael Wang 5 年 前
コミット
953931c32b

+ 3 - 1
src/components/MainLayout/MainLayout.vue

@@ -151,7 +151,7 @@
 </template>
 
 <script>
-import { mapState, mapGetters } from "vuex";
+import { mapState, mapGetters, mapMutations } from "vuex";
 import VueQrcode from "@chenfengyuan/vue-qrcode";
 import SiteMessagePopup from "./SiteMessagePopup.vue";
 
@@ -228,8 +228,10 @@ export default {
           link: links[v.routeCode.toUpperCase()],
         };
       });
+    this.updateMenus(this.menus);
   },
   methods: {
+    ...mapMutations(["updateMenus"]),
     goChangePwd() {
       this.$router.push("/password");
     },

+ 10 - 3
src/features/OfflineExam/OfflineExamHome.vue

@@ -5,7 +5,7 @@
                        line-height: 40px; background-color: #fafafa;"
     >
       当前所在位置:
-      <BreadcrumbItem>{{ isCug ? "考查课考核" : "离线考试" }}</BreadcrumbItem>
+      <BreadcrumbItem>{{ locationTitle }}</BreadcrumbItem>
     </Breadcrumb>
 
     <div class="home">
@@ -18,7 +18,7 @@
 </template>
 
 <script>
-import { mapGetters } from "vuex";
+import { mapState } from "vuex";
 import EcsOfflineList from "./OfflineExamList.vue";
 
 export default {
@@ -32,7 +32,14 @@ export default {
     };
   },
   computed: {
-    ...mapGetters(["isCug"]),
+    ...mapState(["menus"]),
+    locationTitle() {
+      return (
+        this.menus.find(
+          v => v.link.toUpperCase() === this.$route.path.toUpperCase()
+        ) || {}
+      ).name;
+    },
   },
   async mounted() {
     try {

+ 6 - 7
src/features/OnlineExam/OnlineExamHome.vue

@@ -41,15 +41,14 @@ export default {
     };
   },
   computed: {
-    ...mapState(["user", "siteMessagesTimeStamp"]),
+    ...mapState(["user", "siteMessagesTimeStamp", "menus"]),
     ...mapGetters(["isEpcc"]),
     locationTitle() {
-      if (this.examType === "ONLINE") {
-        return "在线考试";
-      } else if (this.examType === "ONLINE_HOMEWORK") {
-        return "在线作业";
-      }
-      return "";
+      return (
+        this.menus.find(
+          v => v.link.toUpperCase() === this.$route.path.toUpperCase()
+        ) || {}
+      ).name;
     },
   },
   beforeRouteEnter(to, from, next) {

+ 9 - 2
src/features/OnlinePractice/OnlinePracticeHome.vue

@@ -5,7 +5,7 @@
                        background-color: #fafafa;"
     >
       当前所在位置:
-      <BreadcrumbItem>在线练习</BreadcrumbItem>
+      <BreadcrumbItem>{{ locationTitle }}</BreadcrumbItem>
     </Breadcrumb>
 
     <div class="home">
@@ -52,7 +52,14 @@ export default {
     };
   },
   computed: {
-    ...globalMapState(["user"]),
+    ...globalMapState(["user", "menus"]),
+    locationTitle() {
+      return (
+        this.menus.find(
+          v => v.link.toUpperCase() === this.$route.path.toUpperCase()
+        ) || {}
+      ).name;
+    },
   },
   async mounted() {
     window._hmt.push(["_trackEvent", "在线练习列表页面", "进入页面"]);

+ 12 - 2
src/features/OnlinePractice/OnlinePracticeRecordDetail.vue

@@ -6,7 +6,7 @@
     >
       当前所在位置:
       <BreadcrumbItem :to="{ name: 'OnlinePracticeHome' }">
-        在线练习
+        {{ locationTitle }}
       </BreadcrumbItem>
       <!-- 不是很容易返回练习详情,需要examStudentId, courseName等等 -->
       <BreadcrumbItem>练习详情</BreadcrumbItem>
@@ -91,7 +91,7 @@
 <script>
 // import { createNamespacedHelpers } from "vuex";
 import moment from "moment";
-// import { mapState as globalMapState } from "vuex";
+import { mapState as globalMapState } from "vuex";
 // const { mapMutations } = createNamespacedHelpers("examHomeModule");
 import ExamPaper from "../OnlineExam/Examing/ExamPaper.vue";
 
@@ -108,6 +108,16 @@ export default {
     };
   },
   computed: {
+    ...globalMapState(["user", "menus"]),
+    locationTitle() {
+      return (
+        this.menus.find(
+          v =>
+            v.link.toUpperCase() ===
+            this.$route.path.match(/\/[^/]*/)[0].toUpperCase()
+        ) || {}
+      ).name;
+    },
     examRecordDataId() {
       return this.$route.query.examRecordDataId - 0;
     },

+ 12 - 2
src/features/OnlinePractice/OnlinePracticeRecordList.vue

@@ -6,7 +6,7 @@
     >
       当前所在位置:
       <BreadcrumbItem :to="{ name: 'OnlinePracticeHome' }">
-        在线练习
+        {{ locationTitle }}
       </BreadcrumbItem>
       <BreadcrumbItem>练习详情</BreadcrumbItem>
     </Breadcrumb>
@@ -74,7 +74,7 @@
 <script>
 // import { createNamespacedHelpers } from "vuex";
 import moment from "moment";
-// import { mapState as globalMapState } from "vuex";
+import { mapState as globalMapState } from "vuex";
 // const { mapMutations } = createNamespacedHelpers("examHomeModule");
 
 export default {
@@ -83,6 +83,16 @@ export default {
     return { recordList: [] };
   },
   computed: {
+    ...globalMapState(["menus"]),
+    locationTitle() {
+      return (
+        this.menus.find(
+          v =>
+            v.link.toUpperCase() ===
+            this.$route.path.match(/\/[^/]*/)[0].toUpperCase()
+        ) || {}
+      ).name;
+    },
     examName() {
       return this.$route.query.examName;
     },

+ 12 - 1
src/features/Password/Password.vue

@@ -5,7 +5,7 @@
                          background-color: #fafafa;"
     >
       当前所在位置:
-      <i-breadcrumb-item>修改密码</i-breadcrumb-item>
+      <BreadcrumbItem>{{ locationTitle }}</BreadcrumbItem>
     </i-breadcrumb>
 
     <div class="password-container">
@@ -42,6 +42,7 @@
 </template>
 
 <script>
+import { mapState } from "vuex";
 export default {
   name: "Password",
   data() {
@@ -126,6 +127,16 @@ export default {
       },
     };
   },
+  computed: {
+    ...mapState(["menus"]),
+    locationTitle() {
+      return (
+        this.menus.find(
+          v => v.link.toUpperCase() === this.$route.path.toUpperCase()
+        ) || {}
+      ).name;
+    },
+  },
   methods: {
     async changePwd() {
       const valid = await this.$refs["form"].validate();

+ 11 - 2
src/features/SiteMessage/SiteMessageDetail.vue

@@ -5,7 +5,7 @@
                          background-color: #fafafa;"
     >
       当前所在位置:
-      <i-breadcrumb-item>公告通知</i-breadcrumb-item>
+      <BreadcrumbItem>{{ locationTitle }}</BreadcrumbItem>
     </i-breadcrumb>
 
     <div style="display: flex; flex-direction: row-reverse;">
@@ -40,7 +40,16 @@ import { mapState, mapMutations } from "vuex";
 export default {
   name: "SiteMessageDetail",
   computed: {
-    ...mapState(["user", "siteMessages", "siteMessagesTimeStamp"]),
+    ...mapState(["user", "siteMessages", "siteMessagesTimeStamp", "menus"]),
+    locationTitle() {
+      return (
+        this.menus.find(
+          v =>
+            v.link.toUpperCase() ===
+            this.$route.path.match(/\/[^/]*/)[0].toUpperCase()
+        ) || {}
+      ).name;
+    },
     message() {
       if (this.siteMessages) {
         return this.siteMessages.find(v => v.id === +this.$route.params.id);

+ 9 - 2
src/features/SiteMessage/SiteMessageHome.vue

@@ -5,7 +5,7 @@
                          background-color: #fafafa;"
     >
       当前所在位置:
-      <i-breadcrumb-item>公告通知</i-breadcrumb-item>
+      <BreadcrumbItem>{{ locationTitle }}</BreadcrumbItem>
     </i-breadcrumb>
 
     <div class="home">
@@ -85,7 +85,14 @@ export default {
     };
   },
   computed: {
-    ...mapState(["user", "siteMessages", "siteMessagesTimeStamp"]),
+    ...mapState(["user", "siteMessages", "siteMessagesTimeStamp", "menus"]),
+    locationTitle() {
+      return (
+        this.menus.find(
+          v => v.link.toUpperCase() === this.$route.path.toUpperCase()
+        ) || {}
+      ).name;
+    },
     siteMessagesComputed() {
       return this.siteMessages.slice(
         (this.page - 1) * this.pageSize,

+ 4 - 0
src/store.js

@@ -211,6 +211,7 @@ export default new Vuex.Store({
     siteMessages: [],
     siteMessagesTimeStamp: Date.now(),
     QECSConfig: {}, // getter/setter 来解决其他页面刷新访问的问题
+    menus: [],
   },
   mutations: {
     updateUser(state, payload) {
@@ -228,6 +229,9 @@ export default new Vuex.Store({
     updateQECSConfig(state, payload) {
       state = Object.assign(state, { QECSConfig: payload });
     },
+    updateMenus(state, payload) {
+      state = Object.assign(state, { menus: payload });
+    },
   },
   actions: {},
   modules: {