fix: force full reload when leaving review detail
This commit is contained in:
@@ -110,6 +110,15 @@ export function Sidebar({ onToggle, collapsed, userRole, frontendJWT = '' }: Sid
|
|||||||
const isCrossCheckingPath = isPathInSection('/cross-checking');
|
const isCrossCheckingPath = isPathInSection('/cross-checking');
|
||||||
const isChatPath = isPathInSection('/chat-with-llm');
|
const isChatPath = isPathInSection('/chat-with-llm');
|
||||||
const isContractTemplatePath = isPathInSection('/contract-template') || isPathInSection('/contract-draft');
|
const isContractTemplatePath = isPathInSection('/contract-template') || isPathInSection('/contract-draft');
|
||||||
|
const shouldForceDocumentNavigation = isPathInSection('/reviewsTest');
|
||||||
|
|
||||||
|
const navigateWithFallback = (path: string) => {
|
||||||
|
if (shouldForceDocumentNavigation && typeof window !== 'undefined') {
|
||||||
|
window.location.assign(path);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
navigate(path);
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
@@ -509,14 +518,14 @@ export function Sidebar({ onToggle, collapsed, userRole, frontendJWT = '' }: Sid
|
|||||||
<div className="py-6 px-4 border-b border-gray-100 flex justify-between items-center">
|
<div className="py-6 px-4 border-b border-gray-100 flex justify-between items-center">
|
||||||
<div className="flex items-center"
|
<div className="flex items-center"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
navigate('/');
|
navigateWithFallback('/');
|
||||||
}}
|
}}
|
||||||
role="button"
|
role="button"
|
||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
onKeyDown={(e) => {
|
onKeyDown={(e) => {
|
||||||
if (e.key === 'Enter' || e.key === ' ') {
|
if (e.key === 'Enter' || e.key === ' ') {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
navigate('/');
|
navigateWithFallback('/');
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -571,6 +580,7 @@ export function Sidebar({ onToggle, collapsed, userRole, frontendJWT = '' }: Sid
|
|||||||
{!item.children ? (
|
{!item.children ? (
|
||||||
<Link
|
<Link
|
||||||
to={item.path}
|
to={item.path}
|
||||||
|
reloadDocument={shouldForceDocumentNavigation}
|
||||||
className={`sidebar-menu-item ${isActive(item.path) ? 'active' : ''} flex items-center ${collapsed ? 'justify-center' : ''}`}
|
className={`sidebar-menu-item ${isActive(item.path) ? 'active' : ''} flex items-center ${collapsed ? 'justify-center' : ''}`}
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
// 只阻止冒泡,不阻止默认行为
|
// 只阻止冒泡,不阻止默认行为
|
||||||
@@ -618,6 +628,7 @@ export function Sidebar({ onToggle, collapsed, userRole, frontendJWT = '' }: Sid
|
|||||||
<Link
|
<Link
|
||||||
key={child.id}
|
key={child.id}
|
||||||
to={child.path}
|
to={child.path}
|
||||||
|
reloadDocument={shouldForceDocumentNavigation}
|
||||||
className={`sidebar-menu-item ${isActive(child.path) ? 'active' : ''} flex items-center ${collapsed ? 'justify-center' : ''}`}
|
className={`sidebar-menu-item ${isActive(child.path) ? 'active' : ''} flex items-center ${collapsed ? 'justify-center' : ''}`}
|
||||||
onClick={(e) => handleSubMenuClick(child, e)}
|
onClick={(e) => handleSubMenuClick(child, e)}
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user