-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f0b007b
commit 36dd4bd
Showing
6 changed files
with
144 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { formatTime } from '@/scripts/utils'; | ||
import { fetchCurrentCatInfo } from '@/services/cat'; | ||
import { Avatar, Descriptions, Modal } from 'antd'; | ||
import { useEffect, useState } from 'react'; | ||
|
||
const View = ({ open, setViewVisible, currentCat }: any) => { | ||
const [data, setData] = useState<any>({}); | ||
|
||
const handleOk = () => { | ||
setViewVisible(false); | ||
}; | ||
|
||
const handleCancel = () => { | ||
setViewVisible(false); | ||
}; | ||
|
||
useEffect(() => { | ||
if (open) { | ||
fetchCurrentCatInfo({ catId: currentCat }).then((res) => setData(res)); | ||
} | ||
}, [open]); | ||
|
||
const { cat } = data; | ||
const { | ||
age, | ||
area, | ||
avatars, | ||
color, | ||
createAt, | ||
details, | ||
// isSnipped, | ||
isSterilized, | ||
name, | ||
popularity, | ||
sex, | ||
// status, | ||
} = cat; | ||
|
||
return ( | ||
<Modal title="猫咪详情" open={open} onOk={handleOk} onCancel={handleCancel}> | ||
<Descriptions> | ||
<Descriptions.Item label="缩略图"> | ||
<Avatar src={avatars[0] ?? ''} /> | ||
</Descriptions.Item> | ||
<Descriptions.Item label="昵称">{name ?? ''}</Descriptions.Item> | ||
<Descriptions.Item label="花色">{color ?? ''}</Descriptions.Item> | ||
<Descriptions.Item label="年龄">{age ?? ''}</Descriptions.Item> | ||
<Descriptions.Item label="性别">{sex ?? ''}</Descriptions.Item> | ||
<Descriptions.Item label="出没区域">{area ?? ''}</Descriptions.Item> | ||
<Descriptions.Item label="热度">{popularity ?? ''}</Descriptions.Item> | ||
<Descriptions.Item label="是否绝育">{isSterilized ?? '' ? '是' : '否'}</Descriptions.Item> | ||
<Descriptions.Item label="创建时间">{formatTime(createAt ?? '')}</Descriptions.Item> | ||
<Descriptions.Item label="描述">{details ?? ''}</Descriptions.Item> | ||
</Descriptions> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default View; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters