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.

feat: test add basename

shuai2c8bcbfd7b97
diff --git a/ui/package.json b/ui/package.json
index 63a1f85d..e10d6e7c 100644
--- a/ui/package.json
+++ b/ui/package.json
@@ -2,7 +2,7 @@
"name": "answer-static",
"version": "0.1.0",
"private": true,
- "homepage": "/",
+ "homepage": "/test",
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
diff --git a/ui/src/components/Header/index.tsx b/ui/src/components/Header/index.tsx
index 2f31af38..b58a36e3 100644
--- a/ui/src/components/Header/index.tsx
+++ b/ui/src/components/Header/index.tsx
@@ -249,24 +249,26 @@ const Header: FC = () => {
</Nav>
) : (
<>
- <Button
- variant="link"
- className={classnames('me-2', {
+ <Link
+ className={classnames('me-2 btn btn-link', {
'link-light': navbarStyle === 'theme-colored',
'link-primary': navbarStyle !== 'theme-colored',
})}
onClick={() => floppyNavigation.storageLoginRedirect()}
- href={userCenter.getLoginUrl()}>
+ to={userCenter.getLoginUrl()}>
{t('btns.login')}
- </Button>
+ </Link>
{loginSetting.allow_new_registrations && (
- <Button
- variant={
- navbarStyle === 'theme-colored' ? 'light' : 'primary'
- }
- href={userCenter.getSignUpUrl()}>
+ <Link
+ className={classnames(
+ 'btn',
+ navbarStyle === 'theme-colored'
+ ? 'btn-light'
+ : 'btn-primary',
+ )}
+ to={userCenter.getSignUpUrl()}>
{t('btns.signup')}
- </Button>
+ </Link>
)}
</>
)}
diff --git a/ui/src/router/alias.ts b/ui/src/router/alias.ts
index 5a155969..050f6c74 100644
--- a/ui/src/router/alias.ts
+++ b/ui/src/router/alias.ts
@@ -17,6 +17,8 @@
* under the License.
*/
+export const REACT_BASE_PATH = process.env.REACT_APP_BASE_URL || '';
+
export const RouteAlias = {
home: '/',
login: '/users/login',
diff --git a/ui/src/utils/floppyNavigation.ts b/ui/src/utils/floppyNavigation.ts
index 45758b31..308d2fac 100644
--- a/ui/src/utils/floppyNavigation.ts
+++ b/ui/src/utils/floppyNavigation.ts
@@ -137,7 +137,7 @@ const navigate = (to: string | number, config: NavigateConfig = {}) => {
} else if (handler === 'replace') {
window.location.replace(to);
} else if (typeof handler === 'function') {
- handler(to, config.options);
+ handler(to === '/test' ? '/' : to, config.options);
}
}
if (typeof to === 'number' && typeof handler === 'function') {