支持带章节作品 网站功能基本完善 🥳
All checks were successful
Build / build-and-test (push) Successful in 39s

[UX]
增加对格式错误的链接检测
在搜索或者切换章节时地址栏和标题会跟着变动

[UI]
不再使用 mdui-collapse 作为作品信息容器
SSR 时作品文段渲染增加到 20 行

[Fix]
SSR 时 Category 与 Fandom 标识错误

[Base]
Summary 不再使用 v-for

[NewBug]
在搜索不到东西时会显示搜索完成, 推断是状态转移不完全
This commit is contained in:
2025-05-27 23:57:47 +08:00
parent 8ff45e210c
commit 7e0087a7db
3 changed files with 89 additions and 37 deletions

View File

@ -21,10 +21,13 @@ export const useWorkReadState = defineStore('workRead', () => {
const category = ref([])
const fandom = ref([])
const lang = ref(null)
const chapters = ref([])
const chapterIndex = ref(null)
function setData(data) {
cid.value = data.chapterId
id.value = data.workId
title.value = data.title
summary.value = [escapeAndFormatText(data.summary)]
summary.value = data.summary ? escapeAndFormatText(data.summary) : null
pseud.value = data.pseud
text.value = data.text
publishedTime.value = data.stats.publishedTime
@ -34,11 +37,26 @@ export const useWorkReadState = defineStore('workRead', () => {
category.value = data.category
fandom.value = data.fandom
lang.value = data.lang
chapters.value = data.chapters || []
chapterIndex.value = data.chapterIndex ?? null
}
async function loadWork(target, targetc) {
if (target == id.value && targetc == cid.value || state.value == 'loading') return
const itarget = parseInt(target)
if (isNaN(itarget)) {
console.log('a')
state.value = 'errformat'
return
}
const itargetc = parseInt(targetc)
if (
itarget === id.value &&
(itargetc === cid.value || (isNaN(itargetc) && cid.value === null)) &&
state.value !== 'loading'
) return
id.value = itarget
cid.value = isNaN(itargetc) ? null : itargetc
state.value = 'loading'
const result = await api.getWork(target, targetc)
const result = await api.getWork(id.value, cid.value)
if (result.status == 200) {
setData(result.data)
state.value = 'ready'
@ -61,6 +79,8 @@ export const useWorkReadState = defineStore('workRead', () => {
category,
fandom,
lang,
chapters,
chapterIndex,
setData,
loadWork
}