mirror of
https://gitee.com/energye/energy.git
synced 2024-12-16 02:11:35 +08:00
131 lines
4.8 KiB
Go
131 lines
4.8 KiB
Go
<!DOCTYPE html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<title>ipc-event</title>
|
||
<style>
|
||
button {
|
||
margin: 5px;
|
||
}
|
||
</style>
|
||
<script type="application/javascript">
|
||
let idx = 0;
|
||
let si = null;
|
||
|
||
function autoIpcEmit() {
|
||
if (si != null) {
|
||
clearInterval(si)
|
||
si = null
|
||
return
|
||
}
|
||
si = setInterval(ipcEmit, 1)
|
||
}
|
||
|
||
function ipcEmit() {
|
||
let objectValueArray = [
|
||
100, 200, "数组里的字符串", 66996.99,
|
||
]
|
||
let objectValue = {
|
||
"stringField": "stringFieldValue",
|
||
"intField": 1000,
|
||
"arrayField": objectValueArray,
|
||
"doubleField": 999991.102,
|
||
"booleanField": true,
|
||
}
|
||
let arrayValue = [
|
||
100, 200, "数组里的字符串", 66996.99, objectValue, true, false
|
||
]
|
||
let ok = ipc.emit("testEmitName", ["stringValue", 100 + idx, true, 1999.66 + idx, "字符串?", 29999.66 + idx, objectValue, arrayValue, 8888888 + idx, null, undefined],
|
||
function (result1, result2, result3, result4, result5, result6, result7, result8, result9, result10, result11, result12, result13) {
|
||
//msg('testEmitName 回调函数执行了', result1, result2, result3, result4, result5, result6, result7, result8, result9, result10, result11, result12);
|
||
|
||
//第2个返回值是 ArrayBuffer 类型,字节数组
|
||
let result2ArrayBuffer = new Uint8Array(result2);
|
||
let result2Decode = new TextDecoder()//中文转码,不乱码
|
||
let decodedString = result2Decode.decode(result2ArrayBuffer);
|
||
|
||
// msg('result1:', JSON.stringify(result1));
|
||
// msg('result2: 字符串-字节数组:', decodedString);
|
||
// msg('result3:', JSON.stringify(result3));
|
||
// msg('result4:', JSON.stringify(result4));
|
||
// msg('result5:', JSON.stringify(result5));
|
||
// msg('result6:', JSON.stringify(result6));
|
||
// msg('result7:', JSON.stringify(result7));
|
||
// msg('result8:', JSON.stringify(result8));
|
||
// msg('result9:', JSON.stringify(result9));
|
||
// msg('result10:', JSON.stringify(result10));
|
||
// msg('result11:', JSON.stringify(result11));
|
||
// msg('result12:', JSON.stringify(result12));
|
||
// msg('result13:', JSON.stringify(result13));
|
||
console.log('result1:', result1)
|
||
console.log('result2:', result2)
|
||
console.log('result3:', result3)
|
||
console.log('result4:', result4)
|
||
console.log('result5:', result5)
|
||
console.log('result6:', result6)
|
||
console.log('result7:', result7)
|
||
console.log('result8:', result8)
|
||
console.log('result9:', result9)
|
||
console.log('result10:', result10)
|
||
console.log('result11:', result11)
|
||
console.log('result12:', result12)
|
||
console.log('result13:', result13)
|
||
});
|
||
//msg('ipc.emit ok?', ok);
|
||
|
||
//let ok1 = ipc.emit([]);
|
||
// msg('ipc.emit ok?', ok1);
|
||
}
|
||
|
||
ipc.on('onTestName1', function (param1, param2, param3) {
|
||
|
||
});
|
||
ipc.on('onTestName2', function (param1, param2, param3) {
|
||
|
||
});
|
||
|
||
function bindFunc() {
|
||
energy.funcName();
|
||
}
|
||
|
||
function bindField() {
|
||
clearMsg();
|
||
msg('stringField', energy.stringField);
|
||
msg('intField', energy.intField);
|
||
msg('doubleField', energy.doubleField);
|
||
msg('boolField', energy.boolField);
|
||
}
|
||
</script>
|
||
</head>
|
||
<body style="margin: 0px;padding: 0px;">
|
||
<p>
|
||
<h3>process-message</h3></p>
|
||
<p><a target="_blank" href="ipc-event.html">open</a></p>
|
||
<p>
|
||
<button onclick="ipcEmit()">ipcEmit</button>
|
||
<button onclick="autoIpcEmit()">自动-ipcEmit</button>
|
||
<br>
|
||
<button onclick="bindFunc()">bindFunc</button>
|
||
<button onclick="bindField()">bindField</button>
|
||
</p>
|
||
<p id="msgHtml"></p>
|
||
</body>
|
||
<script type="application/javascript">
|
||
let msgHtml = document.getElementById("msgHtml");
|
||
|
||
function msg(...vvv) {
|
||
let str = msgHtml.innerHTML;
|
||
for (let i = 0; i < vvv.length; i++) {
|
||
str = str + " " + vvv[i];
|
||
}
|
||
str += "<br>";
|
||
msgHtml.innerHTML = str;
|
||
}
|
||
|
||
function clearMsg() {
|
||
msgHtml.innerHTML = "";
|
||
}
|
||
|
||
msg("ipc-event: 页面加载完成...");
|
||
</script>
|
||
</html> |