Skip to content

Commit f855997

Browse files
feat: prompt generate
1 parent 07a4180 commit f855997

14 files changed

Lines changed: 105 additions & 72 deletions

File tree

‎ui/src/api/API_README.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ FormData;保存返回完整配置,页面以该返回值作为唯一数据来
9696

9797
### 四类特殊资源 API
9898

99+
根据资源范围或业务上下文选择出的 API 对象统一命名为 `requestApi`,包括 `computed` 结果和
100+
局部变量,不使用 `toolApi`、`authorizationApi` 或 `request` 等名称。同一作用域确需同时使用
101+
多套 API 时,以 `request` 为前缀加业务名区分,例如 `requestModelApi`、`requestToolApi`。
102+
直接导入的 API 保持 PascalCase 命名;请求返回的 Promise 不属于此命名规则。
103+
99104
`application`、`knowledge`、`model`、`tool` 是需要同时考虑 Workspace、System 资源管理和
100105
System 共享资源的四类特殊资源。其接口按真实后端边界分别维护在 `admin/workspace/` 与
101106
`admin/system/` 下,不把不同范围的 URL 合并为页面侧 API Map,也不让卡片或 Action 根据路由拼接

‎ui/src/components/COMPONENT_README.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,9 @@ Python 与 JSON 编辑器通过 `<style lang="scss" scoped src="./style.scss">`
480480
编辑器单独设置高度。不在全局 `app.scss` 中覆盖 `.cm-editor`。
481481

482482
基于 CodeMirror 6 的 Python 代码编辑器,通过 `v-model` 管理代码,并在组件内部调用工具 pylint
483-
接口生成诊断。组件最多展示 50 条诊断,并在代码停止输入 500ms 后检查。编辑器提供内置全屏
483+
接口生成诊断。组件通过资源上下文方法判断当前路由范围,分别选择 Workspace、System 资源管理
484+
或 System 共享资源的工具 API;普通编辑与全屏编辑使用相同的接口选择逻辑。
485+
组件最多展示 50 条诊断,并在代码停止输入 500ms 后检查。编辑器提供内置全屏
484486
入口;全屏确认时更新 `v-model` 并触发 `submit-dialog`,`header-extra` 插槽用于添加全屏标题栏操作。
485487

486488
### JsonInput

