Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ui/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ Keep these behaviors:
## Frontend Implementation Notes

- Prefer existing project structure and naming.
- Do not modify shared components under `src/components/` without an explicit user instruction to
change those components. Follow the modification boundary in `src/components/COMPONENT_README.md`.
- Do not write `aria-label` attributes in project source. Add concise Chinese HTML comments before
buttons to describe their purpose, following `src/components/COMPONENT_README.md`.
- Before changing existing behavior, trace the affected flow and dependent requirements, including
Expand Down
10 changes: 9 additions & 1 deletion ui/src/components/COMPONENT_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@

## 选型与目录

### 公共组件修改边界

没有用户明确要求修改公共组件的指令,不允许修改 `src/components/` 下公共组件的内容,
包括 `global/`、`business/` 及其他共享组件目录中的模板、逻辑、样式和接口。
“参考某组件”“使用某组件”或修改业务页面,不视为授权修改该公共组件。
实现前先使用已有 Props、事件和插槽,在所属 View 或功能目录中完成组合与适配。
确实需要修改公共组件时,先说明具体组件、必要性及影响范围,取得明确指令后再修改。
此约束纳入实现前检查和提交前 diff 检查;已有其他工作留下的公共组件改动不擅自覆盖或回退。

依次检查全局 Mk 组件、业务组件、手动导入的共享 UI,最后使用 Element Plus;已有同类封装时
直接复用,例如 `MkDialog`、`MkDrawer`、`MkDropdown`、`MkIcon`、`MkTable`。先用现有 Props、
事件、插槽和样式适配,无法满足必要行为时再新增组件;无明确需求不引入新 UI 库。
Expand Down Expand Up @@ -71,7 +80,6 @@ Admin、Chat 入口调用 `configureMarkdownEditor()` 配置本地高亮、KaTeX
### MkCollapse

`v-model:expanded` 可控制展开状态;未绑定时沿用 `defaultExpanded` 的内部状态。
`destroyOnCollapse` 默认 `true`,设为 `false` 时折叠只隐藏内容,适用于需要保留参数表单及校验的场景。

标题折叠区,`title` 或 `label` 插槽提供标题,默认插槽提供内容。
`defaultExpanded` 默认 `true`,仅设置初始状态;点击标题内部切换,当前不提供展开状态事件。
Expand Down
5 changes: 2 additions & 3 deletions ui/src/components/global/mk-collapse/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ defineOptions({ name: 'MkCollapse' })
const props = withDefaults(
defineProps<{
defaultExpanded?: boolean
destroyOnCollapse?: boolean
indicatorPosition?: 'after' | 'before'
title?: string
triggerClass?: HTMLAttributes['class']
triggerStyle?: HTMLAttributes['style']
}>(),
{ defaultExpanded: true, destroyOnCollapse: true, indicatorPosition: 'before' },
{ defaultExpanded: true, indicatorPosition: 'before' },
)

