From 796047fbe84d51816f44be535501415d3c66dd9d Mon Sep 17 00:00:00 2001
From: yxh <172933527@qq.com>
Date: 星期日, 21 六月 2026 23:24:37 +0800
Subject: [PATCH] yxh
---
small.html | 189 ++++++++++++++++++++++++++++++++++++----------
1 files changed, 146 insertions(+), 43 deletions(-)
diff --git a/small.html b/small.html
index e3515a3..9a166ec 100644
--- a/small.html
+++ b/small.html
@@ -1,4 +1,4 @@
-<!DOCTYPE html>
+锘�<!DOCTYPE html>
<html lang="zh-CN">
<head>
@@ -36,8 +36,7 @@
.header-top {
display: flex;
align-items: center;
- justify-content: center;
- gap: 30px;
+ justify-content: space-between;
}
.logo {
@@ -48,13 +47,19 @@
display: flex;
flex-direction: column;
line-height: 1.2;
- text-align: center;
+ text-align: right;
}
.week-day,
.full-date {
font-size: 16px;
color: #666;
+ }
+
+ .header-right {
+ display: flex;
+ align-items: center;
+ gap: 15px;
}
.clock {
@@ -87,22 +92,35 @@
border-radius: 12px;
display: flex;
flex-direction: row;
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
+ box-shadow: 0 3px 12px rgba(0, 0, 0, 0.15);
overflow: hidden;
flex: 1;
+ border: 2px solid #e0e0e0;
+ }
+
+ .status-active {
+ border-color: #67c23a;
+ }
+
+ .status-waiting {
+ border-color: #e6a23c;
+ }
+
+ .status-missed {
+ border-color: #f56c6c;
}
/* 宸︿晶鐘舵�佹爣绛� (绔栨帓) */
.panel-header {
- width: 60px;
+ width: 70px;
display: flex;
align-items: center;
justify-content: center;
- font-size: 22px;
+ font-size: 32px;
font-weight: bold;
color: #fff;
writing-mode: vertical-rl;
- letter-spacing: 6px;
+ letter-spacing: 12px;
text-align: center;
flex-shrink: 0;
}
@@ -134,27 +152,33 @@
/* 鎮h�呬俊鎭」 (鍥哄畾楂樺害锛屼竴琛屼袱涓�) */
.patient-item {
width: calc(50% - 5px);
- height: 60px;
+ height: 70px;
display: flex;
- justify-content: space-between;
+ justify-content: flex-start;
align-items: center;
- padding: 0 15px;
+ padding: 0 8px;
background: #ffffff;
border: 1px solid #eee;
border-radius: 8px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
+ white-space: nowrap;
+ overflow: hidden;
}
.p-name {
- font-size: 28px;
+ font-size: 36px;
font-weight: bold;
color: #303133;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
}
.p-num {
- font-size: 24px;
+ font-size: 30px;
color: #909399;
font-weight: bold;
+ flex-shrink: 0;
}
/* ================= 搴曢儴鎺у埗鍖� ================= */
@@ -177,6 +201,7 @@
}
#test-voice-btn {
+ display: none;
position: absolute;
right: 20px;
background-color: #007bff;
@@ -195,6 +220,7 @@
/* 璋冭瘯淇℃伅鍖� */
.debug-info {
+ display: none;
font-size: 14px;
color: #999;
background: #f0f0f0;
@@ -222,11 +248,13 @@
<div class="header">
<div class="header-top">
<img src="logo.png" alt="Logo" class="logo">
- <div class="time-box">
- <span class="week-day" id="weekDay">鏄熸湡鏃�</span>
- <span class="full-date" id="fullDate">2024骞�01鏈�01鏃�</span>
+ <div class="header-right">
+ <div class="time-box">
+ <span class="week-day" id="weekDay">鏄熸湡鏃�</span>
+ <span class="full-date" id="fullDate">2024骞�01鏈�01鏃�</span>
+ </div>
+ <div class="clock" id="clock">12:00</div>
</div>
- <div class="clock" id="clock">12:00</div>
</div>
<div class="room-line"><span id="currentRoomId">--</span></div>
</div>
@@ -234,19 +262,19 @@
<!-- 涓讳綋鍐呭 -->
<div class="main-container">
<!-- 1. 姝e湪灏辫瘖 -->
- <div class="panel status-active" style="max-height: calc(60px * 2 + 20px + 20px);">
- <div class="panel-header">姝e湪灏辫瘖</div>
+ <div class="panel status-active" style="max-height: calc(70px * 2 + 20px + 20px);">
+ <div class="panel-header">璇婁腑</div>
<div class="list-content" id="inProgressList"></div>
</div>
<!-- 2. 鍊欒瘖涓� -->
- <div class="panel status-waiting" style="max-height: calc(60px * 4 + 30px + 20px);">
- <div class="panel-header">鍊欒瘖涓�</div>
+ <div class="panel status-waiting" style="max-height: calc(70px * 4 + 30px + 20px);">
+ <div class="panel-header">绛夊��</div>
<div class="list-content" id="waitingList"></div>
</div>
<!-- 3. 杩囧彿 -->
- <div class="panel status-missed" style="max-height: calc(60px * 3 + 20px + 20px);">
+ <div class="panel status-missed" style="max-height: calc(70px * 3 + 20px + 20px);">
<div class="panel-header">杩囧彿</div>
<div class="list-content" id="missedList"></div>
</div>
@@ -254,7 +282,7 @@
<!-- 搴曢儴鎺у埗鏍� -->
<div class="footer">
- <span class="footer-text">娓╅Θ鎻愮ず锛氳鑰愬績绛夊緟锛屼繚鎸佸畨闈欙紒</span>
+ <span class="footer-text">娓╅Θ鎻愮ず锛氳杩囧彿鎮h�呭埌鍒嗚瘖鍙板鐞嗭紒</span>
<button id="test-voice-btn">娴嬭瘯璇煶</button>
</div>
@@ -262,63 +290,130 @@
<div class="debug-info" id="debugInfo">璋冭瘯鐘舵�侊細绛夊緟鏁版嵁...</div>
<script>
+ // ================= URL 鍙傛暟璇诲彇 =================
+ function getUrlParam(name) {
+ var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
+ var r = window.location.search.substr(1).match(reg);
+ if (r != null) return decodeURIComponent(r[2]);
+ return null;
+ }
+
// ================= 閰嶇疆鍙傛暟 =================
var CONFIG = {
- apiBaseUrl: "http://192.168.100.110:48080/admin-api",
- // apiBaseUrl: "http://192.168.100.110:48080/admin-api",
- roomId: "116",
+ // apiBaseUrl: "http://192.168.3.12/admin-api",
+ apiBaseUrl: "http://10.0.2.193/admin-api",
+ roomId: getUrlParam("roomID") || "116",
refreshRate: 5000
};
- var CALL_TIMES = 2; // 鍙彿娆℃暟
+ // 璇婂缂栧彿 鈫� 鍚嶇О鏄犲皠锛氬綋鎺ュ彛鏈繑鍥� roomName 鏃跺厹搴�
+ var ROOM_NAME_MAP = {
+ "116": "1鍙疯瘖瀹�",
+ "117": "2鍙疯瘖瀹�",
+ "118": "3鍙疯瘖瀹�",
+ "119": "4鍙疯瘖瀹�",
+ "121": "6鍙疯瘖瀹�",
+ "123": "8鍙疯瘖瀹�",
+ "125": "鍒嗚瘖鍙�"
+ };
+ var CALL_TIMES = 2; // 鍙彿娆℃暟
- var appState = { roomName: '', lastSpokenPatient: null };
+ var appState = { roomName: '', lastSpokenPatient: null, serverTimeOffset: 0 };
function $(id) { return document.getElementById(id); }
// ================= 鏃堕棿妯″潡 =================
+ function getNow() {
+ return new Date(Date.now() + (appState.serverTimeOffset || 0));
+ }
function updateClock() {
- var now = new Date();
+ var now = getNow();
$('clock').innerText = ('0' + now.getHours()).slice(-2) + ':' + ('0' + now.getMinutes()).slice(-2);
$('fullDate').innerText = now.getFullYear() + '骞�' + ('0' + (now.getMonth() + 1)).slice(-2) + '鏈�' + ('0' + now.getDate()).slice(-2) + '鏃�';
$('weekDay').innerText = ['鏄熸湡鏃�', '鏄熸湡涓�', '鏄熸湡浜�', '鏄熸湡涓�', '鏄熸湡鍥�', '鏄熸湡浜�', '鏄熸湡鍏�'][now.getDay()];
}
+ function syncServerTime(serverTimeStr) {
+ if (!serverTimeStr) return;
+ try {
+ var serverTime = new Date(serverTimeStr);
+ if (!isNaN(serverTime.getTime())) {
+ appState.serverTimeOffset = serverTime.getTime() - Date.now();
+ updateDebugInfo("鏃堕棿宸插悓姝� | 鍋忕Щ=" + (appState.serverTimeOffset / 1000).toFixed(1) + "s");
+ }
+ } catch (e) { updateDebugInfo("鏃堕棿鍚屾澶辫触: " + e.message); }
+ }
setInterval(updateClock, 1000); updateClock();
// ================= 璇煶鎾姤 =================
+ var _gUtterance = null; // GC 淇濇姢
function speakText(text, times) {
times = times || CALL_TIMES;
var isAndroid = /Android/i.test(navigator.userAgent);
if (isAndroid && window.wowjoy && typeof window.wowjoy.speek === 'function') {
- for (var i = 0; i < times; i++) setTimeout(function () { window.wowjoy.speek(text); }, i * 1500);
+ updateDebugInfo("TTS: wowjoy妯″紡");
+ for (var i = 0; i < times; i++) {
+ setTimeout(function () { window.wowjoy.speek(text); }, i * 1500);
+ }
} else if (window.speechSynthesis) {
- window.speechSynthesis.cancel();
- var utterance = new window.SpeechSynthesisUtterance(text);
- utterance.lang = 'zh-CN'; utterance.rate = 1.0;
- window.speechSynthesis.speak(utterance);
- for (var j = 1; j < times; j++) setTimeout(function () { window.speechSynthesis.speak(utterance); }, j * 1500);
+ updateDebugInfo("TTS: speechSynthesis妯″紡");
+ if (window.speechSynthesis.speaking) {
+ window.speechSynthesis.cancel();
+ }
+ function doSpeak(idx) {
+ var u = new window.SpeechSynthesisUtterance(text);
+ u.lang = 'zh-CN';
+ u.rate = 1.0;
+ u.volume = 1.0;
+ _gUtterance = u;
+ u.onend = function () { _gUtterance = null; };
+ u.onerror = function (e) { _gUtterance = null; updateDebugInfo("TTS閿欒: " + (e.error || "unknown")); };
+ window.speechSynthesis.speak(u);
+ }
+ doSpeak(0);
+ for (var j = 1; j < times; j++) {
+ setTimeout((function (idx) { return function () { doSpeak(idx); }; })(j), j * 1500);
+ }
+ } else {
+ updateDebugInfo("TTS: 鏃犲紩鎿庡彲鐢�");
}
}
// ================= 鏁版嵁璇锋眰 =================
function fetchData() {
var url = CONFIG.apiBaseUrl + "/ecg/screen/room-screen-data?roomId=" + CONFIG.roomId;
+ updateDebugInfo("璇锋眰: " + url);
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
+ xhr.timeout = 8000;
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
try {
var response = JSON.parse(xhr.responseText);
processData(response);
- updateDebugInfo("鑾峰彇鏁版嵁鎴愬姛 | 鍘熷鏁版嵁闀垮害: " + (response.data ? Object.keys(response.data).length : 0));
- } catch (e) { updateDebugInfo("JSON瑙f瀽澶辫触: " + e.message); }
- } else { updateDebugInfo("璇锋眰澶辫触锛岀姸鎬佺爜: " + xhr.status); }
+ updateDebugInfo("鎴愬姛 | 鎮h��: " + (response.data ? JSON.stringify(Object.keys(response.data)) : "鏃�"));
+ } catch (e) { updateDebugInfo("澶勭悊澶辫触: " + e.message); }
+ } else if (xhr.status === 0) {
+ updateDebugInfo("缃戠粶閿欒(status=0) | " + url + " | 璇锋鏌PI鏈嶅姟/URL鍙揪鎬�/璺ㄥ煙");
+ } else {
+ updateDebugInfo("璇锋眰澶辫触 | status=" + xhr.status + " | " + url);
+ }
}
};
- xhr.send();
+ xhr.onerror = function () {
+ updateDebugInfo("缃戠粶寮傚父(onerror) | " + url + " | 璁惧鍙兘鏃犳硶璁块棶璇ュ湴鍧�");
+ };
+ xhr.ontimeout = function () {
+ updateDebugInfo("璇锋眰瓒呮椂 | " + url);
+ };
+ try {
+ xhr.send();
+ } catch (e) {
+ updateDebugInfo("send寮傚父: " + e.message);
+ }
}
// ================= 鏍稿績涓氬姟閫昏緫澶勭悊 =================
function processData(res) {
+ syncServerTime(res.serverTime || (res.data && res.data.serverTime) || null);
var data = res.data || res;
// 1. 鏇存柊璇婂鍚嶇О (浠庣涓�鏉℃暟鎹腑鑾峰彇)
@@ -330,6 +425,9 @@
if (waitingArr.length > 0) currentRoomName = waitingArr[0].roomName || currentRoomName;
else if (inProgressArr.length > 0) currentRoomName = inProgressArr[0].roomName || currentRoomName;
else if (missedArr.length > 0) currentRoomName = missedArr[0].roomName || currentRoomName;
+
+ // 鍏滃簳锛氭帴鍙f湭杩斿洖 roomName 鏃讹紝浠庢湰鍦版槧灏勮〃鍙栬瘖瀹ゅ悕绉�
+ currentRoomName = ROOM_NAME_MAP[currentRoomName] || currentRoomName;
appState.roomName = currentRoomName;
$('currentRoomId').innerText = currentRoomName;
@@ -375,7 +473,7 @@
var patientId = currentPatient.patId || currentPatient.seqNum;
if (appState.lastSpokenPatient !== patientId) {
appState.lastSpokenPatient = patientId;
- speakText(currentPatient.patName + "锛岃鍒�" + appState.roomName, CALL_TIMES);
+ speakText(currentPatient.patName + "锛岃鍒�" + appState.roomName + "灏辫瘖", CALL_TIMES);
}
} else {
appState.lastSpokenPatient = null;
@@ -383,19 +481,24 @@
}
// ================= 娓叉煋鍒楄〃 =================
+ function desensitizeName(name) {
+ if (!name || name.length < 2) return name || '';
+ return name.charAt(0) + '*' + name.substring(2);
+ }
+
function renderList(containerId, listData) {
var container = $(containerId);
+ if (!container) return;
container.innerHTML = "";
if (listData.length === 0) {
- container.innerHTML = '<div style="text-align:center; color:#ccc; width:100%; height:60px; line-height:60px; font-size:18px;">鏆傛棤鎮h��</div>';
+ container.innerHTML = '<div style="text-align:center; color:#ccc; width:100%; height:70px; line-height:70px; font-size:18px;">鏆傛棤鎮h��</div>';
return;
}
for (var i = 0; i < listData.length; i++) {
var item = listData[i];
var div = document.createElement('div');
div.className = 'patient-item';
- div.innerHTML = '<span class="p-name">' + (item.patName || '鏈煡') + '</span>' +
- '<span class="p-num">' + (item.seqNum || item.bookSeqNum || '--') + '鍙�</span>';
+ div.innerHTML = '<span class="p-num">' + (item.seqNum || '--') + '鍙�</span> <span class="p-name">' + (item.patName ? desensitizeName(item.patName) : '鏈煡') + '</span>';
container.appendChild(div);
}
}
--
Gitblit v1.9.3