A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.
fix(user-center): Set the pageTitle for the user center page
haitaoo9edfde5759c7
diff --git a/ui/src/pages/UserCenter/Auth/index.tsx b/ui/src/pages/UserCenter/Auth/index.tsxindex 7a43fa09..9387daea 100644--- a/ui/src/pages/UserCenter/Auth/index.tsx+++ b/ui/src/pages/UserCenter/Auth/index.tsx@@ -1,19 +1,25 @@import { memo } from 'react';import { Container, Col } from 'react-bootstrap';import { useSearchParams } from 'react-router-dom';+import { useTranslation } from 'react-i18next';import { userCenterStore } from '@/stores';import { USER_AGENT_NAMES } from '@/common/constants';+import { usePageTags } from '@/hooks';import WeComAuth from './components/WeCom';const Index = () => {+ const { t } = useTranslation('translation');const [searchParam] = useSearchParams();const { agent: ucAgent } = userCenterStore();let agentName = ucAgent?.agent_info.name || '';if (searchParam.get('agent_name')) {agentName = searchParam.get('agent_name') || '';}+ usePageTags({+ title: t('login', { keyPrefix: 'page_title' }),+ });return (<Container style={{ paddingTop: '5rem', paddingBottom: '5rem' }}><Col md={4} className="mx-auto">diff --git a/ui/src/pages/UserCenter/AuthFailed/index.tsx b/ui/src/pages/UserCenter/AuthFailed/index.tsxindex 107ebbb3..05c9c78d 100644--- a/ui/src/pages/UserCenter/AuthFailed/index.tsx+++ b/ui/src/pages/UserCenter/AuthFailed/index.tsx@@ -1,19 +1,25 @@import { memo } from 'react';import { Container } from 'react-bootstrap';import { useSearchParams } from 'react-router-dom';+import { useTranslation } from 'react-i18next';import { userCenterStore } from '@/stores';import { USER_AGENT_NAMES } from '@/common/constants';+import { usePageTags } from '@/hooks';import WeCom from './components/WeCom';const Index = () => {+ const { t } = useTranslation('translation');const [searchParam] = useSearchParams();const { agent: ucAgent } = userCenterStore();let agentName = ucAgent?.agent_info.name || '';if (searchParam.get('agent_name')) {agentName = searchParam.get('agent_name') || '';}+ usePageTags({+ title: t('login', { keyPrefix: 'page_title' }),+ });return (<Container>{USER_AGENT_NAMES.WeCom.toLowerCase() === agentName.toLowerCase() ? (diff --git a/ui/src/stores/pageTags.ts b/ui/src/stores/pageTags.tsindex 6455f937..7b036fa9 100644--- a/ui/src/stores/pageTags.ts+++ b/ui/src/stores/pageTags.ts@@ -33,7 +33,9 @@ const pageTags = create<HelmetStore>((set) => ({o.pageTitle = makePageTitle(params.title, params.subtitle);}o.description =- params.description || siteInfoStore.getState().siteInfo.description;+ params.description ||+ siteInfoStore.getState().siteInfo?.description ||+ '';o.keywords = params.keywords || '';set({diff --git a/ui/src/utils/guard.ts b/ui/src/utils/guard.tsindex e13d7466..7f016f91 100644--- a/ui/src/utils/guard.ts+++ b/ui/src/utils/guard.ts@@ -9,6 +9,7 @@ import {themeSettingStore,seoSettingStore,loginToContinueStore,+ pageTagStore,} from '@/stores';import { RouteAlias } from '@/router/alias';import {@@ -373,6 +374,10 @@ export const initAppSettingsStore = async () => {.updateVersion(appSettings.version, appSettings.revision);siteInfoStore.getState().updateUsers(appSettings.site_users);interfaceStore.getState().update(appSettings.interface);+ pageTagStore.getState().update({+ title: appSettings.general?.name,+ description: appSettings.general?.description,+ });brandingStore.getState().update(appSettings.branding);loginSettingStore.getState().update(appSettings.login);customizeStore.getState().update(appSettings.custom_css_html);