-
Notifications
You must be signed in to change notification settings - Fork 250
/
proxy.html
55 lines (52 loc) · 1.65 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
46
47
48
49
50
51
52
53
54
55
<!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=202412151014"></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;
try {
stage = JSON.parse(e.data);
} catch {
stage = 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:'202412151014',
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>