فهرست منبع

feat(API配置): 新增页面

xieyonghong 3 سال پیش
والد
کامیت
5cfa92d892

+ 17 - 6
src/pages/system/Platforms/Api/base.tsx

@@ -26,7 +26,14 @@ export const ApiModel = model<{
 
 interface ApiPageProps {
   showDebugger?: boolean;
+  /**
+   * true 只展示已赋权的接口
+   */
   isShowGranted?: boolean;
+  /**
+   * false:table暂时所有接口
+   */
+  isOpenGranted?: boolean;
 }
 
 export default observer((props: ApiPageProps) => {
@@ -60,12 +67,15 @@ export default observer((props: ApiPageProps) => {
     const param = new URLSearchParams(location.search);
     const code = param.get('code');
 
-    service.getApiGranted(code!).then((resp: any) => {
-      if (resp.status === 200) {
-        setGrantKeys(resp.result);
-      }
-    });
-  }, [location]);
+    if (props.isOpenGranted === false) {
+    } else {
+      service.getApiGranted(code!).then((resp: any) => {
+        if (resp.status === 200) {
+          setGrantKeys(resp.result);
+        }
+      });
+    }
+  }, [location, props.isOpenGranted]);
 
   useEffect(() => {
     initModel();
@@ -89,6 +99,7 @@ export default observer((props: ApiPageProps) => {
         <Table
           data={ApiModel.data}
           operations={operations}
+          isOpenGranted={props.isOpenGranted}
           isShowGranted={props.isShowGranted}
           grantKeys={GrantKeys}
         />

+ 6 - 2
src/pages/system/Platforms/Api/basePage.tsx

@@ -10,6 +10,8 @@ interface TableProps {
   // 是否只暂时已授权的接口
   isShowGranted?: boolean;
   //
+  isOpenGranted?: boolean;
+  //
   grantKeys: string[];
 }
 
@@ -48,14 +50,16 @@ export default (props: TableProps) => {
   }, [props.isShowGranted, selectKeys, props.data]);
 
   useEffect(() => {
-    if (!props.isShowGranted) {
+    if (props.isOpenGranted === false) {
+      setDataSource(props.data);
+    } else if (!props.isShowGranted) {
       if (props.data && props.data.length && props.operations) {
         getOperations(props.data, props.operations);
       } else {
         setDataSource([]);
       }
     }
-  }, [props.data, props.operations, props.isShowGranted]);
+  }, [props.data, props.operations, props.isShowGranted, props.isOpenGranted]);
 
   const save = useCallback(async () => {
     const param = new URLSearchParams(location.search);

+ 11 - 0
src/pages/system/Platforms/Setting/index.tsx

@@ -0,0 +1,11 @@
+import { PageContainer } from '@ant-design/pro-layout';
+import ApiPage from '../Api/base';
+
+export default () => {
+  return (
+    <PageContainer>
+      <div>配置系统支持API赋权的范围</div>
+      <ApiPage showDebugger={true} isOpenGranted={false} />
+    </PageContainer>
+  );
+};

+ 1 - 0
src/utils/menu/router.ts

@@ -130,6 +130,7 @@ export enum MENUS_CODE {
   'system/Platforms' = 'system/Platforms',
   'system/Platforms/Api' = 'system/Platforms/Api',
   'system/Platforms/View' = 'system/Platforms/View',
+  'system/Platforms/Setting' = 'system/Platforms/Setting',
 }
 
 export type MENUS_CODE_TYPE = keyof typeof MENUS_CODE | string;