feat: 调整 SIM 切换入口

This commit is contained in:
2026-06-27 17:36:21 +08:00
parent 05a4fd960d
commit 78f7a5f46e
3 changed files with 33 additions and 15 deletions
+5 -3
View File
@@ -144,7 +144,6 @@
<span class="sim-slot__state" id="simSlot0State">--</span> <span class="sim-slot__state" id="simSlot0State">--</span>
</div> </div>
<span class="sim-slot__phone" id="simSlot0Phone">--</span> <span class="sim-slot__phone" id="simSlot0Phone">--</span>
<button class="button button--secondary button--compact" type="button" data-sim-switch="0">切到SIM1</button>
</article> </article>
<article class="sim-slot" id="simSlot1"> <article class="sim-slot" id="simSlot1">
@@ -153,7 +152,6 @@
<span class="sim-slot__state" id="simSlot1State">--</span> <span class="sim-slot__state" id="simSlot1State">--</span>
</div> </div>
<span class="sim-slot__phone" id="simSlot1Phone">--</span> <span class="sim-slot__phone" id="simSlot1Phone">--</span>
<button class="button button--secondary button--compact" type="button" data-sim-switch="1">切到SIM2</button>
</article> </article>
</div> </div>
</div> </div>
@@ -227,6 +225,10 @@
<span>当前发送SIM</span> <span>当前发送SIM</span>
<strong id="sendSimLabel">--</strong> <strong id="sendSimLabel">--</strong>
</p> </p>
<div class="send-sim-picker" aria-label="选择发送SIM">
<button class="button button--secondary button--compact" type="button" data-sim-switch="0">SIM1</button>
<button class="button button--secondary button--compact" type="button" data-sim-switch="1">SIM2</button>
</div>
<form id="smsForm" class="stack-form"> <form id="smsForm" class="stack-form">
<label class="field"> <label class="field">
<span class="field__label">目标号码</span> <span class="field__label">目标号码</span>
@@ -419,4 +421,4 @@
<script src="/assets/admin.js" type="module"></script> <script src="/assets/admin.js" type="module"></script>
</body> </body>
</html> </html>
+17 -6
View File
@@ -736,7 +736,7 @@ h3 {
.sim-slot { .sim-slot {
display: grid; display: grid;
grid-template-columns: minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr);
align-items: center; align-items: center;
gap: 8px 12px; gap: 8px 12px;
border: 1px solid var(--hairline); border: 1px solid var(--hairline);
@@ -751,8 +751,8 @@ h3 {
} }
.sim-slot.is-active { .sim-slot.is-active {
border-color: rgba(93, 184, 114, 0.55); border-color: var(--surface-cream-strong);
box-shadow: inset 3px 0 0 var(--success); background: var(--surface-soft);
} }
.sim-slot__topline { .sim-slot__topline {
@@ -782,8 +782,8 @@ h3 {
} }
.sim-slot.is-active .sim-slot__state { .sim-slot.is-active .sim-slot__state {
background: rgba(93, 184, 114, 0.16); background: var(--surface-cream-strong);
color: #2f7c44; color: var(--body-strong);
} }
.sim-slot__phone { .sim-slot__phone {
@@ -979,7 +979,7 @@ h3 {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
gap: 8px; gap: 8px;
margin: -4px 0 var(--space-md); margin: -4px 0 8px;
padding: 0; padding: 0;
} }
@@ -997,6 +997,17 @@ h3 {
overflow-wrap: anywhere; overflow-wrap: anywhere;
} }
.send-sim-picker {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin: 0 0 var(--space-md);
}
.send-sim-picker .button {
min-width: 96px;
}
.field { .field {
display: grid; display: grid;
gap: var(--space-xs); gap: var(--space-xs);
+11 -6
View File
@@ -254,6 +254,11 @@ function renderSendSimLabel() {
setText(elements.sendSimLabel, getActiveSimLabel()); setText(elements.sendSimLabel, getActiveSimLabel());
} }
function setSimSwitchStatus(message, type = '') {
setStatusMessage(elements.simStatus, message);
setStatusMessage(elements.smsStatus, message, type);
}
function getSimSlot(sim = {}, slotNumber) { function getSimSlot(sim = {}, slotNumber) {
return (sim.slots || []).find(slot => slot.slot === slotNumber) || { return (sim.slots || []).find(slot => slot.slot === slotNumber) || {
slot: slotNumber, slot: slotNumber,
@@ -367,15 +372,15 @@ function renderSimStatus(sim = {}) {
const unavailable = slotInfo.present === false; const unavailable = slotInfo.present === false;
button.hidden = singleSlot; button.hidden = singleSlot;
button.disabled = state.simBusy || Boolean(sim.switching) || !supported || isActive || unavailable; button.disabled = state.simBusy || Boolean(sim.switching) || !supported || isActive || unavailable;
button.textContent = isActive ? '正在使用' : `切到SIM${slot + 1}`; button.textContent = isActive ? `SIM${slot + 1} 当前` : `切到SIM${slot + 1}`;
}); });
if (state.simBusy || sim.switching) { if (state.simBusy || sim.switching) {
setStatusMessage(elements.simStatus, '正在切换SIM...'); setSimSwitchStatus('正在切换SIM...');
} else if (supported && activeSlot?.present === true) { } else if (supported && activeSlot?.present === true) {
setStatusMessage(elements.simStatus, `当前 ${getSimDisplayLabel(activeSlot)}`, 'success'); setStatusMessage(elements.simStatus, `当前 ${getSimDisplayLabel(activeSlot)}`);
} else if (supported && activeSlot?.present === false) { } else if (supported && activeSlot?.present === false) {
setStatusMessage(elements.simStatus, `${getSimDisplayLabel(activeSlot)} 未就绪,请检查是否插卡`, 'error'); setStatusMessage(elements.simStatus, `${getSimDisplayLabel(activeSlot)} 未就绪,请检查是否插卡`);
} else if (!supported) { } else if (!supported) {
setStatusMessage(elements.simStatus, '双卡不可用'); setStatusMessage(elements.simStatus, '双卡不可用');
} else { } else {
@@ -867,10 +872,10 @@ async function switchSim(slot) {
body: JSON.stringify({ slot: slotNumber }) body: JSON.stringify({ slot: slotNumber })
}); });
renderSimStatus(result.data || {}); renderSimStatus(result.data || {});
setStatusMessage(elements.simStatus, result.message || `已切换到SIM${slotNumber + 1}`, 'success'); setSimSwitchStatus(result.message || `已切换到SIM${slotNumber + 1}`, 'success');
await refreshAll(); await refreshAll();
} catch (err) { } catch (err) {
setStatusMessage(elements.simStatus, err.message, 'error'); setSimSwitchStatus(err.message, 'error');
await refreshSim().catch(() => {}); await refreshSim().catch(() => {});
} finally { } finally {
state.simBusy = false; state.simBusy = false;