feat: 调整 SIM 切换入口
This commit is contained in:
+5
-3
@@ -144,7 +144,6 @@
|
||||
<span class="sim-slot__state" id="simSlot0State">--</span>
|
||||
</div>
|
||||
<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 class="sim-slot" id="simSlot1">
|
||||
@@ -153,7 +152,6 @@
|
||||
<span class="sim-slot__state" id="simSlot1State">--</span>
|
||||
</div>
|
||||
<span class="sim-slot__phone" id="simSlot1Phone">--</span>
|
||||
<button class="button button--secondary button--compact" type="button" data-sim-switch="1">切到SIM2</button>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
@@ -227,6 +225,10 @@
|
||||
<span>当前发送SIM</span>
|
||||
<strong id="sendSimLabel">--</strong>
|
||||
</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">
|
||||
<label class="field">
|
||||
<span class="field__label">目标号码</span>
|
||||
@@ -419,4 +421,4 @@
|
||||
<script src="/assets/admin.js" type="module"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
||||
+17
-6
@@ -736,7 +736,7 @@ h3 {
|
||||
|
||||
.sim-slot {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
align-items: center;
|
||||
gap: 8px 12px;
|
||||
border: 1px solid var(--hairline);
|
||||
@@ -751,8 +751,8 @@ h3 {
|
||||
}
|
||||
|
||||
.sim-slot.is-active {
|
||||
border-color: rgba(93, 184, 114, 0.55);
|
||||
box-shadow: inset 3px 0 0 var(--success);
|
||||
border-color: var(--surface-cream-strong);
|
||||
background: var(--surface-soft);
|
||||
}
|
||||
|
||||
.sim-slot__topline {
|
||||
@@ -782,8 +782,8 @@ h3 {
|
||||
}
|
||||
|
||||
.sim-slot.is-active .sim-slot__state {
|
||||
background: rgba(93, 184, 114, 0.16);
|
||||
color: #2f7c44;
|
||||
background: var(--surface-cream-strong);
|
||||
color: var(--body-strong);
|
||||
}
|
||||
|
||||
.sim-slot__phone {
|
||||
@@ -979,7 +979,7 @@ h3 {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin: -4px 0 var(--space-md);
|
||||
margin: -4px 0 8px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
@@ -997,6 +997,17 @@ h3 {
|
||||
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 {
|
||||
display: grid;
|
||||
gap: var(--space-xs);
|
||||
|
||||
+11
-6
@@ -254,6 +254,11 @@ function renderSendSimLabel() {
|
||||
setText(elements.sendSimLabel, getActiveSimLabel());
|
||||
}
|
||||
|
||||
function setSimSwitchStatus(message, type = '') {
|
||||
setStatusMessage(elements.simStatus, message);
|
||||
setStatusMessage(elements.smsStatus, message, type);
|
||||
}
|
||||
|
||||
function getSimSlot(sim = {}, slotNumber) {
|
||||
return (sim.slots || []).find(slot => slot.slot === slotNumber) || {
|
||||
slot: slotNumber,
|
||||
@@ -367,15 +372,15 @@ function renderSimStatus(sim = {}) {
|
||||
const unavailable = slotInfo.present === false;
|
||||
button.hidden = singleSlot;
|
||||
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) {
|
||||
setStatusMessage(elements.simStatus, '正在切换SIM...');
|
||||
setSimSwitchStatus('正在切换SIM...');
|
||||
} else if (supported && activeSlot?.present === true) {
|
||||
setStatusMessage(elements.simStatus, `当前 ${getSimDisplayLabel(activeSlot)}`, 'success');
|
||||
setStatusMessage(elements.simStatus, `当前 ${getSimDisplayLabel(activeSlot)}`);
|
||||
} else if (supported && activeSlot?.present === false) {
|
||||
setStatusMessage(elements.simStatus, `${getSimDisplayLabel(activeSlot)} 未就绪,请检查是否插卡`, 'error');
|
||||
setStatusMessage(elements.simStatus, `${getSimDisplayLabel(activeSlot)} 未就绪,请检查是否插卡`);
|
||||
} else if (!supported) {
|
||||
setStatusMessage(elements.simStatus, '双卡不可用');
|
||||
} else {
|
||||
@@ -867,10 +872,10 @@ async function switchSim(slot) {
|
||||
body: JSON.stringify({ slot: slotNumber })
|
||||
});
|
||||
renderSimStatus(result.data || {});
|
||||
setStatusMessage(elements.simStatus, result.message || `已切换到SIM${slotNumber + 1}`, 'success');
|
||||
setSimSwitchStatus(result.message || `已切换到SIM${slotNumber + 1}`, 'success');
|
||||
await refreshAll();
|
||||
} catch (err) {
|
||||
setStatusMessage(elements.simStatus, err.message, 'error');
|
||||
setSimSwitchStatus(err.message, 'error');
|
||||
await refreshSim().catch(() => {});
|
||||
} finally {
|
||||
state.simBusy = false;
|
||||
|
||||
Reference in New Issue
Block a user