diff --git a/src/app/(main)/(mobile)/me/(home)/__tests__/useCategory.test.tsx b/src/app/(main)/(mobile)/me/(home)/__tests__/useCategory.test.tsx index 4e1276996411c..46301dcada90a 100644 --- a/src/app/(main)/(mobile)/me/(home)/__tests__/useCategory.test.tsx +++ b/src/app/(main)/(mobile)/me/(home)/__tests__/useCategory.test.tsx @@ -35,11 +35,6 @@ vi.mock('@/const/auth', () => ({ }, })); -afterEach(() => { - enableAuth = true; - enableClerk = false; -}); - // 目前对 enableAuth 的判定是在 useUserStore 中,所以需要 mock useUserStore // 类型定义: enableAuth: () => boolean describe('useCategory', () => { diff --git a/src/app/(main)/(mobile)/me/(home)/features/useCategory.tsx b/src/app/(main)/(mobile)/me/(home)/features/useCategory.tsx index c268a6d6e5def..981d3b7eda55b 100644 --- a/src/app/(main)/(mobile)/me/(home)/features/useCategory.tsx +++ b/src/app/(main)/(mobile)/me/(home)/features/useCategory.tsx @@ -15,6 +15,7 @@ import { CellProps } from '@/components/Cell'; import { DOCUMENTS, FEEDBACK } from '@/const/url'; import { isServerMode } from '@/const/version'; import { usePWAInstall } from '@/hooks/usePWAInstall'; +import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig'; import { useUserStore } from '@/store/user'; import { authSelectors } from '@/store/user/slices/auth/selectors'; @@ -24,6 +25,7 @@ export const useCategory = () => { const router = useRouter(); const { canInstall, install } = usePWAInstall(); const { t } = useTranslation(['common', 'setting', 'auth']); + const { hideDocs } = useServerConfigStore(featureFlagsSelectors); const [isLogin, isLoginWithAuth, isLoginWithClerk, enableAuth, signOut, isLoginWithNextAuth] = useUserStore((s) => [ authSelectors.isLogin(s), @@ -131,7 +133,7 @@ export const useCategory = () => { /* ↑ cloud slot ↑ */ ...(canInstall ? pwa : []), ...(isLogin && !isServerMode ? data : []), - ...helps, + ...(!hideDocs ? helps : []), ...(enableAuth && isLoginWithNextAuth ? nextAuthSignOut : []), ].filter(Boolean) as CellProps[]; diff --git a/src/app/(main)/changelog/page.tsx b/src/app/(main)/changelog/page.tsx index e08511750edd8..bb2c1258db4e1 100644 --- a/src/app/(main)/changelog/page.tsx +++ b/src/app/(main)/changelog/page.tsx @@ -26,9 +26,9 @@ export const generateMetadata = async () => { }; const Page = async () => { - const hideChangelog = serverFeatureFlags().hideChangelog; + const hideDocs = serverFeatureFlags().hideDocs; - if (hideChangelog) return notFound(); + if (hideDocs) return notFound(); const mobile = await isMobileDevice(); const { t, locale } = await translation('metadata'); diff --git a/src/app/(main)/chat/(workspace)/page.tsx b/src/app/(main)/chat/(workspace)/page.tsx index 0bbc7466eda1c..152b99a21455d 100644 --- a/src/app/(main)/chat/(workspace)/page.tsx +++ b/src/app/(main)/chat/(workspace)/page.tsx @@ -21,7 +21,7 @@ export const generateMetadata = async () => { }; const Page = async () => { - const hideChangelog = serverFeatureFlags().hideChangelog; + const hideDocs = serverFeatureFlags().hideDocs; const mobile = await isMobileDevice(); const { t } = await translation('metadata'); const ld = ldModule.generate({ @@ -35,7 +35,7 @@ const Page = async () => { - {!hideChangelog && ( + {!hideDocs && ( )} diff --git a/src/app/@modal/(.)changelog/page.tsx b/src/app/@modal/(.)changelog/page.tsx index 7f398518debf8..57cc070898d48 100644 --- a/src/app/@modal/(.)changelog/page.tsx +++ b/src/app/@modal/(.)changelog/page.tsx @@ -11,9 +11,9 @@ import UpdateChangelogStatus from './features/UpdateChangelogStatus'; import Loading from './loading'; const Page = async () => { - const hideChangelog = serverFeatureFlags().hideChangelog; + const hideDocs = serverFeatureFlags().hideDocs; - if (hideChangelog) return notFound(); + if (hideDocs) return notFound(); const locale = await getLocale(); const mobile = await isMobileDevice(); diff --git a/src/config/featureFlags/schema.ts b/src/config/featureFlags/schema.ts index e83df3aebaad7..26407d5244e73 100644 --- a/src/config/featureFlags/schema.ts +++ b/src/config/featureFlags/schema.ts @@ -40,7 +40,6 @@ export const FeatureFlagsSchema = z.object({ // please contact us for more information: hello@lobehub.com commercial_hide_github: z.boolean().optional(), commercial_hide_docs: z.boolean().optional(), - commercial_hide_changelog: z.boolean().optional(), }); export type IFeatureFlags = z.infer; @@ -79,7 +78,6 @@ export const DEFAULT_FEATURE_FLAGS: IFeatureFlags = { // please contact us for more information: hello@lobehub.com commercial_hide_github: false, commercial_hide_docs: false, - commercial_hide_changelog: false, }; export const mapFeatureFlagsEnvToState = (config: IFeatureFlags) => { @@ -112,6 +110,5 @@ export const mapFeatureFlagsEnvToState = (config: IFeatureFlags) => { hideGitHub: config.commercial_hide_github, hideDocs: config.commercial_hide_docs, - hideChangelog: config.commercial_hide_changelog, }; }; diff --git a/src/features/User/UserPanel/useMenu.tsx b/src/features/User/UserPanel/useMenu.tsx index fb61cff814885..350a813a7323a 100644 --- a/src/features/User/UserPanel/useMenu.tsx +++ b/src/features/User/UserPanel/useMenu.tsx @@ -175,71 +175,68 @@ export const useMenu = () => { }, ].filter(Boolean) as ItemType[]); - const helps: MenuProps['items'] = hideDocs - ? [] - : ([ - showCloudPromotion && { - icon: , - key: 'cloud', + const helps: MenuProps['items'] = [ + showCloudPromotion && { + icon: , + key: 'cloud', + label: ( + + {t('userPanel.cloud', { name: LOBE_CHAT_CLOUD })} + + ), + }, + { + icon: , + key: 'changelog', + label: {t('changelog')}, + }, + { + children: [ + { + icon: , + key: 'docs', label: ( - - {t('userPanel.cloud', { name: LOBE_CHAT_CLOUD })} + + {t('userPanel.docs')} ), }, { - icon: , - key: 'changelog', - label: {t('changelog')}, + icon: , + key: 'feedback', + label: ( + + {t('userPanel.feedback')} + + ), }, - { - children: [ - { - icon: , - key: 'docs', - label: ( - - {t('userPanel.docs')} - - ), - }, - { - icon: , - key: 'feedback', - label: ( - - {t('userPanel.feedback')} - - ), - }, - { - icon: , - key: 'discord', - label: ( - - {t('userPanel.discord')} - - ), - }, - { - icon: , - key: 'email', - label: ( - - {t('userPanel.email')} - - ), - }, - ], - icon: , - key: 'help', - label: t('userPanel.help'), + icon: , + key: 'discord', + label: ( + + {t('userPanel.discord')} + + ), }, { - type: 'divider', + icon: , + key: 'email', + label: ( + + {t('userPanel.email')} + + ), }, - ].filter(Boolean) as ItemType[]); + ], + icon: , + key: 'help', + label: t('userPanel.help'), + }, + { + type: 'divider', + }, + ].filter(Boolean) as ItemType[]; const mainItems = [ { @@ -252,7 +249,7 @@ export const useMenu = () => { /* ↑ cloud slot ↑ */ ...(canInstall ? pwa : []), ...data, - ...helps, + ...(!hideDocs ? helps : []), ].filter(Boolean) as MenuProps['items']; const logoutItems: MenuProps['items'] = isLoginWithAuth diff --git a/src/server/sitemap.ts b/src/server/sitemap.ts index 1ea0d497041c1..93ed628e30e14 100644 --- a/src/server/sitemap.ts +++ b/src/server/sitemap.ts @@ -196,14 +196,14 @@ export class Sitemap { } async getPage(): Promise { - const hideChangelog = serverFeatureFlags().hideChangelog; + const hideDocs = serverFeatureFlags().hideDocs; const assistantsCategory = Object.values(AssistantCategory); const pluginCategory = Object.values(PluginCategory); const modelCategory = await this.discoverService.getProviderList(DEFAULT_LANG); return [ ...this._genSitemap('/', { noLocales: true }), ...this._genSitemap('/chat', { noLocales: true }), - ...(!hideChangelog ? this._genSitemap('/changelog', { noLocales: true }) : []), + ...(!hideDocs ? this._genSitemap('/changelog', { noLocales: true }) : []), /* ↓ cloud slot ↓ */ /* ↑ cloud slot ↑ */