defineSlots<{ default?: () => unknown; label?: () => unknown }>()
Expand Down Expand Up @@ -54,7 +53,7 @@ const expanded = computed({
</div>
</div>
<el-collapse-transition>
<div v-if="!destroyOnCollapse || expanded" v-show="expanded">
<div v-show="expanded">
<slot />
</div>
</el-collapse-transition>
Expand Down
11 changes: 7 additions & 4 deletions ui/src/views/VIEW_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -405,13 +405,16 @@ Workspace 与 System 授权均使用该工作空间 ID,不读取路由工作
任务选择复用 `SelectApplicationDialog` 与 `SelectToolDialog`,工具限定自定义和工作流类型。
`trigger/trigger-form/request-parameters/RequestParameters.vue` 用 `MkFormList` 展示和删除事件请求参数,
同目录 `RequestParameterDialog.vue` 负责新增、编辑及参数名必填与重名校验;确认后回写,取消保留原值。
`trigger/trigger-form/task-execution/TaskParameters.vue` 展示任务输入及事件参数引用,
`trigger/trigger-form/task-execution/task-parameters.ts` 从资源输入定义生成字段,只补全缺失值,不覆盖已有配置。
`trigger/trigger-form/task-execution/parameters/` 内 `ApplicationParameter.vue` 与 `ToolParameter.vue`
分别生成智能体和工具字段,共用 `ParameterForm.vue` 的输入、事件引用、初始化和校验;
`types.ts` 仅维护跨组件使用的字段描述类型,不再单独拆分每个组件专用的参数工具文件。
初始化只补全缺失值,不覆盖已有自定义配置;切回定时或移除全部事件参数时,引用参数恢复自定义默认值。
智能体包含 Question、启用的文件类型、用户输入和接口参数;工具包含普通输入和工作流用户输入。
抽屉采用类型卡片选择,选中卡片内显示配置,触发周期与 Cron 通过切换按钮切换;新建时需选择周期。
`trigger/trigger-form/task-execution/TriggerTaskGroups.vue` 维护任务分组、展开收起、移除及参数表单,
`trigger/trigger-form/task-execution/TaskExecution.vue` 维护任务分组、展开收起、移除及参数表单,
组件内管理智能体与工具选择弹窗、资源详情加载和任务参数保留,通过 `v-model` 回写任务、
`v-model:loading` 同步加载状态、`change` 通知清理校验,并提供 `validate`、`expandAll`、`reset`。
任务 UI 沿用 AI Chat 技能区的 `MkCollapse` 分组和紧凑资源卡片,参数区折叠后保留挂载以支持完整校验
任务 UI 沿用 AI Chat 技能区的 `MkCollapse` 分组和紧凑资源卡片,保存前先展开全部任务,待参数表单挂载后统一校验
抽屉负责触发器详情查询与保存,将详情资源快照通过 `initialResources` 传入任务组件;
任务组件新增资源后展开任务,抽屉保存时调用分组组件校验全部参数。
保存时校验所有任务,包括折叠的任务;接口失败保持抽屉打开。
Expand Down
2 changes: 1 addition & 1 deletion ui/src/views/system/chat/users/UserFromDrawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ defineExpose({ open })
<el-input v-model="userForm.password" readonly>
<template #suffix>
<el-button text @click="copyText(userForm.password)" class="-mr-1">
<mk-icon name="icon_copy_outlined" class="text-N600"></mk-icon>
<MkIcon name="icon_copy_outlined" class="text-N600" />
</el-button>
</template>
</el-input>
Expand Down
2 changes: 1 addition & 1 deletion ui/src/views/system/chat/users/UserListView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ onMounted(() => loadChatUsers())
<!-- 编辑 -->
<el-tooltip content="编辑" placement="top">
<el-button type="primary" text @click.stop="handleOpenUserFormDrawer(row)">
<mk-icon name="icon_edit_outlined"></mk-icon>
<MkIcon name="icon_edit_outlined" />
</el-button>
</el-tooltip>
<!-- 修改用户密码 -->
Expand Down
2 changes: 1 addition & 1 deletion ui/src/views/system/identity/users/UserFromDrawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ defineExpose({ open })
<el-input v-model="userForm.password" readonly>
<template #suffix>
<el-button text @click="copyText(userForm.password)" class="-mr-1">
<mk-icon name="icon_copy_outlined" class="text-N600"></mk-icon>
<MkIcon name="icon_copy_outlined" class="text-N600" />
</el-button>
</template>
</el-input>
Expand Down
4 changes: 2 additions & 2 deletions ui/src/views/system/identity/users/UserListView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,15 @@ onMounted(() => loadSystemUsers())
<!-- 编辑 -->
<el-tooltip content="编辑" placement="top">
<el-button type="primary" text @click.stop="handleOpenUserFormDrawer(row)">
<mk-icon name="icon_edit_outlined"></mk-icon>
<MkIcon name="icon_edit_outlined" />
</el-button>
</el-tooltip>
<!-- 修改用户密码 -->
<UserPwdButton :user="row" @refresh="loadSystemUsers(false)" />
<!-- 删除 -->
<el-tooltip content="删除" placement="top">
<el-button type="primary" text @click.stop="deleteUser(row)">
<mk-icon name="icon_delete-trash_outlined"></mk-icon>
<MkIcon name="icon_delete-trash_outlined" />
</el-button>
</el-tooltip>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ function getTypeLabel(inputType: string) {
<section>
<div class="mb-4 flex-between">
<h4 class="mk-title-decoration">启动参数</h4>
<el-button link type="primary" @click="handleOpenInitField()">
<el-button text type="primary" @click="handleOpenInitField()">
<MkIcon name="icon_add_outlined" />
<span>添加</span>
</el-button>
</div>
<MkTable :data="initFields" size="small">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ function handleDeleteInputField(index: number) {
<h4 class="mk-title-decoration">输入参数</h4>
<span class="text-N600">使用工具时显示</span>
</div>
<el-button link type="primary" @click="handleOpenInputField()">
<el-button text type="primary" @click="handleOpenInputField()">
<MkIcon name="icon_add_outlined" />
<span>添加</span>
</el-button>
</div>
<MkTable :data="inputFields" size="small">
Expand Down
4 changes: 2 additions & 2 deletions ui/src/views/trigger/TriggerView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,14 @@ onMounted(() => loadTriggers())
<!-- 编辑当前触发器 -->
<el-tooltip content="编辑" placement="top">
<el-button type="primary" text @click.stop="handleOpenTriggerDrawer(row)">
<mk-icon name="icon_edit_outlined"></mk-icon>
<MkIcon name="icon_edit_outlined" />
</el-button>
</el-tooltip>
<!-- 删除当前触发器 -->

<el-tooltip content="删除" placement="top">
<el-button type="primary" text @click.stop="handleDeleteTrigger(row)">
<mk-icon name="icon_delete-trash_outlined"></mk-icon>
<MkIcon name="icon_delete-trash_outlined" />
</el-button>
</el-tooltip>
</div>
Expand Down
22 changes: 10 additions & 12 deletions ui/src/views/trigger/trigger-form/TriggerFormDrawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import TriggerApi from '@/api/admin/workspace/trigger/trigger'
import { ADMIN_API_BASE_PATH } from '@/api/constants'
import { RESOURCE_TYPE, TRIGGER_TYPE, TRIGGER_SCHEDULE_TYPE as SCHEDULE, TRIGGER_INTERVAL_UNIT as INTERVAL } from '@/api/enums'
import type { ApplicationDetail, ToolItem, TriggerPayload, TriggerSetting } from '@/api/types'
import TriggerTaskGroups from './task-execution/TriggerTaskGroups.vue'
import TaskExecution from './task-execution/TaskExecution.vue'
import RequestParameters from './request-parameters/RequestParameters.vue'
import { copyText } from '@/utils/clipboard'
import { MsgSuccess } from '@/utils/message'
Expand All @@ -21,7 +21,7 @@ const detailFailed = ref(false)
const editingId = ref<string>()
const formRef = ref<FormInstance>()
const presetScheduleType = ref<TriggerSetting['schedule_type']>()
const taskGroupsRef = ref<InstanceType<typeof TriggerTaskGroups>>()
const taskExecutionRef = ref<InstanceType<typeof TaskExecution>>()
const resources = ref<Record<string, Partial<ApplicationDetail & ToolItem>>>({})

// HTTP 部署中 randomUUID 可能不可用,使用浏览器安全随机数生成 UUID。
Expand Down Expand Up @@ -184,10 +184,9 @@ function handleSave() {
form.value.name = form.value.name.trim()
saving.value = true
return nextTick()
.then(() => Promise.all([formRef.value?.validate().catch(() => false), taskGroupsRef.value?.validate()]))
.then(() => Promise.all([formRef.value?.validate().catch(() => false), taskExecutionRef.value?.validate()]))
.then((validations) => {
if (validations.some((valid) => !valid)) {
taskGroupsRef.value?.expandAll()
return
}
const payload = cloneDeep(form.value)
Expand Down Expand Up @@ -226,7 +225,7 @@ function resetData() {
saving.value = false
detailFailed.value = false
resources.value = {}
taskGroupsRef.value?.reset()
taskExecutionRef.value?.reset()
presetScheduleType.value = undefined
formRef.value?.clearValidate()
}
Expand Down Expand Up @@ -293,7 +292,7 @@ defineExpose({ open })
<el-input v-model="eventUrl" readonly>
<template #suffix>
<el-button text @click="copyText(eventUrl)" class="-mr-1">
<mk-icon name="icon_copy_outlined" class="text-N600"></mk-icon>
<MkIcon name="icon_copy_outlined" class="text-N600" />
</el-button>
</template>
</el-input>
Expand All @@ -303,16 +302,16 @@ defineExpose({ open })
<el-input v-model="form.trigger_setting.token" readonly>
<template #suffix>
<el-button text @click="copyText(form.trigger_setting.token)">
<mk-icon name="icon_copy_outlined" class="text-N600"></mk-icon>
<MkIcon name="icon_copy_outlined" class="text-N600" />
</el-button>
<!-- 刷新Token -->
<el-button text @click="handleRefreshToken" class="-mr-1">
<mk-icon name="icon_refresh_outlined" class="text-N600"></mk-icon>
<MkIcon name="icon_refresh_outlined" class="text-N600" />
</el-button>
</template>
</el-input>
<!-- 请求参数 -->
<RequestParameters v-model="form.trigger_setting.body" />
<!-- <RequestParameters v-model="form.trigger_setting.body" /> -->
</template>
</div>
</el-form-item>
Expand All @@ -323,12 +322,11 @@ defineExpose({ open })
<!-- 任务执行 -->
<el-form-item label="任务执行" prop="trigger_task">
<div class="mk-gray-card w-full p-4! rounded-xl!">
<TriggerTaskGroups
ref="taskGroupsRef"
<TaskExecution
ref="taskExecutionRef"
v-model="form.trigger_task"
:initial-resources="resources"
v-model:loading="loading"
:active="visible"
:trigger-type="form.trigger_type"
:body="form.trigger_setting.body ?? []"
:disabled="saving || loading"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ function saveField(field: TriggerBodyField, index?: number) {
<div class="flex-between mt-4 mb-2">
<h6>请求参数</h6>
<!-- 添加请求参数 -->
<el-button link type="primary" @click="dialogRef?.open()">添加参数</el-button>
<el-button text type="primary" @click="dialogRef?.open()">
<MkIcon name="icon_add_outlined" />
</el-button>
</div>
<MkFormList v-model="fields" :default-item="defaultField" :min-rows="0" :first-row-has-label="false" :show-add-button="false">
<template #default="{ item, index }">
Expand Down
Loading
Loading