Bladeren bron

完善权限

yangdr 4 weken geleden
bovenliggende
commit
a493bf5245

+ 2 - 2
.env.development

@@ -1,4 +1,4 @@
 NODE_ENV = development
-# VITE_API_URL = http://173.18.12.205:8005
-VITE_API_URL = http://192.18.1.242:8000
+VITE_API_URL = http://173.18.12.205:8005
+# VITE_API_URL = http://192.18.1.242:8000
 # VITE_API_URL = http://192.18.1.235:8000

+ 3 - 0
src/components/LayoutHeader.vue

@@ -169,6 +169,9 @@ function handleLogin(event) {
 onMounted(() => {
   window.addEventListener('message', handleLogin);
   fetchOrgList()
+  if (route.name === 'kmplatform') {
+    router.push({ path: routeList[0].path })
+  }
 })
 
 onBeforeUnmount(() => {

+ 36 - 19
src/dialogs/OCRDialog.vue

@@ -1,5 +1,5 @@
 <template>
-  <el-dialog :title="title" v-model="dialogFormVisible" @closed="handleClosed">
+  <el-dialog :title="title" v-model="dialogFormVisible" width="800" @closed="handleClosed">
     <el-form :model="form" ref="formRef">
       <el-form-item label="任务名称" prop="name" :label-width="formLabelWidth" required>
         <el-input v-model="form.name" autocomplete="off"></el-input>
@@ -53,14 +53,22 @@
         <div class="knowledge-base-detail">
           <div class="management-content">
             <div class="management-content-top">
-              <span class="search">
-                <el-input v-model="knowledgeBase.querySearch" size="large" placeholder="搜索"
-                  @keydown.enter="debounceGetKBfileList" :prefix-icon="Search" />
-              </span>
-              <span class="add-file" :disabled="knowledgeBase.selectedNum > 0 ? 'false' : 'true'"
-                @click="handleSelectedImport">
-                <span class="text">批量导入</span>
-              </span>
+              <div class="left">
+                <span class="search">
+                  <el-input v-model="knowledgeBase.querySearch" size="large" placeholder="搜索"
+                    @keydown.enter="debounceGetKBfileList" :prefix-icon="Search" />
+                </span>
+              </div>
+              <div class="right">
+                <span class="add-file" @click="handleAllImport">
+                  <span class="text">全部导入</span>
+                </span>
+                <span class="add-file" :disabled="knowledgeBase.selectedNum > 0 ? 'false' : 'true'"
+                  @click="handleSelectedImport">
+                  <span class="text">批量导入</span>
+                </span>
+              </div>
+
             </div>
             <el-scrollbar class="management-content-middle">
               <el-table :data="knowledgeBase.filesList" ref="KBTableRef" @selection-change="handleSelectionChange">
@@ -269,6 +277,11 @@ function handleGetKnowledgeBase() {
     console.log(e)
   })
 }
+
+function handleAllImport() {
+
+}
+
 function fetchFile(fileName: string, fileUrl: string) {
   axios.get(fileUrl, { responseType: 'blob' })
     .then(async response => {
@@ -573,7 +586,7 @@ footer {
     width: 10px;
     height: 10px;
     background-color: #F5F5F5;
-    // display: none;
+    display: none;
   }
 
   /*定义滚动条轨道
@@ -592,6 +605,11 @@ footer {
     background-color: #DDDEE0;
   }
 
+  &:hover {
+    &::-webkit-scrollbar {
+      display: block;
+    }
+  }
 }
 
 .knowledge-base {
@@ -725,25 +743,24 @@ footer {
     .management-content-top {
       clear: both;
       flex: 0 0 auto;
-      position: relative;
+      display: flex;
+
+      .right {
+        margin-left: auto;
+      }
+
+      .left {}
 
       .add-file {
-        position: absolute;
-        right: 10px;
-        bottom: 0px;
-        transform: translateY(-25%);
         color: white;
-        // width: 100px;
         background-color: #169BD5;
         margin-left: auto;
         padding: 10px 25px;
         border-radius: 3px;
         display: inline-block;
         cursor: pointer;
-        // float: right;
-        // display: flex;
+        margin-right: 10px;
 
-        // .el-icon,
         .text {
           // vertical-align: middle;
           // margin-left: 10px;

+ 4 - 3
src/main.ts

@@ -1,10 +1,10 @@
 import '@/assets/css/main.css'
 import "@/assets/css/common.less"
 import 'animate.css';
-
+import 'element-plus/dist/index.css'
 import { createApp } from 'vue'
 import ElementPlus from 'element-plus'
-import 'element-plus/dist/index.css'
+
 import * as ElementPlusIconsVue from '@element-plus/icons-vue'
 import { createPinia } from 'pinia'
 import App from './App.vue'
@@ -16,8 +16,9 @@ const app = createApp(App)
 for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
   app.component(key, component)
 }
+app.config.globalProperties.$http = http
 app.use(createPinia())
 app.use(router)
 app.use(ElementPlus)
-app.config.globalProperties.$http = http
+
 app.mount('#app')

+ 56 - 15
src/router/index.ts

@@ -23,26 +23,33 @@ const router = createRouter({
     {
       path: "/",
       redirect: "/kmplatform/home",
+      meta: {
+        auth: false,
+      }
     },
     {
       path: "/login",
       name: "login",
       component: Login,
       meta: {
-
+        auth: false,
       }
     },
     {
       path: "/kmplatform",
       name: "kmplatform",
       component: Layout,
-      redirect: "/kmplatform/home",
+      // redirect: "/kmplatform/home",
+      meta: {
+        auth: false,
+      },
       children: [
         {
           path: "home",
           name: "kmplatform-home",
           meta: {
             title: "主页",
+            auth: true,
           },
           component: Home,
           children: [],
@@ -53,6 +60,7 @@ const router = createRouter({
           meta: {
             title: "知识库",
             keepAlive: true,
+            auth: true,
           },
           component: KnowledgeBase,
           redirect: "/kmplatform/knowledgebase/kbm",
@@ -63,6 +71,7 @@ const router = createRouter({
               meta: {
                 title: "知识库",
                 keepAlive: true,
+                auth: true,
               },
               component: KnowledgeBaseManagement,
             },
@@ -72,6 +81,7 @@ const router = createRouter({
               meta: {
                 title: "知识库",
                 keepAlive: false,
+                auth: true,
               },
               component: KnowledgeManagement,
             },
@@ -82,6 +92,7 @@ const router = createRouter({
           name: "kgbuilder",
           meta: {
             title: "知识图谱构建",
+            auth: true,
           },
           redirect: "/kmplatform/kgbuilder/home",
           component: AppCopy,
@@ -90,6 +101,9 @@ const router = createRouter({
               path: "home",
               name: "home",
               component: HomeView,
+              meta: {
+                auth: true,
+              },
             },
             {
               path: "workspace",
@@ -100,21 +114,33 @@ const router = createRouter({
                   path: "queue/:id",
                   name: "queue",
                   component: () => import("@/views/QueueView.vue"),
+                  meta: {
+                    auth: true,
+                  },
                 },
                 {
                   path: "worker",
                   name: "worker",
                   component: () => import("@/views/WorkerView.vue"),
+                  meta: {
+                    auth: true,
+                  },
                 },
                 {
                   path: "graph",
                   name: "graph",
                   component: () => import("@/views/GraphView.vue"),
+                  meta: {
+                    auth: true,
+                  },
                 },
                 {
                   path: "graph-mgr/:id",
                   name: "graph-mgr",
                   component: () => import("@/views/GraphManagement.vue"),
+                  meta: {
+                    auth: true,
+                  },
                 },
               ],
             },
@@ -122,6 +148,9 @@ const router = createRouter({
               path: "about",
               name: "about",
               component: () => import("@/views/AboutView.vue"),
+              meta: {
+                auth: true,
+              },
             },
           ]
         },
@@ -131,14 +160,19 @@ const router = createRouter({
           redirect: "/kmplatform/openplatform/queue/0",
           meta: {
             title: "开放平台",
+            auth: false,
+
           },
           component: OpenPlatform,
           children: [
-             {
-                  path: "queue/:id",
-                  name: "platformText",
-                  component: () => import("@/views/KMPlatform/OpenPlatform/platformText.vue"),
-                },
+            {
+              path: "queue/:id",
+              name: "platformText",
+              component: () => import("@/views/KMPlatform/OpenPlatform/platformText.vue"),
+              meta: {
+                auth: false,
+              },
+            },
           ],
         },
         {
@@ -146,6 +180,7 @@ const router = createRouter({
           name: "kgpermission",
           meta: {
             title: "系统权限",
+            auth: true,
           },
           redirect: "/kmplatform/kgpermission/AccountManage",
           component: PermissionManage,
@@ -155,6 +190,7 @@ const router = createRouter({
               name: "kgb-RoleManage",
               meta: {
                 title: "角色管理",
+                auth: true,
               },
               component: RoleManage,
             },
@@ -163,6 +199,7 @@ const router = createRouter({
               name: "kgb-AccountManage",
               meta: {
                 title: "账号管理",
+                auth: true,
               },
               component: AccountManage,
             },
@@ -171,6 +208,7 @@ const router = createRouter({
               name: "kgb-Organizational",
               meta: {
                 title: "账号管理",
+                auth: true,
               },
               component: () => import("@/views/KMPlatform/Permission/Organizational.vue"),
             },
@@ -181,18 +219,21 @@ const router = createRouter({
   ],
 });
 
-router.beforeEach((to, from, next) => {
-  if (
-    getSessionVar("session_id") == null &&
+function isLogin() {
+  return getSessionVar("session_id") == null &&
     getSessionVar("username") == null
-  ) {
-    if (to.name !== "login") {
-      next({ name: "login" }); // 重定向到登录页面
+}
+
+router.beforeEach((to, from, next) => {
+  if (isLogin()) {
+    // console.log("a,", to.meta && to.name !== 'login')
+    if (to.meta.auth && to.name !== 'login') {
+      next({ name: 'login' });
     } else {
-      next(); // 确认转移
+      next()
     }
   } else {
-    next(); // 确认转移
+    next()
   }
 });
 

+ 37 - 31
src/stores/menu.js

@@ -7,37 +7,43 @@ import {
 } from "@/utils/session";
 
 export const useMenuStore = defineStore('menu', () => {
-  let routeList = ref(getSessionVar("routeList") ? JSON.parse(getSessionVar("routeList")) : [])
-  //   const routeList = ref([{
-  //     path: '/kmplatform/home',
-  //     name: 'kmplatform-home',
-  //     title: "主页",
-  //     children: []
-  //   },
-  //   {
-  //     path: '/kmplatform/knowledgebase',
-  //     name: 'knowledgebase',
-  //     title: "知识库",
-  //     children: []
-  //   },
-  //   {
-  //     path: '/kmplatform/kgbuilder',
-  //     name: 'kgbuilder',
-  //     title: "知识图谱构建",
-  //     children: []
-  //   },
-  //   {
-  //     path: '/kmplatform/openplatform',
-  //     name: 'openplatform',
-  //     title: "开放平台",
-  //     children: []
-  //   },
-  //   {
-  //     path: '/kmplatform/kgpermission',
-  //     name: 'kgpermission',
-  //     title: "系统权限",
-  //     children: []
-  //   }
+  let routeList = ref(getSessionVar("routeList") ? JSON.parse(getSessionVar("routeList")) : [{
+    path: '/kmplatform/openplatform',
+    name: 'openplatform',
+    title: "开放平台",
+    children: []
+  }])
+
+  // const routeList = ref([{
+  //   path: '/kmplatform/home',
+  //   name: 'kmplatform-home',
+  //   title: "主页",
+  //   children: []
+  // },
+  // {
+  //   path: '/kmplatform/knowledgebase',
+  //   name: 'knowledgebase',
+  //   title: "知识库",
+  //   children: []
+  // },
+  // {
+  //   path: '/kmplatform/kgbuilder',
+  //   name: 'kgbuilder',
+  //   title: "知识图谱构建",
+  //   children: []
+  // },
+  // {
+  //   path: '/kmplatform/openplatform',
+  //   name: 'openplatform',
+  //   title: "开放平台",
+  //   children: []
+  // },
+  // {
+  //   path: '/kmplatform/kgpermission',
+  //   name: 'kgpermission',
+  //   title: "系统权限",
+  //   children: []
+  // }
   // ])
   const operationPermissions = computed(() => {
     let permissions = {}

+ 6 - 4
src/views/KMPlatform/KnowledgeBase/KBM/KnowledgeBaseManagement.vue

@@ -587,15 +587,17 @@ onMounted(() => {
 
       .list-arrange-top {
         clear: both;
-        min-height: 50px;
+        // min-height: 50px;
         background-color: #fff;
-        padding: 10px 20px;
+        // padding: 10px 20px;
         box-sizing: border-box;
+        text-align: right;
 
         .create-kb {
-          margin-left: auto;
+
+          margin: 5px 0px;
           display: inline-block;
-          float: right;
+          // float: right;
           border: none;
           padding: 8px 15px;
           border-radius: 5px;

+ 6 - 2
src/views/KMPlatform/KnowledgeBase/KM/KnowledgeManagement.vue

@@ -51,9 +51,13 @@
             <el-table-column prop="version" label="版本" />
             <el-table-column prop="author" label="作者(主编)" min-width="90" />
             <el-table-column prop="year" label="年份" min-width="60" />
-            <el-table-column prop="creator" label="上传人" />
+            <el-table-column prop="creator" label="上传人">
+              <template #default="{ row }">
+                <el-text line-clamp="1" style="vertical-align: bottom;">{{ row.creator }}</el-text>
+              </template>
+            </el-table-column>
             <el-table-column prop="created_at" label="上传时间" width="155" />
-            <el-table-column prop="" label="状态">
+            <el-table-column prop="status" label="状态">
               <template #default="{ row, $index }">
                 <div class="status">
                   <span v-if="row.status">

+ 26 - 2
src/views/KMPlatform/OpenPlatform/platformText.vue

@@ -111,7 +111,7 @@
         </div>
       </template>
       <p>接口描述:根据指定的源节点ID,获取与其关联的所有关系及目标节点信息。</p>
-      <p class="mx-10">请求方式:GET</p>
+      <p class="mx-10">请求方式:POST</p>
       <p>请求地址:/v1/knowledge/nodes/{srcId}/relationships</p>
 
       <h3>路径参数</h3>
@@ -121,7 +121,19 @@
         <el-table-column prop="required" label="必填" />
         <el-table-column prop="description" label="说明" />
       </el-table>
+      <h3>请求参数 (Request Body - JSON)</h3>
+      <el-table :data="requestParams2" border style="width: 100%">
+        <el-table-column prop="fieldName" label="字段名" />
+        <el-table-column prop="name" label="名称" />
+        <el-table-column prop="type" label="类型" />
+        <el-table-column prop="required" label="必填" />
+        <el-table-column prop="description" label="描述" />
+        <el-table-column prop="defaultValue" label="默认值" />
+      </el-table>
 
+      <h3>请求示例</h3>
+      <!-- <pre><code>{{ requestExample }}</code></pre> -->
+      <pre><code v-html="highlightHtml(requestExample2, 'json')"></code></pre>
       <h3>响应结构 (Response - JSON)</h3>
       <!-- <h4>顶层字段</h4> -->
       <el-table :data="topLevelResponseParams" border style="width: 100%">
@@ -235,6 +247,10 @@ const requestParams = ref([
   { fieldName: 'limit', name: '每页记录数', type: 'int', required: '否', description: '指定每页返回的最大实体数量。', defaultValue: '系统默认' }
 ]);
 
+const requestParams2 = ref([
+  { fieldName: 'relation_name', name: '关系名称', type: 'string', required: '否', description: '(可选)按关系名称过滤结果。', defaultValue: '无' },
+]);
+
 // 请求示例
 const requestExample = ref(`{
     "name": "感冒",
@@ -242,6 +258,10 @@ const requestExample = ref(`{
     "limit": 10
 }`);
 
+const requestExample2 = ref(`
+{
+  "relation_name": "所属科室"
+}`);
 // 响应参数
 const responseParams = ref([
   { fieldName: 'success', name: '请求状态', type: 'Boolean', description: 'true 表示请求成功处理;false 表示发生错误。' },
@@ -296,7 +316,11 @@ const responseExample = ref(`{
 }`);
 // 路径参数
 const pathParams = ref([
-  { paramName: 'srcId', type: 'string', required: '是', description: '源节点的唯一标识符' }
+  { paramName: 'srcId', type: 'string', required: '是', description: '源节点的唯一标识符' },
+  // { paramName: 'category', name: '节点类型', type: 'string', required: '否', description: '(可选)按节点类型过滤结果。', defaultValue: '无' },
+  // { paramName: 'distance', name: '相似度阈值', type: 'Float', required: '否', description: '向量计算的距离阈值。仅返回相似度小于等于此值的实体 (0=完全相等, 2=完全不相关)。值越小,匹配度要求越高。', defaultValue: '1.45' },
+  // { paramName: 'pageNo', name: '页码', type: 'int', required: '否', description: '指定要获取的结果页码(从 1 开始计数)。', defaultValue: '1' },
+  // { paramName: 'limit', name: '每页记录数', type: 'int', required: '否', description: '指定每页返回的最大实体数量。', defaultValue: '系统默认' }
 ]);
 
 // 顶层响应参数

+ 1 - 2
src/views/KMPlatform/Permission/RoleManage.vue

@@ -17,8 +17,7 @@
       <el-table-column prop="description" label="描述" width="400" align="center" />
       <el-table-column fixed="right" label="操作" align="center">
         <template #default="scope">
-          <el-button link type="primary" v-if="operationPermissions['c-1']"
-            @click="handleChange(scope.row)">编辑</el-button>
+          <el-button link type="primary" @click="handleChange(scope.row)">编辑</el-button>
         </template>
       </el-table-column>
     </el-table>

+ 0 - 1
src/views/Login/Login.vue

@@ -287,7 +287,6 @@ onMounted(() => {
   });
 });
 watchEffect(() => {
-  // 监听路由变化
   console.log("route changed", route);
   if (route.query.logout) {
     handleLogout()