-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feat(preview): 支持配置图片水印以及禁止右键下载图片
- Loading branch information
Showing
7 changed files
with
168 additions
and
10 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,5 @@ | ||
--- | ||
"@hi-ui/preview": minor | ||
--- | ||
|
||
feat: 支持配置图片水印以及禁止右键下载图片 |
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,5 @@ | ||
--- | ||
"@hi-ui/hiui": patch | ||
--- | ||
|
||
feat(preview): 支持图片配置水印以及禁止右键下载图片 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import React from 'react' | ||
import Preview from '../src' | ||
import Grid from '@hi-ui/grid' | ||
|
||
/** | ||
* @title 禁止右键下载 | ||
*/ | ||
export const Banned = () => { | ||
const [showIndex, setShowIndex] = React.useState(-1) | ||
const [images] = React.useState([ | ||
'http://i1.mifile.cn/f/i/hiui/docs/card/pic_1.png', | ||
'http://i1.mifile.cn/f/i/hiui/docs/card/pic_2.png', | ||
'http://i1.mifile.cn/f/i/hiui/docs/card/pic_3.png', | ||
'http://i1.mifile.cn/f/i/hiui/docs/card/pic_4.png', | ||
]) | ||
|
||
return ( | ||
<> | ||
<h1>Banned</h1> | ||
<div className="preview-banned__wrap"> | ||
<Preview | ||
title={`pic_${showIndex}.png`} | ||
src={images[showIndex]} | ||
visible={showIndex !== -1} | ||
disabledDownload={true} | ||
onClose={() => { | ||
setShowIndex(-1) | ||
}} | ||
/> | ||
|
||
<Grid.Row gutter={true}> | ||
{images.map((url, index) => { | ||
return ( | ||
<Grid.Col span={4} key={index}> | ||
<div> | ||
<img | ||
src={url} | ||
style={{ width: '100%', cursor: 'pointer' }} | ||
onClick={() => { | ||
setShowIndex(index) | ||
}} | ||
/> | ||
</div> | ||
</Grid.Col> | ||
) | ||
})} | ||
</Grid.Row> | ||
</div> | ||
</> | ||
) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import React from 'react' | ||
import Preview from '../src' | ||
import Grid from '@hi-ui/grid' | ||
|
||
/** | ||
* @title 添加水印 | ||
*/ | ||
export const Watermark = () => { | ||
const [showIndex, setShowIndex] = React.useState(-1) | ||
const [images] = React.useState([ | ||
'http://i1.mifile.cn/f/i/hiui/docs/card/pic_1.png', | ||
'http://i1.mifile.cn/f/i/hiui/docs/card/pic_2.png', | ||
'http://i1.mifile.cn/f/i/hiui/docs/card/pic_3.png', | ||
'http://i1.mifile.cn/f/i/hiui/docs/card/pic_4.png', | ||
]) | ||
|
||
return ( | ||
<> | ||
<h1>Watermark</h1> | ||
<div className="preview-watermark__wrap"> | ||
<Preview | ||
title={`pic_${showIndex}.png`} | ||
src={images[showIndex]} | ||
visible={showIndex !== -1} | ||
onClose={() => { | ||
setShowIndex(-1) | ||
}} | ||
watermarkProps={{ | ||
content: ['HiUI', '做中台,就用 HiUI'], | ||
style: { | ||
pointerEvents: 'none', | ||
position: 'fixed', | ||
top: 0, | ||
right: 0, | ||
bottom: 0, | ||
left: 0, | ||
zIndex: 2048, | ||
}, | ||
}} | ||
/> | ||
|
||
<Grid.Row gutter={true}> | ||
{images.map((url, index) => { | ||
return ( | ||
<Grid.Col span={4} key={index}> | ||
<div> | ||
<img | ||
src={url} | ||
style={{ width: '100%', cursor: 'pointer' }} | ||
onClick={() => { | ||
setShowIndex(index) | ||
}} | ||
/> | ||
</div> | ||
</Grid.Col> | ||
) | ||
})} | ||
</Grid.Row> | ||
</div> | ||
</> | ||
) | ||
} |