-
Notifications
You must be signed in to change notification settings - Fork 9
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
syb01094648
committed
Feb 20, 2024
1 parent
f83f565
commit 0f91885
Showing
9 changed files
with
98 additions
and
2 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
48 changes: 48 additions & 0 deletions
48
src/components/map-control-group/export-image-control/index.tsx
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,48 @@ | ||
import { ExportImageControl } from '@antv/larkmap'; | ||
import { Image, Modal } from 'antd'; | ||
import React, { useState } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { downloadImg } from '.././../../utils'; | ||
import useStyle from './styles'; | ||
|
||
export const ExportImage = () => { | ||
const styles = useStyle(); | ||
const [imageData, setImageData] = useState(''); | ||
const [isModalOpen, setIsModalOpen] = useState(false); | ||
const { t } = useTranslation(); | ||
|
||
const onExport = (value: string) => { | ||
setIsModalOpen(true); | ||
setImageData(value); | ||
}; | ||
|
||
const handle = () => { | ||
setIsModalOpen(false); | ||
setImageData(''); | ||
}; | ||
|
||
const onOk = () => { | ||
setIsModalOpen(false); | ||
downloadImg(imageData); | ||
setImageData(''); | ||
}; | ||
return ( | ||
<> | ||
<ExportImageControl | ||
onExport={onExport} | ||
className={styles.l7ExportImg} | ||
imageType="jpeg" | ||
position={'bottomright'} | ||
/> | ||
<Modal | ||
title={t('export-img-control_title')} | ||
open={isModalOpen} | ||
okText={t('btn.download_btn.xiaZai')} | ||
onOk={onOk} | ||
onCancel={handle} | ||
> | ||
<Image src={imageData} /> | ||
</Modal> | ||
</> | ||
); | ||
}; |
28 changes: 28 additions & 0 deletions
28
src/components/map-control-group/export-image-control/styles.ts
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,28 @@ | ||
import { css } from '@emotion/css'; | ||
import { theme } from 'antd'; | ||
|
||
const useStyle = () => { | ||
const { useToken } = theme; | ||
const { token } = useToken(); | ||
|
||
const { colorBgContainer, colorIcon, colorText } = | ||
token; | ||
return { | ||
l7ExportImg: css` | ||
background: ${colorBgContainer}; | ||
color: ${colorIcon}; | ||
svg { | ||
fill: ${colorIcon} !important; | ||
} | ||
:hover { | ||
background: ${colorBgContainer} !important; | ||
svg { | ||
color: ${colorText} !important; | ||
fill: ${colorText} !important; | ||
} | ||
} | ||
`, | ||
}; | ||
}; | ||
export default useStyle; |
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
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