Skip to content

Commit 79a0963

Browse files
DymoneLewisboyongjiong
authored andcommitted
fix(extension): 优化snapshot插件,实现snapshotBase64和snapshotBlob支持自定义导出参数 & 优化snapshot文档和demo
1 parent 5881175 commit 79a0963

File tree

10 files changed

+634
-311
lines changed

10 files changed

+634
-311
lines changed

examples/feature-examples/src/pages/extensions/snapshot/index.tsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,18 @@ export default function SnapshotExample() {
163163
// 预览 blob
164164
const previewBlob = () => {
165165
if (lfRef.current) {
166-
setBase64Data('')
166+
setBlobData('')
167+
const params: ToImageOptions = {
168+
fileType,
169+
backgroundColor,
170+
partial,
171+
width,
172+
height,
173+
padding,
174+
quality,
175+
}
167176
lfRef.current
168-
.getSnapshotBlob(backgroundColor, fileType)
177+
.getSnapshotBlob(backgroundColor, fileType, params)
169178
.then(
170179
({
171180
data,
@@ -186,7 +195,7 @@ export default function SnapshotExample() {
186195
// 预览 base64
187196
const previewBase64 = async () => {
188197
if (lfRef.current) {
189-
setBlobData('')
198+
setBase64Data('')
190199
const params: ToImageOptions = {
191200
fileType,
192201
backgroundColor,
@@ -310,17 +319,17 @@ export default function SnapshotExample() {
310319
<div ref={containerRef} className="graph"></div>
311320
</Flex>
312321
<Row>
313-
<Col span={12}>
322+
<Col span={24}>
314323
{blobData && (
315324
<>
316325
<h2>blobData</h2>
317-
<img key="blob" src={blobData} />
326+
<img style={{ width: '100%' }} key="blob" src={blobData} />
318327
</>
319328
)}
320329
{base64Data && (
321330
<>
322331
<h2>base64Data</h2>
323-
<img key="base64" src={base64Data} />
332+
<img style={{ width: '100%' }} key="base64" src={base64Data} />
324333
</>
325334
)}
326335
</Col>

0 commit comments

Comments
 (0)