minishouyin/test/test-ipc-message.js
2025-11-12 11:35:57 +08:00

19 lines
676 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 测试服务器进程向主进程发送消息的功能
console.log('测试服务器进程向主进程发送消息...');
// 检查是否有process.send方法
if (process.send) {
console.log('process.send方法存在尝试发送测试消息...');
// 发送测试消息
process.send({ type: 'TEST_MESSAGE', data: '这是一条测试消息' });
console.log('测试消息已发送');
// 发送OPEN_CASH_DRAWER消息
process.send({ type: 'OPEN_CASH_DRAWER' });
console.log('OPEN_CASH_DRAWER消息已发送');
} else {
console.log('process.send方法不存在当前环境不支持向父进程发送消息');
}
console.log('测试脚本执行完毕');