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 299c57190436a81f1cc98b57153a25246f8d3ade Author: shuai <[email protected]> AuthorDate: Fri Mar 22 18:34:46 2024 +0800 fix: a tag check basename --- ui/src/components/Header/index.tsx | 25 +++++++++++----------- ui/src/components/PageTags/index.tsx | 8 +++++-- ui/src/pages/Admin/Answers/index.tsx | 8 +++---- ui/src/pages/Admin/Questions/index.tsx | 6 +++--- .../pages/Install/components/FifthStep/index.tsx | 10 ++++++--- .../Ask/components/SearchQuestion/index.tsx | 5 +++-- ui/src/pages/Questions/EditAnswer/index.tsx | 8 +++---- 7 files changed, 40 insertions(+), 30 deletions(-) diff --git a/ui/src/components/Header/index.tsx b/ui/src/components/Header/index.tsx index b58a36e3..2757f6c1 100644 --- a/ui/src/components/Header/index.tsx +++ b/ui/src/components/Header/index.tsx @@ -24,7 +24,6 @@ import { Nav, Form, FormControl, - Button, Col, } from 'react-bootstrap'; import { useTranslation } from 'react-i18next'; @@ -175,24 +174,26 @@ const Header: FC = () => { /> ) : ( <> - <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/components/PageTags/index.tsx b/ui/src/components/PageTags/index.tsx index 6bed2125..5d3dd5d7 100644 --- a/ui/src/components/PageTags/index.tsx +++ b/ui/src/components/PageTags/index.tsx @@ -20,6 +20,7 @@ import { FC, useEffect, useLayoutEffect } from 'react'; import { Helmet } from 'react-helmet-async'; +import { REACT_BASE_PATH } from '@/router/alias'; import { brandingStore, pageTagStore, siteInfoStore } from '@/stores'; import { getCurrentLang } from '@/utils/localize'; @@ -76,7 +77,7 @@ const Index: FC = () => { <link rel="icon" type="image/png" - href={favicon || square_icon || '/favicon.ico'} + href={favicon || square_icon || `${REACT_BASE_PATH}/favicon.ico`} /> <link rel="icon" type="image/png" sizes="192x192" href={square_icon} /> <link rel="apple-touch-icon" type="image/png" href={square_icon} /> @@ -84,7 +85,10 @@ const Index: FC = () => { {keywords && <meta name="keywords" content={keywords} />} {description && <meta name="description" content={description} />} {doInsertCustomCSS && ( - <link rel="stylesheet" href={`${process.env.PUBLIC_URL}/custom.css`} /> + <link + rel="stylesheet" + href={`${process.env.PUBLIC_URL}${REACT_BASE_PATH}/custom.css`} + /> )} </Helmet> ); diff --git a/ui/src/pages/Admin/Answers/index.tsx b/ui/src/pages/Admin/Answers/index.tsx index 091fe2db..c05aa77e 100644 --- a/ui/src/pages/Admin/Answers/index.tsx +++ b/ui/src/pages/Admin/Answers/index.tsx @@ -19,7 +19,7 @@ import { FC } from 'react'; import { Form, Table, Stack } from 'react-bootstrap'; -import { useSearchParams } from 'react-router-dom'; +import { useSearchParams, Link } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import classNames from 'classnames'; @@ -110,8 +110,8 @@ const Answers: FC = () => { return ( <tr key={li.id}> <td> - <a - href={pathFactory.answerLanding({ + <Link + to={pathFactory.answerLanding({ questionId: li.question_id, slugTitle: li.question_info.url_title, answerId: li.id, @@ -120,7 +120,7 @@ const Answers: FC = () => { className="text-break text-wrap" rel="noreferrer"> {li.question_info.title} - </a> + </Link> {li.accepted === 2 && ( <Icon name="check-circle-fill" diff --git a/ui/src/pages/Admin/Questions/index.tsx b/ui/src/pages/Admin/Questions/index.tsx index 0488a08b..254aeaec 100644 --- a/ui/src/pages/Admin/Questions/index.tsx +++ b/ui/src/pages/Admin/Questions/index.tsx @@ -109,13 +109,13 @@ const Questions: FC = () => { return ( <tr key={li.id}> <td> - <a - href={pathFactory.questionLanding(li.id, li.url_title)} + <Link + to={pathFactory.questionLanding(li.id, li.url_title)} target="_blank" className="text-break text-wrap" rel="noreferrer"> {li.title} - </a> + </Link> {li.accepted_answer_id > 0 && ( <Icon name="check-circle-fill" diff --git a/ui/src/pages/Install/components/FifthStep/index.tsx b/ui/src/pages/Install/components/FifthStep/index.tsx index 7a9061f9..4ec99a5c 100644 --- a/ui/src/pages/Install/components/FifthStep/index.tsx +++ b/ui/src/pages/Install/components/FifthStep/index.tsx @@ -21,6 +21,7 @@ import { FC } from 'react'; import { Button } from 'react-bootstrap'; import { useTranslation, Trans } from 'react-i18next'; +import { REACT_BASE_PATH } from '@/router/alias'; import Progress from '../Progress'; interface Props { @@ -37,15 +38,18 @@ const Index: FC<Props> = ({ visible, siteUrl = '' }) => { <p> <Trans i18nKey="install.ready_description"> If you ever feel like changing more settings, visit - <a href={`${siteUrl}/users/login`}> admin section</a>; find it in the - site menu. + <a href={`${siteUrl}${REACT_BASE_PATH}/users/login`}> + {' '} + admin section + </a> + ; find it in the site menu. </Trans> </p> <p>{t('good_luck')}</p> <div className="d-flex align-items-center justify-content-between"> <Progress step={5} /> - <Button href={siteUrl}>{t('done')}</Button> + <Button href={`${siteUrl}${REACT_BASE_PATH}`}>{t('done')}</Button> </div> </div> ); diff --git a/ui/src/pages/Questions/Ask/components/SearchQuestion/index.tsx b/ui/src/pages/Questions/Ask/components/SearchQuestion/index.tsx index 96b2b0ac..0f1f527a 100644 --- a/ui/src/pages/Questions/Ask/components/SearchQuestion/index.tsx +++ b/ui/src/pages/Questions/Ask/components/SearchQuestion/index.tsx @@ -20,6 +20,7 @@ import { memo } from 'react'; import { Accordion, ListGroup } from 'react-bootstrap'; import { useTranslation } from 'react-i18next'; +import { Link } from 'react-router-dom'; import { Icon } from '@/components'; import { pathFactory } from '@/router/pathFactory'; @@ -45,10 +46,10 @@ const SearchQuestion = ({ similarQuestions }) => { return ( <ListGroup.Item action - as="a" + as={Link} className="link-dark text-wrap text-break" key={item.id} - href={pathFactory.questionLanding(item.id, item.url_title)} + to={pathFactory.questionLanding(item.id, item.url_title)} target="_blank"> <span className={`${ diff --git a/ui/src/pages/Questions/EditAnswer/index.tsx b/ui/src/pages/Questions/EditAnswer/index.tsx index fbb3e327..a76a7bd0 100644 --- a/ui/src/pages/Questions/EditAnswer/index.tsx +++ b/ui/src/pages/Questions/EditAnswer/index.tsx @@ -19,7 +19,7 @@ import React, { useState, useRef, useEffect, useLayoutEffect } from 'react'; import { Row, Col, Form, Button, Card } from 'react-bootstrap'; -import { useParams, useNavigate } from 'react-router-dom'; +import { useParams, useNavigate, Link } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import dayjs from 'dayjs'; @@ -217,12 +217,12 @@ const Index = () => { <h3 className="mb-4">{t('title')}</h3> <Row> <Col className="page-main flex-auto"> - <a - href={pathFactory.questionLanding(qid, data?.question.url_title)} + <Link + to={pathFactory.questionLanding(qid, data?.question.url_title)} target="_blank" rel="noreferrer"> <h5 className="mb-3">{data?.question.title}</h5> - </a> + </Link> <div className="question-content-wrap"> <div
