Merge pull request #913 from SuanmoSuanyangTechnology/fix/userinfo_zy
fix(web): userinfo
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
* @Author: ZhaoYing
|
* @Author: ZhaoYing
|
||||||
* @Date: 2026-02-02 15:07:49
|
* @Date: 2026-02-02 15:07:49
|
||||||
* @Last Modified by: ZhaoYing
|
* @Last Modified by: ZhaoYing
|
||||||
* @Last Modified time: 2026-04-07 12:18:58
|
* @Last Modified time: 2026-04-16 10:28:18
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* AppHeader Component
|
* AppHeader Component
|
||||||
@@ -31,7 +31,7 @@ const { Header } = Layout;
|
|||||||
/**
|
/**
|
||||||
* @param source - Breadcrumb source type ('space' or 'manage'), defaults to 'manage'
|
* @param source - Breadcrumb source type ('space' or 'manage'), defaults to 'manage'
|
||||||
*/
|
*/
|
||||||
const AppHeader: FC<{source?: 'space' | 'manage';}> = ({source = 'manage'}) => {
|
const AppHeader: FC<{ source?: 'space' | 'manage'; }> = ({ source = 'manage' }) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const settingModalRef = useRef<SettingModalRef>(null)
|
const settingModalRef = useRef<SettingModalRef>(null)
|
||||||
@@ -39,7 +39,7 @@ const AppHeader: FC<{source?: 'space' | 'manage';}> = ({source = 'manage'}) => {
|
|||||||
|
|
||||||
const { user, logout } = useUser();
|
const { user, logout } = useUser();
|
||||||
const { allBreadcrumbs } = useMenu();
|
const { allBreadcrumbs } = useMenu();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dynamically select breadcrumb source based on current route
|
* Dynamically select breadcrumb source based on current route
|
||||||
* - Knowledge base list: uses 'space' breadcrumb
|
* - Knowledge base list: uses 'space' breadcrumb
|
||||||
@@ -48,24 +48,24 @@ const AppHeader: FC<{source?: 'space' | 'manage';}> = ({source = 'manage'}) => {
|
|||||||
*/
|
*/
|
||||||
const getBreadcrumbSource = () => {
|
const getBreadcrumbSource = () => {
|
||||||
const pathname = location.pathname;
|
const pathname = location.pathname;
|
||||||
|
|
||||||
// Knowledge base list page uses default space breadcrumb
|
// Knowledge base list page uses default space breadcrumb
|
||||||
if (pathname === '/knowledge-base') {
|
if (pathname === '/knowledge-base') {
|
||||||
return 'space';
|
return 'space';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Knowledge base detail pages use independent breadcrumb
|
// Knowledge base detail pages use independent breadcrumb
|
||||||
if (pathname.includes('/knowledge-base/') && pathname !== '/knowledge-base') {
|
if (pathname.includes('/knowledge-base/') && pathname !== '/knowledge-base') {
|
||||||
return 'space-detail';
|
return 'space-detail';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Other pages use the passed source
|
// Other pages use the passed source
|
||||||
return source;
|
return source;
|
||||||
};
|
};
|
||||||
|
|
||||||
const breadcrumbSource = getBreadcrumbSource();
|
const breadcrumbSource = getBreadcrumbSource();
|
||||||
const breadcrumbs = allBreadcrumbs[breadcrumbSource] || [];
|
const breadcrumbs = allBreadcrumbs[breadcrumbSource] || [];
|
||||||
|
|
||||||
|
|
||||||
/** Handle user logout */
|
/** Handle user logout */
|
||||||
const handleLogout = () => {
|
const handleLogout = () => {
|
||||||
@@ -127,7 +127,7 @@ const AppHeader: FC<{source?: 'space' | 'manage';}> = ({source = 'manage'}) => {
|
|||||||
onClick: handleLogout,
|
onClick: handleLogout,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format breadcrumb items with proper titles, paths, and click handlers
|
* Format breadcrumb items with proper titles, paths, and click handlers
|
||||||
* - Translates i18n keys to display text
|
* - Translates i18n keys to display text
|
||||||
@@ -146,7 +146,7 @@ const AppHeader: FC<{source?: 'space' | 'manage';}> = ({source = 'manage'}) => {
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!isLast) {
|
if (!isLast) {
|
||||||
if ((menu as any).onClick) {
|
if ((menu as any).onClick) {
|
||||||
item.onClick = (e: React.MouseEvent) => {
|
item.onClick = (e: React.MouseEvent) => {
|
||||||
@@ -162,7 +162,7 @@ const AppHeader: FC<{source?: 'space' | 'manage';}> = ({source = 'manage'}) => {
|
|||||||
return item;
|
return item;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const handleOpenChange = (open: boolean) => {
|
const handleOpenChange = (open: boolean) => {
|
||||||
setOpen(open);
|
setOpen(open);
|
||||||
|
|||||||
Reference in New Issue
Block a user