浏览代码

Merge branch 'dev' of https://git.citupro.com/zhengnaiwen_citu/menduner into dev

lifanagju_citu 6 月之前
父节点
当前提交
60594c48ad
共有 3 个文件被更改,包括 68 次插入32 次删除
  1. 25 22
      src/layout/enterprise.vue
  2. 32 0
      src/store/system.js
  3. 11 10
      src/views/recruit/enterprise/jobFair/detailsBox.vue

+ 25 - 22
src/layout/enterprise.vue

@@ -6,7 +6,7 @@
       <div class="content-box d-flex flex-column" :style="`width: ${ !isInWhiteList(route.path, whiteList) ? 'calc(100vw - 230px)' : '100%'}`">
         <div v-if="!isInWhiteList(route.path, whiteList)" class="breadcrumbs_sticky">
           <div class=" d-flex align-center justify-space-between">
-            <v-breadcrumbs :items="breadcrumbs" elevation="3">
+            <v-breadcrumbs :items="system.breadcrumbs" elevation="3">
               <template v-slot:item="{ item }">
                 <span class="text" :class="{active: !item.disabled}" @click="toPath(item)">{{ item.text }}</span>
               </template>
@@ -35,9 +35,11 @@ import Headers from './company/navBar.vue'
 import side from './company/side.vue'
 import { useRouter, useRoute } from 'vue-router'
 import { watch, ref, computed } from 'vue'
+import { useSystem } from '@/store/system'
 
 const router = useRouter()
 const route = useRoute()
+const system = useSystem()
 const key = computed(() => {
   return route.path + Math.random()
 })
@@ -60,31 +62,32 @@ const isInWhiteList = (url, whiteList)=> {
   return false
 }
 
-const breadcrumbs = ref([])
-const getTitle = (list, fullPath) => {
-  const _fullPath = fullPath.split('/')
-  const arr = list.map((item, index) => {
-    // 重组路径
-    if (item.path === list[index - 1]?.path) return false
-    const text = item.meta.title
-    const _path = item.path.split('/')
-    const obj = {
-      text,
-      to: _path.map((e, i) => _fullPath[i]).join('/')
-    }
-    return obj
-  }).filter(e => e) || []
-  if (arr?.length) {
-    arr[arr.length - 1].disabled = true
-    arr[arr.length - 1].link = true
-  }
-  breadcrumbs.value = arr
-}
+// const breadcrumbs = ref([])
+// const getTitle = (list, fullPath) => {
+//   const _fullPath = fullPath.split('/')
+//   const arr = list.map((item, index) => {
+//     // 重组路径
+//     if (item.path === list[index - 1]?.path) return false
+//     const text = item.meta.title
+//     const _path = item.path.split('/')
+//     const obj = {
+//       text,
+//       to: _path.map((e, i) => _fullPath[i]).join('/')
+//     }
+//     return obj
+//   }).filter(e => e) || []
+//   if (arr?.length) {
+//     arr[arr.length - 1].disabled = true
+//     arr[arr.length - 1].link = true
+//   }
+//   breadcrumbs.value = arr
+// }
 
 watch(
   () => route.matched,
   (val) => {    
-    getTitle(val, route.fullPath)
+    // getTitle(val, route.fullPath)
+    system.setBreadcrumbs(val, route.fullPath)
   },
   { immediate: true },
   { deep: true }

+ 32 - 0
src/store/system.js

@@ -0,0 +1,32 @@
+import { defineStore } from 'pinia'
+import { ref } from 'vue'
+
+export const useSystem = defineStore('system', 
+  () => {
+    const breadcrumbs = ref([])
+
+    const setBreadcrumbs = (matched, fullPath) => {
+      const _fullPath = fullPath.split('/')
+      const arr = matched.map((item, index) => {
+        // 重组路径
+        if (item.path === matched[index - 1]?.path) return false
+        const text = item.meta.title
+        const _path = item.path.split('/')
+        const obj = {
+          text,
+          to: _path.map((e, i) => _fullPath[i]).join('/')
+        }
+        return obj
+      }).filter(e => e) || []
+      if (arr?.length) {
+        arr[arr.length - 1].disabled = true
+        arr[arr.length - 1].link = true
+      }
+      breadcrumbs.value =  arr
+    }
+    return {
+      setBreadcrumbs,
+      breadcrumbs
+    }
+  }
+)

+ 11 - 10
src/views/recruit/enterprise/jobFair/detailsBox.vue

@@ -3,20 +3,21 @@
 </template>
 
 <script setup>
+import { useSystem } from '@/store/system'
+const system = useSystem()
 // 处理详情名称
-// import { useRouter, useRoute } from 'vue-router'
-// import { getJobFair } from '@/api/recruit/enterprise/jobFair'
+import { useRouter, useRoute } from 'vue-router'
+import { getJobFair } from '@/api/recruit/enterprise/jobFair'
 // import { onMounted } from 'vue';
-// const route = useRoute()
+const route = useRoute()
 // const router = useRouter()
 
-// const getMsg = async () => {
-//   const res = await getJobFair(route.params.id)
-//   route.matched[1].meta.title = res.title
-//   route.matched[1].meta.title = 111
-//   console.log(route)
-// }
-// getMsg()
+const getMsg = async () => {
+  const res = await getJobFair(route.params.id)
+  route.matched[1].meta.title = res.title
+  system.setBreadcrumbs(route.matched, route.fullPath)
+}
+getMsg()
 
 </script>