perf: Fix some style bugs

This commit is contained in:
wangdan-fit2cloud 2025-12-09 19:09:34 +08:00
parent d68acede6f
commit cc3607936e
15 changed files with 88 additions and 40 deletions

View File

@ -0,0 +1,33 @@
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()
},
})
/**
*
* @params
* source : APPLICATION, KNOWLEDGE, TOOL
* data : {name: string}
*/
const getFolder: (
source: string,
data?: any,
loading?: Ref<boolean>,
) => Promise<Result<Array<any>>> = (source, data, loading) => {
return get(`${prefix.value}/${source}/folder`, data, loading)
}
export default {
getFolder,
}

View File

@ -50,7 +50,7 @@
</template>
<script setup lang="ts">
import { ref, watch, reactive } from 'vue'
import folderApi from '@/api/folder'
import folderApi from '@/api/workspace/folder'
import { MsgSuccess, MsgAlert } from '@/utils/message'
import { t } from '@/locales'
import useStore from '@/stores'
@ -138,7 +138,7 @@ const submitHandle = async () => {
.then((res) => {
MsgSuccess(t('common.createSuccess'))
folder.setCurrentFolder(res.data)
folder.asyncGetFolder(sourceType.value, {}, loading)
folder.asyncGetFolder(sourceType.value, {}, 'workspace',loading)
clearData()
emit('refresh')
dialogVisible.value = false

View File

@ -30,7 +30,7 @@
</template>
<script setup lang="ts">
import { ref, watch, reactive } from 'vue'
import folderApi from '@/api/folder'
import folderApi from '@/api/workspace/folder'
import { MsgError, MsgSuccess } from '@/utils/message'
import { t } from '@/locales'
import useStore from '@/stores'
@ -77,7 +77,7 @@ const open = (data: any, is_folder?: any) => {
function getFolder() {
const params = {}
folder.asyncGetFolder(props.source, params, loading).then((res: any) => {
folder.asyncGetFolder(props.source, params, 'workspace', loading).then((res: any) => {
folderList.value = res.data
if (folderList.value?.length > 0) {
currentNodeKey.value = folderList.value[0]?.id
@ -154,7 +154,7 @@ defineExpose({ open })
border-radius: 6px;
}
:deep(.el-tree) {
height: calc(100vh - 320px)!important;
height: calc(100vh - 320px) !important;
}
}
</style>

View File

@ -140,7 +140,7 @@ import ResourceAuthorizationDrawer from '@/components/resource-authorization-dra
import { t } from '@/locales'
import MoveToDialog from '@/components/folder-tree/MoveToDialog.vue'
import { i18n_name } from '@/utils/common'
import folderApi from '@/api/folder'
import folderApi from '@/api/workspace/folder'
import { EditionConst } from '@/utils/permission/data'
import { hasPermission } from '@/utils/permission/index'
import useStore from '@/stores'

View File

@ -247,7 +247,7 @@ const toolTreeData = ref<any[]>([])
const toolList = ref<any[]>([])
async function getToolFolder() {
const res: any = await folder.asyncGetFolder(SourceTypeEnum.TOOL, {}, loading)
const res: any = await folder.asyncGetFolder(SourceTypeEnum.TOOL, {}, apiType.value, loading)
toolTreeData.value = res.data
folder.setCurrentFolder(res.data?.[0] || {})
}
@ -269,7 +269,7 @@ const applicationTreeData = ref<any[]>([])
const applicationList = ref<any[]>([])
function getApplicationFolder() {
folder.asyncGetFolder(SourceTypeEnum.APPLICATION, {}, loading).then((res: any) => {
folder.asyncGetFolder(SourceTypeEnum.APPLICATION, {}, apiType.value, loading).then((res: any) => {
applicationTreeData.value = res.data
folder.setCurrentFolder(res.data?.[0] || {})
})
@ -309,6 +309,4 @@ async function handleClick(val: string) {
onMounted(() => {})
</script>
<style lang="scss" scoped>
</style>
<style lang="scss" scoped></style>

View File

@ -210,7 +210,7 @@ const toolTreeData = ref<any[]>([])
const toolList = ref<any[]>([])
async function getToolFolder() {
const res: any = await folder.asyncGetFolder(SourceTypeEnum.TOOL, {}, loading)
const res: any = await folder.asyncGetFolder(SourceTypeEnum.TOOL, {}, apiType.value, loading)
toolTreeData.value = res.data
folder.setCurrentFolder(res.data?.[0] || {})
}
@ -237,7 +237,9 @@ function folderClickHandle(row: any) {
async function handleClick(val: string) {
if (['DATA_SOURCE_TOOL', 'CUSTOM_TOOL'].includes(val)) {
await getToolFolder()
if (!route.path.includes('shared')) {
await getToolFolder()
}
getToolList()
}
}

View File

@ -230,7 +230,7 @@ const toolTreeData = ref<any[]>([])
const toolList = ref<any[]>([])
async function getToolFolder() {
const res: any = await folder.asyncGetFolder(SourceTypeEnum.TOOL, {}, loading)
const res: any = await folder.asyncGetFolder(SourceTypeEnum.TOOL, {}, apiType.value, loading)
toolTreeData.value = res.data
folder.setCurrentFolder(res.data?.[0] || {})
}
@ -257,7 +257,9 @@ function folderClickHandle(row: any) {
async function handleClick(val: string) {
if (['DATA_SOURCE_TOOL', 'CUSTOM_TOOL'].includes(val)) {
await getToolFolder()
if (!route.path.includes('shared')) {
await getToolFolder()
}
getToolList()
}
}

View File

@ -1,6 +1,6 @@
import { defineStore } from 'pinia'
import { type Ref } from 'vue'
import folderApi from '@/api/folder'
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
const useFolderStore = defineStore('folder', {
state: () => ({
@ -10,14 +10,18 @@ const useFolderStore = defineStore('folder', {
setCurrentFolder(folder: any) {
this.currentFolder = folder
},
async asyncGetFolder(source: string, data: any, loading?: Ref<boolean>) {
async asyncGetFolder(source: string, data: any, systemType: any, loading?: Ref<boolean>) {
return new Promise((resolve, reject) => {
folderApi
loadSharedApi({
type: 'folder',
isShared: this.currentFolder?.id === 'share',
systemType,
})
.getFolder(source, data, loading)
.then((res) => {
.then((res: any) => {
resolve(res)
})
.catch((error) => {
.catch((error: any) => {
reject(error)
})
})

View File

@ -19,6 +19,7 @@ import paragraphSystemShareApi from '@/api/system-shared/paragraph'
import problemSystemShareApi from '@/api/system-shared/problem'
import chatUserSystemShareApi from '@/api/system-shared/chat-user'
import workspaceApi from '@/api/workspace/workspace'
import folderWorkspaceApi from '@/api/workspace/folder'
import systemUserApi from '@/api/user/user'
import ToolResourceApi from '@/api/system-resource-management/tool'
import knowledgeResourceApi from '@/api/system-resource-management/knowledge'
@ -32,7 +33,7 @@ import applicationKeyResourceApi from '@/api/system-resource-management/applicat
import workflowVersionResourceApi from '@/api/system-resource-management/workflow-version'
import chatLogResourceApi from '@/api/system-resource-management/chat-log'
import resourceAuthorizationResourceApi from '@/api/system-resource-management/resource-authorization'
import folderResourceApi from '@/api/system-resource-management/folder'
// 普通 API
const workspaceApiMap = {
knowledge: knowledgeWorkspaceApi,
@ -48,6 +49,7 @@ const workspaceApiMap = {
workflowVersion: workflowVersionWorkspaceApi,
chatLog: chatLogWorkspaceApi,
resourceAuthorization: resourceAuthorizationWorkspaceApi,
folder: folderWorkspaceApi,
} as any
// 系统分享 API
@ -76,6 +78,7 @@ const systemManageApiMap = {
workflowVersion: workflowVersionResourceApi,
chatLog: chatLogResourceApi,
resourceAuthorization: resourceAuthorizationResourceApi,
folder: folderResourceApi,
} as any
const data = {

View File

@ -212,7 +212,7 @@ function folderClickHandle(row: any) {
function getFolder() {
const params = {}
folder.asyncGetFolder('KNOWLEDGE', params, folderLoading).then((res: any) => {
folder.asyncGetFolder('KNOWLEDGE', params,apiType.value, folderLoading).then((res: any) => {
folderList.value = res.data
currentFolder.value = res.data?.[0] || {}
getList()

View File

@ -183,7 +183,7 @@ function folderClickHandle(row: any) {
function getFolder() {
const params = {}
folder.asyncGetFolder('TOOL', params, folderLoading).then((res: any) => {
folder.asyncGetFolder('TOOL', params, apiType.value, folderLoading).then((res: any) => {
folderList.value = res.data
currentFolder.value = res.data?.[0] || {}
getList()

View File

@ -646,14 +646,16 @@ function openCreateFolder() {
function getFolder(bool?: boolean) {
const params = {}
folder.asyncGetFolder(SourceTypeEnum.APPLICATION, params, loading).then((res: any) => {
folderList.value = res.data
if (bool) {
//
folder.setCurrentFolder(res.data?.[0] || {})
}
getList()
})
folder
.asyncGetFolder(SourceTypeEnum.APPLICATION, params, apiType.value, loading)
.then((res: any) => {
folderList.value = res.data
if (bool) {
//
folder.setCurrentFolder(res.data?.[0] || {})
}
getList()
})
}
function clickFolder(item: any) {

View File

@ -52,13 +52,15 @@ const folderList = ref<any[]>([])
function getFolder(bool?: boolean) {
const params = {}
folder.asyncGetFolder(SourceTypeEnum.KNOWLEDGE, params, loading).then((res: any) => {
folderList.value = res.data
if (bool) {
//
folder.setCurrentFolder(res.data?.[0] || {})
}
})
folder
.asyncGetFolder(SourceTypeEnum.KNOWLEDGE, params, apiType.value, loading)
.then((res: any) => {
folderList.value = res.data
if (bool) {
//
folder.setCurrentFolder(res.data?.[0] || {})
}
})
}
function folderClickHandle(row: any) {

View File

@ -26,7 +26,9 @@
<el-radio-button value="">{{ $t('common.status.all') }}</el-radio-button>
<el-radio-button value="CUSTOM">{{ $t('views.tool.title') }}</el-radio-button>
<el-radio-button value="MCP">MCP</el-radio-button>
<el-radio-button value="DATA_SOURCE">{{ $t('views.tool.dataSource.title') }}</el-radio-button>
<el-radio-button value="DATA_SOURCE">{{
$t('views.tool.dataSource.title')
}}</el-radio-button>
</el-radio-group>
</el-space>
</template>
@ -65,7 +67,7 @@ const folderList = ref<any[]>([])
function getFolder(bool?: boolean) {
const params = {}
folder.asyncGetFolder(SourceTypeEnum.TOOL, params, loading).then((res: any) => {
folder.asyncGetFolder(SourceTypeEnum.TOOL, params, apiType.value, loading).then((res: any) => {
folderList.value = res.data
if (bool) {
//