‎ui/src/components/business/resource-authorization-drawer/index.vue‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const folderData = ref<FolderItem>()
3232
const submitting = ref(false)
3333
3434
/* System 资源管理使用专属用户/用户组授权接口,工作空间沿用现有接口。 */
35-
const authorizationApi = computed(() => (isSystemResource() ? SystemResourceAuthorizationApi : ResourceAuthorizationApi))
35+
const requestApi = computed(() => (isSystemResource() ? SystemResourceAuthorizationApi : ResourceAuthorizationApi))
3636
3737
/* 资源类型与权限选项 */
3838
const folderPermissionMap = {
@@ -105,13 +105,13 @@ function submitPermissions(permission: ResourcePermission, includeChildren: bool
105105
const authorizationRef = isUserGroup ? userGroupAuthorizationRef.value : userAuthorizationRef.value
106106
submitting.value = true
107107
const request = isUserGroup
108-
? authorizationApi.value.putResourceUserGroupAuthorization(
108+
? requestApi.value.putResourceUserGroupAuthorization(
109109
workspaceId,
110110
targetId.value,
111111
authorizationType.value,
112112
pendingSubjectIds.value.map((id) => ({ user_group_id: id, ...permissionScope })),
113113
)
114-
: authorizationApi.value.putResourceAuthorization(
114+
: requestApi.value.putResourceAuthorization(
115115
workspaceId,
116116
targetId.value,
117117
authorizationType.value,
@@ -164,7 +164,7 @@ defineExpose({ open })
164164
v-if="targetType === 'user-group' && targetId && workspaceId"
165165
:key="targetId"
166166
:submitting="submitting"
167-
:api="authorizationApi"
167+
:api="requestApi"
168168
:workspace-id="workspaceId"
169169
:target-id="targetId"
170170
:type="authorizationType"
@@ -177,7 +177,7 @@ defineExpose({ open })
177177
v-if="targetType === 'user' && targetId && workspaceId"
178178
:key="targetId"
179179
:submitting="submitting"
180-
:api="authorizationApi"
180+
:api="requestApi"
181181
:workspace-id="workspaceId"
182182
:target-id="targetId"
183183
:type="authorizationType"

‎ui/src/components/business/select-model/index.vue‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@ function getProviderIcon(modelId: unknown) {
8787
// 创建模型:根据当前资源范围传入完整 API,创建后由调用方刷新选项。
8888
const selectRef = useTemplateRef<SelectInstance>('selectRef')
8989
const allModelProvider: ModelProviderItem = { icon: '', name: '全部模型', provider: 'all' }
90-
const createModelApi = computed(() => {
90+
const requestApi = computed(() => {
9191
if (isWorkspaceResource()) return ModelApi
9292
if (isSystemSharedResource()) return SystemSharedModelApi
9393
return undefined
9494
})
9595
9696
function handleOpenCreateModel(open: () => void) {
97-
if (props.disabled || !props.canAdd || !createModelApi.value) return
97+
if (props.disabled || !props.canAdd || !requestApi.value) return
9898
selectRef.value?.blur()
9999
open()
100100
}
@@ -157,9 +157,9 @@ function openModelParams() {
157157
</div>
158158
</template>
159159

160-
<template v-if="canAdd && createModelApi" #footer>
160+
<template v-if="canAdd && requestApi" #footer>
161161
<slot name="footer">
162-
<ButtonAddModel :api="createModelApi" :current-provider="allModelProvider" :providers="providerOptions" @refresh="emit('refresh')">
162+
<ButtonAddModel :api="requestApi" :current-provider="allModelProvider" :providers="providerOptions" @refresh="emit('refresh')">
163163
<template #default="{ open }">
164164
<el-button type="primary" link :disabled="disabled" @click.stop="handleOpenCreateModel(open)">
165165
<MkIcon name="icon_add_outlined" />

‎ui/src/components/codemirror-editor/python.vue‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
<script setup lang="ts">
2-
import { ref } from 'vue'
2+
import { computed, ref } from 'vue'
33
import type { EditorState } from '@codemirror/state'
44
import { linter, type Diagnostic } from '@codemirror/lint'
55
import { python } from '@codemirror/lang-python'
66
import { Codemirror } from 'vue-codemirror'
77
import ToolApi from '@/api/admin/workspace/tool/tool'
8+
import SystemResourceToolApi from '@/api/admin/system/resource-management/tool/tool'
9+
import SystemSharedToolApi from '@/api/admin/system/shared-resources/tool/tool'
810
import type { ToolPylintIssue } from '@/api/types'
11+
import { isSystemResource, isSystemSharedResource } from '@/utils/resource-context'
912
1013
defineOptions({ name: 'PythonCodeEditor', inheritAttrs: false })
1114
@@ -16,6 +19,13 @@ const emit = defineEmits<{ submitDialog: [code: string] }>()
1619
1720
defineSlots<{ 'header-extra'?(): unknown }>()
1821
22+
// Python 校验使用当前资源范围的工具接口。
23+
const requestApi = computed(() => {
24+
if (isSystemResource()) return SystemResourceToolApi
25+
if (isSystemSharedResource()) return SystemSharedToolApi
26+
return ToolApi
27+
})
28+
1929
function getDocumentPosition(state: EditorState, line: number, column: number) {
2030
const safeLine = Math.max(1, Math.min(line, state.doc.lines))
2131
const documentLine = state.doc.line(safeLine)
@@ -35,7 +45,8 @@ const codeLinter = linter(
3545
const lintSource = view.state.doc.toString()
3646
if (!lintSource.trim()) return []
3747
38-
return ToolApi.postToolPylint(lintSource)
48+
return requestApi.value
49+
.postToolPylint(lintSource)
3950
.then((issues) => {
4051
if (lintSource !== view.state.doc.toString()) return []
4152
return issues.slice(0, 50).map((issue) => createDiagnostic(view.state, issue))

‎ui/src/components/global/mk-icon/LoadingIcon.vue‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ const loadingSize = computed(() => (typeof props.size === 'number' ? `${props.si
2222
</template>
2323
<style scoped lang="scss">
2424
.loading-icon {
25+
:deep(.el-loading-spinner .circular) {
26+
display: block;
27+
margin-inline: auto;
28+
}
29+
2530
:deep(.el-loading-spinner .path) {
2631
stroke-width: 4px;
2732
}

‎ui/src/constants/theme.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const DEFAULT_THEME_SETTING = { icon: '', loginLogo: '', loginImage: '',
2424

2525
export const DEFAULT_PLATFORM_SETTING = {
2626
showUserManual: true,
27-
userManualUrl: 'https://maxkb.cn/docs/v2/',
27+
userManualUrl: 'https://docs.fit2cloud.com/maxkb/',
2828
showForum: true,
2929
forumUrl: 'https://bbs.fit2cloud.com/c/mk/11',
3030
showProject: true,

‎ui/src/views/knowledge/index.vue‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ function handleSearchChange(query?: Dict<unknown>) {
8181
}
8282
8383
function loadKnowledgePage(pagination: { currentPage: number; pageSize: number }) {
84-
const request = isShared.value ? SharedApi : KnowledgeApi
84+
const requestApi = isShared.value ? SharedApi : KnowledgeApi
8585
const folderId = isShared.value ? {} : { folder_id: currentFolder.value.id || FOLDER_ENTRY_ID.ALL }
86-
return request.getKnowledgePage(pagination, { ...knowledgeQuery.value, ...folderId })
86+
return requestApi.getKnowledgePage(pagination, { ...knowledgeQuery.value, ...folderId })
8787
}
8888
8989
/* 知识库维护 */

‎ui/src/views/tool/index.vue‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ function handleSearchChange(query?: Dict<unknown>) {
7676
const toolType = ref<ToolType | ''>('')
7777
7878
function loadToolsPage(pagination: { currentPage: number; pageSize: number }) {
79-
const request = isShared.value ? SharedApi : ToolApi
79+
const requestApi = isShared.value ? SharedApi : ToolApi
8080
const folderId = isShared.value ? {} : { folder_id: currentFolder.value.id || FOLDER_ENTRY_ID.ALL }
81-
return request.getToolPage(pagination, { ...toolQuery.value, tool_type: toolType.value, ...folderId })
81+
return requestApi.getToolPage(pagination, { ...toolQuery.value, tool_type: toolType.value, ...folderId })
8282
}
8383
8484
// 加载工具商店

‎ui/src/views/tool/tool-store/ApplyStoreToolDialog.vue‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ function handleSubmit() {
4545
4646
const commonPayload = { folder_id: props.folderId || 'default', name }
4747
const isSharedResource = isSystemSharedResource()
48-
const toolApi = isSharedResource ? SystemSharedToolApi : ToolApi
49-
const toolStoreApi = isSharedResource ? SystemSharedToolStoreApi : WorkspaceToolStoreApi
5048
let request: Promise<ToolItem>
5149
5250
if (tool.label === 'workflow_template') {
53-
request = toolApi.postTool({ ...commonPayload, code: '{}', tool_type: TOOL_TYPE.WORKFLOW, work_flow_template: tool })
51+
const requestApi = isSharedResource ? SystemSharedToolApi : ToolApi
52+
request = requestApi.postTool({ ...commonPayload, code: '{}', tool_type: TOOL_TYPE.WORKFLOW, work_flow_template: tool })
5453
} else {
55-
request = toolStoreApi.postStoreTool(tool.id, {
54+
const requestApi = isSharedResource ? SystemSharedToolStoreApi : WorkspaceToolStoreApi
55+
request = requestApi.postStoreTool(tool.id, {
5656
...commonPayload,
5757
download_callback_url: tool.downloadCallbackUrl ?? '',
5858
download_url: tool.downloadUrl ?? '',

0 commit comments

Comments
 (0)