diff --git a/packages/ui/preview/src/Preview.tsx b/packages/ui/preview/src/Preview.tsx index dc34e2cbd..bbf3c259d 100644 --- a/packages/ui/preview/src/Preview.tsx +++ b/packages/ui/preview/src/Preview.tsx @@ -45,7 +45,7 @@ export const Preview = forwardRef( onClose, src, previewWatermarkProps, - ifAllowDownload = false, + ifAllowDownload = true, }, ref ) => { @@ -319,20 +319,7 @@ export const Preview = forwardRef( )} - + )} diff --git a/packages/ui/preview/stories/banned.stories.tsx b/packages/ui/preview/stories/banned.stories.tsx new file mode 100644 index 000000000..14d5c3c9b --- /dev/null +++ b/packages/ui/preview/stories/banned.stories.tsx @@ -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 ( + <> +

Banned

+
+ { + setShowIndex(-1) + }} + /> + + + {images.map((url, index) => { + return ( + +
+ { + setShowIndex(index) + }} + /> +
+
+ ) + })} +
+
+ + ) +} diff --git a/packages/ui/preview/stories/index.stories.tsx b/packages/ui/preview/stories/index.stories.tsx index 2a2e3581e..d74e26467 100644 --- a/packages/ui/preview/stories/index.stories.tsx +++ b/packages/ui/preview/stories/index.stories.tsx @@ -3,6 +3,8 @@ import Preview from '../src' export * from './basic.stories' export * from './multiple.stories' +export * from './watermark.stories' +export * from './banned.stories' export default { title: 'Data Display/Preview', diff --git a/packages/ui/preview/stories/watermark.stories.tsx b/packages/ui/preview/stories/watermark.stories.tsx new file mode 100644 index 000000000..49b6a76a3 --- /dev/null +++ b/packages/ui/preview/stories/watermark.stories.tsx @@ -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 ( + <> +

Watermark

+
+ { + setShowIndex(-1) + }} + previewWatermarkProps={{ + content: ['HiUI', '做中台,就用 HiUI'], + style: { + pointerEvents: 'none', + position: 'fixed', + top: 0, + right: 0, + bottom: 0, + left: 0, + zIndex: 2048, + }, + }} + /> + + + {images.map((url, index) => { + return ( + +
+ { + setShowIndex(index) + }} + /> +
+
+ ) + })} +
+
+ + ) +}