Skip to content

Commit 72549cd

Browse files
feat: tool
1 parent 5a83b48 commit 72549cd

29 files changed

Lines changed: 134 additions & 200 deletions

‎ui/src/components.d.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ declare module 'vue' {
2020
MdEditor: typeof import('./components/global/markdown-editor/MdEditor.vue')['default']
2121
MdEditorMagnify: typeof import('./components/global/markdown-editor/MdEditorMagnify.vue')['default']
2222
MdPreview: typeof import('./components/global/markdown-editor/MdPreview.vue')['default']
23-
MkAction: typeof import('./components/global/mk-action/index.vue')['default']
23+
MkAction: typeof import('./components/global/mk-table/MkAction.vue')['default']
2424
MkCollapse: typeof import('./components/global/mk-collapse/index.vue')['default']
2525
MkComplexSearch: typeof import('./components/global/mk-complex-search/index.vue')['default']
2626
MkDialog: typeof import('./components/global/mk-dialog/index.vue')['default']
@@ -42,7 +42,6 @@ declare module 'vue' {
4242
MkTable: typeof import('./components/global/mk-table/index.vue')['default']
4343
MkTableFilter: typeof import('./components/global/mk-table/MkTableFilter.vue')['default']
4444
MkTableMoreDropdown: typeof import('./components/global/mk-table/MkTableMoreDropdown.vue')['default']
45-
MkTableOperationGroup: typeof import('./components/global/mk-action/MkTableOperationGroup.vue')['default']
4645
MkTagGroup: typeof import('./components/global/mk-tag-group/index.vue')['default']
4746
MkTooltip: typeof import('./components/global/mk-tooltip/index.vue')['default']
4847
MkViewLayout: typeof import('./components/global/mk-view-layout/index.vue')['default']
@@ -64,7 +63,7 @@ declare global {
6463
const MdEditor: typeof import('./components/global/markdown-editor/MdEditor.vue')['default']
6564
const MdEditorMagnify: typeof import('./components/global/markdown-editor/MdEditorMagnify.vue')['default']
6665
const MdPreview: typeof import('./components/global/markdown-editor/MdPreview.vue')['default']
67-
const MkAction: typeof import('./components/global/mk-action/index.vue')['default']
66+
const MkAction: typeof import('./components/global/mk-table/MkAction.vue')['default']
6867
const MkCollapse: typeof import('./components/global/mk-collapse/index.vue')['default']
6968
const MkComplexSearch: typeof import('./components/global/mk-complex-search/index.vue')['default']
7069
const MkDialog: typeof import('./components/global/mk-dialog/index.vue')['default']
@@ -86,7 +85,6 @@ declare global {
8685
const MkTable: typeof import('./components/global/mk-table/index.vue')['default']
8786
const MkTableFilter: typeof import('./components/global/mk-table/MkTableFilter.vue')['default']
8887
const MkTableMoreDropdown: typeof import('./components/global/mk-table/MkTableMoreDropdown.vue')['default']
89-
const MkTableOperationGroup: typeof import('./components/global/mk-action/MkTableOperationGroup.vue')['default']
9088
const MkTagGroup: typeof import('./components/global/mk-tag-group/index.vue')['default']
9189
const MkTooltip: typeof import('./components/global/mk-tooltip/index.vue')['default']
9290
const MkViewLayout: typeof import('./components/global/mk-view-layout/index.vue')['default']

‎ui/src/components/COMPONENT_README.md‎

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -293,23 +293,12 @@ Dialog、Drawer、Popover、嵌套区域等其他大、小表格均禁止开启
293293
`clearSelection()`。操作栏与 `MkViewLayout` 复用 `LayoutBatchFooter`,统一全选、半选、数量和
294294
取消行为;它在主内容滚动区域内吸附于页面底部,不随表格内容滚出可视区域。
295295

296-
### MkTableOperationGroup、MkAction
297-
298-
`MkTableOperationGroup` 与 `MkAction`、`context.ts` 统一维护在 `global/mk-action/`。
299-
表格操作列使用 `MkTableOperationGroup` 默认插槽声明操作,按模板顺序将前 `maxVisible` 个操作
300-
(默认 2)显示为图标按钮,其余自动进入 More;没有剩余操作时不显示 More。
301-
每个直接子组件代表一个操作,业务 Action 内使用 `MkAction` 作为展示入口。
302-
整个操作的显隐条件必须写在直接子组件的 `v-if` 上;不通过 `v-show` 或子组件内部条件控制计数。
303-
支持展开 `template` Fragment,忽略注释和文本;循环操作提供稳定且唯一的 key。
304-
禁用操作仍占位。开关等独立控件放在操作栏外,页面按实际入口数量设置操作列宽。
305-
306-
`MkAction` 位于 `global/mk-action/index.vue`,适用于表格和卡片,接收 `label`、SVG Symbol 名称
307-
`icon`、`disabled`、`divided`,发出 `click`。
308-
通过上下文自动选择图标按钮加 Tooltip 或图标加文字菜单项;独立使用默认显示按钮,
309-
放入 `MkDropdownMenu` 时显示菜单项。点击阻止冒泡,`divided` 在按钮模式和自动 More 首项中不生效。
310-
业务 Action 保留自己的请求与浮层生命周期,不需要传递展示模式或维护操作配置数组。
311-
操作栏内部复用 `MkTableMoreDropdown` 并开启 `persistent`,菜单收起时保留业务 Action 与已打开浮层。
312-
操作跨越外露和 More 边界时会重新挂载,业务浮层打开期间不要重排入口或改变 `maxVisible`。
296+
### MkAction
297+
298+
`global/mk-table/MkAction.vue` 统一单个操作的两种外观,通过 `display="menu"`(默认)或
299+
`display="button"` 显式选择菜单项或带 Tooltip 的图标按钮,不注入或推断展示上下文。
300+
接收 `label`、SVG Symbol 名称 `icon`、`disabled`、`divided`,发出 `click` 并阻止点击冒泡。
301+
`divided` 仅用于菜单模式。页面自行组合外露操作与 `MkTableMoreDropdown`,不自动分配位置。
313302

314303
### MkTagGroup
315304

‎ui/src/components/global/mk-action/MkTableOperationGroup.vue‎

Lines changed: 0 additions & 60 deletions
This file was deleted.

‎ui/src/components/global/mk-action/context.ts‎

Lines changed: 0 additions & 9 deletions
This file was deleted.

‎ui/src/components/global/mk-dropdown/MkDropdownMenu.vue‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
<script setup lang="ts">
2-
import { provide, ref } from 'vue'
3-
import { actionContextKey, type ActionContext } from '../mk-action/context'
4-
52
defineOptions({ name: 'MkDropdownMenu', inheritAttrs: false })
63
7-
provide(actionContextKey, ref<ActionContext>({ display: 'menu' }))
8-
94
defineSlots<{
10-
/** 菜单项,使用 MkDropdownItem 或以 MkAction 为入口的业务 Action */
5+
/** 菜单项,仅使用 MkDropdownItem */
116
default(): unknown
127
}>()
138
</script>

ui/src/components/global/mk-action/index.vue renamed to ui/src/components/global/mk-table/MkAction.vue

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,18 @@
11
<script setup lang="ts">
2-
import { inject } from 'vue'
3-
import { actionContextKey } from './context'
4-
52
defineOptions({ name: 'MkAction', inheritAttrs: false })
6-
defineProps<{ label: string; icon: string; disabled?: boolean; divided?: boolean }>()
3+
withDefaults(defineProps<{ display?: 'menu' | 'button'; label: string; icon: string; disabled?: boolean; divided?: boolean }>(), { display: 'menu' })
74
const emit = defineEmits<{ click: [event: MouseEvent] }>()
8-
const context = inject(actionContextKey, undefined)
95
</script>
106

117
<template>
128
<!-- 菜单操作 -->
13-
<MkDropdownItem
14-
v-if="context?.display === 'menu'"
15-
v-bind="$attrs"
16-
:disabled="disabled"
17-
:divided="divided && !context.first"
18-
@click.stop="emit('click', $event)"
19-
>
9+
<MkDropdownItem v-if="display === 'menu'" v-bind="$attrs" :disabled="disabled" :divided="divided" @click.stop="emit('click', $event)">
2010
<template #icon><MkIcon :name="icon" /></template>
2111
{{ label }}
2212
</MkDropdownItem>
2313
<MkTooltip v-else :content="label" placement="top">
2414
<!-- 图标操作 -->
25-
<el-button v-bind="$attrs" type="primary" text :disabled="disabled" @click.stop="emit('click', $event)">
15+
<el-button v-bind="$attrs" text type="primary" :disabled="disabled" @click.stop="emit('click', $event)">
2616
<MkIcon :name="icon" />
2717
</el-button>
2818
</MkTooltip>

‎ui/src/components/global/mk-table/MkTableMoreDropdown.vue‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const hasDropdownItems = computed(() => hasRenderableSlotContent(slots.default?.
1616
</script>
1717

1818
<template>
19-
<MkDropdown v-if="hasDropdownItems" trigger="click" placement="bottom-end" v-bind="$attrs">
19+
<MkDropdown v-if="hasDropdownItems" class="mk-table-more-dropdown [button+&]:ml-1" trigger="click" placement="bottom-end" v-bind="$attrs">
2020
<el-button type="primary" text @click.stop>
2121
<MkIcon name="icon_more_outlined" />
2222
</el-button>

‎ui/src/views/VIEW_README.md‎

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -804,18 +804,13 @@ application、tool、knowledge 的 WorkflowView 统一使用一个 `loading` 控
804804

805805
`system/resource-management/ModelResourceView.vue` 与 `ToolResourceView.vue` 使用
806806
`MkViewLayout`、`MkComplexSearch` 和 `MkTable` 展示跨工作空间资源。
807-
模型操作列通过 `MkTableOperationGroup` 按插槽顺序外露编辑与资源授权,其余操作自动进入 More;
808-
参数设置的显隐条件直接写在 Action 上,业务 Action 复用 `MkAction` 适配按钮与菜单。
809-
模型 `action-dropdown` 中的编辑、删除、参数设置、授权和关联资源入口统一使用 `MkAction`。
810-
资源管理页复用 `EditModelAction`,传入 System API、供应商和禁用状态;该 Action 内聚编辑抽屉,
811-
保存后发送 `refresh`。共享模型页继续组合相同业务 Action,在卡片菜单中自动显示为菜单项。
812-
资源管理删除保留页面专属确认、引用数量提示、加载状态和分页回退,通过 `MkAction` 展示,
813-
不强行复用卡片的 `DeleteModelAction`。
814-
工具操作列同样使用 `MkTableOperationGroup`,按现有模板顺序和显隐条件外露前两个操作;
815-
启停开关位于操作组外,不计入两个操作。商店工具改名、System 工作流跳转和带引用提示、
816-
分页回退的删除继续由资源管理页维护,通过 `MkAction` 展示。
817-
工具 `action-dropdown` 内的各操作统一使用 `MkAction`,Workspace 和共享工具卡片仍通过
818-
`MkDropdownMenu` 自动显示菜单项,保留原有 API、权限条件、事件和浮层生命周期。
807+
模型操作列使用 `EditModelAction display="button"` 展示编辑按钮,其余操作放入 `MkTableMoreDropdown`;
808+
`EditModelAction` 透传 `display` 给 `MkAction`,默认保持菜单模式,内部管理编辑抽屉,保存后发出 `refresh`。
809+
模型和工具仅编辑、资源授权四个 Action 使用 `MkAction` 并透传显式 `display`,默认菜单模式;
810+
其他业务 Action 继续使用 `MkDropdownItem`,页面按现有布局显式选择按钮或菜单。
811+
工具操作列保留独立启停开关,
812+
其余操作放入 `MkTableMoreDropdown`。菜单开启 `persistent`,业务 Action 使用 `MkDropdownItem`,
813+
保留各自 API、权限条件、事件和浮层生命周期。资源管理页保留带引用提示和分页回退的独立删除流程。
819814
名称、类型、创建者(工具另含来源)筛选和工作空间表头筛选变化后回到第一页;分页大小变化由
820815
`MkTable` 重置页码。工作空间列及选项查询只在企业版开启,`workspace_ids` 沿用 JSON 数组字符串。
821816
页面使用 v3 的 System 权限方法保留迁移前已有的操作权限,不增加创建、导入、批量或复制入口。

‎ui/src/views/model/model-card/action-dropdown/AuthorizeModelAction.vue‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { RESOURCE_TYPE } from '@/api/enums'
55
import ResourceAuthorizationDrawer from '@/components/business/resource-authorization-drawer/index.vue'
66
77
defineOptions({ name: 'AuthorizeModelAction' })
8-
const props = defineProps<{ model: ModelItem; label: string }>()
8+
const props = defineProps<{ model: ModelItem; label: string; display?: 'menu' | 'button' }>()
99
1010
const drawerMounted = ref(false)
1111
const authorizationDrawerRef = useTemplateRef<InstanceType<typeof ResourceAuthorizationDrawer>>('authorizationDrawerRef')
@@ -22,7 +22,7 @@ function handleDrawerClosed() {
2222

2323
<template>
2424
<!-- 资源授权 -->
25-
<MkAction :label="label" icon="icon_passkeys_outlined" @click="handleOpenAuthorization" />
25+
<MkAction :display="display" :label="label" icon="icon_passkeys_outlined" @click="handleOpenAuthorization" />
2626
<ResourceAuthorizationDrawer
2727
v-if="drawerMounted"
2828
ref="authorizationDrawerRef"

‎ui/src/views/model/model-card/action-dropdown/DeleteModelAction.vue‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,8 @@ function handleDeleteModel() {
2424

2525
<template>
2626
<!-- 删除模型 -->
27-
<MkAction :label="label" icon="icon_delete-trash_outlined" divided @click="handleDeleteModel" />
27+
<MkDropdownItem divided @click="handleDeleteModel">
28+
<template #icon><MkIcon name="icon_delete-trash_outlined" /></template>
29+
<span>{{ label }}</span>
30+
</MkDropdownItem>
2831
</template>

0 commit comments

Comments
 (0)