mirror of
https://github.com/yibaiba/hideck.git
synced 2026-12-05 08:01:10 +00:00
feat(phone): start WiFi calling with a switch under the mode picker
Keep phone_mode as the path. Turning the switch off only stops the service instead of forcing a change to cellular or VoLTE.
This commit is contained in:
1 parent
aaf774b8bc
commit
bb4cccda50
6 files changed
+165
-40
No files matched your search
@@ -248,24 +248,8 @@ const airplaneHint = computed(() => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="policy-setting-row"
|
||||
:class="{ 'is-active': local.vowifi_enabled }"
|
||||
>
|
||||
<span><strong>软件电话</strong><small>开启后可用浏览器/命令拨号。WiFi calling 会锁定飞行;蜂窝和 VoLTE 会退出飞行</small></span>
|
||||
<div class="flex items-center gap-2">
|
||||
<span v-if="vowifiFailed" class="text-xs text-orange-500 dark:text-orange-400">未生效</span>
|
||||
<el-icon v-if="vowifiPending" class="animate-spin text-gray-400"><Loading /></el-icon>
|
||||
<el-switch
|
||||
v-model="local.vowifi_enabled"
|
||||
:disabled="!canToggle || vowifiPending"
|
||||
@change="onVoWiFiToggle"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="policy-setting-row" :class="{ 'is-active': local.phone_mode === 'cellular' || local.phone_mode === 'volte' }">
|
||||
<span><strong>通话方式</strong><small>切换即开启电话。WiFi calling 开飞行;蜂窝走软件 IMS 数据;VoLTE 走模组原生 IMS</small></span>
|
||||
<span><strong>通话方式</strong><small>只选路径。WiFi calling 开飞行;蜂窝走软件 IMS 数据;VoLTE 走模组原生 IMS</small></span>
|
||||
<div class="policy-field-control">
|
||||
<el-select
|
||||
:model-value="local.phone_mode ?? 'wifi'"
|
||||
@@ -282,6 +266,28 @@ const airplaneHint = computed(() => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="policy-setting-row"
|
||||
:class="{ 'is-active': local.vowifi_enabled }"
|
||||
>
|
||||
<span>
|
||||
<strong>{{ (local.phone_mode ?? 'wifi') === 'wifi' ? '启动' : '软件电话' }}</strong>
|
||||
<small>{{ (local.phone_mode ?? 'wifi') === 'wifi'
|
||||
? '打开后开始注册。关掉只停服务,不会改成蜂窝或 VoLTE'
|
||||
: '开启后可用浏览器/命令拨号。蜂窝和 VoLTE 会退出飞行' }}</small>
|
||||
</span>
|
||||
<div class="flex items-center gap-2">
|
||||
<span v-if="vowifiFailed" class="text-xs text-orange-500 dark:text-orange-400">未生效</span>
|
||||
<el-icon v-if="vowifiPending" class="animate-spin text-gray-400"><Loading /></el-icon>
|
||||
<el-switch
|
||||
v-model="local.vowifi_enabled"
|
||||
:disabled="!canToggle || vowifiPending"
|
||||
aria-label="启动 WiFi calling"
|
||||
@change="onVoWiFiToggle"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="(local.phone_mode ?? 'wifi') === 'cellular'" class="policy-setting-row">
|
||||
<span><strong>蜂窝数据策略</strong><small>只影响流量。仅打电话时开:挂断后关数据,待机不能被叫</small></span>
|
||||
<div class="policy-field-control">
|
||||
|
||||
@@ -138,7 +138,7 @@ const {
|
||||
</div>
|
||||
<template v-else>
|
||||
<div v-if="hint" class="text-xs text-amber-600 dark:text-amber-400">{{ hint }}</div>
|
||||
<div class="grid grid-cols-1 sm:grid-cols-3 gap-2">
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-2">
|
||||
<div class="flex items-center justify-between rounded-lg px-3 py-2 bg-white dark:bg-white/5">
|
||||
<span class="text-sm text-gray-700 dark:text-gray-200">飞行<small class="block text-xs text-gray-400 font-normal">{{ wifiCallingLocksRadio ? 'WiFi calling 已锁定' : '关闭后注册运营商' }}</small></span>
|
||||
<div class="flex items-center gap-2">
|
||||
@@ -163,18 +163,6 @@ const {
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center justify-between rounded-lg px-3 py-2 bg-white dark:bg-white/5">
|
||||
<span class="text-sm text-gray-700 dark:text-gray-200">软件电话</span>
|
||||
<div class="flex items-center gap-2">
|
||||
<span v-if="vowifiFailed" class="text-xs text-orange-500">未生效</span>
|
||||
<el-icon v-if="vowifiPending" class="animate-spin text-gray-400"><Loading /></el-icon>
|
||||
<el-switch
|
||||
v-model="local.vowifi_enabled"
|
||||
:disabled="vowifiPending"
|
||||
@change="onVoWiFiToggle"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-2">
|
||||
<div class="flex items-center justify-between rounded-lg px-3 py-2 bg-white dark:bg-white/5">
|
||||
@@ -208,6 +196,24 @@ const {
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center justify-between rounded-lg px-3 py-2 bg-white dark:bg-white/5">
|
||||
<span class="text-sm text-gray-700 dark:text-gray-200">
|
||||
{{ (local.phone_mode ?? 'wifi') === 'wifi' ? '启动' : '软件电话' }}
|
||||
<small class="block text-xs text-gray-400 font-normal">{{ (local.phone_mode ?? 'wifi') === 'wifi'
|
||||
? '打开才启动,关掉只停服务,不会改成蜂窝或 VoLTE'
|
||||
: '开启后可拨号' }}</small>
|
||||
</span>
|
||||
<div class="flex items-center gap-2">
|
||||
<span v-if="vowifiFailed" class="text-xs text-orange-500">未生效</span>
|
||||
<el-icon v-if="vowifiPending" class="animate-spin text-gray-400"><Loading /></el-icon>
|
||||
<el-switch
|
||||
v-model="local.vowifi_enabled"
|
||||
:disabled="vowifiPending"
|
||||
aria-label="启动 WiFi calling"
|
||||
@change="onVoWiFiToggle"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-xs leading-5 text-gray-500 dark:text-gray-400">
|
||||
<template v-if="wifiCallingLocksRadio">WiFi calling 占用射频,飞行已锁定,网络不可用。</template>
|
||||
<template v-else-if="radioMode === 'airplane'">飞行已开,射频关闭。关掉飞行后才会注册运营商。</template>
|
||||
|
||||
@@ -16,6 +16,34 @@
|
||||
.device-selector :deep(.el-select) { width: 100%; }
|
||||
.device-selector :deep(.el-select__wrapper) { min-height: 44px; background: var(--ui-surface); }
|
||||
.phone-mode-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
|
||||
.phone-wifi-calling-switch {
|
||||
flex: 1 1 100%;
|
||||
min-height: 44px;
|
||||
padding: 8px 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
border: 1px solid var(--ui-border);
|
||||
border-radius: 6px;
|
||||
background: var(--ui-surface-muted);
|
||||
}
|
||||
.phone-wifi-calling-switch.is-on {
|
||||
border-color: color-mix(in srgb, var(--ui-primary) 38%, var(--ui-border));
|
||||
}
|
||||
.phone-wifi-calling-switch span {
|
||||
display: grid;
|
||||
gap: 2px;
|
||||
color: var(--ui-text);
|
||||
font-size: 13px;
|
||||
font-weight: 650;
|
||||
}
|
||||
.phone-wifi-calling-switch small {
|
||||
color: var(--ui-text-muted);
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
line-height: 1.45;
|
||||
}
|
||||
.phone-mode-hint { flex: 1 1 100%; margin: 0; color: var(--ui-text-muted); font-size: 12px; line-height: 1.45; }
|
||||
.phone-mode-hint.is-warn { color: var(--ui-warning); }
|
||||
.console-loading { min-height: 560px; display: grid; place-items: center; color: var(--ui-text-muted); }
|
||||
|
||||
+47
-10
@@ -100,17 +100,36 @@ const selectedMode = computed(() => {
|
||||
const selectedStrategy = computed(() => selected.value?.data_strategy === 'always' ? 'always' : 'on_demand')
|
||||
const modePending = ref(false)
|
||||
|
||||
async function toggleWifiCalling(rawVal: string | number | boolean) {
|
||||
const enabled = rawVal === true
|
||||
if (!selectedDevice.value || !!call.value || modePending.value) return
|
||||
if (enabled === (selected.value?.vowifi_enabled === true)) return
|
||||
modePending.value = true
|
||||
phone.clearError()
|
||||
try {
|
||||
const result = enabled
|
||||
? await devicesService.enableVoWiFi(selectedDevice.value, {
|
||||
mode: 'wifi',
|
||||
data_strategy: selectedStrategy.value
|
||||
})
|
||||
: await devicesService.disableVoWiFi(selectedDevice.value)
|
||||
if (!result.ok) throw new Error(result.error?.message || (enabled ? '打开 WiFi calling 失败' : '关闭 WiFi calling 失败'))
|
||||
await phone.refresh()
|
||||
ElMessage.success(enabled ? 'WiFi calling 已打开' : 'WiFi calling 已关闭')
|
||||
} catch (error) {
|
||||
phone.error = phoneErrorMessage(error, enabled ? '打开 WiFi calling 失败' : '关闭 WiFi calling 失败')
|
||||
} finally {
|
||||
modePending.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function changePhoneMode(mode: string) {
|
||||
if (!selectedDevice.value || !!call.value || modePending.value) return
|
||||
if ((mode === 'cellular' || mode === 'volte') && selected.value?.rf_lock) {
|
||||
ElMessage.warning('这张 Lebara UK 分享卡不能切蜂窝或 VoLTE,驻国内网会切到 20404,WiFi calling 会废')
|
||||
return
|
||||
}
|
||||
if (
|
||||
mode === selectedMode.value
|
||||
&& selected.value
|
||||
&& (isDeviceReady(selected.value) || selected.value.vowifi_active)
|
||||
) {
|
||||
if (mode === selectedMode.value) {
|
||||
return
|
||||
}
|
||||
modePending.value = true
|
||||
@@ -336,17 +355,35 @@ async function sendDTMF(digit: string) {
|
||||
? (selectedStrategy === 'always' ? '网络已开,数据会保持连接。' : '网络已开,只有拨号时才连数据,挂断后关闭。')
|
||||
: '会正常驻网,待机不走流量。打蜂窝电话会临时打开数据。' }}
|
||||
</p>
|
||||
<p v-else-if="selectedMode === 'volte'" class="phone-mode-hint">
|
||||
<p v-if="selectedMode === 'volte'" class="phone-mode-hint">
|
||||
{{ selected?.native_volte?.reboot_required
|
||||
? '原生 IMS 已写入。UAC 声卡要重启模组后才出现,现在可以试信令,音频可能不可用。'
|
||||
: '会驻网并用模组原生 IMS 打电话,不走软件 WiFi calling。打开「网络」才会用上网流量。' }}
|
||||
</p>
|
||||
<p v-else-if="selected?.rf_lock" class="phone-mode-hint">
|
||||
<div
|
||||
v-show="selectedMode === 'wifi'"
|
||||
class="phone-wifi-calling-switch"
|
||||
:class="{ 'is-on': selected?.vowifi_enabled === true }"
|
||||
>
|
||||
<span>
|
||||
启动
|
||||
<small>{{
|
||||
selected?.vowifi_enabled
|
||||
? (selected.vowifi_active || isDeviceReady(selected) ? '已启动,正在走 WiFi calling' : '已打开,正在注册')
|
||||
: '打开开关才会启动。关掉只停服务,不会改成蜂窝或 VoLTE'
|
||||
}}</small>
|
||||
</span>
|
||||
<el-switch
|
||||
:model-value="selected?.vowifi_enabled === true"
|
||||
:disabled="!!call || modePending"
|
||||
:loading="modePending"
|
||||
aria-label="启动 WiFi calling"
|
||||
@change="toggleWifiCalling"
|
||||
/>
|
||||
</div>
|
||||
<p v-if="selected?.rf_lock" class="phone-mode-hint is-warn">
|
||||
这张分享卡不能驻国内网,否则 IMSI 会切到 20404,WiFi calling 会废
|
||||
</p>
|
||||
<p v-else-if="selected && !isDeviceReady(selected) && !selected.vowifi_active" class="phone-mode-hint">
|
||||
软件电话未开启,点 WiFi calling 即可拉起
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
import { readFile } from 'node:fs/promises'
|
||||
import { nextTick, ref } from 'vue'
|
||||
import { useCardPolicyToggles, type PolicyMirror } from '../src/composables/useCardPolicyToggles'
|
||||
|
||||
@@ -204,6 +205,41 @@ test('volte with software phone does not lock flight', async () => {
|
||||
assert.equal(toggles.local.value.airplane_enabled, false)
|
||||
})
|
||||
|
||||
test('card policy puts a start switch under wifi calling instead of only a mode picker', async () => {
|
||||
const panel = await readFile(new URL('../src/components/CardPolicyPanel.vue', import.meta.url), 'utf8')
|
||||
const inline = await readFile(new URL('../src/components/EsimCardPolicyInline.vue', import.meta.url), 'utf8')
|
||||
assert.match(panel, /<strong>通话方式<\/strong>[\s\S]*phone_mode \?\? 'wifi'\) === 'wifi' \? '启动' : '软件电话'[\s\S]*onVoWiFiToggle/)
|
||||
assert.match(inline, />通话方式</)
|
||||
assert.match(inline, /phone_mode \?\? 'wifi'\) === 'wifi' \? '启动' : '软件电话'[\s\S]*onVoWiFiToggle/)
|
||||
})
|
||||
|
||||
test('turning wifi calling off keeps the wifi path and only stops the service', async () => {
|
||||
const source = ref<PolicyMirror | null>(mirror({
|
||||
vowifi_enabled: true,
|
||||
airplane_enabled: true,
|
||||
phone_mode: 'wifi'
|
||||
}))
|
||||
let applied: PolicyMirror | null = null
|
||||
const toggles = useCardPolicyToggles(source, {
|
||||
applyNetwork: async () => ({ ok: true }),
|
||||
applyVoWiFi: async (_enabled, next) => {
|
||||
applied = next
|
||||
return { ok: true }
|
||||
},
|
||||
applyAirplane: async () => ({ ok: true }),
|
||||
applyPhoneMode: async () => ({ ok: true })
|
||||
})
|
||||
await nextTick()
|
||||
|
||||
await toggles.onVoWiFiToggle(false)
|
||||
|
||||
assert.equal(applied?.phone_mode, 'wifi')
|
||||
assert.equal(applied?.vowifi_enabled, false)
|
||||
assert.equal(applied?.airplane_enabled, true)
|
||||
assert.equal(toggles.local.value.phone_mode, 'wifi')
|
||||
assert.equal(toggles.local.value.vowifi_enabled, false)
|
||||
})
|
||||
|
||||
test('wifi calling locks camp so radio cannot independently leave airplane', async () => {
|
||||
const source = ref<PolicyMirror | null>(mirror({
|
||||
vowifi_enabled: true,
|
||||
|
||||
@@ -95,3 +95,15 @@ test('phone layout has responsive single-column and 44px touch targets', () => {
|
||||
assert.match(callBar, /width: 44px; height: 44px/)
|
||||
assert.match(shell, /repeat\(5, minmax\(44px, 1fr\)\)/)
|
||||
})
|
||||
|
||||
test('wifi calling keeps a dedicated start switch under the mode control', () => {
|
||||
assert.match(phoneView, /async function toggleWifiCalling/)
|
||||
assert.match(phoneView, /v-show="selectedMode === 'wifi'"/)
|
||||
assert.match(phoneView, /class="phone-wifi-calling-switch"/)
|
||||
assert.match(phoneView, /disableVoWiFi\(selectedDevice\.value\)/)
|
||||
assert.match(phoneView, /打开开关才会启动/)
|
||||
assert.match(phoneView, /:disabled="!!call \|\| modePending"/)
|
||||
assert.doesNotMatch(phoneView, /modePending \|\| !!selected\?\.rf_lock/)
|
||||
assert.doesNotMatch(phoneView, /点 WiFi calling 即可拉起/)
|
||||
assert.match(phoneCSS, /\.phone-wifi-calling-switch \{[\s\S]*min-height: 44px/)
|
||||
})
|
||||
Reference in new issue
Block a user