Skip to content

Commit

Permalink
Optimize result view actions and handle loading state
Browse files Browse the repository at this point in the history
- Disable actions when result is loading
- Add conditional action rendering based on loading state
  • Loading branch information
曾凯 committed Dec 20, 2024
1 parent b62bd4a commit f61f043
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/ResultView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ export function ResultView({
const longestBlockSummary = useMemo(() => getCodeBlockSummary(longestCodeBlock), [longestCodeBlock]);

const actions = useMemo(() => {
// 如果正在加载,返回空数组
if (isLoading) {
return [];
}

const baseActions = [
<Action
key="paste"
Expand Down Expand Up @@ -146,7 +151,7 @@ export function ResultView({
}

return baseActions;
}, [hasCodeBlock, codeBlocks, longestCodeBlock, longestBlockSummary, response]);
}, [hasCodeBlock, codeBlocks, longestCodeBlock, longestBlockSummary, response, isLoading]);

const metadata = useMemo(() => (
<Detail.Metadata>
Expand Down

0 comments on commit f61f043

Please sign in to comment.