XieYongHong 3 роки тому
батько
коміт
9acdc0d23b

BIN
public/images/device/button.png


+ 1 - 1
src/locales/zh-CN/pages.ts

@@ -197,7 +197,7 @@ export default {
   'pages.device.product.status.all': '全部',
   'pages.device.productDetail': '产品详情',
   'pages.device.productDetail.id': '产品ID',
-  'pages.device.productDetail.classifiedName': '所属品类',
+  'pages.device.productDetail.classifiedName': '产品分类',
   'pages.device.productDetail.protocolName': '消息协议',
   'pages.device.productDetail.transportProtocol': '接入方式',
   'pages.device.productDetail.createTime': '创建时间',

+ 18 - 6
src/pages/device/Instance/Detail/index.tsx

@@ -24,7 +24,7 @@ import SystemConst from '@/utils/const';
 import { getMenuPathByCode, getMenuPathByParams, MENUS_CODE } from '@/utils/menu';
 import useSendWebsocketMessage from '@/hooks/websocket/useSendWebsocketMessage';
 import { PermissionButton } from '@/components';
-import { QuestionCircleOutlined, SyncOutlined } from '@ant-design/icons';
+import { QuestionCircleOutlined } from '@ant-design/icons';
 import Service from '@/pages/device/Instance/service';
 import useLocation from '@/hooks/route/useLocation';
 import { onlyMessage } from '@/utils/util';
@@ -426,7 +426,9 @@ const InstanceDetail = observer(() => {
         //     defaultMessage: '应用配置',
         //   })}
         // </Button>,
-        <SyncOutlined
+        <img 
+        style={{marginRight:20,cursor: 'pointer'}}
+        src={require('/public/images/device/button.png')} 
           onClick={() => {
             getDetail(params.id);
             service.getConfigMetadata(params.id).then((config) => {
@@ -435,10 +437,20 @@ const InstanceDetail = observer(() => {
                 message.success('操作成功!');
               }
             });
-          }}
-          style={{ fontSize: 20, marginRight: 20 }}
-          key="1"
-        />,
+          }}/>
+        // <SyncOutlined
+        //   onClick={() => {
+        //     getDetail(params.id);
+        //     service.getConfigMetadata(params.id).then((config) => {
+        //       if (config.status === 200) {
+        //         InstanceModel.config = config?.result || [];
+        //         message.success('操作成功!');
+        //       }
+        //     });
+        //   }}
+        //   style={{ fontSize: 20, marginRight: 20 }}
+        //   key="1"
+        // />,
       ]}
     >
       {list.find((k) => k.key === InstanceModel.active)?.component}

+ 131 - 0
src/pages/home/Api/index.tsx

@@ -0,0 +1,131 @@
+import { Button, Card, Col, Input, Popover, Row } from 'antd';
+import { useEffect, useState } from 'react';
+import { service } from '@/pages/system/Platforms';
+import Service from '../service'
+import * as moment from 'moment';
+import ApiPage from '@/pages/system/Platforms/Api/base'
+
+const defaultHeight = 50;
+
+
+export default () => {
+
+    const api = new Service()
+    const [clientId, setClientId] = useState('');
+    const [secureKey, setSecureKey] = useState('');
+    const [sdkDetail, setSdkDetail] = useState<any>({});
+
+    const getDetail = async (id: string) => {
+        const resp = await service.getDetail(id);
+        if (resp.status === 200) {
+            setClientId(resp.result?.id);
+            setSecureKey(resp.result?.secureKey);
+        }
+    };
+
+    const getSDKDetail = async () => {
+        const resp = await service.getSdk();
+        if (resp.status === 200) {
+            setSdkDetail(resp.result[0]);
+        }
+    };
+
+    const downLoad = (url: string) => {
+        if (url) {
+            const downNode = document.createElement('a');
+            downNode.href = url;
+            downNode.download = `${moment(new Date()).format('YYYY-MM-DD-HH-mm-ss')}.sdk`;
+            downNode.style.display = 'none';
+            downNode.setAttribute('target', '_blank');
+            document.body.appendChild(downNode);
+            downNode.click();
+            document.body.removeChild(downNode);
+        }
+    };
+
+
+    useEffect(() => {
+        //  请求SDK下载地址
+        getSDKDetail();
+        api.userDetail().then(res => {
+            if (res.status === 200) {
+              api.apiDetail(
+                {
+                  "terms": [
+                    {
+                      "column": "userId",
+                      "value": res.result.id
+                    }
+                  ]
+                }
+              ).then(response => {
+                if (response.status === 200) {
+                  getDetail(response.result.data[0].id)
+                }
+              })
+            }
+          })
+    }, []);
+
+
+
+    const downLoadJDK = (
+        <div>
+            <div
+                style={{
+                    width: 500,
+                    borderRadius: 2,
+                    marginBottom: 12,
+                }}
+            >
+                <Input.TextArea value={sdkDetail?.dependency} rows={6} readOnly />
+            </div>
+            <Button
+                type={'primary'}
+                style={{ width: '100%' }}
+                onClick={() => {
+                    downLoad(sdkDetail.sdk);
+                }}
+            >
+                jar下载
+            </Button>
+        </div>
+    );
+
+    return (
+        <Row gutter={[16, 16]}>
+            <Col span={24}>
+                <Row gutter={16}>
+                    <Col span={12}>
+                        <Card title="基本信息">
+                            <div style={{ height: defaultHeight }}>
+                                <div>
+                                    <span style={{ fontWeight: 'bold', fontSize: 16 }}>clientId: </span>
+                                    {clientId}
+                                </div>
+                                <div>
+                                    <span style={{ fontWeight: 'bold', fontSize: 16 }}>secureKey: </span>
+                                    {secureKey}
+                                </div>
+                            </div>
+                        </Card>
+                    </Col>
+                    <Col span={12}>
+                        <Card title="SDK下载">
+                            <div style={{ height: defaultHeight }}>
+                                <Popover trigger="click" title={'POM依赖'} content={downLoadJDK}>
+                                    <Button> Java </Button>
+                                </Popover>
+                            </div>
+                        </Card>
+                    </Col>
+                </Row>
+            </Col>
+            <Col span={24}>
+                <Card title={'API文档'}>
+                    <ApiPage type={'authorize'} showDebugger={true} isShowGranted={true} showHome={true} />
+                </Card>
+            </Col>
+        </Row>
+    );
+};

