更新 HTML 前端页面(接入失效按钮的接收数据展示、添加 ES6 测试案例)
This commit is contained in:
parent
0a1f1228cb
commit
2e389918f3
|
|
@ -92,12 +92,13 @@
|
|||
</div>
|
||||
|
||||
<div style="margin-bottom: 20px;">
|
||||
<div style="font-size: 13px; font-weight: bold; color: #64748b; margin-bottom: 8px;">高级业务样式</div>
|
||||
<div style="font-size: 13px; font-weight: bold; color: #64748b; margin-bottom: 8px;">高级业务样式与测试</div>
|
||||
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 8px;">
|
||||
<button class="btn btn-orange" style="margin:0; padding:10px; font-size:13px;" onclick="callNativePrintColumns()">分栏打印测试</button>
|
||||
<button class="btn btn-orange" style="margin:0; padding:10px; font-size:13px;" onclick="callNativePrintAlarm()">警情通知单</button>
|
||||
<button class="btn btn-orange" style="margin:0; padding:10px; font-size:13px;" onclick="callNativePrintDemo(false)">2寸演示单据</button>
|
||||
<button class="btn btn-orange" style="margin:0; padding:10px; font-size:13px;" onclick="callNativePrintDemo(true)">3寸演示单据</button>
|
||||
<button class="btn" style="margin:0; padding:10px; font-size:13px; background: #0ea5e9; grid-column: span 2;" onclick="testES6Features()">ES6 引擎特性测试</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -460,7 +461,66 @@
|
|||
document.getElementById('aboutModal').style.display = 'none';
|
||||
}
|
||||
|
||||
// 安卓回调函数:退出确认时执行
|
||||
// 打印机查纸回调
|
||||
window.onPaperStateChanged = function(hasPaper) {
|
||||
if (hasPaper) {
|
||||
alert("打印机状态正常:当前有纸");
|
||||
} else {
|
||||
alert("⚠️ 打印机缺纸!请装入纸卷!");
|
||||
}
|
||||
updatePrinterStatus();
|
||||
};
|
||||
|
||||
// PTT 各种事件回调
|
||||
window.onPttEvent = function(eventType, payload) {
|
||||
console.log("收到 PTT 事件: ", eventType, payload);
|
||||
var msg = "";
|
||||
switch(eventType) {
|
||||
case 'GroupList':
|
||||
msg = "获取群组成功,共 " + payload.length + " 个群组。第一组: " + (payload[0] ? payload[0].groupName : "无");
|
||||
break;
|
||||
case 'MemberList':
|
||||
msg = "获取群成员成功,共 " + payload.length + " 个成员。";
|
||||
break;
|
||||
case 'SpeakerUpdate':
|
||||
msg = "当前讲话人: " + payload.talkName + " (组:" + payload.groupName + ")";
|
||||
break;
|
||||
case 'PlayStatus':
|
||||
msg = (payload.playStatus === 1 ? "开始播放:" : "结束播放:") + payload.talkName;
|
||||
break;
|
||||
case 'TempCall':
|
||||
msg = "临时呼叫消息: " + payload.msg;
|
||||
break;
|
||||
case 'UpdateGroup':
|
||||
msg = "进入群组: " + payload.groupName;
|
||||
break;
|
||||
case 'Alarm':
|
||||
msg = "⚠️收到报警: " + payload.memberName + " (纬度:" + payload.latitude + ")";
|
||||
break;
|
||||
default:
|
||||
msg = "收到事件: " + eventType;
|
||||
}
|
||||
showPttResult("[回调] " + msg);
|
||||
};
|
||||
|
||||
// ES6 特性测试函数
|
||||
function testES6Features() {
|
||||
try {
|
||||
const arr = [1, 2, 3];
|
||||
const [a, ...rest] = arr;
|
||||
let sum = rest.reduce((acc, val) => acc + val, 0);
|
||||
const myMap = new Map();
|
||||
myMap.set('key', `Sum is ${sum}`);
|
||||
|
||||
new Promise((resolve) => {
|
||||
setTimeout(() => resolve(myMap.get('key')), 100);
|
||||
}).then(res => {
|
||||
alert(`ES6 引擎测试成功!\n解构: a=${a}\nPromise/Map 返回: ${res}`);
|
||||
});
|
||||
} catch(e) {
|
||||
alert("ES6 测试失败: " + e.message);
|
||||
}
|
||||
}
|
||||
function addExitText() {
|
||||
var tag = document.getElementById('inject-status');
|
||||
if (tag) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue