[Base] 更新 SSR 机制, 支持流式渲染注入 head 标签
All checks were successful
Build / build-and-test (push) Successful in 28s

损失的 TTFB 可以忽略不计
This commit is contained in:
2025-06-05 18:02:03 +08:00
parent b1804ae060
commit eca669d62a
9 changed files with 234 additions and 118 deletions

View File

@ -2,6 +2,8 @@ import { ref, computed, watch } from 'vue'
import { defineStore } from 'pinia'
import { useRouter, useRoute } from 'vue-router'
import { useHeadHelper } from '../ssr/headHelper.js'
export const useRouteStore = defineStore('route', () => {
const router = useRouter()
const route = useRoute()
@ -16,7 +18,9 @@ export const useRouteStore = defineStore('route', () => {
)
const lastFromDrawer = ref(0)
const customTitle = ref(null)
const title = computed(() => customTitle.value || route.meta.title || route.name)
const title = import.meta.env.SSR ?
computed(() => route.meta.title || route.name) :
computed(() => customTitle.value || route.meta.title || route.name)
function drawerPress(target) {
if (lastFromDrawer.value == 0) {
lastFromDrawer.value = 1

View File

@ -62,9 +62,10 @@ export const useWorkReadState = defineStore('workRead', () => {
if (result.status == 200) {
setData(result.data)
state.value = 'ready'
} else {
id.value = target
} else if (result.status == 404) {
state.value = import.meta.env.SSR ? 'ssrnotfound' : 'notfound'
} else if (result.status == 401) {
state.value = 'unauth'
}
}
return {