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: the route of the question page is adjusted to /questions/add, and redirect /questions/ask to /questions/add
shuaidf3b1a1a3904
diff --git a/ui/src/components/Header/index.tsx b/ui/src/components/Header/index.tsxindex dbc7565d..2d151b88 100644--- a/ui/src/components/Header/index.tsx+++ b/ui/src/components/Header/index.tsx@@ -57,7 +57,7 @@ const Header: FC = () => {* Automatically append `tag` information when creating a question*/const tagMatch = useMatch('/tags/:slugName');- let askUrl = '/questions/ask';+ let askUrl = '/questions/add';if (tagMatch && tagMatch.params.slugName) {askUrl = `${askUrl}?tags=${encodeURIComponent(tagMatch.params.slugName)}`;}diff --git a/ui/src/router/routes.ts b/ui/src/router/routes.tsindex 59907b41..4b98f205 100644--- a/ui/src/router/routes.ts+++ b/ui/src/router/routes.ts@@ -75,6 +75,13 @@ const routes: RouteNode[] = [{path: 'questions/ask',page: 'pages/Questions/Ask',+ guard: () => {+ return guard.askRedirect();+ },+ },+ {+ path: 'questions/add',+ page: 'pages/Questions/Ask',guard: () => {return guard.activated();},diff --git a/ui/src/utils/guard.ts b/ui/src/utils/guard.tsindex e033f795..85ab5e69 100644--- a/ui/src/utils/guard.ts+++ b/ui/src/utils/guard.ts@@ -392,7 +392,7 @@ export const initAppSettingsStore = async () => {};export const googleSnapshotRedirect = () => {- const gr: TGuardResult = { ok: true };+ const gr: TGuardResult = { ok: false };const searchStr = new URLSearchParams(window.location.search)?.get('q') || '';if (window.location.host !== 'webcache.googleusercontent.com') {return gr;@@ -409,6 +409,17 @@ export const googleSnapshotRedirect = () => {return gr;};+export const askRedirect = () => {+ const searchStr = new URLSearchParams(window.location.search);+ const gr: TGuardResult = {+ ok: false,+ redirect: searchStr+ ? `/questions/add?${searchStr.toString()}`+ : '/questions/add',+ };+ return gr;+};+let appInitialized = false;export const setupApp = async () => {/**diff --git a/ui/template/header.html b/ui/template/header.htmlindex 404df75b..1d20c2dd 100644--- a/ui/template/header.html+++ b/ui/template/header.html@@ -174,7 +174,7 @@</form></div><!-- <div class="xl-none mt-3 pb-1 nav-item">- <a class="text-capitalize text-nowrap btn btn-light" href="/questions/ask">{{translator $.language "ui.btns.add_question"}}</a>+ <a class="text-capitalize text-nowrap btn btn-light" href="/questions/add">{{translator $.language "ui.btns.add_question"}}</a></div> --><div class="d-none d-xl-flex justify-content-start justify-content-sm-end col-lg-4"><!-- <a role="button" tabindex="0" href="/users/login" class="me-2 link-light btn btn-link">