This is an automated email from the ASF dual-hosted git repository.
dockerzhang 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 bde52ae60 [INLONG-7319][Dashboard] Support global configuration of
Provider and Layout (#7320)
bde52ae60 is described below
commit bde52ae609202b79c20def972d938be9989e4d42
Author: Daniel <[email protected]>
AuthorDate: Fri Feb 3 19:32:41 2023 +0800
[INLONG-7319][Dashboard] Support global configuration of Provider and
Layout (#7320)
---
inlong-dashboard/.gitignore | 4 +-
inlong-dashboard/src/{router.tsx => App.tsx} | 85 +++++------------
.../src/components/DashboardCard/index.module.less | 2 -
.../Provider/antd.cover.less} | 0
inlong-dashboard/src/components/Provider/index.tsx | 101 +++++++++++++++++++++
.../src/configs/default/{index.ts => conf.ts} | 6 ++
inlong-dashboard/src/configs/default/index.ts | 7 +-
.../src/configs/locales/{index.ts => conf.ts} | 17 +---
inlong-dashboard/src/configs/locales/index.ts | 17 +---
.../src/configs/menus/{index.ts => conf.ts} | 32 +------
inlong-dashboard/src/configs/menus/index.ts | 48 +---------
.../src/configs/pagination/{index.ts => conf.ts} | 4 +-
inlong-dashboard/src/configs/pagination/index.ts | 11 +--
.../src/configs/routes/{index.tsx => conf.ts} | 72 +--------------
.../src/configs/routes/{index.tsx => index.ts} | 101 +--------------------
inlong-dashboard/src/index.tsx | 2 +-
inlong-dashboard/src/themes/index.less | 26 ------
inlong-dashboard/src/themes/style.less | 64 -------------
inlong-dashboard/src/utils/request.ts | 1 +
19 files changed, 148 insertions(+), 452 deletions(-)
diff --git a/inlong-dashboard/.gitignore b/inlong-dashboard/.gitignore
index 3e1dbf2b4..d1db86e1a 100644
--- a/inlong-dashboard/.gitignore
+++ b/inlong-dashboard/.gitignore
@@ -1,9 +1,7 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring
files.
# dependencies
-/node_modules
-/.pnp
-.pnp.js
+node_modules
# testing
/coverage
diff --git a/inlong-dashboard/src/router.tsx b/inlong-dashboard/src/App.tsx
similarity index 65%
rename from inlong-dashboard/src/router.tsx
rename to inlong-dashboard/src/App.tsx
index 80fe60d8c..8e86e418a 100644
--- a/inlong-dashboard/src/router.tsx
+++ b/inlong-dashboard/src/App.tsx
@@ -17,9 +17,7 @@
* under the License.
*/
-import React, { Suspense, lazy, useEffect, useCallback, useState } from
'react';
-import { ConfigProvider, Spin } from 'antd';
-import dayjs from 'dayjs';
+import React, { Suspense, lazy, useEffect, useCallback } from 'react';
import { HashRouter as Router, Switch, Route, Redirect } from
'react-router-dom';
import {
useLocation,
@@ -29,17 +27,16 @@ import {
useSelector,
useRequest,
} from '@/hooks';
-import { PageLoading } from '@ant-design/pro-layout';
import { Provider } from 'react-redux';
-import Layout from '@/components/Layout';
import routes, { RouteProps } from '@/configs/routes';
import { State } from '@/models';
import request from '@/utils/request';
import { localesConfig } from '@/configs/locales';
import store from './models';
-import i18n from './i18n';
-import '@/themes/index.less';
import Login from '@/pages/Login';
+import { config } from '@/configs/default';
+
+const { AppProvider, AppLoading, AppLayout } = config;
const lazyComponentCache: Record<string, ReturnType<typeof lazy>> = {};
@@ -58,7 +55,7 @@ const renderRoutes = function (routes: RouteProps[],
parentPath = ''): any[] {
<Route
key={compiledPath}
path={compiledPath}
- exact={route.exact}
+ exact
strict={route.strict}
render={props => {
const LazyComponent = lazyComponentCache[compiledPath] ||
lazy(route.component);
@@ -73,6 +70,7 @@ const renderRoutes = function (routes: RouteProps[],
parentPath = ''): any[] {
);
}, []);
};
+
const App = () => {
const location = useLocation();
const history = useHistory();
@@ -80,8 +78,6 @@ const App = () => {
const locale = useSelector<State, State['locale']>(state => state.locale);
- const [antdMessages, setAntdMessages] = useState();
-
useRequest(
{
url: '/user/currentUser',
@@ -101,43 +97,6 @@ const App = () => {
},
);
- const importLocale = useCallback(async locale => {
- if (!localesConfig[locale]) return;
-
- const { uiComponentPath, dayjsPath } = localesConfig[locale];
- const [messagesDefault, messagesExtends, antdMessages] = await
Promise.all([
- import(
- /* webpackChunkName: 'default-locales-[request]' */
- `@/locales/${locale}.json`
- ),
- import(
- /* webpackChunkName: 'extends-locales-[request]' */
- `@/locales/extends/${locale}.json`
- ),
- import(
- /* webpackInclude: /(zh_CN|en_US)\.js$/ */
- /* webpackChunkName: 'antd-locales-[request]' */
- `antd/es/locale/${uiComponentPath}.js`
- ),
- import(
- /* webpackInclude: /(zh-cn|en)\.js$/ */
- /* webpackChunkName: 'dayjs-locales-[request]' */
- `dayjs/esm/locale/${dayjsPath}.js`
- ),
- ]);
- i18n.changeLanguage(locale);
- i18n.addResourceBundle(locale, 'translation', {
- ...messagesDefault.default,
- ...messagesExtends.default,
- });
- dayjs.locale(dayjsPath);
- setAntdMessages(antdMessages.default);
- }, []);
-
- useEffect(() => {
- importLocale(locale);
- }, [locale, importLocale]);
-
const setCurrentMenu = useCallback(
pathname => {
dispatch({
@@ -161,22 +120,18 @@ const App = () => {
setCurrentMenu(location.pathname);
}, [history, location, setCurrentMenu]);
- return antdMessages ? (
- <ConfigProvider locale={antdMessages} autoInsertSpaceInButton={false}>
- <Switch>
- <Route exact path="/login" render={() => <Login />} />
- <Layout>
- <Suspense fallback={<PageLoading />}>
- <Switch>
- <Route exact path="/" render={() => <Redirect to="/group" />} />
- {renderRoutes(routes)}
- </Switch>
- </Suspense>
- </Layout>
- </Switch>
- </ConfigProvider>
- ) : (
- <Spin />
+ return (
+ <Switch>
+ <Route exact path="/login" render={() => <Login />} />
+ <AppLayout>
+ <Suspense fallback={<AppLoading />}>
+ <Switch>
+ <Route exact path="/" render={() => <Redirect to="/group" />} />
+ {renderRoutes(routes)}
+ </Switch>
+ </Suspense>
+ </AppLayout>
+ </Switch>
);
};
@@ -190,7 +145,9 @@ const Content = () => (
requestMethod: request,
}}
>
- <App />
+ <AppProvider>
+ <App />
+ </AppProvider>
</UseRequestProvider>
</Router>
);
diff --git a/inlong-dashboard/src/components/DashboardCard/index.module.less
b/inlong-dashboard/src/components/DashboardCard/index.module.less
index 01774456c..a3f0d6558 100644
--- a/inlong-dashboard/src/components/DashboardCard/index.module.less
+++ b/inlong-dashboard/src/components/DashboardCard/index.module.less
@@ -18,8 +18,6 @@
* under the License.
*/
-@import '@/themes/antd.var.less';
-
.dashCardNums {
font-family: @number-font-family;
font-size: 36px;
diff --git a/inlong-dashboard/src/themes/cover.less
b/inlong-dashboard/src/components/Provider/antd.cover.less
similarity index 100%
rename from inlong-dashboard/src/themes/cover.less
rename to inlong-dashboard/src/components/Provider/antd.cover.less
diff --git a/inlong-dashboard/src/components/Provider/index.tsx
b/inlong-dashboard/src/components/Provider/index.tsx
new file mode 100644
index 000000000..e03cd3737
--- /dev/null
+++ b/inlong-dashboard/src/components/Provider/index.tsx
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import React, { useEffect, useCallback, useState } from 'react';
+import { ConfigProvider, Spin } from 'antd';
+import dayjs from 'dayjs';
+import { useDispatch, useSelector, useRequest } from '@/hooks';
+import { State } from '@/models';
+import { localesConfig } from '@/configs/locales';
+import i18n from '@/i18n';
+import './antd.cover.less';
+
+const Provider = ({ children }) => {
+ const dispatch = useDispatch();
+
+ const locale = useSelector<State, State['locale']>(state => state.locale);
+
+ const [antdMessages, setAntdMessages] = useState();
+
+ useRequest(
+ {
+ url: '/user/currentUser',
+ method: 'POST',
+ },
+ {
+ onSuccess: result => {
+ dispatch({
+ type: 'setUserInfo',
+ payload: {
+ userName: result.name,
+ userId: result.userId,
+ roles: result.roles,
+ },
+ });
+ },
+ },
+ );
+
+ const importLocale = useCallback(async locale => {
+ if (!localesConfig[locale]) return;
+
+ const { uiComponentPath, dayjsPath } = localesConfig[locale];
+ const [messagesDefault, messagesExtends, antdMessages] = await
Promise.all([
+ import(
+ /* webpackChunkName: 'default-locales-[request]' */
+ `@/locales/${locale}.json`
+ ),
+ import(
+ /* webpackChunkName: 'extends-locales-[request]' */
+ `@/locales/extends/${locale}.json`
+ ),
+ import(
+ /* webpackInclude: /(zh_CN|en_US)\.js$/ */
+ /* webpackChunkName: 'antd-locales-[request]' */
+ `antd/es/locale/${uiComponentPath}.js`
+ ),
+ import(
+ /* webpackInclude: /(zh-cn|en)\.js$/ */
+ /* webpackChunkName: 'dayjs-locales-[request]' */
+ `dayjs/esm/locale/${dayjsPath}.js`
+ ),
+ ]);
+ i18n.changeLanguage(locale);
+ i18n.addResourceBundle(locale, 'translation', {
+ ...messagesDefault.default,
+ ...messagesExtends.default,
+ });
+ dayjs.locale(dayjsPath);
+ setAntdMessages(antdMessages.default);
+ }, []);
+
+ useEffect(() => {
+ importLocale(locale);
+ }, [locale, importLocale]);
+
+ return antdMessages ? (
+ <ConfigProvider locale={antdMessages} autoInsertSpaceInButton={false}>
+ {children}
+ </ConfigProvider>
+ ) : (
+ <Spin />
+ );
+};
+
+export default Provider;
diff --git a/inlong-dashboard/src/configs/default/index.ts
b/inlong-dashboard/src/configs/default/conf.ts
similarity index 81%
copy from inlong-dashboard/src/configs/default/index.ts
copy to inlong-dashboard/src/configs/default/conf.ts
index b0e25699f..bfa2e8024 100644
--- a/inlong-dashboard/src/configs/default/index.ts
+++ b/inlong-dashboard/src/configs/default/conf.ts
@@ -16,10 +16,16 @@
* specific language governing permissions and limitations
* under the License.
*/
+import { PageLoading } from '@ant-design/pro-layout';
import i18n from '@/i18n';
+import Provider from '@/components/Provider';
+import Layout from '@/components/Layout';
export const config = {
title: '',
logo: '/logo.svg',
loginUrl: `${window.location.origin}/#/${i18n?.language || ''}/login`,
+ AppProvider: Provider,
+ AppLoading: PageLoading,
+ AppLayout: Layout,
};
diff --git a/inlong-dashboard/src/configs/default/index.ts
b/inlong-dashboard/src/configs/default/index.ts
index b0e25699f..bee53ba95 100644
--- a/inlong-dashboard/src/configs/default/index.ts
+++ b/inlong-dashboard/src/configs/default/index.ts
@@ -16,10 +16,5 @@
* specific language governing permissions and limitations
* under the License.
*/
-import i18n from '@/i18n';
-export const config = {
- title: '',
- logo: '/logo.svg',
- loginUrl: `${window.location.origin}/#/${i18n?.language || ''}/login`,
-};
+export { config } from './conf';
diff --git a/inlong-dashboard/src/configs/locales/index.ts
b/inlong-dashboard/src/configs/locales/conf.ts
similarity index 74%
copy from inlong-dashboard/src/configs/locales/index.ts
copy to inlong-dashboard/src/configs/locales/conf.ts
index e4c48f3ed..494391caa 100644
--- a/inlong-dashboard/src/configs/locales/index.ts
+++ b/inlong-dashboard/src/configs/locales/conf.ts
@@ -17,15 +17,9 @@
* under the License.
*/
-interface LocalesType {
- [key: string]: {
- label: string;
- uiComponentPath: string;
- dayjsPath: string;
- };
-}
+import type { LocalesType } from '.';
-export const localesConfig: LocalesType = {
+const localesConf: LocalesType = {
cn: {
label: '简体中文',
uiComponentPath: 'zh_CN',
@@ -38,9 +32,4 @@ export const localesConfig: LocalesType = {
},
};
-export const getCurrentLocale = () => {
- const pathLocale = window.location.hash.split('/')[1];
- if (localesConfig[pathLocale]) return pathLocale;
-
- return 'cn';
-};
+export default localesConf;
diff --git a/inlong-dashboard/src/configs/locales/index.ts
b/inlong-dashboard/src/configs/locales/index.ts
index e4c48f3ed..c08fd9f58 100644
--- a/inlong-dashboard/src/configs/locales/index.ts
+++ b/inlong-dashboard/src/configs/locales/index.ts
@@ -17,7 +17,9 @@
* under the License.
*/
-interface LocalesType {
+import localesConf from './conf';
+
+export interface LocalesType {
[key: string]: {
label: string;
uiComponentPath: string;
@@ -25,18 +27,7 @@ interface LocalesType {
};
}
-export const localesConfig: LocalesType = {
- cn: {
- label: '简体中文',
- uiComponentPath: 'zh_CN',
- dayjsPath: 'zh-cn',
- },
- en: {
- label: 'English',
- uiComponentPath: 'en_US',
- dayjsPath: 'en',
- },
-};
+export const localesConfig = localesConf;
export const getCurrentLocale = () => {
const pathLocale = window.location.hash.split('/')[1];
diff --git a/inlong-dashboard/src/configs/menus/index.ts
b/inlong-dashboard/src/configs/menus/conf.ts
similarity index 67%
copy from inlong-dashboard/src/configs/menus/index.ts
copy to inlong-dashboard/src/configs/menus/conf.ts
index 25d011bcd..35349ce02 100644
--- a/inlong-dashboard/src/configs/menus/index.ts
+++ b/inlong-dashboard/src/configs/menus/conf.ts
@@ -18,33 +18,9 @@
*/
import i18n from '@/i18n';
-import { treeToArray } from '@/utils';
+import type { MenuItemType } from '.';
-export interface MenuItemType {
- name: string;
- key?: string; // auto generate
- deepKey?: string; // auto generate
- children?: MenuItemType[];
- path?: string;
- isAdmin?: boolean;
-}
-
-const genMenuKey = (array: Omit<MenuItemType, 'key'>[], parentKey = ''):
MenuItemType[] => {
- return array.map((item, index) => {
- let obj = { ...item };
- const num = index + 1 < 10 ? `0${index + 1}` : (index + 1).toString();
- const currentKey = `${parentKey}${num}`;
- if (obj.children) {
- obj.children = genMenuKey(obj.children, currentKey);
- }
- return {
- ...obj,
- key: currentKey,
- };
- });
-};
-
-const menusTree: MenuItemType[] = genMenuKey([
+const menusTree: MenuItemType[] = [
{
path: '/group',
name: i18n.t('configs.menus.Groups'),
@@ -88,8 +64,6 @@ const menusTree: MenuItemType[] = genMenuKey([
},
],
},
-]);
-
-export const menuArrays: Omit<MenuItemType, 'children'>[] =
treeToArray(menusTree, 'key', 'pKey');
+];
export default menusTree;
diff --git a/inlong-dashboard/src/configs/menus/index.ts
b/inlong-dashboard/src/configs/menus/index.ts
index 25d011bcd..f19e26c1d 100644
--- a/inlong-dashboard/src/configs/menus/index.ts
+++ b/inlong-dashboard/src/configs/menus/index.ts
@@ -17,8 +17,8 @@
* under the License.
*/
-import i18n from '@/i18n';
import { treeToArray } from '@/utils';
+import menusTreeConf from './conf';
export interface MenuItemType {
name: string;
@@ -44,51 +44,7 @@ const genMenuKey = (array: Omit<MenuItemType, 'key'>[],
parentKey = ''): MenuIte
});
};
-const menusTree: MenuItemType[] = genMenuKey([
- {
- path: '/group',
- name: i18n.t('configs.menus.Groups'),
- },
- {
- path: '/consume',
- name: i18n.t('configs.menus.Subscribe'),
- },
- {
- name: i18n.t('configs.menus.Clusters'),
- children: [
- {
- path: '/clusters',
- name: i18n.t('configs.menus.Clusters'),
- },
- {
- path: '/clusterTags',
- name: i18n.t('configs.menus.ClusterTags'),
- },
- ],
- },
- {
- path: '/node',
- name: i18n.t('configs.menus.Nodes'),
- },
- {
- path: '/process',
- name: i18n.t('configs.menus.Process'),
- },
- {
- name: i18n.t('configs.menus.SystemManagement'),
- isAdmin: true,
- children: [
- {
- path: '/user',
- name: i18n.t('configs.menus.UserManagement'),
- },
- {
- path: '/approval',
- name: i18n.t('configs.menus.ProcessManagement'),
- },
- ],
- },
-]);
+const menusTree: MenuItemType[] = genMenuKey(menusTreeConf);
export const menuArrays: Omit<MenuItemType, 'children'>[] =
treeToArray(menusTree, 'key', 'pKey');
diff --git a/inlong-dashboard/src/configs/pagination/index.ts
b/inlong-dashboard/src/configs/pagination/conf.ts
similarity index 86%
copy from inlong-dashboard/src/configs/pagination/index.ts
copy to inlong-dashboard/src/configs/pagination/conf.ts
index 8edf35884..c1efd9d4e 100644
--- a/inlong-dashboard/src/configs/pagination/index.ts
+++ b/inlong-dashboard/src/configs/pagination/conf.ts
@@ -19,7 +19,7 @@
import i18n from '@/i18n';
-export const showTotal = (total: number) => i18n.t('configs.pagination.Total',
{ total });
+const showTotal = (total: number) => i18n.t('configs.pagination.Total', {
total });
const paginationConf = {
showQuickJumper: true,
@@ -28,6 +28,4 @@ const paginationConf = {
showTotal,
};
-export const defaultSize = +paginationConf.pageSizeOptions[0];
-
export default paginationConf;
diff --git a/inlong-dashboard/src/configs/pagination/index.ts
b/inlong-dashboard/src/configs/pagination/index.ts
index 8edf35884..6142fc964 100644
--- a/inlong-dashboard/src/configs/pagination/index.ts
+++ b/inlong-dashboard/src/configs/pagination/index.ts
@@ -17,16 +17,7 @@
* under the License.
*/
-import i18n from '@/i18n';
-
-export const showTotal = (total: number) => i18n.t('configs.pagination.Total',
{ total });
-
-const paginationConf = {
- showQuickJumper: true,
- showSizeChanger: true,
- pageSizeOptions: ['10', '20', '50', '100'],
- showTotal,
-};
+import paginationConf from './conf';
export const defaultSize = +paginationConf.pageSizeOptions[0];
diff --git a/inlong-dashboard/src/configs/routes/index.tsx
b/inlong-dashboard/src/configs/routes/conf.ts
similarity index 53%
copy from inlong-dashboard/src/configs/routes/index.tsx
copy to inlong-dashboard/src/configs/routes/conf.ts
index 8cbfdcefe..54fdd32d0 100644
--- a/inlong-dashboard/src/configs/routes/index.tsx
+++ b/inlong-dashboard/src/configs/routes/conf.ts
@@ -17,159 +17,89 @@
* under the License.
*/
-import { pathToRegexp } from 'path-to-regexp';
-import type { RouteProps as ReactRouteProps } from 'react-router-dom';
-
-export interface RouteProps extends Omit<ReactRouteProps, 'component'> {
- component?: () => Promise<{ default: any }>;
- childRoutes?: RouteProps[];
-}
+import type { RouteProps } from '.';
const routes: RouteProps[] = [
{
path: '/login',
component: () => import('@/pages/Login'),
- exact: true,
},
{
path: '/group',
component: () => import('@/pages/GroupDashboard'),
- exact: true,
childRoutes: [
{
path: '/create/:id?',
component: () => import('@/pages/GroupDetail'),
- exact: true,
},
{
path: '/detail/:id',
component: () => import('@/pages/GroupDetail'),
- exact: true,
},
],
},
{
path: '/consume',
component: () => import('@/pages/ConsumeDashboard'),
- exact: true,
childRoutes: [
{
path: '/create/:id?',
component: () => import('@/pages/ConsumeDetail'),
- exact: true,
},
{
path: '/detail/:id',
component: () => import('@/pages/ConsumeDetail'),
- exact: true,
},
],
},
{
path: '/process',
- exact: true,
childRoutes: [
{
path: '/:type?',
component: () => import('@/pages/Process'),
- exact: true,
childRoutes: [
{
path: '/:id',
component: () => import('@/pages/ProcessDetail'),
- exact: true,
},
],
},
{
path: '/detail/:id',
component: () => import('@/pages/ProcessDetail'),
- exact: true,
},
],
},
{
path: '/user',
component: () => import('@/pages/UserManagement'),
- exact: true,
},
{
path: '/approval',
component: () => import('@/pages/ProcessManagement'),
- exact: true,
},
{
path: '/clusters',
component: () => import('@/pages/Clusters'),
- exact: true,
childRoutes: [
{
path: '/node',
component: () => import('@/pages/Clusters/NodeManage'),
- exact: true,
},
],
},
{
path: '/clusterTags',
component: () => import('@/pages/ClusterTags'),
- exact: true,
},
{
path: '/node',
component: () => import('@/pages/Nodes'),
- exact: true,
},
{
component: () => import('@/pages/Error/404'),
},
];
-/**
- * In a route tree structure array, get all the routing path configuration
simple array collection
- * @param {array} routes
- * @param {string} parentPath Root of current routes
- * @param {function} filterFunction Custom filter function, default none, that
is, get all by default
- * @param {function} returnFunction Custom return function, default none, that
is, return compiledPath by default
- * @return {array}
- */
-function getRoutesPaths(
- routes: RouteProps[],
- parentPath = '',
- filterFunction?: (compiledPath: string, item: RouteProps) => boolean,
- returnFunction?: (compiledPath: string, item: RouteProps) => any,
-): string[] {
- return routes.reduce((acc, item) => {
- const { path, childRoutes } = item;
- const compiledPath = `${parentPath}${path}`;
- const childPaths = childRoutes
- ? getRoutesPaths(childRoutes, compiledPath, filterFunction,
returnFunction)
- : [];
-
- const currentReturn = returnFunction ? returnFunction(compiledPath, item)
: compiledPath;
- return acc.concat(
- filterFunction && !filterFunction(compiledPath, item) ? [] :
currentReturn,
- childPaths,
- );
- }, []);
-}
-
-// All routing path configuration of the project
-const allRoutesPaths = getRoutesPaths(routes);
-
-// The hash format of allRoutesPaths is purely for convenience and efficiency
in use
-const allRoutesPathsMap = allRoutesPaths.reduce(
- (acc, cur) => ({
- ...acc,
- [cur]: true,
- }),
- {},
-);
-
-// Determine whether the incoming pathname has a corresponding route
-export function getPathnameExist(pathname: string): boolean {
- if (allRoutesPathsMap[pathname]) return true;
- return allRoutesPaths.some(route => pathToRegexp(route).test(pathname));
-}
-
export default routes;
diff --git a/inlong-dashboard/src/configs/routes/index.tsx
b/inlong-dashboard/src/configs/routes/index.ts
similarity index 57%
rename from inlong-dashboard/src/configs/routes/index.tsx
rename to inlong-dashboard/src/configs/routes/index.ts
index 8cbfdcefe..0599838f2 100644
--- a/inlong-dashboard/src/configs/routes/index.tsx
+++ b/inlong-dashboard/src/configs/routes/index.ts
@@ -19,112 +19,13 @@
import { pathToRegexp } from 'path-to-regexp';
import type { RouteProps as ReactRouteProps } from 'react-router-dom';
+import routes from './conf';
export interface RouteProps extends Omit<ReactRouteProps, 'component'> {
component?: () => Promise<{ default: any }>;
childRoutes?: RouteProps[];
}
-const routes: RouteProps[] = [
- {
- path: '/login',
- component: () => import('@/pages/Login'),
- exact: true,
- },
- {
- path: '/group',
- component: () => import('@/pages/GroupDashboard'),
- exact: true,
- childRoutes: [
- {
- path: '/create/:id?',
- component: () => import('@/pages/GroupDetail'),
- exact: true,
- },
- {
- path: '/detail/:id',
- component: () => import('@/pages/GroupDetail'),
- exact: true,
- },
- ],
- },
- {
- path: '/consume',
- component: () => import('@/pages/ConsumeDashboard'),
- exact: true,
- childRoutes: [
- {
- path: '/create/:id?',
- component: () => import('@/pages/ConsumeDetail'),
- exact: true,
- },
- {
- path: '/detail/:id',
- component: () => import('@/pages/ConsumeDetail'),
- exact: true,
- },
- ],
- },
- {
- path: '/process',
- exact: true,
- childRoutes: [
- {
- path: '/:type?',
- component: () => import('@/pages/Process'),
- exact: true,
- childRoutes: [
- {
- path: '/:id',
- component: () => import('@/pages/ProcessDetail'),
- exact: true,
- },
- ],
- },
- {
- path: '/detail/:id',
- component: () => import('@/pages/ProcessDetail'),
- exact: true,
- },
- ],
- },
- {
- path: '/user',
- component: () => import('@/pages/UserManagement'),
- exact: true,
- },
- {
- path: '/approval',
- component: () => import('@/pages/ProcessManagement'),
- exact: true,
- },
- {
- path: '/clusters',
- component: () => import('@/pages/Clusters'),
- exact: true,
- childRoutes: [
- {
- path: '/node',
- component: () => import('@/pages/Clusters/NodeManage'),
- exact: true,
- },
- ],
- },
- {
- path: '/clusterTags',
- component: () => import('@/pages/ClusterTags'),
- exact: true,
- },
- {
- path: '/node',
- component: () => import('@/pages/Nodes'),
- exact: true,
- },
- {
- component: () => import('@/pages/Error/404'),
- },
-];
-
/**
* In a route tree structure array, get all the routing path configuration
simple array collection
* @param {array} routes
diff --git a/inlong-dashboard/src/index.tsx b/inlong-dashboard/src/index.tsx
index 5aeedecc0..800a2d148 100644
--- a/inlong-dashboard/src/index.tsx
+++ b/inlong-dashboard/src/index.tsx
@@ -19,6 +19,6 @@
import React from 'react';
import ReactDOM from 'react-dom';
-import App from '@/router';
+import App from '@/App';
ReactDOM.render(<App />, document.getElementById('root'));
diff --git a/inlong-dashboard/src/themes/index.less
b/inlong-dashboard/src/themes/index.less
deleted file mode 100644
index 52d130210..000000000
--- a/inlong-dashboard/src/themes/index.less
+++ /dev/null
@@ -1,26 +0,0 @@
-
-/*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-
-// nprogress
-@import '~nprogress/nprogress.css';
-
-@import './cover.less';
-
-@import './style.less';
diff --git a/inlong-dashboard/src/themes/style.less
b/inlong-dashboard/src/themes/style.less
deleted file mode 100644
index e06f56b70..000000000
--- a/inlong-dashboard/src/themes/style.less
+++ /dev/null
@@ -1,64 +0,0 @@
-
-/*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-
-h1,
-h2,
-h3,
-h4,
-h5,
-h6 {
- margin: 0;
-}
-
-body {
- // https://github.com/postcss/postcss-color-function
- background: #fff;
- @media (--abs-md) {
- background-color: #333;
- }
-}
-
-::-webkit-scrollbar {
- width: 8px;
- height: 8px;
- background: none;
-}
-
-::-webkit-scrollbar-thumb {
- border-radius: 4px;
- background-color: #ccc;
-}
-
-::-webkit-scrollbar-corner {
- background-color: #eaedf0;
-}
-
-ul,
-ol {
- list-style: none;
-}
-
-pre {
- padding: 10px;
- background: #f6f7fb;
- font-size: 12px;
- overflow: auto;
- border-radius: 8px;
-}
diff --git a/inlong-dashboard/src/utils/request.ts
b/inlong-dashboard/src/utils/request.ts
index 019fd6647..e0fe57914 100644
--- a/inlong-dashboard/src/utils/request.ts
+++ b/inlong-dashboard/src/utils/request.ts
@@ -23,6 +23,7 @@ import { RequestOptionsInit } from 'umi-request/types';
import nprogress from 'nprogress';
import { config } from '@/configs/default';
import requestConcurrentMiddleware from './requestConcurrentMiddleware';
+import 'nprogress/nprogress.css';
export interface FetchOptions extends RequestOptionsInit {
url: string;