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 @@ -208,6 +208,8 @@ Keep these behaviors:
## Frontend Implementation Notes

- Prefer existing project structure and naming.
- 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
why the current implementation exists. If the requested change is likely to remove a requirement
or introduce a regression, pause before editing, explain the risk, recommend a safer approach,
Expand Down
8 changes: 8 additions & 0 deletions ui/src/api/API_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,11 @@ System 资源管理的用户授权维护在 `admin/system/resource-management/re
由接口内部读取,loading 由组件管理。`ResourceAuthorizationDrawer` 内部通过
`isSystemResource()` 选择完整的用户授权 API 对象,作为该抽屉的范围选择例外;用户组仍使用
现有 Workspace 接口,不推测 System 用户组路径。

### 关联资源

`admin/workspace/related-resources.ts` 维护关联资源查询:
`getResourceDependencies` 查询当前资源依赖的资源,对应后端 `mapping_resource`;
`getResourceDependents` 查询引用当前资源的资源,对应后端 `resource_mapping`。
前端按关联资源语义命名,后端接口路径保持不变。该文件当前保留旧版请求签名,
尚未完成 v3 请求适配及页面接入。
7 changes: 1 addition & 6 deletions ui/src/api/admin/core/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ interface ExportRequestConfig extends AxiosRequestConfig {
skipGlobalErrorMessage?: boolean
}

interface StreamRequestConfig {
signal?: AbortSignal
}

function setRequestHeaders(config: InternalAxiosRequestConfig) {
const { auth, user } = useStore()

Expand Down Expand Up @@ -256,7 +252,7 @@ export async function downloadRequest(
}

/** 发送 POST 请求并返回可逐块读取的原始响应。 */
export function postStream(base: string, path: string, data?: unknown, config?: StreamRequestConfig): Promise<Response> {
export function postStream(base: string, path: string, data?: unknown): Promise<Response> {
const { auth, user } = useStore()
const headers: Record<string, string> = { 'Content-Type': 'application/json' }
if (auth.token) {
Expand All @@ -269,7 +265,6 @@ export function postStream(base: string, path: string, data?: unknown, config?:
method: 'POST',
headers,
body: data === undefined ? undefined : JSON.stringify(data),
signal: config?.signal,
})
}

Expand Down
4 changes: 2 additions & 2 deletions ui/src/api/admin/workspace/application/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ const putApplicationPublish = (applicationId: string) => {
}

/** 使用指定模型流式生成或优化系统提示词。 */
const postPromptGenerate = (applicationId: string, modelId: string, payload: PromptGeneratePayload, signal?: AbortSignal) => {
return postStream(ADMIN_API_BASE_PATH, `${getPrefix()}/${applicationId}/model/${modelId}/prompt_generate`, payload, { signal })
const postPromptGenerate = (applicationId: string, modelId: string, payload: PromptGeneratePayload) => {
return postStream(ADMIN_API_BASE_PATH, `${getPrefix()}/${applicationId}/model/${modelId}/prompt_generate`, payload)
}

export default {
Expand Down
33 changes: 33 additions & 0 deletions ui/src/api/admin/workspace/related-resources.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Result } from '@/request/Result'
import { get, put, post, del } from '@/request/index'
import type { Ref } from 'vue'
import type { pageRequest } from '@/api/type/common'
const prefix = '/workspace'

/** 获取引用当前资源的资源。 */
const getResourceDependents: (
workspace_id: string,
resource: string,
resource_id: string,
page: pageRequest,
params?: any,
loading?: Ref<boolean>,
) => Promise<Result<any>> = (workspace_id, resource, resource_id, page, params, loading) => {
return get(`${prefix}/${workspace_id}/resource_mapping/${resource}/${resource_id}/${page.current_page}/${page.page_size}`, params, loading)
}
/** 获取当前资源依赖的资源。 */
const getResourceDependencies: (
workspace_id: string,
resource: string,
resource_id: string,
page: pageRequest,
params?: any,
loading?: Ref<boolean>,
) => Promise<Result<any>> = (workspace_id, resource, resource_id, page, params, loading) => {
return get(`${prefix}/${workspace_id}/mapping_resource/${resource}/${resource_id}/${page.current_page}/${page.page_size}`, params, loading)
}

export default {
getResourceDependents,
getResourceDependencies,
}
11 changes: 11 additions & 0 deletions ui/src/components/COMPONENT_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ src/components/
│ │ └── ModelParamsDialog.vue # 模型参数动态表单弹窗
│ ├── workspace-dropdown/
│ │ └── index.vue # 工作空间选择下拉框
│ ├── related-resources-drawer/ # 关联资源查看抽屉(待完成 v3 接入)
│ │ └── index.vue
│ ├── resource-authorization-drawer/ # 资源用户组、用户授权抽屉与权限配置弹窗
│ │ ├── index.vue
│ │ ├── UserAuthorization.vue # 按用户查询与授权
Expand Down Expand Up @@ -171,6 +173,8 @@ import WorkspaceRelationTags from '@/components/business/workspace-relation-tags

## 组件约定

- 项目源码不编写 `aria-label` 属性。按钮前添加简短中文 HTML 备注说明实际用途,
例如 `<!-- 删除文件 -->`;已有用途备注时不重复添加。此规则适用于公共组件、页面和工作流节点。
- 高频、稳定、跨多数页面使用的基础组件放入 `global`。
- 跨页面复用且依赖业务类型、固定业务接口或领域交互的组件放入 `business/<component-name>`,
由使用方手动导入。业务组件不使用 `Mk` 前缀,也不再按 Workspace 等上级领域增加额外目录。
Expand Down Expand Up @@ -1369,3 +1373,10 @@ import WorkspaceRelationTags from '@/components/business/workspace-relation-tags
资源授权抽屉内部公共展示 Props 放在同目录 `types.ts`,权限选项类型从
`RESOURCE_PERMISSION_OPTIONS` 派生;用户和用户组 API Props 分别保留完整 API 对象类型,
用户组组件只接收具备用户组方法的 Workspace API。

### RelatedResourcesDrawer

关联资源查看抽屉,路径为 `business/related-resources-drawer/index.vue`,组件名为
`RelatedResourcesDrawer`。标题为“关联资源”,操作入口文案统一为“查看关联资源”;
两个方向分别显示“依赖的资源”和“引用此资源的资源”。
当前保留旧版实现,尚未完成 v3 请求、国际化依赖适配及页面接入。
Loading
Loading