-
Notifications
You must be signed in to change notification settings - Fork 242
/
proxy.html
45 lines (42 loc) · 1.5 KB
/
proxy.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<!DOCTYPE html>
<html>
<head>
<title>通用设计器隐藏渲染</title>
<meta charset="utf-8" />
<style>html,body{margin:0}</style>
</head>
<div id="app"></div>
<body>
<script src="dist/viewer.js?v=202408251032"></script>
<script type="module">
let { searchParams } = new URL(location.href);
let id = searchParams.get('pId');//从地址栏获取pId并返回回去,供父页面识别
let action = searchParams.get('action');
let { origin } = location;
window.addEventListener('message', async e => {
let stage = JSON.parse(e.data);
let { page } = stage;
if (page.viewer == 'iot') {
console.error('IoT大屏不支持隐藏渲染');
parent.postMessage({ pId: id }, origin);
} else {
let latent = action != 'print';
let vf = await viewer.install({
version:'202408251032',
use: page.viewer,
latent,
});
if (latent) {
let renderData = await vf.getHTML({ stage });
parent.postMessage({ pId: id, renderData }, origin);
} else {
await vf.print({ stage });
parent.postMessage({ pId: id }, origin);
}
}
});
//通知父页面当前页面就绪
parent.postMessage({ pId: id, action: 'ready' }, origin);
</script>
</body>
</html>