mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
feat: update folder retrieval to include id and refactor folder path handling
This commit is contained in:
parent
7b9fae5d24
commit
a23f34b224
|
|
@ -6,7 +6,17 @@ import { type Ref } from 'vue'
|
|||
|
||||
const prefix = '/system/resource/application'
|
||||
|
||||
|
||||
/**
|
||||
* 获取全部应用
|
||||
* @param param
|
||||
* @param loading
|
||||
*/
|
||||
const getAllApplication: (param?: any, loading?: Ref<boolean>) => Promise<Result<any[]>> = (
|
||||
param,
|
||||
loading,
|
||||
) => {
|
||||
return get(`${prefix}`, param, loading)
|
||||
}
|
||||
/**
|
||||
* 获取分页应用
|
||||
* param {
|
||||
|
|
@ -314,6 +324,7 @@ const getMcpTools: (application_id: string, loading?: Ref<boolean>) => Promise<R
|
|||
}
|
||||
|
||||
export default {
|
||||
getAllApplication,
|
||||
getApplication,
|
||||
putApplication,
|
||||
delApplication,
|
||||
|
|
|
|||
|
|
@ -2,14 +2,8 @@ import { Result } from '@/request/Result'
|
|||
import { get, post, del, put } from '@/request/index'
|
||||
import { type Ref } from 'vue'
|
||||
|
||||
import useStore from '@/stores'
|
||||
const prefix: any = { _value: '/workspace/' }
|
||||
Object.defineProperty(prefix, 'value', {
|
||||
get: function () {
|
||||
const { user } = useStore()
|
||||
return this._value + user.getWorkspaceId()
|
||||
},
|
||||
})
|
||||
const prefix = '/system/resource'
|
||||
|
||||
|
||||
/**
|
||||
* 获得文件夹列表
|
||||
|
|
@ -22,7 +16,7 @@ const getFolder: (
|
|||
data?: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<Array<any>>> = (source, data, loading) => {
|
||||
return get(`${prefix.value}/${source}/folder`, data, loading)
|
||||
return get(`${prefix}/${source}/folder`, data, loading)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -153,7 +153,9 @@ const props = defineProps({
|
|||
const emit = defineEmits(['clickNodes', 'onmousedown'])
|
||||
|
||||
const apiType = computed(() => {
|
||||
if (route.path.includes('resource-management')) {
|
||||
if (route.path.includes('shared')) {
|
||||
return 'systemShare'
|
||||
} else if (route.path.includes('resource-management')) {
|
||||
return 'systemManage'
|
||||
} else {
|
||||
return 'workspace'
|
||||
|
|
@ -247,7 +249,7 @@ const toolTreeData = ref<any[]>([])
|
|||
const toolList = ref<any[]>([])
|
||||
|
||||
async function getToolFolder() {
|
||||
const res: any = await folder.asyncGetFolder(SourceTypeEnum.TOOL, {}, apiType.value, loading)
|
||||
const res: any = await folder.asyncGetFolder(SourceTypeEnum.TOOL, {id: props.id}, apiType.value, loading)
|
||||
toolTreeData.value = res.data
|
||||
folder.setCurrentFolder(res.data?.[0] || {})
|
||||
}
|
||||
|
|
@ -256,7 +258,7 @@ async function getToolList() {
|
|||
const res = await loadSharedApi({
|
||||
type: 'tool',
|
||||
isShared: folder.currentFolder?.id === 'share',
|
||||
systemType: 'workspace',
|
||||
systemType: apiType.value,
|
||||
}).getToolList({
|
||||
folder_id: folder.currentFolder?.id || user.getWorkspaceId(),
|
||||
tool_type: 'CUSTOM',
|
||||
|
|
@ -269,7 +271,7 @@ const applicationTreeData = ref<any[]>([])
|
|||
const applicationList = ref<any[]>([])
|
||||
|
||||
function getApplicationFolder() {
|
||||
folder.asyncGetFolder(SourceTypeEnum.APPLICATION, {}, apiType.value, loading).then((res: any) => {
|
||||
folder.asyncGetFolder(SourceTypeEnum.APPLICATION, {id: props.id}, apiType.value, loading).then((res: any) => {
|
||||
applicationTreeData.value = res.data
|
||||
folder.setCurrentFolder(res.data?.[0] || {})
|
||||
})
|
||||
|
|
@ -278,7 +280,7 @@ function getApplicationFolder() {
|
|||
async function getApplicationList() {
|
||||
const res = await loadSharedApi({
|
||||
type: 'application',
|
||||
systemType: 'workspace',
|
||||
systemType: apiType.value,
|
||||
}).getAllApplication({
|
||||
folder_id: folder.currentFolder?.id || user.getWorkspaceId(),
|
||||
})
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ const toolTreeData = ref<any[]>([])
|
|||
const toolList = ref<any[]>([])
|
||||
|
||||
async function getToolFolder() {
|
||||
const res: any = await folder.asyncGetFolder(SourceTypeEnum.TOOL, {}, apiType.value, loading)
|
||||
const res: any = await folder.asyncGetFolder(SourceTypeEnum.TOOL, {id: props.id}, apiType.value, loading)
|
||||
toolTreeData.value = res.data
|
||||
folder.setCurrentFolder(res.data?.[0] || {})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -230,7 +230,7 @@ const toolTreeData = ref<any[]>([])
|
|||
const toolList = ref<any[]>([])
|
||||
|
||||
async function getToolFolder() {
|
||||
const res: any = await folder.asyncGetFolder(SourceTypeEnum.TOOL, {}, apiType.value, loading)
|
||||
const res: any = await folder.asyncGetFolder(SourceTypeEnum.TOOL, {id: props.id}, apiType.value, loading)
|
||||
toolTreeData.value = res.data
|
||||
folder.setCurrentFolder(res.data?.[0] || {})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue