This is an automated email from the ASF dual-hosted git repository.

shuai pushed a commit to branch feat/baseurl
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git

commit 2c8bcbfd7b9773ef30e0d605c0b50608d9169f03
Author: shuai <[email protected]>
AuthorDate: Fri Mar 22 15:31:25 2024 +0800

    feat: test add basename
---
 ui/package.json                    |  2 +-
 ui/src/components/Header/index.tsx | 24 +++++++++++++-----------
 ui/src/router/alias.ts             |  2 ++
 ui/src/utils/floppyNavigation.ts   |  2 +-
 4 files changed, 17 insertions(+), 13 deletions(-)

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') {

Reply via email to