소스 검색

在菜单上添加“知识更新管理”

yangdr 1 개월 전
부모
커밋
1790a5bea1
5개의 변경된 파일51개의 추가작업 그리고 11개의 파일을 삭제
  1. 4 4
      package-lock.json
  2. 1 1
      package.json
  3. 36 4
      src/components/LayoutHeader.vue
  4. 2 0
      src/dialogs/OCRDialog.vue
  5. 8 2
      src/views/Login/Login.vue

+ 4 - 4
package-lock.json

@@ -18,7 +18,7 @@
         "axios": "^1.8.4",
         "crypto-js": "^4.2.0",
         "date-fns": "^4.1.0",
-        "element-plus": "^2.9.6",
+        "element-plus": "^2.9.8",
         "file-saver": "^2.0.5",
         "github-markdown-css": "^5.8.1",
         "highlight.js": "^11.11.1",
@@ -3353,9 +3353,9 @@
       "license": "ISC"
     },
     "node_modules/element-plus": {
-      "version": "2.9.6",
-      "resolved": "https://registry.npmjs.org/element-plus/-/element-plus-2.9.6.tgz",
-      "integrity": "sha512-D9zU28Ce0s/9O/Vp3ewemikxzFVA6gdZyMwmWijHijo+t5/9H3sHRTIm1WlfeNpFW2Yq0y8nHXD0fU5YxU6qlQ==",
+      "version": "2.9.8",
+      "resolved": "https://mirrors.huaweicloud.com/repository/npm/element-plus/-/element-plus-2.9.8.tgz",
+      "integrity": "sha512-srViUaUdfblBKGMeuEPiXxxKlH5aUmKqEwmhb/At9Sj91DbU6od/jYN1955cTnzt3wTSA7GfnZF7UiRX9sdRHg==",
       "license": "MIT",
       "dependencies": {
         "@ctrl/tinycolor": "^3.4.1",

+ 1 - 1
package.json

@@ -22,7 +22,7 @@
     "axios": "^1.8.4",
     "crypto-js": "^4.2.0",
     "date-fns": "^4.1.0",
-    "element-plus": "^2.9.6",
+    "element-plus": "^2.9.8",
     "file-saver": "^2.0.5",
     "github-markdown-css": "^5.8.1",
     "highlight.js": "^11.11.1",

+ 36 - 4
src/components/LayoutHeader.vue

@@ -5,8 +5,9 @@
       <span class="knowledge-graph-icon" @click="router.push({ path: '/home' })"></span>
     </div> -->
     <div class="menu">
-      <el-menu :default-active="currentPath" class="el-menu-demo" mode="horizontal" router>
-        <el-menu-item :index="item.path" v-for="item in routeList" :key="item.name">{{ item.title }}</el-menu-item>
+      <el-menu :default-active="currentPath" ref="menuRef" class="el-menu-demo" mode="horizontal">
+        <el-menu-item :index="item.path" v-for="item in routeList" :key="item.name"
+          @click="handleMenuClick(item.path)">{{ item.title }}</el-menu-item>
       </el-menu>
     </div>
     <div style="align-self: center;">
@@ -26,14 +27,16 @@
 </template>
 
 <script setup>
-import { ref } from 'vue'
-import { computed } from "vue";
+import { ref, computed, onMounted, onBeforeUnmount } from 'vue'
 import { useMenuStore } from "@/stores/menu.js"
 import { useRoute, useRouter } from "vue-router";
 import { getSessionVar, clearSessionVar } from '@/utils/session'
 import EditPasswordDialog from "@/components/EditPasswordDialog.vue"
 const route = useRoute()
 const router = useRouter()
+let timer
+
+const menuRef = ref()
 // console.log('route', route)
 const { routeList } = useMenuStore()
 const user = ref({
@@ -66,6 +69,35 @@ const handleLogout = () => {
   clearSessionVar()
 }
 
+
+function handleMenuClick(path) {
+  if (/^https?/g.test(path)) {
+    // path = 'http://localhost:8081/home.html'
+    const newWindow = window.open(path, '_blank');
+    timer = setInterval(() => {
+      newWindow?.postMessage({ type: 'login', username: getSessionVar("full_name") }, "*")
+    }, 1000)
+    menuRef.value.updateActiveIndex(currentPath.value)
+  } else {
+    router.push({ path: path })
+  }
+}
+function handleLogin(event) {
+  const { type, status } = event.data
+  if (type === 'login' && status === 'ok') {
+    // alert('登录成功')
+    clearInterval(timer)
+  }
+}
+onMounted(() => {
+  window.addEventListener('message', handleLogin);
+})
+
+onBeforeUnmount(() => {
+  window.removeEventListener('message', handleLogin);
+  clearInterval(timer)
+})
+
 // console.log(menu.menu)
 </script>
 

+ 2 - 0
src/dialogs/OCRDialog.vue

@@ -295,6 +295,7 @@ function fetchFile(fileName: string, fileUrl: string) {
 function handleSelectedImport() {
   const SelectionRows = KBTableRef.value.getSelectionRows()
   handleImportFiles(toRaw(SelectionRows))
+  KBTableRef.value.clearSelection()
   // console.log(SelectionRows)
 }
 // 使用原生方法计算文件的hash值,该方法兼容性较差
@@ -341,6 +342,7 @@ function handleImportFiles(filesList: any[]) {
     // if (i > 0) break;
     fetchFile(filesList[i].file_name, filesList[i].minio_url)
   }
+  knowledgeBase.value.visible = false
 }
 
 /**

+ 8 - 2
src/views/Login/Login.vue

@@ -60,6 +60,7 @@
 import { onMounted, ref, watch, watchEffect } from "vue";
 import { useRouter, useRoute } from "vue-router";
 import { userLogin, userSignin } from "@/api/AgentApi";
+import { knowledgeGraphAddr } from "@/utils/config"
 import {
   deleteSessionVar,
   getSessionVar,
@@ -220,8 +221,13 @@ const handleLoginSubmit = () => {
     res.records[0].menu_permissions.forEach((item: any) => {
       if (item.menu_name == "知识更新管理") {
         knowledageSystem = 'true';
-      }
-      if (item.menu_route) {
+        routeList.push({
+          path: knowledgeGraphAddr,
+          name: '',
+          title: item.name,
+          children: item.children,
+        });
+      } else if (item.menu_route) {
         routeList.push({
           path: item.menu_route,
           name: item.menu_route.split("/")[2],