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

shuai pushed a commit to branch test
in repository https://gitbox.apache.org/repos/asf/answer.git


The following commit(s) were added to refs/heads/test by this push:
     new df3b1a1a fix: the route of the question page is adjusted to 
/questions/add, and redirect /questions/ask to /questions/add
df3b1a1a is described below

commit df3b1a1a3904c65ea18e3574877e97264c26086b
Author: shuai <lishuail...@sifou.com>
AuthorDate: Thu Aug 28 14:45:05 2025 +0800

    fix: the route of the question page is adjusted to /questions/add, and 
redirect /questions/ask to /questions/add
---
 ui/src/components/Header/index.tsx |  2 +-
 ui/src/router/routes.ts            |  7 +++++++
 ui/src/utils/guard.ts              | 13 ++++++++++++-
 ui/template/header.html            |  2 +-
 4 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/ui/src/components/Header/index.tsx 
b/ui/src/components/Header/index.tsx
index 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.ts
index 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.ts
index 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.html
index 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">

Reply via email to