Skip to content

Commit c605a9e

Browse files
feat: tool
1 parent 33d83c6 commit c605a9e

26 files changed

Lines changed: 351 additions & 269 deletions

File tree

‎ui/src/api/admin/workspace/model/model.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ const putPauseModelDownload = (modelId: string) => {
4242
return put<undefined, boolean>(`${getPrefix()}/${modelId}/pause_download`)
4343
}
4444

45+
46+
4547
export default {
4648
deleteModel,
4749
getModelDetail,
Lines changed: 5 additions & 0 deletions
Loading

‎ui/src/assets/tool/icon_mcp.svg‎

Lines changed: 5 additions & 0 deletions
Loading

‎ui/src/assets/tool/icon_skill.svg‎

Lines changed: 3 additions & 0 deletions
Loading

‎ui/src/assets/tool/icon_tool.svg‎

Lines changed: 4 additions & 0 deletions
Loading
Lines changed: 4 additions & 0 deletions
Loading
Lines changed: 7 additions & 0 deletions
Loading

‎ui/src/components.d.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ declare module 'vue' {
2323
MkEmpty: typeof import('./components/global/mk-empty/index.vue')['default']
2424
MkFilterableDropdown: typeof import('./components/global/mk-filterable-dropdown/index.vue')['default']
2525
MkIcon: typeof import('./components/global/mk-icon/index.vue')['default']
26-
MkLoadMore: typeof import('./components/global/mk-load-more/index.vue')['default']
26+
MkInfiniteScroll: typeof import('./components/global/mk-infinite-scroll/index.vue')['default']
2727
MkSearchInput: typeof import('./components/global/mk-search-input/index.vue')['default']
2828
MkStatusLabel: typeof import('./components/global/mk-status-label/index.vue')['default']
2929
MkTable: typeof import('./components/global/mk-table/index.vue')['default']
3030
MkTagGroup: typeof import('./components/global/mk-tag-group/index.vue')['default']
3131
MkViewLayout: typeof import('./components/global/mk-view-layout/index.vue')['default']
3232
RouterLink: typeof import('vue-router')['RouterLink']
3333
RouterView: typeof import('vue-router')['RouterView']
34+
ToolIcon: typeof import('./components/global/mk-icon/ToolIcon.vue')['default']
3435
}
3536
}
3637

@@ -47,12 +48,13 @@ declare global {
4748
const MkEmpty: typeof import('./components/global/mk-empty/index.vue')['default']
4849
const MkFilterableDropdown: typeof import('./components/global/mk-filterable-dropdown/index.vue')['default']
4950
const MkIcon: typeof import('./components/global/mk-icon/index.vue')['default']
50-
const MkLoadMore: typeof import('./components/global/mk-load-more/index.vue')['default']
51+
const MkInfiniteScroll: typeof import('./components/global/mk-infinite-scroll/index.vue')['default']
5152
const MkSearchInput: typeof import('./components/global/mk-search-input/index.vue')['default']
5253
const MkStatusLabel: typeof import('./components/global/mk-status-label/index.vue')['default']
5354
const MkTable: typeof import('./components/global/mk-table/index.vue')['default']
5455
const MkTagGroup: typeof import('./components/global/mk-tag-group/index.vue')['default']
5556
const MkViewLayout: typeof import('./components/global/mk-view-layout/index.vue')['default']
5657
const RouterLink: typeof import('vue-router')['RouterLink']
5758
const RouterView: typeof import('vue-router')['RouterView']
59+
const ToolIcon: typeof import('./components/global/mk-icon/ToolIcon.vue')['default']
5860
}

‎ui/src/components/COMPONENT_README.md‎

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ src/components/
6565
│ │ └── index.vue # 带搜索过滤和滚动列表的下拉选择
6666
│ ├── mk-icon/
6767
│ │ └── index.vue # SVG Symbol 与 Element Plus 图标统一入口
68-
│ ├── mk-load-more/
68+
│ ├── mk-infinite-scroll/
6969
│ │ └── index.vue # 分页列表滚动触底加载与结束状态
7070
│ ├── mk-view-layout/
7171
│ │ ├── index.vue # 路由页面标题、操作区和内容区统一结构
@@ -319,13 +319,15 @@ Element Plus Dropdown 属性和事件通过 `$attrs` 传入,并暴露 `handleO
319319
仍可自行使用 `el-scrollbar`。页面可以在同一个插槽中组织标题、内容和空状态,并只写一次业务
320320
状态判断。传入 `aside` 插槽后才会渲染左侧栏;左右结构上方的独立内容放入 `top` 插槽。页面加载状态通过
321321
`loading` Prop 传入,由组件将 Element Plus Loading 遮罩绑定到整个布局根节点。默认插槽没有
322-
渲染 `Header` 时会自动显示当前标题;显式渲染后则由页面控制标题内容。
322+
渲染 `Header` 时会自动显示当前标题;显式渲染后则由页面控制标题内容。`collapsible` 默认为
323+
`false`;传入后,展开状态仅在鼠标移入侧栏或焦点进入侧栏时显示收起按钮,收起状态始终显示展开
324+
按钮。收起时释放侧栏宽度,页面不需要自行维护折叠状态。
323325

324326
主内容区固定保留 `px-6` 水平留白。内置滚动容器会抵消两侧留白,再为滚动内容补回 `24px`
325327
水平间距,使滚动条贴齐主区域右边界,并允许 `MkTable` 的底部操作栏延伸至完整主区域宽度。
326328

327329
```vue
328-
<MkViewLayout :loading="loading">
330+
<MkViewLayout :loading="loading" collapsible>
329331
<template #aside>左侧列表</template>
330332
<template #default>右侧内容</template>
331333
</MkViewLayout>
@@ -368,17 +370,19 @@ Element Plus Dropdown 属性和事件通过 `$attrs` 传入,并暴露 `handleO
368370
<MkIcon :icon="Setting" :size="20" />
369371
```
370372

