Skip to content

refactor: simplify preview handling and remove unnecessary code#488

Merged
j2rong4cn merged 14 commits into
mainfrom
refactor-preview
May 2, 2026
Merged

refactor: simplify preview handling and remove unnecessary code#488
j2rong4cn merged 14 commits into
mainfrom
refactor-preview

Conversation

@j2rong4cn

@j2rong4cn j2rong4cn commented Apr 28, 2026

Copy link
Copy Markdown
Member

Description / 描述

移除非必要的createMemo,因为预览文件会重载File组件

<Match when={objStore.state === State.File}>
<File />
</Match>
</Switch>

修复无法下载加密压缩包内的文件,由 #329 引入

Motivation and Context / 背景

Close #487
#446 (comment)

How Has This Been Tested? / 测试

Checklist / 检查清单

  • I have read the CONTRIBUTING document.
    我已阅读 CONTRIBUTING 文档。
  • I have formatted my code with go fmt or prettier.
    我已使用 go fmtprettier 格式化提交的代码。
  • I have added appropriate labels to this PR (or mentioned needed labels in the description if lacking permissions).
    我已为此 PR 添加了适当的标签(如无权限或需要的标签不存在,请在描述中说明,管理员将后续处理)。
  • I have requested review from relevant code authors using the "Request review" feature when applicable.
    我已在适当情况下使用"Request review"功能请求相关代码作者进行审查。
  • I have updated the repository accordingly (If it’s needed).
    我已相应更新了相关仓库(若适用)。

@j2rong4cn
j2rong4cn marked this pull request as draft April 28, 2026 11:46
@j2rong4cn
j2rong4cn marked this pull request as ready for review April 29, 2026 01:39
@j2rong4cn

j2rong4cn commented Apr 29, 2026

Copy link
Copy Markdown
Member Author

播放压缩包内的视频时,下一个视频会跳转到压缩包外,想着一起改了,改的地方有点多,下次吧
压缩包内只能顺序读取,不推荐在线预览(不支持响应206状态码)

return getPreviews({ ...objStore.obj, provider: objStore.provider })
})
const selectedPreviewKey = createMemo(() => searchParams["preview"] || "")
const previews = getPreviews({ ...objStore.obj, provider: objStore.provider })

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果使用createMemo在预览压缩包时更新objStore.obj这里也会更新,导致回到压缩包根目录

@j2rong4cn
j2rong4cn force-pushed the refactor-preview branch from 93e08f4 to cf503e9 Compare May 1, 2026 10:19
@j2rong4cn j2rong4cn changed the title refactor: simplify preview handling and remove unnecessary memoization refactor: simplify preview handling and remove unnecessary code May 2, 2026
@j2rong4cn
j2rong4cn requested a review from Copilot May 2, 2026 07:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors preview handling (notably around OpenWith and preview selection) and fixes encrypted-archive inner-file downloading by propagating the archive password into generated /ae links, while also tightening a couple of type and config edges.

Changes:

  • Simplify preview component wiring by removing some memoization/prop plumbing and using the shared OpenWith component directly.
  • Fix encrypted archive inner-file download/link generation by carrying pass through ArchiveObj and appending it in useLink for /ae URLs.
  • Correct API typing for fsArchiveList and add a TS path mapping to improve solid-contextmenu type resolution.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tsconfig.json Adds a paths mapping for solid-contextmenu typings.
src/utils/api.ts Fixes fsArchiveList return type to a paged response promise.
src/types/obj.ts Extends ArchiveObj with pass to carry archive passwords.
src/pages/home/previews/video.tsx Adjusts Artplayer type imports.
src/pages/home/previews/download.tsx Removes openWith prop/conditional OpenWith render in download preview.
src/pages/home/previews/archive.tsx Refactors error handling and ensures inner-file objects carry pass; simplifies preview UI composition.
src/pages/home/previews/aliyun_video.tsx Adjusts Artplayer type imports; removes unused loading binding from useFetch.
src/pages/home/file/open-with.tsx Removes memoization around external preview list computation.
src/pages/home/file/File.tsx Simplifies preview selection logic and removes Download openWith fallback behavior.
src/hooks/useLink.ts Improves query-param concatenation and appends pass for archive inner-file links.
src/hooks/useFetch.ts Adds a brief comment clarifying intended pairing with handleResp.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/pages/home/file/open-with.tsx
Comment thread src/pages/home/file/File.tsx
Comment thread src/pages/home/previews/archive.tsx Outdated
Comment thread src/pages/home/previews/download.tsx Outdated
@j2rong4cn
j2rong4cn merged commit 157a3e6 into main May 2, 2026
1 check passed
@j2rong4cn
j2rong4cn deleted the refactor-preview branch May 2, 2026 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

压缩包功能缺陷:压缩包内视频无法拖拽进度条(v4.1.10);升级 v4.2.1 后压缩包内文件/文件夹完全无法打开

2 participants