feat(tauri): global library command layer (#55)#106
Merged
Conversation
Add 7 #[tauri::command]s over LibraryStore (#54): library_list / library_favorite / library_unfavorite / library_categorize / library_rename / library_delete / library_import_to_project. Register them in lib.rs invoke_handler and manage a LibraryState (Arc<LibraryStore> rooted at <app_data_dir>/OpenTake/Library). library_import_to_project resolves an entry's stored copy, probes it via the media engine, and appends it to the current project's manifest with a fresh asset id. MediaError is mapped to Err(String) at the boundary. Adds set_category / rename_category to LibraryStore for the categorize / rename commands (additive; reuse the store write-lock + atomic manifest). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
5 tasks
appergb
approved these changes
Jun 23, 2026
appergb
left a comment
Owner
There was a problem hiding this comment.
审核通过 ✅(自动审核流程)
- 实现 issue #55 全部 7 个 Tauri 命令(library_list/favorite/unfavorite/categorize/rename/delete/import_to_project),薄壳包装 LibraryStore,错误处理一致(MediaError→Err(String)),DTO 与前端 #37-C 约定(camelCase/type/favoritedAt)对齐。
- 已 retarget 到 main(原 stacked 在 #104 之上的阻塞已随 #104 合并解除);针对 main 重新触发的 CI 双绿。
- library_import_to_project 流程正确(resolve stored copy → probe → import_media_file 新 asset id)。
follow-up(非阻塞,@Felix201209 可后续处理):
- library_delete 与 library_unfavorite 目前函数体完全相同(纯别名),建议语义区分(unfavorite 保留文件 / delete 删文件)或合并。
- library_favorite 的 source 仅 is_file() 校验,建议加 canonicalize() 防 ../。
- probe_or_default / display_name 与 media.rs 私有函数重复,建议提 pub(crate) 复用。
- #104 的 remove() 静默吞错(library.rs:322)建议补 tracing::warn!。
5 tasks
H-Chris233
pushed a commit
to H-Chris233/OpenTake
that referenced
this pull request
Jun 24, 2026
…ged; clarify appergb#37 vs appergb#91 scope
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
#37 全局可复用素材库的命令层(#37-B)。在 #54 的
LibraryStore之上加 7 个#[tauri::command],lib.rsinvoke_handler 追加注册,并manage一个LibraryState(Arc<LibraryStore>,根目录<app_data_dir>/OpenTake/Library)。新命令集中在新文件
src-tauri/src/library.rs,不触碰在飞 PR(#77/#79)的既有文件。7 个命令(DTO 供 #37-C 前端对齐)
library_listcategory?: string(空/省略=全部,非空=按分类)LibraryEntryDto[]library_favoritesource: string, type: string, category?: string, thumb?: stringLibraryEntryDto(favoritedAt服务端取钟)library_unfavoriteid: stringbooleanlibrary_categorizeid: string, category?: string(None=清空)LibraryEntryDtolibrary_renamefrom: string, to?: string(分类批量改名,None=取消分类)number(改动条数)library_deleteid: stringbooleanlibrary_import_to_projectid: stringLibraryImportDto { id, name, path }LibraryEntryDto(camelCase):{ id, type, category?, favoritedAt, source?, thumb? }。LibraryImportDto:{ id, name, path }(新建的项目侧资产;前端随后get_media拉全量目录)。验收对照(#55)
MediaError→Err(String))。library_import_to_project解析库内存储副本 → probe → 以新 asset id 拷进当前项目 manifest(一份收藏可导入多个项目)。typekey /favoritedAt)。cargo fmt --all、clippy -p opentake-tauri -D warnings、cargo check -p opentake-tauri全绿;新增set_category/rename_category配套单测在opentake-media通过(12/12)。实现说明
LibraryStore原本无元数据更新方法,本 PR 为categorize/rename在 store 追加set_category/rename_category(纯增量,复用既有 write-lock + 原子 manifest 写入),命令层保持薄壳。依赖 #54(本 PR base 为其分支
feat-54-library-backend,合并 #54 后将自动 retarget main)。Closes #55
🤖 Generated with Claude Code