Skip to content

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: naviage add base path

shuai571c2b1a19d6
diff --git a/ui/src/utils/floppyNavigation.ts b/ui/src/utils/floppyNavigation.ts
index 308d2fac..30be62ca 100644
--- a/ui/src/utils/floppyNavigation.ts
+++ b/ui/src/utils/floppyNavigation.ts
@@ -19,7 +19,7 @@
import type { NavigateFunction } from 'react-router-dom';
-import { RouteAlias } from '@/router/alias';
+import { RouteAlias, REACT_BASE_PATH } from '@/router/alias';
import Storage from '@/utils/storage';
import { REDIRECT_PATH_STORAGE_KEY } from '@/common/constants';
import { getLoginUrl } from '@/utils/userCenter';
@@ -133,8 +133,22 @@ const navigate = (to: string | number, config: NavigateConfig = {}) => {
handler = 'replace';
}
if (handler === 'href') {
+ if (
+ to.startsWith('/') &&
+ !to.startsWith('//') &&
+ !to.startsWith(REACT_BASE_PATH)
+ ) {
+ to = `${REACT_BASE_PATH}${to}`;
+ }
window.location.href = to;
} else if (handler === 'replace') {
+ if (
+ to.startsWith('/') &&
+ !to.startsWith('//') &&
+ !to.startsWith(REACT_BASE_PATH)
+ ) {
+ to = `${REACT_BASE_PATH}${to}`;
+ }
window.location.replace(to);
} else if (typeof handler === 'function') {
handler(to === '/test' ? '/' : to, config.options);