Skip to content

Commit

Permalink
fix(extension): 完善snapshot使用方式和修复跨域报错
Browse files Browse the repository at this point in the history
  • Loading branch information
fanyang committed Jul 23, 2024
1 parent 206fcb3 commit 1f89e85
Show file tree
Hide file tree
Showing 6 changed files with 499 additions and 87 deletions.
11 changes: 11 additions & 0 deletions examples/feature-examples/.umirc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,5 +154,16 @@ export default defineConfig({
},
],
},
{
name: 'test',
path: '/test',
routes: [
{
path: '/test/mini-map&snapshot',
name: 'mini-map&snapshot 测试',
component: './test/mini-map&snapshot',
},
],
},
],
})
18 changes: 13 additions & 5 deletions examples/feature-examples/src/pages/extensions/snapshot/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default function SnapshotExample() {
const [backgroundColor, setBackgroundColor] = useState<string>('white') // 背景颜色
const [padding, setPadding] = useState<number>() //padding
const [quality, setQuality] = useState<number>() // 图片质量
const [partial, setPartial] = useState<boolean>(true) // 导出局部渲染
const [partial, setPartial] = useState<boolean>(false) // 导出局部渲染

const [blobData, setBlobData] = useState('')
const [base64Data, setBase64Data] = useState('')
Expand All @@ -87,7 +87,6 @@ export default function SnapshotExample() {
container: containerRef.current!,
plugins: [Snapshot, DndPanel],
})

lf.register(CustomHtml)
lf.register(ImageNode)

Expand Down Expand Up @@ -131,7 +130,7 @@ export default function SnapshotExample() {
}, [])

// 下载
const downLoad = () => {
const downLoad = async () => {
const params: ToImageOptions = {
fileType,
backgroundColor,
Expand All @@ -142,7 +141,16 @@ export default function SnapshotExample() {
quality,
}
console.log(params, 'params')
lfRef.current?.getSnapshot(fileName, params)
await lfRef.current?.getSnapshot(fileName, params)
// await lfRef.current?.extension.snapshot?.getSnapshot(fileName, params)
// 测试
// lfRef.current?.addNode({
// type: 'circle',
// x: 100,
// y: 100,
// text: '新增circle',
// id: '777'
// })
}

// 预览 blob
Expand Down Expand Up @@ -282,7 +290,7 @@ export default function SnapshotExample() {
onChange={(value) => handleInputChange(value, 'quality')}
/>
<span>导出局部渲染:</span>
<Switch defaultChecked onChange={(partial) => setPartial(partial)} />
<Switch onChange={(partial) => setPartial(partial)} />
</Space>
<Divider />
<Space>
Expand Down
46 changes: 0 additions & 46 deletions examples/feature-examples/src/pages/extensions/snapshot/uml.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.viewport {
position: relative;
height: calc(100vh - 270px);
overflow: hidden;
}
Loading

0 comments on commit 1f89e85

Please sign in to comment.