You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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.
背景
为图书馆模块补充"扫码借书"流程:扫描馆藏条码 → 按条码查询书籍 → 确认借书提交。同时修复续借的 toast 提示问题。
新增功能
code == 1精确判断,补齐缺失参数。安全性与误操作控制
具体改动
新增文件
lib/page/library/scan_borrow_window.dart— 扫码借书页面,复用项目已有qr_code_dart_scan,无新增依赖。getScannedBorrowBook(barcode)查询书籍。BookDetailCard,失败 toast 报错并恢复扫描。_borrowStatusFor四层判定:预期书不匹配 / 条码精确命中在架 → 可借 / 命中但不在架 → 展示原因 / 无命中取首个在架副本 / 均不满足 → 无可借馆藏。_submitBorrow仅可借时调用borrowBook()发起真实借书,成功后刷新借阅列表并退出。修改文件
lib/repository/xidian_ids/library_session.dart— 图书馆接口层getScannedBorrowBook(barcode):请求api/search/list.html,searchFiled: "barcode",解析第一本为BookInfo,补封面。borrowBook(barcode, bookInfo, searchCode):请求api/borrow/borrow.html,提交barNumber/cardNumber/bookName/author/searchCode。内部通过_getUserBarcode()提前获取读者条码作为cardNumber。borrowScannedBook()作为语义入口转发到borrowBook。renew():按code == 1判断成功并返回固定"续借成功",失败抛出LibraryOperationException;补齐bookName/isbn/author参数。LibraryOperationException异常类及_throwIfLibrarySessionExpired辅助判断。lib/page/library/book_detail_card.dart— 搜索结果页防误借showBorrowAction/onBorrowRequest参数。ScanBorrowWindow(expectedBook: bookInfo)。lib/page/library/search_book_window.dart— 搜索页借书入口ScanBorrowWindow(expectedBook: bookInfo)。lib/page/library/library_window.dart— 图书馆主页ScanBorrowWindow()(自由扫码模式)。lib/page/library/borrow_info_card.dart— 借阅列表续借async/try/catch/finally,finally保证加载框关闭。国际化
zh_CN.yaml/zh_TW.yaml/en_US.yaml新增扫码引导、状态反馈、误扫提示、防误借警告等文案。测试
构建成功。