371-
### MkLoadMore
373+
### MkInfiniteScroll
372374

373375
分页列表的滚动触底加载组件,使用 `IntersectionObserver` 监听组件所在滚动区域的底部,不依赖
374-
Element Plus 的 `v-infinite-scroll`。通过 `paginationConfig` 接收 `currentPage`、`pageSize` 和
375-
`total`,组件内部判断是否加载完成;接近底部时,`load` 事件返回下一页页码。`loading` 用于阻止
376-
重复请求并展示加载状态,`disabled` 可临时禁用加载,`distance` 设置提前触发距离且默认为
377-
`200px`。数据不足以撑满滚动区域时会继续加载,直至填满或全部加载完成。`loading` 和 `finished`
378-
插槽可覆盖默认提示。
376+
Element Plus 的 `v-infinite-scroll`。组件通过 `v-model` 管理已经加载的列表数据,通过 `load`
377+
传入按页请求方法,并在内部管理页码、首次加载、数据追加、加载状态、结束状态和过期请求。请求
378+
方法接收 `{ currentPage, pageSize }`,返回包含 `records`、`current`、`size` 和 `total` 的分页结果。
379+
默认每页加载 20 条,可通过 `pageSize` 修改。组件挂载后自动加载第一页,之后只在底部哨兵随
380+
用户滚动进入可视区域时加载下一页。查询条件变化时通过组件暴露的 `reset()` 重新加载。
379381

380382
```vue
381-
<MkLoadMore :loading="loadingMore" :pagination-config="paginationConfig" @load="loadPage" />
383+
<MkInfiniteScroll ref="infiniteScrollRef" v-model="resources" :load="loadResourcePage">
384+
<ResourceCard v-for="resource in resources" :key="resource.id" :resource="resource" />
385+
</MkInfiniteScroll>
382386
```
383387

384388
### MkSearchInput
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<script setup lang="ts">
2+
import { resetUrl } from '@/utils/common'
3+
import { TOOL_TYPE } from '@/api/enums'
4+
defineOptions({ name: 'ToolIcon' })
5+
const props = defineProps({
6+
type: {
7+
type: [String, Number],
8+
default: '',
9+
},
10+
size: {
11+
type: [String, Number],
12+
default: 24,
13+
},
14+
icon: String,
15+
})
16+
</script>
17+
<template>
18+
<el-avatar v-if="icon" shape="square" :size="size" style="background: none">
19+
<img :src="resetUrl(icon)" alt="" />
20+
</el-avatar>
21+
<el-avatar v-else-if="type == TOOL_TYPE.MCP" shape="square" :size="size">
22+
<img src="@/assets/tool/icon_mcp.svg" style="width: 73%" alt="" />
23+
</el-avatar>
24+
<el-avatar v-else-if="type == TOOL_TYPE.SKILL" shape="square" :size="size">
25+
<img src="@/assets/tool/icon_skill.svg" style="width: 63%" alt="" />
26+
</el-avatar>
27+
<el-avatar v-else-if="type == TOOL_TYPE.DATA_SOURCE" class="bg-purple!" shape="square" :size="size">
28+
<img src="@/assets/tool/icon_datasource.svg" style="width: 58%" alt="" />
29+
</el-avatar>
30+
<el-avatar v-else-if="type == TOOL_TYPE.WORKFLOW" class="bg-success!" shape="square" :size="size">
31+
<img src="@/assets/workflow/logo_workflow.svg" style="width: 62%" alt="" />
32+
</el-avatar>
33+
<el-avatar v-else class="bg-success!" shape="square" :size="size">
34+
<img src="@/assets/tool/icon_tool.svg" style="width: 63%" alt="" />
35+
</el-avatar>
36+
</template>

0 commit comments

Comments
 (0)