Commit 94a7e78b by Liu

fix:kuan

parent dee25152
...@@ -81,7 +81,9 @@ export const Home: React.FC = () => { ...@@ -81,7 +81,9 @@ export const Home: React.FC = () => {
} }
// 处理工具按钮点击 // 处理工具按钮点击
const requestIdRef = useRef(0) // 标记最新请求,避免旧响应覆盖
const _handleToolClick = useCallback(async (isToolBtn: boolean, toolId?: string, ignoreUrlToolId?: boolean) => { const _handleToolClick = useCallback(async (isToolBtn: boolean, toolId?: string, ignoreUrlToolId?: boolean) => {
const currentRequestId = ++requestIdRef.current
// 提质增效模式 / 数据助手 / 通用模式:都先清空数据,重新拉常见问题 // 提质增效模式 / 数据助手 / 通用模式:都先清空数据,重新拉常见问题
setOtherQuestions((prev: any) => ({ setOtherQuestions((prev: any) => ({
...prev, ...prev,
...@@ -115,7 +117,8 @@ export const Home: React.FC = () => { ...@@ -115,7 +117,8 @@ export const Home: React.FC = () => {
const res = await fetchEfficiencyQuestionList({ const res = await fetchEfficiencyQuestionList({
toolId: sessionToolId || finalToolId, toolId: sessionToolId || finalToolId,
}) })
if (res && res.data && res.data.questions) { // 只接受当前最新的请求结果,避免旧请求覆盖新请求
if (currentRequestId === requestIdRef.current && res?.data?.questions) {
setOtherQuestions((prev: any) => ({ setOtherQuestions((prev: any) => ({
...prev, ...prev,
content: res.data.questions || [], content: res.data.questions || [],
...@@ -126,7 +129,9 @@ export const Home: React.FC = () => { ...@@ -126,7 +129,9 @@ export const Home: React.FC = () => {
console.error('获取工具相关问题失败:', error) console.error('获取工具相关问题失败:', error)
} }
finally { finally {
setIsDataLoaded(true) // 无论成功失败都标记为已加载 // 仅在当前请求仍是最新时更新加载态,避免闪烁
if (currentRequestId === requestIdRef.current)
setIsDataLoaded(true)
} }
}, [originalOtherQuestions, location.search]) }, [originalOtherQuestions, location.search])
...@@ -329,7 +334,7 @@ export const Home: React.FC = () => { ...@@ -329,7 +334,7 @@ export const Home: React.FC = () => {
<div className="hidden sm:flex h-full flex-none ml-auto"> <div className="hidden sm:flex h-full flex-none ml-auto">
<div <div
className="w-full h-full bg-transparent box-border rounded-[24px]" className="w-full h-full bg-transparent box-border rounded-[24px]"
style={{ width: '420px', height: 'calc(100vh - 64px)', background: '#FFFFFF', padding: '0 30px' }} style={{ height: 'calc(100vh - 64px)', background: '#FFFFFF', padding: '0 30px' }}
> >
<Outlet /> <Outlet />
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment