* 应用课本切换 * @param {string} bookKey - 目标课本 key * @returns {Promise }
(bookKey)
| 137 | * @returns {Promise<void>} |
| 138 | */ |
| 139 | async applyBookChange(bookKey) { |
| 140 | await this.loadBooks(); |
| 141 | |
| 142 | const resolved = this.resolveBookByKey(bookKey); |
| 143 | if (!resolved?.bookPath) { |
| 144 | this.state.bookPath = ''; |
| 145 | this.state.bookKey = ''; |
| 146 | this.renderEmptyState(this.config.ERROR_MESSAGES.NO_DATA); |
| 147 | return; |
| 148 | } |
| 149 | |
| 150 | this.state.bookKey = resolved.key || bookKey; |
| 151 | this.state.bookPath = resolved.bookPath.trim(); |
| 152 | setStorage(this.config.STORAGE_KEYS.BOOK_SELECTION, this.state.bookKey); |
| 153 | |
| 154 | this.updateBookSelects(); |
| 155 | await this.loadBookConfig(); |
| 156 | this.renderUnitList(); |
| 157 | this.renderUnitSelect(); |
| 158 | this.resetUnitListScroll(); |
| 159 | } |
| 160 | |
| 161 | /** |
| 162 | * 加载课本配置(book.json) |
no test coverage detected