@liujitcn/kratos-admin-system 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +137 -0
- package/dist/package/declarations/index.d.ts +1 -0
- package/dist/package/declarations/src/ai.d.ts +10 -0
- package/dist/package/declarations/src/api/base/ai_message.d.ts +27 -0
- package/dist/package/declarations/src/api/base/ai_session.d.ts +17 -0
- package/dist/package/declarations/src/api/base/ai_tool.d.ts +7 -0
- package/dist/package/declarations/src/api/base/oauth.d.ts +13 -0
- package/dist/package/declarations/src/api/base/sse.d.ts +31 -0
- package/dist/package/declarations/src/api/system/auth.d.ts +17 -0
- package/dist/package/declarations/src/api/system/base_api.d.ts +22 -0
- package/dist/package/declarations/src/api/system/base_area.d.ts +19 -0
- package/dist/package/declarations/src/api/system/base_config.d.ts +20 -0
- package/dist/package/declarations/src/api/system/base_dept.d.ts +21 -0
- package/dist/package/declarations/src/api/system/base_dict.d.ts +32 -0
- package/dist/package/declarations/src/api/system/base_job.d.ts +28 -0
- package/dist/package/declarations/src/api/system/base_log.d.ts +9 -0
- package/dist/package/declarations/src/api/system/base_menu.d.ts +21 -0
- package/dist/package/declarations/src/api/system/base_migration.d.ts +10 -0
- package/dist/package/declarations/src/api/system/base_post.d.ts +21 -0
- package/dist/package/declarations/src/api/system/base_role.d.ts +23 -0
- package/dist/package/declarations/src/api/system/base_tenant.d.ts +21 -0
- package/dist/package/declarations/src/api/system/base_user.d.ts +23 -0
- package/dist/package/declarations/src/api/system/code_gen.d.ts +14 -0
- package/dist/package/declarations/src/api/system/code_gen_column.d.ts +12 -0
- package/dist/package/declarations/src/api/system/code_gen_proto.d.ts +10 -0
- package/dist/package/declarations/src/api/system/code_gen_sse.d.ts +8 -0
- package/dist/package/declarations/src/api/system/code_gen_table.d.ts +18 -0
- package/dist/package/declarations/src/api/system/project_document.d.ts +9 -0
- package/dist/package/declarations/src/components/Ai.vue.d.ts +3 -0
- package/dist/package/declarations/src/index.d.ts +3 -0
- package/dist/package/declarations/src/module.d.ts +2 -0
- package/dist/package/declarations/src/rpc/base/v1/ai_message.d.ts +82 -0
- package/dist/package/declarations/src/rpc/base/v1/ai_session.d.ts +176 -0
- package/dist/package/declarations/src/rpc/base/v1/ai_tool.d.ts +59 -0
- package/dist/package/declarations/src/rpc/base/v1/oauth.d.ts +167 -0
- package/dist/package/declarations/src/rpc/base/v1/sse.d.ts +13 -0
- package/dist/package/declarations/src/rpc/common/v1/common.d.ts +57 -0
- package/dist/package/declarations/src/rpc/common/v1/enum.d.ts +58 -0
- package/dist/package/declarations/src/rpc/common/v1/types.d.ts +60 -0
- package/dist/package/declarations/src/rpc/google/protobuf/empty.d.ts +11 -0
- package/dist/package/declarations/src/rpc/google/protobuf/timestamp.d.ts +107 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/auth.d.ts +156 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_api.d.ts +193 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_area.d.ts +82 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_config.d.ts +112 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_dept.d.ts +112 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_dict.d.ts +215 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_job.d.ts +177 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_log.d.ts +87 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_menu.d.ts +151 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_migration.d.ts +64 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_post.d.ts +112 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_role.d.ts +128 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_tenant.d.ts +112 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_user.d.ts +161 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/code_gen.d.ts +155 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/code_gen_column.d.ts +143 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/code_gen_proto.d.ts +86 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/code_gen_table.d.ts +149 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/project_document.d.ts +64 -0
- package/dist/package/declarations/src/rpc/system/common/v1/enum.d.ts +67 -0
- package/dist/package/declarations/src/views/ai/chat/attachment.d.ts +14 -0
- package/dist/package/declarations/src/views/ai/chat/components/AiMarkdown.vue.d.ts +13 -0
- package/dist/package/declarations/src/views/ai/chat/components/ChatPanel.vue.d.ts +45 -0
- package/dist/package/declarations/src/views/ai/chat/components/SessionPanel.vue.d.ts +34 -0
- package/dist/package/declarations/src/views/ai/chat/components/XSender.vue.d.ts +12 -0
- package/dist/package/declarations/src/views/ai/chat/index.vue.d.ts +4 -0
- package/dist/package/declarations/src/views/ai/chat/message.d.ts +59 -0
- package/dist/package/declarations/src/views/ai/chat/stream.d.ts +10 -0
- package/dist/package/declarations/src/views/ai/chat/types.d.ts +115 -0
- package/dist/package/declarations/src/views/base/api/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/area/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/config/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/dept/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/dict/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/dict/item.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/job/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/job/log.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/log/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/menu/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/migration/index.vue.d.ts +4 -0
- package/dist/package/declarations/src/views/base/post/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/role/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/tenant/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/user/components/dept-tree.vue.d.ts +19 -0
- package/dist/package/declarations/src/views/base/user/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/profile/components/base.vue.d.ts +13 -0
- package/dist/package/declarations/src/views/profile/components/password.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/profile/components/security.vue.d.ts +15 -0
- package/dist/package/declarations/src/views/profile/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/tool/api-doc/index.vue.d.ts +4 -0
- package/dist/package/declarations/src/views/tool/code-gen/code-preview/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/tool/code-gen/columns/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/tool/code-gen/columns/option-copy.d.ts +25 -0
- package/dist/package/declarations/src/views/tool/code-gen/components/CodeGenProgressDialog.vue.d.ts +16 -0
- package/dist/package/declarations/src/views/tool/code-gen/components/CodePreviewPane.vue.d.ts +9 -0
- package/dist/package/declarations/src/views/tool/code-gen/config.d.ts +32 -0
- package/dist/package/declarations/src/views/tool/code-gen/preview/capabilities.d.ts +20 -0
- package/dist/package/declarations/src/views/tool/code-gen/preview/data.d.ts +42 -0
- package/dist/package/declarations/src/views/tool/code-gen/preview/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/tool/code-gen/proto/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/tool/code-gen/table/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/tool/project-doc/index.vue.d.ts +4 -0
- package/dist/package/src/ai.ts +16 -0
- package/dist/package/src/api/base/ai_message.ts +139 -0
- package/dist/package/src/api/base/ai_session.ts +77 -0
- package/dist/package/src/api/base/ai_tool.ts +22 -0
- package/dist/package/src/api/base/oauth.ts +47 -0
- package/dist/package/src/api/base/sse.ts +192 -0
- package/dist/package/src/api/system/auth.ts +65 -0
- package/dist/package/src/api/system/base_api.ts +95 -0
- package/dist/package/src/api/system/base_area.ts +73 -0
- package/dist/package/src/api/system/base_config.ts +82 -0
- package/dist/package/src/api/system/base_dept.ts +83 -0
- package/dist/package/src/api/system/base_dict.ts +144 -0
- package/dist/package/src/api/system/base_job.ts +125 -0
- package/dist/package/src/api/system/base_log.ts +32 -0
- package/dist/package/src/api/system/base_menu.ts +83 -0
- package/dist/package/src/api/system/base_migration.ts +35 -0
- package/dist/package/src/api/system/base_post.ts +83 -0
- package/dist/package/src/api/system/base_role.ts +93 -0
- package/dist/package/src/api/system/base_tenant.ts +83 -0
- package/dist/package/src/api/system/base_user.ts +93 -0
- package/dist/package/src/api/system/code_gen.ts +56 -0
- package/dist/package/src/api/system/code_gen_column.ts +43 -0
- package/dist/package/src/api/system/code_gen_proto.ts +32 -0
- package/dist/package/src/api/system/code_gen_sse.ts +33 -0
- package/dist/package/src/api/system/code_gen_table.ts +74 -0
- package/dist/package/src/api/system/project_document.ts +33 -0
- package/dist/package/src/components/Ai.vue +57 -0
- package/dist/package/src/index.ts +3 -0
- package/dist/package/src/module.ts +17 -0
- package/dist/package/src/rpc/base/v1/ai_message.ts +98 -0
- package/dist/package/src/rpc/base/v1/ai_session.ts +214 -0
- package/dist/package/src/rpc/base/v1/ai_tool.ts +74 -0
- package/dist/package/src/rpc/base/v1/oauth.ts +199 -0
- package/dist/package/src/rpc/base/v1/sse.ts +22 -0
- package/dist/package/src/rpc/common/v1/common.ts +71 -0
- package/dist/package/src/rpc/common/v1/enum.ts +71 -0
- package/dist/package/src/rpc/common/v1/types.ts +77 -0
- package/dist/package/src/rpc/google/protobuf/empty.ts +19 -0
- package/dist/package/src/rpc/google/protobuf/timestamp.ts +115 -0
- package/dist/package/src/rpc/system/admin/v1/auth.ts +208 -0
- package/dist/package/src/rpc/system/admin/v1/base_api.ts +241 -0
- package/dist/package/src/rpc/system/admin/v1/base_area.ts +105 -0
- package/dist/package/src/rpc/system/admin/v1/base_config.ts +140 -0
- package/dist/package/src/rpc/system/admin/v1/base_dept.ts +140 -0
- package/dist/package/src/rpc/system/admin/v1/base_dict.ts +249 -0
- package/dist/package/src/rpc/system/admin/v1/base_job.ts +206 -0
- package/dist/package/src/rpc/system/admin/v1/base_log.ts +101 -0
- package/dist/package/src/rpc/system/admin/v1/base_menu.ts +195 -0
- package/dist/package/src/rpc/system/admin/v1/base_migration.ts +81 -0
- package/dist/package/src/rpc/system/admin/v1/base_post.ts +134 -0
- package/dist/package/src/rpc/system/admin/v1/base_role.ts +151 -0
- package/dist/package/src/rpc/system/admin/v1/base_tenant.ts +134 -0
- package/dist/package/src/rpc/system/admin/v1/base_user.ts +190 -0
- package/dist/package/src/rpc/system/admin/v1/code_gen.ts +176 -0
- package/dist/package/src/rpc/system/admin/v1/code_gen_column.ts +170 -0
- package/dist/package/src/rpc/system/admin/v1/code_gen_proto.ts +104 -0
- package/dist/package/src/rpc/system/admin/v1/code_gen_table.ts +179 -0
- package/dist/package/src/rpc/system/admin/v1/project_document.ts +79 -0
- package/dist/package/src/rpc/system/common/v1/enum.ts +80 -0
- package/dist/package/src/typings/swagger-ui-dist.d.ts +28 -0
- package/dist/package/src/typings/x-markdown-vue.d.ts +1 -0
- package/dist/package/src/views/ai/chat/attachment.ts +65 -0
- package/dist/package/src/views/ai/chat/components/AiMarkdown.vue +162 -0
- package/dist/package/src/views/ai/chat/components/ChatPanel.vue +1861 -0
- package/dist/package/src/views/ai/chat/components/SessionPanel.vue +316 -0
- package/dist/package/src/views/ai/chat/components/XSender.vue +554 -0
- package/dist/package/src/views/ai/chat/index.vue +848 -0
- package/dist/package/src/views/ai/chat/message.ts +416 -0
- package/dist/package/src/views/ai/chat/stream.ts +115 -0
- package/dist/package/src/views/ai/chat/types.ts +126 -0
- package/dist/package/src/views/base/api/index.vue +455 -0
- package/dist/package/src/views/base/area/index.vue +269 -0
- package/dist/package/src/views/base/config/index.vue +530 -0
- package/dist/package/src/views/base/dept/index.vue +461 -0
- package/dist/package/src/views/base/dict/index.vue +304 -0
- package/dist/package/src/views/base/dict/item.vue +373 -0
- package/dist/package/src/views/base/job/index.vue +535 -0
- package/dist/package/src/views/base/job/log.vue +202 -0
- package/dist/package/src/views/base/log/index.vue +317 -0
- package/dist/package/src/views/base/menu/index.vue +944 -0
- package/dist/package/src/views/base/migration/index.vue +791 -0
- package/dist/package/src/views/base/post/index.vue +324 -0
- package/dist/package/src/views/base/role/index.vue +684 -0
- package/dist/package/src/views/base/tenant/index.vue +328 -0
- package/dist/package/src/views/base/user/components/dept-tree.vue +75 -0
- package/dist/package/src/views/base/user/index.vue +783 -0
- package/dist/package/src/views/profile/components/base.vue +320 -0
- package/dist/package/src/views/profile/components/password.vue +269 -0
- package/dist/package/src/views/profile/components/security.vue +443 -0
- package/dist/package/src/views/profile/index.vue +199 -0
- package/dist/package/src/views/tool/api-doc/index.vue +275 -0
- package/dist/package/src/views/tool/code-gen/code-preview/index.vue +233 -0
- package/dist/package/src/views/tool/code-gen/columns/index.vue +1456 -0
- package/dist/package/src/views/tool/code-gen/columns/option-copy.ts +125 -0
- package/dist/package/src/views/tool/code-gen/components/CodeGenProgressDialog.vue +328 -0
- package/dist/package/src/views/tool/code-gen/components/CodePreviewPane.vue +42 -0
- package/dist/package/src/views/tool/code-gen/config.ts +175 -0
- package/dist/package/src/views/tool/code-gen/preview/capabilities.ts +34 -0
- package/dist/package/src/views/tool/code-gen/preview/data.ts +331 -0
- package/dist/package/src/views/tool/code-gen/preview/index.vue +831 -0
- package/dist/package/src/views/tool/code-gen/proto/index.vue +703 -0
- package/dist/package/src/views/tool/code-gen/table/index.vue +864 -0
- package/dist/package/src/views/tool/project-doc/index.vue +561 -0
- package/package.json +60 -0
- package/tsconfig.json +13 -0
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
<!-- API 管理 -->
|
|
2
|
+
<template>
|
|
3
|
+
<div class="table-box">
|
|
4
|
+
<ProTable ref="proTable" row-key="id" :columns="columns" :request-api="requestBaseApiTable" />
|
|
5
|
+
|
|
6
|
+
<el-drawer v-model="detailDrawer.visible" title="API 详情" size="70%" @close="handleCloseDetail">
|
|
7
|
+
<el-descriptions v-if="detailData" :column="1" border>
|
|
8
|
+
<el-descriptions-item label="工具名">{{ detailData.tool_name }}</el-descriptions-item>
|
|
9
|
+
<el-descriptions-item label="工具提示词">
|
|
10
|
+
<div class="tool-prompts">
|
|
11
|
+
<el-tag v-for="prompt in detailToolPrompts" :key="prompt" effect="plain">{{ prompt }}</el-tag>
|
|
12
|
+
<span v-if="!detailToolPrompts.length">--</span>
|
|
13
|
+
</div>
|
|
14
|
+
</el-descriptions-item>
|
|
15
|
+
<el-descriptions-item label="服务名">{{ detailData.service_name }}</el-descriptions-item>
|
|
16
|
+
<el-descriptions-item label="服务描述">{{ detailData.service_desc }}</el-descriptions-item>
|
|
17
|
+
<el-descriptions-item label="描述">{{ detailData.desc }}</el-descriptions-item>
|
|
18
|
+
<el-descriptions-item label="操作方法">{{ detailData.operation }}</el-descriptions-item>
|
|
19
|
+
<el-descriptions-item label="请求方法">{{ detailData.method }}</el-descriptions-item>
|
|
20
|
+
<el-descriptions-item label="请求地址">{{ detailData.path }}</el-descriptions-item>
|
|
21
|
+
<el-descriptions-item label="MCP工具">{{ formatStatus(detailData.mcp_status) }}</el-descriptions-item>
|
|
22
|
+
<el-descriptions-item label="Agent工具">{{ formatStatus(detailData.agent_status) }}</el-descriptions-item>
|
|
23
|
+
</el-descriptions>
|
|
24
|
+
|
|
25
|
+
<div v-if="detailDoc" class="api-doc">
|
|
26
|
+
<section class="api-doc-section">
|
|
27
|
+
<div class="api-doc-title">请求参数</div>
|
|
28
|
+
<el-table
|
|
29
|
+
v-if="detailParameters.length > 0"
|
|
30
|
+
:data="detailParameters"
|
|
31
|
+
row-key="path"
|
|
32
|
+
default-expand-all
|
|
33
|
+
:tree-props="{ children: 'children' }"
|
|
34
|
+
>
|
|
35
|
+
<el-table-column prop="path" label="字段" min-width="220" />
|
|
36
|
+
<el-table-column prop="in" label="位置" width="90" />
|
|
37
|
+
<el-table-column label="类型" min-width="180">
|
|
38
|
+
<template #default="{ row }">{{ formatSchemaType(row) }}</template>
|
|
39
|
+
</el-table-column>
|
|
40
|
+
<el-table-column label="必填" width="80" align="center">
|
|
41
|
+
<template #default="{ row }">{{ row.required ? "是" : "否" }}</template>
|
|
42
|
+
</el-table-column>
|
|
43
|
+
<el-table-column prop="description" label="说明" min-width="240" show-overflow-tooltip />
|
|
44
|
+
</el-table>
|
|
45
|
+
<el-empty v-else description="无请求参数" :image-size="72" />
|
|
46
|
+
</section>
|
|
47
|
+
|
|
48
|
+
<section class="api-doc-section">
|
|
49
|
+
<div class="api-doc-title">请求体</div>
|
|
50
|
+
<el-table
|
|
51
|
+
v-if="requestBodyRows.length > 0"
|
|
52
|
+
:data="requestBodyRows"
|
|
53
|
+
row-key="path"
|
|
54
|
+
default-expand-all
|
|
55
|
+
:tree-props="{ children: 'children' }"
|
|
56
|
+
>
|
|
57
|
+
<el-table-column prop="path" label="字段" min-width="220" />
|
|
58
|
+
<el-table-column label="类型" min-width="180">
|
|
59
|
+
<template #default="{ row }">{{ formatSchemaType(row) }}</template>
|
|
60
|
+
</el-table-column>
|
|
61
|
+
<el-table-column label="必填" width="80" align="center">
|
|
62
|
+
<template #default="{ row }">{{ row.required ? "是" : "否" }}</template>
|
|
63
|
+
</el-table-column>
|
|
64
|
+
<el-table-column prop="description" label="说明" min-width="240" show-overflow-tooltip />
|
|
65
|
+
</el-table>
|
|
66
|
+
<el-empty v-else description="无请求体" :image-size="72" />
|
|
67
|
+
</section>
|
|
68
|
+
|
|
69
|
+
<section class="api-doc-section">
|
|
70
|
+
<div class="api-doc-title">返回值</div>
|
|
71
|
+
<el-collapse v-if="detailResponses.length > 0">
|
|
72
|
+
<el-collapse-item v-for="response in detailResponses" :key="response.status" :name="response.status">
|
|
73
|
+
<template #title>
|
|
74
|
+
<span class="api-doc-response-title">{{ response.status }} {{ response.description }}</span>
|
|
75
|
+
</template>
|
|
76
|
+
<el-table
|
|
77
|
+
v-if="responseBodyRows(response).length > 0"
|
|
78
|
+
:data="responseBodyRows(response)"
|
|
79
|
+
row-key="path"
|
|
80
|
+
default-expand-all
|
|
81
|
+
:tree-props="{ children: 'children' }"
|
|
82
|
+
>
|
|
83
|
+
<el-table-column prop="path" label="字段" min-width="220" />
|
|
84
|
+
<el-table-column label="类型" min-width="180">
|
|
85
|
+
<template #default="{ row }">{{ formatSchemaType(row) }}</template>
|
|
86
|
+
</el-table-column>
|
|
87
|
+
<el-table-column prop="description" label="说明" min-width="240" show-overflow-tooltip />
|
|
88
|
+
</el-table>
|
|
89
|
+
<el-empty v-else description="无响应体" :image-size="72" />
|
|
90
|
+
</el-collapse-item>
|
|
91
|
+
</el-collapse>
|
|
92
|
+
<el-empty v-else description="无返回值" :image-size="72" />
|
|
93
|
+
</section>
|
|
94
|
+
</div>
|
|
95
|
+
</el-drawer>
|
|
96
|
+
|
|
97
|
+
<FormDialog
|
|
98
|
+
v-model="editDialog.visible"
|
|
99
|
+
ref="editDialogRef"
|
|
100
|
+
title="编辑API"
|
|
101
|
+
width="760px"
|
|
102
|
+
:model="editForm"
|
|
103
|
+
:fields="editFields"
|
|
104
|
+
label-width="120px"
|
|
105
|
+
@confirm="handleSubmitEdit"
|
|
106
|
+
@close="handleCloseEditDialog"
|
|
107
|
+
/>
|
|
108
|
+
</div>
|
|
109
|
+
</template>
|
|
110
|
+
|
|
111
|
+
<script setup lang="ts">
|
|
112
|
+
import { computed, reactive, ref } from "vue";
|
|
113
|
+
import { ElMessage, ElMessageBox } from "element-plus";
|
|
114
|
+
import { EditPen, View } from "@element-plus/icons-vue";
|
|
115
|
+
import type { ColumnProps, ProTableInstance } from "@liujitcn/kratos-admin-core/components/ProTable/interface";
|
|
116
|
+
import ProTable from "@liujitcn/kratos-admin-core/components/ProTable";
|
|
117
|
+
import FormDialog from "@liujitcn/kratos-admin-core/components/Dialog/FormDialog.vue";
|
|
118
|
+
import type { ProFormField } from "@liujitcn/kratos-admin-core/components/ProForm/interface";
|
|
119
|
+
import { useAuthButtons } from "@liujitcn/kratos-admin-core/auth";
|
|
120
|
+
import { defBaseApiService } from "@liujitcn/kratos-admin-system/api/system/base_api";
|
|
121
|
+
import { Status } from "@liujitcn/kratos-admin-system/rpc/common/v1/enum";
|
|
122
|
+
import type { BaseApi, BaseApiDoc, BaseApiDocResponse, BaseApiDocSchema, PageBaseApiRequest } from "@liujitcn/kratos-admin-system/rpc/system/admin/v1/base_api";
|
|
123
|
+
import { buildPageRequest } from "@liujitcn/kratos-admin-core/table";
|
|
124
|
+
|
|
125
|
+
defineOptions({
|
|
126
|
+
name: "BaseApi",
|
|
127
|
+
inheritAttrs: false
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
const { BUTTONS } = useAuthButtons();
|
|
131
|
+
const proTable = ref<ProTableInstance>();
|
|
132
|
+
const editDialogRef = ref<InstanceType<typeof FormDialog>>();
|
|
133
|
+
const detailData = ref<BaseApi>();
|
|
134
|
+
const detailDoc = ref<BaseApiDoc>();
|
|
135
|
+
|
|
136
|
+
const detailDrawer = reactive({
|
|
137
|
+
visible: false
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
const editDialog = reactive({
|
|
141
|
+
visible: false
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
const editForm = reactive({
|
|
145
|
+
id: 0,
|
|
146
|
+
tool_name: "",
|
|
147
|
+
tool_prompts: [] as string[],
|
|
148
|
+
mcp_status: Status.ENABLE,
|
|
149
|
+
agent_status: Status.ENABLE
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
const requestBodyRows = computed(() => schemaRows(detailDoc.value?.request_body));
|
|
153
|
+
|
|
154
|
+
/** 将 ProtoJSON 省略的空重复字段固定为数组,供详情区域安全渲染。 */
|
|
155
|
+
const detailParameters = computed(() => detailDoc.value?.parameters ?? []);
|
|
156
|
+
const detailResponses = computed(() => detailDoc.value?.responses ?? []);
|
|
157
|
+
const detailToolPrompts = computed(() => detailData.value?.tool_prompts ?? []);
|
|
158
|
+
|
|
159
|
+
/** API 编辑表单字段配置。 */
|
|
160
|
+
const editFields: ProFormField[] = [
|
|
161
|
+
{
|
|
162
|
+
prop: "tool_name",
|
|
163
|
+
label: "工具名",
|
|
164
|
+
component: "input",
|
|
165
|
+
props: { disabled: true }
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
prop: "tool_prompts",
|
|
169
|
+
label: "工具提示词",
|
|
170
|
+
component: "dynamic-list",
|
|
171
|
+
props: { inputProps: { placeholder: "请输入工具提示词" } }
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
prop: "mcp_status",
|
|
175
|
+
label: "MCP工具状态",
|
|
176
|
+
component: "switch",
|
|
177
|
+
props: { activeValue: Status.ENABLE, inactiveValue: Status.DISABLE, activeText: "启用", inactiveText: "禁用" }
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
prop: "agent_status",
|
|
181
|
+
label: "Agent工具状态",
|
|
182
|
+
component: "switch",
|
|
183
|
+
props: { activeValue: Status.ENABLE, inactiveValue: Status.DISABLE, activeText: "启用", inactiveText: "禁用" }
|
|
184
|
+
}
|
|
185
|
+
];
|
|
186
|
+
|
|
187
|
+
const statusOptions = [
|
|
188
|
+
{ label: "启用", value: Status.ENABLE },
|
|
189
|
+
{ label: "禁用", value: Status.DISABLE }
|
|
190
|
+
];
|
|
191
|
+
|
|
192
|
+
/** API 表格列配置。 */
|
|
193
|
+
const columns: ColumnProps[] = [
|
|
194
|
+
{ prop: "tool_name", label: "工具名", minWidth: 260, search: { el: "input" } },
|
|
195
|
+
{
|
|
196
|
+
prop: "tool_prompts",
|
|
197
|
+
label: "工具提示词",
|
|
198
|
+
minWidth: 240,
|
|
199
|
+
search: { el: "input", key: "tool_prompt" },
|
|
200
|
+
render: scope => formatToolPrompts((scope.row as BaseApi).tool_prompts)
|
|
201
|
+
},
|
|
202
|
+
{ prop: "service_name", label: "服务名", minWidth: 180, search: { el: "input" } },
|
|
203
|
+
{ prop: "service_desc", label: "服务描述", minWidth: 180, search: { el: "input" } },
|
|
204
|
+
{ prop: "desc", label: "描述", minWidth: 180, search: { el: "input" } },
|
|
205
|
+
{ prop: "operation", label: "操作方法", minWidth: 260, search: { el: "input" } },
|
|
206
|
+
{ prop: "method", label: "请求方法", width: 110, search: { el: "input" } },
|
|
207
|
+
{ prop: "path", label: "请求地址", minWidth: 260, search: { el: "input" } },
|
|
208
|
+
{
|
|
209
|
+
prop: "mcp_status",
|
|
210
|
+
label: "MCP工具状态",
|
|
211
|
+
width: 120,
|
|
212
|
+
enum: statusOptions,
|
|
213
|
+
search: { el: "select" },
|
|
214
|
+
cellType: "status",
|
|
215
|
+
statusProps: {
|
|
216
|
+
activeValue: Status.ENABLE,
|
|
217
|
+
inactiveValue: Status.DISABLE,
|
|
218
|
+
activeText: "启用",
|
|
219
|
+
inactiveText: "禁用",
|
|
220
|
+
disabled: () => !BUTTONS.value["base:api:mcp-status"],
|
|
221
|
+
beforeChange: scope => handleBeforeSetMcpStatus(scope.row as BaseApi)
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
prop: "agent_status",
|
|
226
|
+
label: "Agent工具状态",
|
|
227
|
+
width: 130,
|
|
228
|
+
enum: statusOptions,
|
|
229
|
+
search: { el: "select" },
|
|
230
|
+
cellType: "status",
|
|
231
|
+
statusProps: {
|
|
232
|
+
activeValue: Status.ENABLE,
|
|
233
|
+
inactiveValue: Status.DISABLE,
|
|
234
|
+
activeText: "启用",
|
|
235
|
+
inactiveText: "禁用",
|
|
236
|
+
disabled: () => !BUTTONS.value["base:api:agent-status"],
|
|
237
|
+
beforeChange: scope => handleBeforeSetAgentStatus(scope.row as BaseApi)
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
prop: "operation",
|
|
242
|
+
label: "操作",
|
|
243
|
+
width: 210,
|
|
244
|
+
fixed: "right",
|
|
245
|
+
cellType: "actions",
|
|
246
|
+
actions: [
|
|
247
|
+
{
|
|
248
|
+
label: "编辑",
|
|
249
|
+
type: "primary",
|
|
250
|
+
link: true,
|
|
251
|
+
icon: EditPen,
|
|
252
|
+
hidden: () => !BUTTONS.value["base:api:update"],
|
|
253
|
+
onClick: scope => handleOpenEditDialog(scope.row as BaseApi)
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
label: "详情",
|
|
257
|
+
type: "primary",
|
|
258
|
+
link: true,
|
|
259
|
+
icon: View,
|
|
260
|
+
hidden: () => !BUTTONS.value["base:api:info"],
|
|
261
|
+
onClick: scope => handleOpenDetail((scope.row as BaseApi).id)
|
|
262
|
+
}
|
|
263
|
+
]
|
|
264
|
+
}
|
|
265
|
+
];
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* 请求 API 分页列表,并由 ProTable 统一维护分页与搜索参数。
|
|
269
|
+
*/
|
|
270
|
+
async function requestBaseApiTable(params: PageBaseApiRequest) {
|
|
271
|
+
const data = await defBaseApiService.PageBaseApi(buildPageRequest(params));
|
|
272
|
+
return { data: { list: data.base_apis ?? [], total: data.total } };
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* 刷新 API 表格。
|
|
277
|
+
*/
|
|
278
|
+
function refreshTable() {
|
|
279
|
+
proTable.value?.getTableList();
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* 打开 API 详情抽屉。
|
|
284
|
+
*/
|
|
285
|
+
async function handleOpenDetail(apiId: number) {
|
|
286
|
+
const [baseApi, baseApiDoc] = await Promise.all([
|
|
287
|
+
defBaseApiService.GetBaseApi({ id: apiId }),
|
|
288
|
+
defBaseApiService.GetBaseApiDoc({ id: apiId })
|
|
289
|
+
]);
|
|
290
|
+
detailData.value = baseApi;
|
|
291
|
+
detailDoc.value = baseApiDoc;
|
|
292
|
+
detailDrawer.visible = true;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* 关闭详情抽屉并清空旧数据,避免下次打开时短暂展示旧详情。
|
|
297
|
+
*/
|
|
298
|
+
function handleCloseDetail() {
|
|
299
|
+
detailDrawer.visible = false;
|
|
300
|
+
detailData.value = undefined;
|
|
301
|
+
detailDoc.value = undefined;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* 打开 API 编辑弹窗并回填当前行数据。
|
|
306
|
+
*/
|
|
307
|
+
function handleOpenEditDialog(row: BaseApi) {
|
|
308
|
+
editForm.id = row.id;
|
|
309
|
+
editForm.tool_name = row.tool_name;
|
|
310
|
+
editForm.tool_prompts = [...(row.tool_prompts ?? [])];
|
|
311
|
+
editForm.mcp_status = row.mcp_status;
|
|
312
|
+
editForm.agent_status = row.agent_status;
|
|
313
|
+
editDialog.visible = true;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* 关闭 API 编辑弹窗并清空表单状态。
|
|
318
|
+
*/
|
|
319
|
+
function handleCloseEditDialog() {
|
|
320
|
+
editDialog.visible = false;
|
|
321
|
+
editForm.id = 0;
|
|
322
|
+
editForm.tool_name = "";
|
|
323
|
+
editForm.tool_prompts = [];
|
|
324
|
+
editForm.mcp_status = Status.ENABLE;
|
|
325
|
+
editForm.agent_status = Status.ENABLE;
|
|
326
|
+
editDialogRef.value?.clearValidate();
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* 提交 API 编辑配置。
|
|
331
|
+
*/
|
|
332
|
+
async function handleSubmitEdit() {
|
|
333
|
+
await editDialogRef.value?.validate();
|
|
334
|
+
await defBaseApiService.UpdateBaseApi({
|
|
335
|
+
id: editForm.id,
|
|
336
|
+
tool_prompts: editForm.tool_prompts.filter(Boolean),
|
|
337
|
+
mcp_status: editForm.mcp_status,
|
|
338
|
+
agent_status: editForm.agent_status
|
|
339
|
+
});
|
|
340
|
+
ElMessage.success("保存成功");
|
|
341
|
+
handleCloseEditDialog();
|
|
342
|
+
refreshTable();
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* MCP 工具状态切换前进行二次确认,并调用状态接口完成持久化。
|
|
347
|
+
*/
|
|
348
|
+
async function handleBeforeSetMcpStatus(row: BaseApi) {
|
|
349
|
+
const nextStatus = row.mcp_status === Status.ENABLE ? Status.DISABLE : Status.ENABLE;
|
|
350
|
+
const text = nextStatus === Status.ENABLE ? "启用" : "禁用";
|
|
351
|
+
const apiName = row.desc || row.operation || `ID:${row.id}`;
|
|
352
|
+
try {
|
|
353
|
+
await ElMessageBox.confirm(`是否确定${text}该 API 的 MCP 工具能力?\nAPI:${apiName}`, "提示", {
|
|
354
|
+
confirmButtonText: "确认",
|
|
355
|
+
cancelButtonText: "取消",
|
|
356
|
+
type: "warning"
|
|
357
|
+
});
|
|
358
|
+
await defBaseApiService.SetBaseApiMcpStatus({ id: row.id, mcp_status: nextStatus });
|
|
359
|
+
ElMessage.success(`${text}成功`);
|
|
360
|
+
refreshTable();
|
|
361
|
+
return true;
|
|
362
|
+
} catch {
|
|
363
|
+
return false;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Agent 工具状态切换前进行二次确认,并调用状态接口完成持久化。
|
|
369
|
+
*/
|
|
370
|
+
async function handleBeforeSetAgentStatus(row: BaseApi) {
|
|
371
|
+
const nextStatus = row.agent_status === Status.ENABLE ? Status.DISABLE : Status.ENABLE;
|
|
372
|
+
const text = nextStatus === Status.ENABLE ? "启用" : "禁用";
|
|
373
|
+
const apiName = row.desc || row.operation || `ID:${row.id}`;
|
|
374
|
+
try {
|
|
375
|
+
await ElMessageBox.confirm(`是否确定${text}该 API 的 Agent 工具能力?\nAPI:${apiName}`, "提示", {
|
|
376
|
+
confirmButtonText: "确认",
|
|
377
|
+
cancelButtonText: "取消",
|
|
378
|
+
type: "warning"
|
|
379
|
+
});
|
|
380
|
+
await defBaseApiService.SetBaseApiAgentStatus({ id: row.id, agent_status: nextStatus });
|
|
381
|
+
ElMessage.success(`${text}成功`);
|
|
382
|
+
refreshTable();
|
|
383
|
+
return true;
|
|
384
|
+
} catch {
|
|
385
|
+
return false;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* 格式化工具提示词列表。
|
|
391
|
+
*/
|
|
392
|
+
function formatToolPrompts(prompts: string[]) {
|
|
393
|
+
if (!prompts?.length) return "--";
|
|
394
|
+
return prompts.filter(Boolean).join(";");
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* 格式化 API 工具状态。
|
|
399
|
+
*/
|
|
400
|
+
function formatStatus(status: Status) {
|
|
401
|
+
if (status === Status.ENABLE) return "启用";
|
|
402
|
+
if (status === Status.DISABLE) return "禁用";
|
|
403
|
+
return "未知";
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* 将可选 Schema 转成表格行。
|
|
408
|
+
*/
|
|
409
|
+
function schemaRows(schema?: BaseApiDocSchema) {
|
|
410
|
+
return schema ? [schema] : [];
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* 获取响应体表格行。
|
|
415
|
+
*/
|
|
416
|
+
function responseBodyRows(response: BaseApiDocResponse) {
|
|
417
|
+
return schemaRows(response.body);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* 格式化 Schema 类型,补充格式、引用类型与枚举值。
|
|
422
|
+
*/
|
|
423
|
+
function formatSchemaType(schema: BaseApiDocSchema) {
|
|
424
|
+
const values = [schema.type];
|
|
425
|
+
if (schema.format) values.push(`<${schema.format}>`);
|
|
426
|
+
if (schema.ref) values.push(schema.ref);
|
|
427
|
+
// ProtoJSON 会省略空 repeated 字段,枚举缺失时按空数组展示。
|
|
428
|
+
if (schema.enum?.length > 0) values.push(schema.enum.join(" | "));
|
|
429
|
+
return values.filter(Boolean).join(" ");
|
|
430
|
+
}
|
|
431
|
+
</script>
|
|
432
|
+
|
|
433
|
+
<style scoped lang="scss">
|
|
434
|
+
.api-doc {
|
|
435
|
+
margin-top: 18px;
|
|
436
|
+
}
|
|
437
|
+
.api-doc-section {
|
|
438
|
+
margin-top: 20px;
|
|
439
|
+
}
|
|
440
|
+
.api-doc-title {
|
|
441
|
+
margin-bottom: 10px;
|
|
442
|
+
font-size: 15px;
|
|
443
|
+
font-weight: 600;
|
|
444
|
+
color: var(--el-text-color-primary);
|
|
445
|
+
}
|
|
446
|
+
.api-doc-response-title {
|
|
447
|
+
font-weight: 500;
|
|
448
|
+
color: var(--el-text-color-primary);
|
|
449
|
+
}
|
|
450
|
+
.tool-prompts {
|
|
451
|
+
display: flex;
|
|
452
|
+
flex-wrap: wrap;
|
|
453
|
+
gap: 8px;
|
|
454
|
+
}
|
|
455
|
+
</style>
|