-
Notifications
You must be signed in to change notification settings - Fork 130
feat(grid-view): 优化图片加载策略以减轻后端压力 #346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,7 +1,7 @@ | ||||||||
| import { Center, VStack, Icon, Text } from "@hope-ui/solid" | ||||||||
| import { Motion } from "solid-motionone" | ||||||||
| import { useContextMenu } from "solid-contextmenu" | ||||||||
| import { batch, Show } from "solid-js" | ||||||||
| import { batch, Show, createSignal, onMount, onCleanup } from "solid-js" | ||||||||
| import { CenterLoading, LinkWithPush, ImageWithError } from "~/components" | ||||||||
| import { usePath, useRouter, useUtil } from "~/hooks" | ||||||||
| import { checkboxOpen, getMainColor, local, selectIndex } from "~/store" | ||||||||
|
|
@@ -27,8 +27,37 @@ export const GridItem = (props: { obj: StoreObj; index: number }) => { | |||||||
| const { pushHref, to } = useRouter() | ||||||||
| const { openWithDoubleClick, toggleWithClick, restoreSelectionCache } = | ||||||||
| useSelectWithMouse() | ||||||||
|
|
||||||||
| const [isVisible, setIsVisible] = createSignal(false) | ||||||||
|
||||||||
| const [loaded, setLoaded] = createSignal(false) | ||||||||
| const [canLoad, setCanLoad] = createSignal(false) | ||||||||
| let ref: HTMLDivElement | undefined | ||||||||
| let loadTimeout: number | undefined | ||||||||
|
||||||||
| let loadTimeout: number | undefined | |
| let loadTimeout: ReturnType<typeof setTimeout> | undefined |
Copilot
AI
Jan 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This use of variable 'ref' always evaluates to false.
Copilot
AI
Jan 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The timeout is not cleared when a new intersection event occurs while a previous timeout is still pending. If the element rapidly enters and exits the viewport, multiple setTimeout callbacks could be queued, potentially causing canLoad to be set to true even after the element has left the viewport. Clear the existing timeout before setting a new one.
| if (entry.isIntersecting) { | |
| if (entry.isIntersecting) { | |
| if (loadTimeout) clearTimeout(loadTimeout) |
Copilot
AI
Jan 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The isVisible signal is updated but never used anywhere in the component logic or rendering. This adds unnecessary overhead. Either remove this line or utilize the signal if it's intended for future use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The onLoad prop is redundantly specified both in the spread operator and explicitly. Since props are spread with {...props}, the explicit onLoad={props.onLoad} is unnecessary. Remove the explicit onLoad line or restructure to avoid redundancy.