From e80f0dac9662a01db3f2df93f2964c8cdf32ca09 Mon Sep 17 00:00:00 2001 From: yibaiba <946100224@qq.com> Date: Thu, 13 Aug 2026 13:38:48 +0800 Subject: [PATCH] [dashboard-prototype-migration-DASH-02] rebuild connection focus stage --- web/src/components/ConnectionFocusStage.vue | 231 ++++++++++++++++++++ web/src/utils/dashboardPresentation.ts | 5 + web/src/views/Dashboard.vue | 119 +--------- web/tests/dashboardPresentation.test.ts | 19 +- 4 files changed, 264 insertions(+), 110 deletions(-) create mode 100644 web/src/components/ConnectionFocusStage.vue diff --git a/web/src/components/ConnectionFocusStage.vue b/web/src/components/ConnectionFocusStage.vue new file mode 100644 index 00000000..8239b353 --- /dev/null +++ b/web/src/components/ConnectionFocusStage.vue @@ -0,0 +1,231 @@ + + + + + diff --git a/web/src/utils/dashboardPresentation.ts b/web/src/utils/dashboardPresentation.ts index 31d7aa0c..f95497a1 100644 --- a/web/src/utils/dashboardPresentation.ts +++ b/web/src/utils/dashboardPresentation.ts @@ -53,6 +53,11 @@ export function createDashboardStages( ]) } +export function canAnimateDashboardConnection(device: DashboardDevice): boolean { + if (!device.healthy || device.vowifi_active !== true) return false + return !createDashboardStages(device.vowifi_runtime).some(stage => stage.ready === false) +} + export function createDashboardDevicePresentation( device: DashboardDevice ): DashboardDevicePresentation { diff --git a/web/src/views/Dashboard.vue b/web/src/views/Dashboard.vue index 7df42fae..93b58feb 100644 --- a/web/src/views/Dashboard.vue +++ b/web/src/views/Dashboard.vue @@ -3,6 +3,7 @@ import { onMounted, ref, computed } from 'vue' import { storeToRefs } from 'pinia' import { useRouter } from 'vue-router' import DeviceCard from '../components/DeviceCard.vue' +import ConnectionFocusStage from '../components/ConnectionFocusStage.vue' import PageHeader from '../components/PageHeader.vue' import EmptyState from '../components/EmptyState.vue' import ListSkeleton from '../components/ListSkeleton.vue' @@ -58,31 +59,6 @@ const selectedDevice = computed(() => { || devices.value.find((device) => device.healthy) || devices.value[0] }) -const selectedDeviceIP = computed(() => selectedDevice.value?.public_ipv6 || selectedDevice.value?.public_ip || '') -const selectedRuntime = computed(() => selectedDevice.value?.vowifi_runtime) -const selectedConnectionTitle = computed(() => { - const device = selectedDevice.value - if (!device) return '等待设备' - if (!device.healthy) return '设备离线' - if (device.vowifi_active) return 'Wi-Fi Calling' - return device.operator || '网络检测中' -}) -const selectedConnectionState = computed(() => { - const device = selectedDevice.value - if (!device) return '没有可用设备' - if (!device.healthy) return '当前设备不可用' - return device.vowifi_active ? '已连接' : ([device.network_duplex, device.network_mode].filter(Boolean).join(' ') || '控制面在线') -}) -const selectedStages = computed(() => { - const runtime = selectedRuntime.value - return [ - { key: 'SIM', ready: runtime?.sim_ready }, - { key: 'Access', ready: runtime?.access_ready }, - { key: 'Tunnel', ready: runtime?.tunnel_ready }, - { key: 'IMS', ready: runtime?.ims_ready }, - { key: 'SMS', ready: runtime?.sms_ready } - ] -}) async function fetchDevices() { await dashboard.fetchDevices() @@ -146,54 +122,12 @@ onMounted(() => { -
-
-
- ACTIVE DEVICE - - {{ selectedDevice.healthy ? '在线' : '离线' }} - -
-

{{ selectedConnectionTitle }}

- {{ selectedConnectionState }} -

{{ selectedDevice.name || selectedDevice.id }} · {{ selectedDevice.id }}

- -
- -
- {{ [selectedDevice.network_duplex, selectedDevice.network_mode].filter(Boolean).join(' ') || '未驻网' }} - {{ selectedDevice.signal_dbm || '--' }} dBm -
-
- - -
+
@@ -299,37 +233,7 @@ onMounted(() => { diff --git a/web/tests/dashboardPresentation.test.ts b/web/tests/dashboardPresentation.test.ts index cd132300..e80c91e4 100644 --- a/web/tests/dashboardPresentation.test.ts +++ b/web/tests/dashboardPresentation.test.ts @@ -2,6 +2,7 @@ import assert from 'node:assert/strict' import test from 'node:test' import type { DashboardDevice } from '../src/types/api.ts' import { + canAnimateDashboardConnection, createDashboardDevicePresentation, formatDashboardNetworkType, formatDashboardSignal, @@ -70,16 +71,30 @@ test('uses explicit missing-value copy without mutating API data', () => { }) test('keeps offline state distinct from a failed or unknown VoWiFi stage', () => { - const presentation = createDashboardDevicePresentation(createDevice({ + const device = createDevice({ healthy: false, vowifi_active: true, vowifi_runtime: { sim_ready: false } - })) + }) + const presentation = createDashboardDevicePresentation(device) assert.equal(presentation.statusLabel, '离线') assert.equal(presentation.connectionTitle, '设备离线') assert.equal(presentation.connectionState, '当前设备不可用') assert.deepEqual(presentation.stages.map(stage => stage.ready), [false, undefined, undefined, undefined, undefined]) + assert.equal(canAnimateDashboardConnection(device), false) +}) + +test('animates the service path only for active VoWiFi without failed stages', () => { + assert.equal(canAnimateDashboardConnection(createDevice({ + vowifi_active: true, + vowifi_runtime: { sim_ready: true, access_ready: true } + })), true) + assert.equal(canAnimateDashboardConnection(createDevice({ + vowifi_active: true, + vowifi_runtime: { tunnel_ready: false } + })), false) + assert.equal(canAnimateDashboardConnection(createDevice({ vowifi_active: false })), false) }) test('formats cellular connection and validates signal sentinels', () => {