MCPcopy
hub / github.com/iChochy/NCE / applyBookChange

Method applyBookChange

js/ReadingSystem.js:139–159  ·  view source on GitHub ↗

* 应用课本切换 * @param {string} bookKey - 目标课本 key * @returns {Promise }

(bookKey)

Source from the content-addressed store, hash-verified

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)

Callers 2

applyBookFromHashMethod · 0.95
bindWindowEventsMethod · 0.95

Calls 9

loadBooksMethod · 0.95
resolveBookByKeyMethod · 0.95
renderEmptyStateMethod · 0.95
updateBookSelectsMethod · 0.95
loadBookConfigMethod · 0.95
renderUnitListMethod · 0.95
renderUnitSelectMethod · 0.95
resetUnitListScrollMethod · 0.95
setStorageFunction · 0.90

Tested by

no test coverage detected