Skip to content

feat(tauri): global library command layer (#55)#106

Merged
appergb merged 1 commit into
mainfrom
feat-55-library-commands
Jun 23, 2026
Merged

feat(tauri): global library command layer (#55)#106
appergb merged 1 commit into
mainfrom
feat-55-library-commands

Conversation

@Felix201209

Copy link
Copy Markdown
Collaborator

概述

#37 全局可复用素材库的命令层(#37-B)。在 #54LibraryStore 之上加 7 个 #[tauri::command],lib.rs invoke_handler 追加注册,并 manage 一个 LibraryState(Arc<LibraryStore>,根目录 <app_data_dir>/OpenTake/Library)。

新命令集中在新文件 src-tauri/src/library.rs,不触碰在飞 PR(#77/#79)的既有文件。

7 个命令(DTO 供 #37-C 前端对齐)

命令 参数 返回
library_list category?: string(空/省略=全部,非空=按分类) LibraryEntryDto[]
library_favorite source: string, type: string, category?: string, thumb?: string LibraryEntryDto(favoritedAt 服务端取钟)
library_unfavorite id: string boolean
library_categorize id: string, category?: string(None=清空) LibraryEntryDto
library_rename from: string, to?: string(分类批量改名,None=取消分类) number(改动条数)
library_delete id: string boolean
library_import_to_project id: string LibraryImportDto { id, name, path }

LibraryEntryDto(camelCase):{ id, type, category?, favoritedAt, source?, thumb? }
LibraryImportDto:{ id, name, path }(新建的项目侧资产;前端随后 get_media 拉全量目录)。

验收对照(#55)

  • 7 个命令可用且有错误处理(MediaErrorErr(String))。
  • library_import_to_project 解析库内存储副本 → probe → 以新 asset id 拷进当前项目 manifest(一份收藏可导入多个项目)。
  • DTO 与前端 全局可复用素材库 + 收藏(跨项目调用/分类/音效库/全库可见) #37-C 对齐(camelCase / type key / favoritedAt)。
  • cargo fmt --allclippy -p opentake-tauri -D warningscargo 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

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>
@Felix201209 Felix201209 requested a review from appergb as a code owner June 23, 2026 12:47
Copilot AI review requested due to automatic review settings June 23, 2026 12:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@appergb appergb deleted the branch main June 23, 2026 13:25
@appergb appergb closed this Jun 23, 2026
@appergb appergb reopened this Jun 23, 2026
@appergb appergb changed the base branch from feat-54-library-backend to main June 23, 2026 13:27

@appergb appergb left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

审核通过 ✅(自动审核流程)

  • 实现 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!。

@appergb appergb merged commit 7309702 into main Jun 23, 2026
4 checks passed
@appergb appergb deleted the feat-55-library-commands branch June 23, 2026 13:30
H-Chris233 pushed a commit to H-Chris233/OpenTake that referenced this pull request Jun 24, 2026
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.

[#37-B] 全局库 Tauri 命令层(list/favorite/categorize/rename/delete/import_to_project)

3 participants