fix:loading

This commit is contained in:
yujiangping
2026-03-09 16:45:48 +08:00
parent e1939ef472
commit 0f221b7ee6
2 changed files with 40 additions and 31 deletions

View File

@@ -4,7 +4,7 @@
* @Author: yujiangping * @Author: yujiangping
* @Date: 2025-11-10 18:52:55 * @Date: 2025-11-10 18:52:55
* @LastEditors: yujiangping * @LastEditors: yujiangping
* @LastEditTime: 2026-03-03 14:46:08 * @LastEditTime: 2026-03-09 16:39:07
*/ */
import { forwardRef, useImperativeHandle, useState, useRef } from 'react'; import { forwardRef, useImperativeHandle, useState, useRef } from 'react';
import { Switch } from 'antd'; import { Switch } from 'antd';
@@ -58,6 +58,8 @@ const ShareModal = forwardRef<ShareModalRef,ShareModalRefProps>(({ handleShare:
} }
const handleShare = async() => { const handleShare = async() => {
setLoading(true);
try {
const workspaceIds = spaceList const workspaceIds = spaceList
.map(item => item.target_kb?.workspace_id) .map(item => item.target_kb?.workspace_id)
.filter(Boolean) .filter(Boolean)
@@ -68,6 +70,9 @@ const ShareModal = forwardRef<ShareModalRef,ShareModalRefProps>(({ handleShare:
// Close modal after sharing // Close modal after sharing
handleClose(); handleClose();
} finally {
setLoading(false);
}
} }
const handleChange = (checked: boolean, item: any) => { const handleChange = (checked: boolean, item: any) => {
// Toggle shared knowledge base status // Toggle shared knowledge base status

View File

@@ -4,7 +4,7 @@
* @Author: yujiangping * @Author: yujiangping
* @Date: 2025-11-10 18:52:55 * @Date: 2025-11-10 18:52:55
* @LastEditors: yujiangping * @LastEditors: yujiangping
* @LastEditTime: 2025-12-03 18:44:58 * @LastEditTime: 2026-03-09 16:34:51
*/ */
import { forwardRef, useImperativeHandle, useState } from 'react'; import { forwardRef, useImperativeHandle, useState } from 'react';
import { Switch } from 'antd'; import { Switch } from 'antd';
@@ -50,16 +50,17 @@ const ShareModal = forwardRef<ShareModalRef,ShareModalRefProps>(({ handleShare:
setSpaceList(filteredItems as SpaceItem[]); setSpaceList(filteredItems as SpaceItem[]);
} }
const handleShare = async() => { const handleShare = async() => {
// Get all data with checked = true // Get all data with checked = true
const checkedItems = spaceList.filter(item => item.is_active); const checkedItems = spaceList.filter(item => item.is_active);
debugger
// Get currently selected item (corresponding to curIndex) // Get currently selected item (corresponding to curIndex)
const selectedItem = curIndex !== -1 ? spaceList[curIndex] : null; const selectedItem = curIndex !== -1 ? spaceList[curIndex] : null;
if(!selectedItem){ if(!selectedItem){
messageApi.error(t('knowledgeBase.selectSpace')); messageApi.error(t('knowledgeBase.selectSpace'));
return; return;
} }
setLoading(true);
try {
const payload = { const payload = {
source_kb_id: kbId ?? '', source_kb_id: kbId ?? '',
target_workspace_id: selectedItem?.id ?? '', target_workspace_id: selectedItem?.id ?? '',
@@ -78,6 +79,9 @@ const ShareModal = forwardRef<ShareModalRef,ShareModalRefProps>(({ handleShare:
// Close modal after sharing // Close modal after sharing
handleClose(); handleClose();
} finally {
setLoading(false);
}
} }
const handleClick = (index: number, checked: boolean) => { const handleClick = (index: number, checked: boolean) => {
if (!checked) return; if (!checked) return;