+ 27 - 1
src/pages/home/index.tsx

@@ -4,6 +4,7 @@ import Comprehensive from './comprehensive';
 import Device from './device';
 import Init from './init';
 import Ops from './ops';
+import Api from './Api'
 import Service from './service';
 import { Skeleton } from 'antd';
 
@@ -12,6 +13,7 @@ const Home = () => {
   type ViewType = keyof typeof ViewMap;
   const [current, setCurrent] = useState<ViewType>('init'); // 默认为初始化
   const [loading, setLoading] = useState(true);
+  const [detail, setDetail] = useState<any>({})
 
   const ViewMap = {
     init: <Init changeView={(value: ViewType) => setCurrent(value)} />,
@@ -31,11 +33,35 @@ const Home = () => {
         }
       }
     });
+
   }, []);
+  useEffect(() => {
+    service.userDetail().then(res => {
+      if (res.status === 200) {
+        service.apiDetail(
+          {
+            "terms": [
+              {
+                "column": "userId",
+                "value": res.result.id
+              }
+            ]
+          }
+        ).then(response => {
+          if (response.status === 200) {
+            setDetail(response.result?.data)
+          }
+        })
+      }
+    })
+  }, [])
+
   return (
     <PageContainer>
       <Skeleton loading={loading} active>
-        {ViewMap[current]}
+        {
+          detail && detail.length > 0 ? <Api /> : <>{ViewMap[current]}</>
+        }
       </Skeleton>
     </PageContainer>
   );

+ 9 - 0
src/pages/home/service.ts

@@ -21,6 +21,15 @@ class Service {
       method: 'POST',
       data,
     });
+  userDetail = () =>
+    request(`/${SystemConst.API_BASE}/user/detail`, {
+      method: 'GET',
+    })
+  apiDetail = (data:any) =>
+    request(`/${SystemConst.API_BASE}/api-client/_query`, {
+      method: 'POST',
+      data,
+    });
 }
 
 export default Service;

+ 2 - 0
src/pages/notice/Config/Log/index.tsx

@@ -65,6 +65,8 @@ const Log = observer(() => {
     {
       dataIndex: 'action',
       title: '操作',
+      valueType: 'option',
+      hideInSearch:true,
       render: (text, record) => [
         <a
           onClick={() => {

+ 1 - 0
src/pages/notice/Template/Log/index.tsx

@@ -65,6 +65,7 @@ const Log = observer(() => {
     {
       dataIndex: 'action',
       title: '操作',
+      hideInSearch:true,
       render: (text, record) => [
         <a
           key="info"

+ 1 - 1
src/pages/system/Platforms/Api/base.tsx

@@ -103,7 +103,7 @@ export default observer((props: ApiPageProps) => {
           showHome={props.showHome}
           type={props.type}
           onSelect={(data) => {
-            console.log(data);
+            // console.log(data);
             ApiModel.data = data;
             ApiModel.showTable = true;
           }}

+ 3 - 3
src/pages/system/Platforms/Api/leftTree.tsx

@@ -33,7 +33,7 @@ export default (props: LeftTreeType) => {
   const updateTreeData = useCallback(
     (list: DataNode[], parentItem: any): DataNode[] => {
       let newArray: any[] = list;
-      console.log(list, props.grantKeys);
+      // console.log(list, props.grantKeys);
       if (props.type === 'empowerment') {
         newArray = list.filter(
           (item: any) =>
@@ -102,7 +102,7 @@ export default (props: LeftTreeType) => {
     });
 
     forkJoin(ofArray).subscribe((res) => {
-      console.log(res);
+      // console.log(res);
       setLoading(false);
       setTreeData(extraData ? [extraData, ...res] : res);
     });
@@ -169,7 +169,7 @@ export default (props: LeftTreeType) => {
     }
   }, [props.operations, props.grantKeys, props.type]);
 
-  console.log(treeData);
+  // console.log(treeData);
   return (
     <div
       style={{