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

Method loadBooks

js/ReadingSystem.js:91–104  ·  view source on GitHub ↗

* 从 data.json 加载所有可用的课本数据 * @returns {Promise } 课本数据列表

()

Source from the content-addressed store, hash-verified

89 * @returns {Promise<Array>} 课本数据列表
90 */
91 async loadBooks() {
92 if (this.state.books.length) return this.state.books;
93
94 try {
95 const response = await fetch('data.json');
96 const data = await response.json();
97 this.state.books = Array.isArray(data.books) ? data.books : [];
98 return this.state.books;
99 } catch (error) {
100 console.error(this.config.ERROR_MESSAGES.LOAD_BOOKS, error);
101 this.state.books = [];
102 return [];
103 }
104 }
105
106 /**
107 * 根据 key 查找课本

Callers 2

initMethod · 0.95
applyBookChangeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected