From 0540db2c8d882193bc37fdf3d8584bb3195db4fc Mon Sep 17 00:00:00 2001
From: npmrun <1549469775@qq.com>
Date: Sat, 18 Apr 2026 23:23:41 +0800
Subject: [PATCH] refactor(auth): replace 'pending' with 'initialized' in auth
session and update loading states across components
---
app/components/AppShell.vue | 6 ++---
app/components/PostComments.vue | 4 ++--
app/layouts/public.vue | 25 +++++++++++++++------
app/pages/@[publicSlug]/about/index.vue | 4 ++--
app/pages/@[publicSlug]/index.vue | 4 ++--
app/pages/@[publicSlug]/posts/[postSlug].vue | 4 ++--
app/pages/@[publicSlug]/posts/index.vue | 4 ++--
app/pages/@[publicSlug]/reading/index.vue | 4 ++--
app/pages/@[publicSlug]/timeline/index.vue | 4 ++--
app/pages/index/index.vue | 2 +-
app/pages/me/profile/index.vue | 6 ++---
app/pages/p/[publicSlug]/t/[shareToken].vue | 4 ++--
packages/drizzle-pkg/db.sqlite | Bin 143360 -> 143360 bytes
.../public/profile/[publicSlug]/home-header.get.ts | 7 +++---
14 files changed, 44 insertions(+), 34 deletions(-)
diff --git a/app/components/AppShell.vue b/app/components/AppShell.vue
index f593412..3c83137 100644
--- a/app/components/AppShell.vue
+++ b/app/components/AppShell.vue
@@ -10,7 +10,7 @@ withDefaults(
)
const route = useRoute()
-const { loggedIn, user, refresh, clear, pending } = useAuthSession()
+const { loggedIn, user, refresh, clear, initialized } = useAuthSession()
const { fetchData } = useClientApi()
const { allowRegister, siteName } = useGlobalConfig()
@@ -93,7 +93,7 @@ async function logout() {
try {
await fetchData<{ success: boolean }>('/api/auth/logout', { method: 'POST' })
clear()
- await navigateTo('/login')
+ await navigateTo('/')
} finally {
logoutLoading.value = false
}
@@ -158,7 +158,7 @@ async function logout() {
-
+
diff --git a/app/components/PostComments.vue b/app/components/PostComments.vue
index 55cf70c..621f40d 100644
--- a/app/components/PostComments.vue
+++ b/app/components/PostComments.vue
@@ -164,10 +164,10 @@ async function submitComment() {
评论
-
+
加载评论…
-
+
评论加载失败
diff --git a/app/layouts/public.vue b/app/layouts/public.vue
index 38dbb92..b068c25 100644
--- a/app/layouts/public.vue
+++ b/app/layouts/public.vue
@@ -7,7 +7,7 @@ import {
import { unwrapApiBody, type ApiResponse } from '../utils/http/factory'
const route = useRoute()
-const { loggedIn, pending, refresh } = useAuthSession()
+const { loggedIn, refresh, initialized } = useAuthSession()
const { siteName } = useGlobalConfig()
const showPublicLayoutToggle = computed(() => /^\/@[^/]+$/.test(route.path))
@@ -40,14 +40,25 @@ const { data: publicHomeHeader } = await useAsyncData(
const headerBrandTo = computed(() => (profileSlug.value ? `/@${profileSlug.value}` : '/'))
const headerBrandTitle = computed(() => {
- if (profileSlug.value && publicHomeHeader.value?.title) {
- return publicHomeHeader.value.title
+ if (!profileSlug.value) {
+ return siteName.value
+ }
+ const t = publicHomeHeader.value?.title
+ if (typeof t === 'string' && t.trim().length) {
+ return t.trim()
}
return siteName.value
})
-const headerBrandIconUrl = computed(() =>
- profileSlug.value ? publicHomeHeader.value?.iconUrl ?? null : null,
-)
+const headerBrandIconUrl = computed(() => {
+ if (!profileSlug.value) {
+ return null
+ }
+ const u = publicHomeHeader.value?.iconUrl
+ if (typeof u !== 'string' || !u.trim()) {
+ return null
+ }
+ return u.trim()
+})
type LayoutBySlug = Record
@@ -137,7 +148,7 @@ onMounted(() => {
阅读
-
+
({
-
+
加载中…
-
+
diff --git a/app/pages/@[publicSlug]/index.vue b/app/pages/@[publicSlug]/index.vue
index b54f219..7e6764a 100644
--- a/app/pages/@[publicSlug]/index.vue
+++ b/app/pages/@[publicSlug]/index.vue
@@ -148,10 +148,10 @@ const showBioReadMore = computed(() => {
-
+
加载中…
-
+
diff --git a/app/pages/@[publicSlug]/posts/[postSlug].vue b/app/pages/@[publicSlug]/posts/[postSlug].vue
index 5ba24eb..b4c6274 100644
--- a/app/pages/@[publicSlug]/posts/[postSlug].vue
+++ b/app/pages/@[publicSlug]/posts/[postSlug].vue
@@ -80,10 +80,10 @@ const editPostHref = computed(() =>
-
+
加载中…
-
+
diff --git a/app/pages/@[publicSlug]/posts/index.vue b/app/pages/@[publicSlug]/posts/index.vue
index c1affc4..3348049 100644
--- a/app/pages/@[publicSlug]/posts/index.vue
+++ b/app/pages/@[publicSlug]/posts/index.vue
@@ -77,11 +77,11 @@ const { data, pending, error } = await useAsyncData(
-
+
加载中…
-
+
加载中…
-
+
加载中…
('/api/auth/logout', { method: 'POST' })
clear()
- await navigateTo('/login')
+ await navigateTo('/')
} finally {
logoutLoading.value = false
}
diff --git a/app/pages/me/profile/index.vue b/app/pages/me/profile/index.vue
index e94cb27..e001ab4 100644
--- a/app/pages/me/profile/index.vue
+++ b/app/pages/me/profile/index.vue
@@ -243,14 +243,14 @@ async function save() {
-
+
diff --git a/app/pages/p/[publicSlug]/t/[shareToken].vue b/app/pages/p/[publicSlug]/t/[shareToken].vue
index 28f80b1..010b8b8 100644
--- a/app/pages/p/[publicSlug]/t/[shareToken].vue
+++ b/app/pages/p/[publicSlug]/t/[shareToken].vue
@@ -36,10 +36,10 @@ const renderedUnlistedPostBody = computed(() => {
-
+
加载中…
-
+
{{ data.kind }}
diff --git a/packages/drizzle-pkg/db.sqlite b/packages/drizzle-pkg/db.sqlite
index be9e14b30584c66ddfd2a8431783a4c930f2dd7e..31ab19f898954111beafc242456063a7808a451c 100644
GIT binary patch
delta 1129
zcmb`GPe>F|9LL|=nbDn1=dJ0oZW^v&rP#P{{y8&Ac<>OWkOzgL4$bb)+N!yWYuFw_
z7a@Wmv_a@%U|p-t9k5$<>6Ap^p;NjZG$YA_2@)Q9W3?F=7&XlN_`&bZ_kDk#-+Ne^LpVLt
zcnMl}Thr7{l(lPv*HL{v)dLTrU_Uu`-b+^iuEMVMy1Br3|9Bi$06(b7Fqu+@@dx}F
zJurSEVD$~2?F=Qag$Lr1kdaE6!>N#vX|~RNa%+v`4XQPpEw?wahl2ZenE+YfM&nc|U^Bj23Xt&t<_G+LLJ)T_g`CNN
z`Sl^wh^8GJ+G3BZ1h9$UcN$d`O>!7ZSd#^;WBJc>-lO}jvY>l>_986kGKCHfczi;{
z<-WQNpPv)g4J$bhp-7<)fL^01)Ip$~Mx*U?#s~igDoUXezl077qS+-=3HGn=$%8Jh
z$LR*59e{T1vath#NN++zGl97uL8_Dh6~>e>T2JZ4^axbGeW6&bi;IcLViqU@Z=t
z%>$=kbA6T=lgo;3tGaGWs;+6$Xfdrxrd8IYqHLy1qh=vpE@-gzM7I*KbvyMc>E0My
zA=~J>mrPtisT6q@{!fB;@AOodngrY=_Dyj6Rz=7I0UT=3fTo3*(8$DA569gjm5C5+
z-F)}nKNig$^d47^L#F0jvX<-zRYDHF00e3P)IfJ}&N5;|$goDlz1kLr#>W?zYEEUY
z?^HyBVcq-f;XpK(1ptVKyWZx#UVA8k@RQ~`06j%6nnnpP{M_MAD4J|&s+N|V1#8Ye
zdf6^i#h|rVI(HtnZoPRaRhJ9%PH|_)v&RS-h65}g6L=7DJDV2*2Iaq_QMa+ld)e2I
zWHPytefSl@;93BL0YEco21Do2wLB35Y(7Z6nicsn=|)w1NRXZ7ksVMIrp%JBd4;`6E)7GqPz&>TlgNKj~*CJ-eIPV}|`|p=Wr0
z_`DUwp?z=NX1!Ltz9fT^ENTC?Wo*d8jI|%`W^SW(PaPt
diff --git a/server/api/public/profile/[publicSlug]/home-header.get.ts b/server/api/public/profile/[publicSlug]/home-header.get.ts
index a02e5fe..6d8ee14 100644
--- a/server/api/public/profile/[publicSlug]/home-header.get.ts
+++ b/server/api/public/profile/[publicSlug]/home-header.get.ts
@@ -27,11 +27,10 @@ export default defineEventHandler(async (event) => {
const configuredTitle = typeof titleCfg === "string" ? titleCfg.trim() : "";
const configuredIcon = typeof iconCfg === "string" ? iconCfg.trim() : "";
- const publicAvatar = owner.avatarVisibility === "public" ? owner.avatar : null;
- const nickname = owner.nickname?.trim() ?? "";
+ const site = typeof siteName === "string" ? siteName.trim() : "";
- const title = configuredTitle || nickname || siteName;
- const iconUrl = configuredIcon || publicAvatar || null;
+ const title = configuredTitle || site;
+ const iconUrl = configuredIcon.length > 0 ? configuredIcon : null;
return R.success({ title, iconUrl });
});