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

leezng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/inlong.git


The following commit(s) were added to refs/heads/master by this push:
     new f9c38a09e [INLONG-7367][Dashboard] Enabled more global config (#7369)
f9c38a09e is described below

commit f9c38a09e534d0d461c97ae4d2b6e81c409d2f16
Author: Daniel <[email protected]>
AuthorDate: Wed Feb 15 11:42:13 2023 +0800

    [INLONG-7367][Dashboard] Enabled more global config (#7369)
---
 inlong-dashboard/src/App.tsx                 | 26 ++++++++++++++++++--------
 inlong-dashboard/src/configs/default/conf.ts |  7 +++++++
 inlong-dashboard/src/utils/request.ts        |  7 ++-----
 3 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/inlong-dashboard/src/App.tsx b/inlong-dashboard/src/App.tsx
index 5859bbe4a..e0008a893 100644
--- a/inlong-dashboard/src/App.tsx
+++ b/inlong-dashboard/src/App.tsx
@@ -29,10 +29,9 @@ import { State } from '@/models';
 import request from '@/utils/request';
 import { localesConfig } from '@/configs/locales';
 import store from './models';
-import Login from '@/pages/Login';
 import { config } from '@/configs/default';
 
-const { AppProvider, AppLoading, AppLayout } = config;
+const { AppProvider, AppLoading, AppLayout, useLogin, redirectRoutes } = 
config;
 
 const lazyComponentCache: Record<string, ReturnType<typeof lazy>> = {};
 
@@ -99,15 +98,26 @@ const App = () => {
 
   return (
     <Switch>
-      <Route exact path="/login" render={() => <Login />} />
-      <AppLayout>
-        <Suspense fallback={<AppLoading />}>
+      <Suspense fallback={<AppLoading />}>
+        {useLogin && (
+          <Route
+            exact
+            path="/login"
+            render={() => {
+              const LazyLogin = lazy(() => import('@/pages/Login'));
+              return <LazyLogin />;
+            }}
+          />
+        )}
+        <AppLayout>
           <Switch>
-            <Route exact path="/" render={() => <Redirect to="/group" />} />
+            {Object.keys(redirectRoutes).map(path => (
+              <Route exact path={path} render={() => <Redirect 
to={redirectRoutes[path]} />} />
+            ))}
             {renderRoutes(routes)}
           </Switch>
-        </Suspense>
-      </AppLayout>
+        </AppLayout>
+      </Suspense>
     </Switch>
   );
 };
diff --git a/inlong-dashboard/src/configs/default/conf.ts 
b/inlong-dashboard/src/configs/default/conf.ts
index 8fefba699..646a2057d 100644
--- a/inlong-dashboard/src/configs/default/conf.ts
+++ b/inlong-dashboard/src/configs/default/conf.ts
@@ -20,14 +20,21 @@ import { PageLoading } from '@ant-design/pro-layout';
 import i18n from '@/i18n';
 import Provider from '@/components/Provider';
 import Layout from '@/components/Layout';
+import { message } from 'antd';
 
 const conf = {
   title: '',
   logo: '/logo.svg',
+  useLogin: true,
+  redirectRoutes: {
+    '/': '/group',
+  } as Record<string, string>,
   loginUrl: `${window.location.origin}/#/${i18n?.language || ''}/login`,
   AppProvider: Provider,
   AppLoading: PageLoading,
   AppLayout: Layout,
+  requestPrefix: '/inlong/manager/api',
+  requestErrorAlert: (msg: string) => message.error(msg),
 };
 
 export default conf;
diff --git a/inlong-dashboard/src/utils/request.ts 
b/inlong-dashboard/src/utils/request.ts
index e0fe57914..6fc70528d 100644
--- a/inlong-dashboard/src/utils/request.ts
+++ b/inlong-dashboard/src/utils/request.ts
@@ -17,7 +17,6 @@
  * under the License.
  */
 
-import { message as Message } from 'antd';
 import { extend } from 'umi-request';
 import { RequestOptionsInit } from 'umi-request/types';
 import nprogress from 'nprogress';
@@ -35,10 +34,8 @@ export interface RequestOptions extends FetchOptions {
   noGlobalError?: boolean;
 }
 
-export const apiPrefix = '/inlong/manager/api';
-
 const extendRequest = extend({
-  prefix: apiPrefix,
+  prefix: config.requestPrefix,
   timeout: 60 * 1000,
 });
 
@@ -102,7 +99,7 @@ export default function request(_options: RequestOptions | 
string) {
         msg = message || status;
       }
 
-      if (msg) Message.error(msg);
+      if (msg) config.requestErrorAlert(msg);
       return Promise.reject(new Error(msg));
     })
     .finally(() => {

Reply via email to