This is an automated email from the ASF dual-hosted git repository.
juzhiyuan pushed a commit to branch next
in repository https://gitbox.apache.org/repos/asf/incubator-apisix-dashboard.git
The following commit(s) were added to refs/heads/next by this push:
new f5c1389 Feat setting (#214)
f5c1389 is described below
commit f5c1389723807f49b0a83de54a7736c92373a96d
Author: 琚致远 <[email protected]>
AuthorDate: Mon May 25 06:21:10 2020 +0800
Feat setting (#214)
* feat: refactor setting
* fix: setting
* feat: update version
---
config/config.ts | 12 +-----------
package.json | 2 +-
src/app.tsx | 2 +-
src/pages/{ => Settings}/Settings.tsx | 3 ++-
src/pages/Settings/index.ts | 2 ++
src/pages/Settings/service.ts | 16 ++++++++++++++++
src/pages/Settings/typing.d.ts | 9 +++++++++
src/pages/ssl/List.tsx | 2 +-
src/pages/ssl/typing.d.ts | 2 +-
src/typings.d.ts | 14 --------------
src/utils/setting.ts | 9 ---------
11 files changed, 34 insertions(+), 39 deletions(-)
diff --git a/config/config.ts b/config/config.ts
index ab1862e..b332ab4 100644
--- a/config/config.ts
+++ b/config/config.ts
@@ -4,12 +4,7 @@ import defaultSettings from './defaultSettings';
import proxy from './proxy';
import routes from './routes';
-const { REACT_APP_ENV, NODE_ENV } = process.env;
-
-const getRequestPrefix = () => {
- if (NODE_ENV === 'development') return '/api';
- return '';
-};
+const { REACT_APP_ENV } = process.env;
export default defineConfig({
hash: true,
@@ -38,11 +33,6 @@ export default defineConfig({
publicPath: '/',
define: {
REACT_APP_ENV: REACT_APP_ENV || false,
- ADMIN_API_SCHEMA: 'http',
- ADMIN_API_HOST: '127.0.0.1:9080',
- ADMIN_API_PATH: '/apisix/admin',
- API_KEY: '',
- API_REQUEST_PREFIX: getRequestPrefix(),
},
// Theme for antd: https://ant.design/docs/react/customize-theme-cn
theme: {
diff --git a/package.json b/package.json
index f8f260c..1e38476 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "apisix-dashboard",
- "version": "1.0.1",
+ "version": "1.0.2",
"private": true,
"description": "Dashboard for APISIX",
"scripts": {
diff --git a/src/app.tsx b/src/app.tsx
index 9e5d5fd..70ce2e1 100644
--- a/src/app.tsx
+++ b/src/app.tsx
@@ -3,7 +3,7 @@ import { notification } from 'antd';
import { RequestConfig, history } from 'umi';
import { BasicLayoutProps, Settings as LayoutSettings } from
'@ant-design/pro-layout';
-import { getAdminAPIConfig } from '@/utils/setting';
+import { getAdminAPIConfig } from '@/pages/Settings';
import RightContent from '@/components/RightContent';
import Footer from '@/components/Footer';
import { queryCurrent } from '@/services/user';
diff --git a/src/pages/Settings.tsx b/src/pages/Settings/Settings.tsx
similarity index 98%
rename from src/pages/Settings.tsx
rename to src/pages/Settings/Settings.tsx
index 193d88c..4589c79 100644
--- a/src/pages/Settings.tsx
+++ b/src/pages/Settings/Settings.tsx
@@ -3,7 +3,8 @@ import { useForm } from 'antd/es/form/util';
import { Button, Card, Form, Input, notification, Select } from 'antd';
import { useIntl, FormattedMessage, history } from 'umi';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
-import { getAdminAPIConfig } from '@/utils/setting';
+
+import { getAdminAPIConfig } from './service';
const { Option } = Select;
diff --git a/src/pages/Settings/index.ts b/src/pages/Settings/index.ts
new file mode 100644
index 0000000..d990ce6
--- /dev/null
+++ b/src/pages/Settings/index.ts
@@ -0,0 +1,2 @@
+export { default } from './Settings';
+export * from './service';
diff --git a/src/pages/Settings/service.ts b/src/pages/Settings/service.ts
new file mode 100644
index 0000000..18d87bd
--- /dev/null
+++ b/src/pages/Settings/service.ts
@@ -0,0 +1,16 @@
+export const getRequestPrefix = () => {
+ if (process.env.NODE_ENV === 'development') {
+ return '/api';
+ }
+ return '';
+};
+
+export const getAdminAPIConfig = (): SettingModule.AdminAPIConfig => {
+ return {
+ schema: localStorage.getItem('GLOBAL_ADMIN_API_SCHEMA') || 'http',
+ host: localStorage.getItem('GLOBAL_ADMIN_API_HOST') || '127.0.0.1:9080',
+ path: localStorage.getItem('GLOBAL_ADMIN_API_PATH') || '/apisix/admin',
+ prefix: getRequestPrefix(),
+ key: localStorage.getItem('GLOBAL_ADMIN_API_KEY') || '',
+ };
+};
diff --git a/src/pages/Settings/typing.d.ts b/src/pages/Settings/typing.d.ts
new file mode 100644
index 0000000..e846281
--- /dev/null
+++ b/src/pages/Settings/typing.d.ts
@@ -0,0 +1,9 @@
+declare namespace SettingModule {
+ interface AdminAPIConfig {
+ schema: string;
+ host: string;
+ path: string;
+ prefix: string;
+ key: string;
+ }
+}
diff --git a/src/pages/ssl/List.tsx b/src/pages/ssl/List.tsx
index 5a21d64..16949eb 100644
--- a/src/pages/ssl/List.tsx
+++ b/src/pages/ssl/List.tsx
@@ -5,8 +5,8 @@ import { Button, Modal, notification, Switch } from 'antd';
import { history, useIntl } from 'umi';
import { PlusOutlined } from '@ant-design/icons';
-import { fetchList as fetchSSLList, remove as removeSSL } from './service';
import { ListItem } from '@/transforms/global';
+import { fetchList as fetchSSLList, remove as removeSSL } from './service';
interface SearchParamsProps {
current: number;
diff --git a/src/pages/ssl/typing.d.ts b/src/pages/ssl/typing.d.ts
index 4799329..337adb6 100644
--- a/src/pages/ssl/typing.d.ts
+++ b/src/pages/ssl/typing.d.ts
@@ -1,5 +1,5 @@
declare namespace SSLModule {
- export type SSL = {
+ type SSL = {
sni: string[];
cert: string;
key: string;
diff --git a/src/typings.d.ts b/src/typings.d.ts
index 6eb33dc..b52e470 100644
--- a/src/typings.d.ts
+++ b/src/typings.d.ts
@@ -37,20 +37,6 @@ declare let
ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION: 'site' | undefine
declare const REACT_APP_ENV: 'test' | 'dev' | 'pre' | false;
-declare let ADMIN_API_SCHEMA;
-declare let ADMIN_API_HOST;
-declare let ADMIN_API_PATH;
-declare let API_KEY: '';
-declare let API_REQUEST_PREFIX: '';
-
-declare interface AdminAPIConfig {
- schema: string;
- host: string;
- path: string;
- prefix: string;
- key: string;
-}
-
type PageMode = 'CREATE' | 'EDIT' | 'VIEW';
interface PluginProperty {
diff --git a/src/utils/setting.ts b/src/utils/setting.ts
deleted file mode 100644
index 9b5898c..0000000
--- a/src/utils/setting.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-export const getAdminAPIConfig = (): AdminAPIConfig => {
- return {
- schema: localStorage.getItem('GLOBAL_ADMIN_API_SCHEMA') ||
ADMIN_API_SCHEMA,
- host: localStorage.getItem('GLOBAL_ADMIN_API_HOST') || ADMIN_API_HOST,
- path: localStorage.getItem('GLOBAL_ADMIN_API_PATH') || ADMIN_API_PATH,
- prefix: API_REQUEST_PREFIX,
- key: localStorage.getItem('GLOBAL_ADMIN_API_KEY') || API_KEY
- };
-}