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

Method resolveBookByKey

js/ReadingSystem.js:111–121  ·  view source on GitHub ↗

* 根据 key 查找课本 * @param {string} bookKey - 课本标识 key * @returns {Object|null} 匹配的课本对象

(bookKey)

Source from the content-addressed store, hash-verified

109 * @returns {Object|null} 匹配的课本对象
110 */
111 resolveBookByKey(bookKey) {
112 if (!this.state.books.length) return null;
113
114 const exact = this.state.books.find((book) => book?.key === bookKey);
115 if (exact?.bookPath) return exact;
116
117 const fallback = this.state.books.find((book) => book?.key === this.config.DEFAULT_BOOK_KEY);
118 if (fallback?.bookPath) return fallback;
119
120 return this.state.books.find((book) => book?.bookPath) || null;
121 }
122
123 /**
124 * 从 URL hash 应用课本

Callers 1

applyBookChangeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected