From f19412953fbec09eb25b9e06dcbb393df5881d60 Mon Sep 17 00:00:00 2001 From: npmrun <1549469775@qq.com> Date: Fri, 24 Apr 2026 22:30:58 +0800 Subject: [PATCH] feat(global-config): add showDiscoverInHeaderForGuest option and update related components - Introduced a new configuration option `showDiscoverInHeaderForGuest` to control the visibility of the "Discover" navigation link for guests. - Updated the AppShell component to conditionally render the "Discover" link based on the user's login status and the new config option. - Modified global configuration handling to include the new option, ensuring it is fetched and saved correctly. - Enhanced middleware to allow guest access to the "Discover" route if the new config option is enabled. These changes improve the user experience by providing guests with access to discover content while maintaining control over navigation visibility. --- app/components/AppShell.vue | 17 ++++++++++++++--- app/composables/useGlobalConfig.ts | 3 +++ app/middleware/auth.global.ts | 6 +++++- app/pages/me/admin/config/index.vue | 12 +++++++++++- app/pages/me/posts/[id].vue | 14 ++++++-------- app/pages/me/posts/new.vue | 9 ++------- app/utils/post-slug.ts | 11 +++++++++++ packages/drizzle-pkg/db.sqlite | Bin 163840 -> 163840 bytes server/api/config/global.get.ts | 6 +++++- server/api/discover/users.get.ts | 10 +++++++++- server/service/config/registry.ts | 7 +++++++ server/utils/auth-api-routes.ts | 1 + 12 files changed, 74 insertions(+), 22 deletions(-) diff --git a/app/components/AppShell.vue b/app/components/AppShell.vue index b12d5c9..c86d8dc 100644 --- a/app/components/AppShell.vue +++ b/app/components/AppShell.vue @@ -12,7 +12,7 @@ withDefaults( const route = useRoute() const { loggedIn, user, clear, initialized, ensureClientMeSynced } = useAuthSession() const { fetchData } = useClientApi() -const { allowRegister, siteName } = useGlobalConfig() +const { allowRegister, siteName, showDiscoverInHeaderForGuest } = useGlobalConfig() const logoutLoading = ref(false) @@ -63,6 +63,7 @@ function navActive(to: string) { const consoleNavActive = computed(() => navActive('/me')) const showQuickCreate = computed(() => loggedIn.value && initialized.value) +const showGuestDiscoverNav = computed(() => !loggedIn.value && showDiscoverInHeaderForGuest.value) const accountMenuItems = computed(() => { const u = user.value @@ -122,11 +123,12 @@ async function logout() {