File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,24 +7,35 @@ import { useParams } from "react-router";
77export default function PresetViewPage ( ) {
88 const { id } = useParams ( ) ;
99 const [ presetId , setPresetId ] = useState < string > ( "" ) ;
10+ const [ isLoading , setIsLoading ] = useState ( true ) ;
1011
1112 const preset = useSquarePreset ( presetId )
1213
1314 useEffect ( ( ) => {
1415 if ( id ) {
1516 setPresetId ( id ) ;
1617 }
18+ setIsLoading ( true ) ;
1719 } , [ id ] ) ;
1820
1921 useEffect ( ( ) => {
2022 if ( preset ) {
2123 incrementViews ( preset . rawPath ) ;
22- }
23- } )
24+ setIsLoading ( false ) ;
25+ } else if ( presetId ) {
26+ // 如果有 presetId 但没有找到 preset,说明加载完成但未找到
27+ setIsLoading ( false ) ;
28+ }
29+ } , [ preset , presetId ] ) ;
30+
31+ if ( isLoading ) {
32+ return < div > Loading...</ div > ;
33+ }
2434
2535 if ( ! presetId || typeof presetId !== "string" || ! preset ) {
2636 return < div > Preset not found</ div > ;
2737 }
38+
2839 return (
2940 < MainLayout >
3041 < PresetDetails squarePreset = { preset } />
You can’t perform that action at this time.
0 commit comments