feat: 实验室设置+护眼模式+Web清理

合并 PR #1278 by fjsuta
This commit is contained in:
WangXuanMeng
2026-06-02 18:32:28 +08:00
committed by GitHub
parent 5da2e85395
commit b25244fcde
18 changed files with 611 additions and 21 deletions
+2 -15
View File
@@ -47,7 +47,7 @@ export const useBookStore = defineStore('book', {
},
getters: {
bookProgress: (state): BookProgress | undefined => {
if (state.catalog.length == 0) return
if (state.catalog.length === 0) return
const { chapterIndex, chapterPos, name, author } = state.readingBook
const title = state.catalog[chapterIndex]?.title
if (!title) return
@@ -63,13 +63,12 @@ export const useBookStore = defineStore('book', {
theme: state => {
return state.config.theme
},
isNight: state => state.config.theme == 6,
isNight: state => state.config.theme === 6,
},
actions: {
/** 从后端加载书架书籍,优先返回内存缓存 */
async loadBookShelf(): Promise<Book[]> {
const fetchBookshellf_promise = API.getBookShelf().then(resp => {
console.log('API.getBookShelf数据返回')
const { isSuccess, data, errorMsg } = resp.data
if (isSuccess === true) {
if (
@@ -91,16 +90,13 @@ export const useBookStore = defineStore('book', {
}
ElMessage.error(errorMsg ?? '后端返回格式错误!')
}
console.log('书架数据已更新')
return this.shelf
})
if (this.shelf.length > 0) {
// bookshelf data fetched before:do not await
console.log('返回缓存书架数据')
return this.shelf
} else {
console.log('从阅读后端获取书架数据...')
return await fetchBookshellf_promise
}
},
@@ -126,7 +122,6 @@ export const useBookStore = defineStore('book', {
ElMessage.info(`书籍${name}: 章节目录已更新`)
}
this.catalog = data
console.log(`书籍${name}: 章节目录已更新`)
return this.catalog
})
if (
@@ -134,10 +129,8 @@ export const useBookStore = defineStore('book', {
this.catalog.length > 0 &&
this.catalog.length - 1 >= chapterIndex
) {
console.log(`返回书籍《${name}》 缓存的章节目录`)
return this.catalog
} else {
console.log(`从阅读后端获取书籍《${name}》 章节目录数据...`)
return await fetchChapterList_promise
}
},
@@ -155,14 +148,8 @@ export const useBookStore = defineStore('book', {
if (webReadConfigLoadedDate === undefined) {
const _config = await API.getReadConfig()
webReadConfigLoadedDate = new Date()
console.log(
`${this.$id}.loadWebConfig: ${webReadConfigLoadedDate.toLocaleString()}成功加载阅读配置`,
)
return this.setConfig(_config)
}
console.log(
`${this.$id}.loadWebConfig: 已于${webReadConfigLoadedDate.toLocaleString()}成功加载`,
)
},
setConfig(config?: webReadConfig) {
this.config = Object.assign({}, this.config, config)