|
1 | | -import React, {useEffect, useState} from "react"; |
| 1 | +import React, { useEffect, useState } from "react"; |
2 | 2 | import axios from "axios"; |
| 3 | +import { useParams } from 'dva/router' |
| 4 | + |
3 | 5 | import Page from "@alicloud/console-components-page"; |
4 | 6 | import Table from "@alicloud/console-components-table"; |
5 | | -import {Badge, Button} from "@alicloud/console-components"; |
6 | | -import {LinkButton} from "@alicloud/console-components-actions"; |
| 7 | +import { Badge, Button } from "@alicloud/console-components"; |
| 8 | +import { LinkButton } from "@alicloud/console-components-actions"; |
| 9 | + |
7 | 10 |
|
8 | 11 | const AppDetail: React.FC<{}> = () => { |
9 | | - const [appList, setAppList] = useState([]); |
| 12 | + console.log("useParams", useParams); |
| 13 | + const params = useParams(); |
| 14 | + console.log("params", params); |
| 15 | + |
| 16 | + const [appItem, setAppItem] = useState(""); |
10 | 17 | useEffect(() => { |
11 | 18 | fetchAppList(); |
12 | 19 | }, []); |
13 | 20 | // 这个是分页接口,但是需要拿到全部数据 |
14 | 21 | const fetchAppList = async () => { |
15 | | - const data = await axios.get('/api/application/getApplicationList') |
| 22 | + const data = await axios.get('/api/application/describeApplication', { params: { appName: 'example-spring-cloud' } }) |
16 | 23 | .then(function (response) { |
17 | | - return response?.data?.data; |
| 24 | + return response?.data; |
18 | 25 | }); |
19 | | - setAppList(data); |
| 26 | + setAppItem(data.appName); |
20 | 27 | }; |
21 | 28 |
|
22 | 29 | return ( |
23 | 30 | <Page> |
24 | | - <Page.Header title="应用列表"/> |
| 31 | + <Page.Header title="应用详情" /> |
25 | 32 | <Page.Content> |
26 | | - <Table |
27 | | - exact |
28 | | - fixedBarExpandWidth={[24]} |
29 | | - affixActionBar |
30 | | - dataSource={appList} |
31 | | - primaryKey="appName" |
32 | | - search={{ |
33 | | - filter: [ |
34 | | - { |
35 | | - value: 'AppName', |
36 | | - label: '应用名称', |
37 | | - }, |
38 | | - ], |
39 | | - defaultValue: 'AppName', |
40 | | - }} |
41 | | - pagination={{ |
42 | | - current: 1, |
43 | | - total: 80, |
44 | | - pageSize: 20, |
45 | | - }} |
46 | | - selection={({selectedRowKeys}: any) => ( |
47 | | - <> |
48 | | - <Badge count={selectedRowKeys.length}> |
49 | | - <Button disabled={selectedRowKeys.length === 0}> |
50 | | - Delete |
51 | | - </Button> |
52 | | - </Badge> |
53 | | - </> |
54 | | - )} |
55 | | - > |
56 | | - <Table.Column title="应用名" cell={render} width={200}/> |
57 | | - </Table> |
| 33 | + {appItem} |
58 | 34 | </Page.Content> |
59 | 35 | </Page> |
60 | 36 | ) |
61 | 37 | } |
62 | 38 |
|
63 | 39 |
|
64 | | -const render = (value :any, index:any, record:any) => { |
| 40 | +const render = (value: any, index: any, record: any) => { |
65 | 41 | console.log(value, index, record); |
66 | 42 | return ( |
67 | 43 | <LinkButton |
68 | 44 | href={`https://baidu.com`} |
69 | | - // onClick={() => { |
70 | | - // alert("on click"); |
71 | | - // }} |
| 45 | + // onClick={() => { |
| 46 | + // alert("on click"); |
| 47 | + // }} |
72 | 48 | > |
73 | 49 | {record.appName} |
74 | 50 | </LinkButton> |
|
0 commit comments