Przeglądaj źródła

修改标签和面包屑,添加申请审核

lrf 8 miesięcy temu
rodzic
commit
e9e73a77ad

+ 16 - 8
src/components/Breadcrumb/index.vue

@@ -14,11 +14,15 @@
 </template>
 
 <script setup>
+import { get } from 'lodash-es'
 import { onBeforeMount, ref, watch } from 'vue'
 import { useRoute } from 'vue-router'
 import { compile } from 'path-to-regexp'
 import { translateRouteTitle } from '@/utils/i18n'
 import router from '@/router'
+import { UserStore } from '@/store/user'
+const userStore = UserStore()
+const menus = computed(() => userStore.menus)
 
 const currentRoute = useRoute()
 const pathCompile = (path) => {
@@ -31,21 +35,25 @@ const breadcrumbs = ref([])
 
 function getBreadcrumb() {
   let matched = currentRoute.matched.filter((item) => item.meta && item.meta.title)
-  const first = matched[0]
+  let menus = matched.map((i) => getMenu(i))
+  const first = menus[0]
   if (!isDashboard(first)) {
-    matched = [{ path: '/', meta: { title: 'home' } }].concat(matched)
+    menus = [{ path: '/', meta: { title: '首页' } }].concat(matched)
   }
-  breadcrumbs.value = matched.filter((item) => {
+  breadcrumbs.value = menus.filter((item) => {
     return item.meta && item.meta.title && item.meta.breadcrumb !== false
   })
 }
 
+const getMenu = (route) => {
+  const menu = menus.value.find((f) => f.path === route.path)
+  console.log(menu)
+  if (menu) route.meta.title = get(menu, 'name')
+  return route
+}
+
 function isDashboard(route) {
-  const name = route && route.name
-  if (!name) {
-    return false
-  }
-  return name.toString().trim().toLocaleLowerCase() === 'home'.toLocaleLowerCase()
+  return route.path === '/'
 }
 
 function handleLink(item) {

+ 12 - 12
src/lang/package/zh-cn/menus.js

@@ -1,16 +1,16 @@
 export default {
-  home: '首页',
-  system: '系统管理',
-  platform: '平台设置',
-  information: '信息管理',
-  user: '用户管理',
-  board: '数据看板',
-  center: '个人中心',
-  password: '修改密码',
-  log: '日志管理',
-  message: '站内消息',
-  journal: '行研产研',
-  journal_notes: '期刊管理'
+  // home: '首页',
+  // system: '系统管理',
+  // platform: '平台设置',
+  // information: '信息管理',
+  // user: '用户管理',
+  // board: '数据看板',
+  // center: '个人中心',
+  // password: '修改密码',
+  // log: '日志管理',
+  // message: '站内消息',
+  // journal: '行研产研',
+  // journal_notes: '期刊管理'
 
   // system_menus: '菜单设置',
   // system_userMenus: '用户目录',

+ 2 - 0
src/layout/parts/Header.vue

@@ -7,6 +7,7 @@
         </div>
         <div class="right">
           <!-- <LangSelect class="navbar-item"></LangSelect> -->
+          <message style="margin-right: 10px" />
           <el-dropdown>
             <el-icon style="margin-right: 8px; margin-top: 1px">
               <setting />
@@ -28,6 +29,7 @@
 </template>
 
 <script setup>
+import message from './header/message.vue'
 import { UserStore } from '@/store/user'
 import { useTagsViewStore } from '@/store'
 const userStore = UserStore()

+ 23 - 24
src/layout/parts/Tagsbar.vue

@@ -1,14 +1,8 @@
 <template>
   <div class="tags-container">
     <el-scrollbar class="scroll-container" :vertical="false" @wheel.prevent="handleScroll">
-      <router-link
-        ref="tagRef"
-        v-for="tag in visitedViews"
-        :key="tag.fullPath"
-        :class="'tags-item ' + (isActive(tag) ? 'active' : '')"
-        :to="{ path: tag.path, query: tag.query }"
-      >
-      <!-- @click.middle="!isAffix(tag) ? closeSelectedTag(tag) : ''"
+      <router-link ref="tagRef" v-for="tag in visitedViews" :key="tag.fullPath" :class="'tags-item ' + (isActive(tag) ? 'active' : '')" :to="{ path: tag.path, query: tag.query }">
+        <!-- @click.middle="!isAffix(tag) ? closeSelectedTag(tag) : ''"
         @contextmenu.prevent="openContentMenu(tag, $event)" -->
         {{ translateRouteTitle(tag.title) }}
         <SvgIcon class="close-icon" icon-class="close" v-if="!isAffix(tag)" @click.prevent.stop="closeSelectedTag(tag)"></SvgIcon>
@@ -45,6 +39,7 @@
 </template>
 
 <script setup>
+import { get } from 'lodash-es'
 import { ref, watch, onMounted, getCurrentInstance, computed } from 'vue'
 import { useRoute, useRouter } from 'vue-router'
 import defaultSettings from '@/settings'
@@ -52,7 +47,9 @@ import { storeToRefs } from 'pinia'
 import { resolve } from 'path-browserify'
 import { translateRouteTitle } from '@/utils/i18n'
 import { useTagsViewStore } from '@/store'
-
+import { UserStore } from '@/store/user'
+const userStore = UserStore()
+const menus = computed(() => userStore.menus)
 const { proxy } = getCurrentInstance()
 const router = useRouter()
 const route = useRoute()
@@ -123,25 +120,27 @@ function filterAffixTags(routes, basePath = '/') {
 }
 
 function initTags() {
-  const tags = filterAffixTags([])
-  affixTags.value = tags
-  for (const tag of tags) {
-    // Must have tag name
-    if (tag.name) {
-      tagsViewStore.addVisitedView(tag)
-    }
-  }
+  // const tags = filterAffixTags([])
+  // affixTags.value = tags
+  // for (const tag of tags) {
+  //   // Must have tag name
+  //   if (tag.name) {
+  //     tagsViewStore.addVisitedView(tag)
+  //   }
+  // }
 }
 
 function addTags() {
-  if (route.meta.title) {
+  const nowPath = route.path
+  const menu = menus.value.find((f) => f.path === nowPath)
+  if (menu) {
     tagsViewStore.addView({
-      name: route.name,
-      title: t(route.meta.title),
-      path: route.path,
-      fullPath: route.fullPath,
-      affix: route.meta?.affix,
-      keepAlive: route.meta?.keepAlive
+      name: get(menu, 'route_name'),
+      title: get(menu, 'name'),
+      path: get(menu, 'path'),
+      fullPath: get(menu, 'path'),
+      affix: true,
+      keepAlive: true
     })
   }
 }

+ 47 - 0
src/layout/parts/header/message.vue

@@ -0,0 +1,47 @@
+<template>
+  <el-badge :value="notReadNum">
+    <el-icon><Bell /></el-icon>
+  </el-badge>
+</template>
+
+<script setup>
+import { MessageStore } from '@/store/api/system/message'
+import { UserStore } from '@/store/user'
+import { get } from 'lodash-es'
+import { initClient } from '@/utils/stomp'
+const userStore = UserStore()
+const user = computed(() => userStore.user)
+const messageStore = MessageStore()
+const $checkRes = inject('$checkRes')
+const mqClient = ref()
+
+const notReadNum = ref(0)
+
+// 请求
+onMounted(async () => {
+  searchMessage()
+})
+
+
+const toSubscribe = () => {
+  const userid = get(user, 'value.id')
+  const subscribes = { [`/exchange/systemEx/${userid}`]: dealMsg }
+  mqClient.value = initClient(subscribes)
+}
+const dealMsg = (data) => {
+  console.log(data)
+  searchMessage()
+}
+const searchMessage = async () => {
+  // 没有用户id就不查了
+  if (!get(user, 'value.id')) return
+  // 只要1个数据,主要是要总数
+  const res = await messageStore.checkNotRead()
+  if ($checkRes(res)) {
+    const nrn = get(res, 'data', 0)
+    notReadNum.value = nrn
+  }
+  toSubscribe()
+}
+</script>
+<style scoped></style>

+ 2 - 0
src/router/index.js

@@ -9,6 +9,7 @@ import { routes as log_routes } from './modules/log'
 import { routes as message_routes } from './modules/message'
 import { routes as journal_routes } from './modules/journal'
 import { routes as center_routes } from './modules/center'
+import { routes as exam_routes } from './modules/exam'
 export const homeIndex = () => import('@/views/home/index.vue')
 export const Layout = () => import('@/layout/index.vue')
 
@@ -72,6 +73,7 @@ export const constantRoutes = [
       ...message_routes,
       ...journal_routes,
       ...center_routes,
+      ...exam_routes,
     ]
   }
 ]

+ 14 - 0
src/router/modules/exam.js

@@ -0,0 +1,14 @@
+import i18n from '@/lang'
+export const routes = [
+  {
+    path: '/exam',
+    name: 'exam_index',
+    meta: {
+      title: i18n.global.t('menus.exam'),
+      affix: true,
+      keepAlive: true,
+      alwaysShow: false
+    },
+    component: () => import('@/views/exam/index.vue')
+  }
+]

+ 16 - 1
src/store/api/system/message.js

@@ -34,12 +34,27 @@ export const MessageStore = defineStore('message', () => {
     const res = await axios.$post(`${url}/remind/${payload}`)
     return res
   }
+  const checkNotRead = async (payload) => {
+    const res = await axios.$get(`${url}/adminCheckNotRead`)
+    return res
+  }
+  /**
+   * 全部已读
+   * @param {number} payload 管理员id
+   * @returns
+   */
+  const read = async (payload) => {
+    const res = await axios.$get(`${url}/adminRead/${payload}`)
+    return res
+  }
   return {
     query,
     fetch,
     create,
     update,
     del,
-    remind
+    remind,
+    checkNotRead,
+    read
   }
 })

+ 1 - 1
src/store/modules/tagsView.js

@@ -1,5 +1,5 @@
 export const useTagsViewStore = defineStore('tagsView', () => {
-  const visitedViews = ref([{ affix: true, fullPath: '/', keepAlive: true, name: 'home', path: '/', title: 'home' }])
+  const visitedViews = ref([{ affix: true, fullPath: '/', keepAlive: true, name: 'home', path: '/', title: '首页' }])
   const cachedViews = ref([])
 
   /**

+ 8 - 0
src/views/exam/index.vue

@@ -0,0 +1,8 @@
+<template>
+  <div id="index">
+    <p>index</p>
+  </div>
+</template>
+
+<script setup></script>
+<style scoped></style>