mirror of
https://github.com/yibaiba/hideck.git
synced 2026-12-06 00:01:20 +00:00
feat: refine auto-answer settings controls
This commit is contained in:
1 parent
cbe6e032e2
commit
98cab4e769
13 files changed
+388
-195
No files matched your search
@@ -20,7 +20,7 @@ import (
|
||||
|
||||
const (
|
||||
maxAutoAnswerAudioBytes = 16 << 20
|
||||
defaultAutoAnswerDelaySeconds = 30
|
||||
defaultAutoAnswerDelaySeconds = 8
|
||||
)
|
||||
|
||||
type phoneSettingsResponse struct {
|
||||
|
||||
@@ -25,6 +25,24 @@ func (settingsPromptDecoder) DecodePCM(_ context.Context, path string) ([]int16,
|
||||
return make([]int16, 160), 8000, nil
|
||||
}
|
||||
|
||||
func TestPhoneSettingsPayloadUsesEightSecondDefault(t *testing.T) {
|
||||
service, err := phone.NewService(phone.ServiceOptions{
|
||||
Gateway: &phoneRouteGatewayStub{}, WebRTCUDPAddress: "127.0.0.1:0",
|
||||
AutoAnswer: phone.AutoAnswerConfig{Devices: map[string]phone.AutoAnswerDeviceConfig{
|
||||
"dev-1": {Enabled: false},
|
||||
}},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { _ = service.Close(context.Background()) })
|
||||
|
||||
payload := (&Server{phone: service}).phoneSettingsPayload()
|
||||
if len(payload.AutoAnswer.Devices) != 1 || payload.AutoAnswer.Devices[0].DelaySeconds != 8 {
|
||||
t.Fatalf("auto answer payload = %+v, want 8 second default", payload.AutoAnswer.Devices)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPhoneSettingsEnableAutoAnswerAndPersist(t *testing.T) {
|
||||
gin.SetMode(gin.TestMode)
|
||||
directory := t.TempDir()
|
||||
|
||||
+23
-13
@@ -208,9 +208,8 @@ function retryStartup() {
|
||||
</p>
|
||||
|
||||
<div class="mb-5">
|
||||
<input
|
||||
type="text"
|
||||
v-model="confirmText"
|
||||
<el-input
|
||||
v-model="confirmText"
|
||||
class="license-input w-full px-4 py-3 text-center text-sm font-semibold outline-none transition-all"
|
||||
:placeholder="t('disclaimer.placeholder', { phrase: expectedConfirmText })"
|
||||
@paste.prevent
|
||||
@@ -223,10 +222,11 @@ function retryStartup() {
|
||||
</p>
|
||||
|
||||
<div class="flex gap-4">
|
||||
<button @click="rejectDisclaimer" class="license-reject flex-1 px-4 py-3 text-sm font-bold transition-colors">
|
||||
<el-button class="license-reject flex-1 px-4 py-3 text-sm font-bold transition-colors" @click="rejectDisclaimer">
|
||||
{{ t('disclaimer.reject') }}
|
||||
</button>
|
||||
<button
|
||||
</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="acceptDisclaimer"
|
||||
:disabled="!canAccept"
|
||||
:class="[
|
||||
@@ -237,7 +237,7 @@ function retryStartup() {
|
||||
]"
|
||||
>
|
||||
{{ acceptingDisclaimer ? t('common.loading') : t('disclaimer.accept') }}
|
||||
</button>
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -300,19 +300,29 @@ function retryStartup() {
|
||||
}
|
||||
|
||||
.license-input {
|
||||
border: 1px solid var(--ui-border);
|
||||
border-radius: 16px;
|
||||
background: var(--ui-surface-subtle);
|
||||
color: var(--ui-text);
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.license-input:focus {
|
||||
border-color: var(--ui-primary);
|
||||
.license-input .el-input__wrapper {
|
||||
min-height: 44px;
|
||||
border-radius: var(--ui-radius-md);
|
||||
background: var(--ui-surface-subtle);
|
||||
box-shadow: 0 0 0 1px var(--ui-border) inset;
|
||||
}
|
||||
|
||||
.license-input .el-input__wrapper.is-focus {
|
||||
box-shadow: var(--ui-focus);
|
||||
}
|
||||
|
||||
.license-input .el-input__inner {
|
||||
color: var(--ui-text);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.license-reject,
|
||||
.license-accept {
|
||||
min-height: 44px;
|
||||
margin-left: 0;
|
||||
border: 1px solid var(--ui-border);
|
||||
border-radius: var(--ui-radius-pill);
|
||||
}
|
||||
|
||||
Vendored
+1
@@ -70,6 +70,7 @@ declare module 'vue' {
|
||||
ElSegmented: typeof import('element-plus/es')['ElSegmented']
|
||||
ElSelect: typeof import('element-plus/es')['ElSelect']
|
||||
ElSkeleton: typeof import('element-plus/es')['ElSkeleton']
|
||||
ElSlider: typeof import('element-plus/es')['ElSlider']
|
||||
ElSwitch: typeof import('element-plus/es')['ElSwitch']
|
||||
ElTable: typeof import('element-plus/es')['ElTable']
|
||||
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
|
||||
|
||||
@@ -53,7 +53,7 @@ const selecting = ref(false)
|
||||
const expanded = ref('')
|
||||
const selected = ref<string[]>([])
|
||||
const searchInput = ref<{ focus?: () => void } | null>(null)
|
||||
const nameInput = ref<HTMLInputElement | null>(null)
|
||||
const nameInput = ref<{ focus?: () => void } | null>(null)
|
||||
const fileInput = ref<HTMLInputElement | null>(null)
|
||||
const draftName = ref('')
|
||||
const draftNumber = ref('')
|
||||
@@ -259,7 +259,7 @@ function toggleAdd() {
|
||||
return
|
||||
}
|
||||
adding.value = true
|
||||
void nextTick(() => nameInput.value?.focus())
|
||||
void nextTick(() => nameInput.value?.focus?.())
|
||||
}
|
||||
|
||||
function resetDraft() {
|
||||
@@ -492,11 +492,11 @@ async function reload() {
|
||||
<form v-if="adding" class="picker-form" @submit.prevent="saveManual">
|
||||
<label>
|
||||
名字
|
||||
<input ref="nameInput" v-model="draftName" name="drawer-contact-name" autocomplete="name" maxlength="64" placeholder="张三" />
|
||||
<el-input ref="nameInput" v-model="draftName" name="drawer-contact-name" autocomplete="name" maxlength="64" placeholder="张三" />
|
||||
</label>
|
||||
<label>
|
||||
号码
|
||||
<input
|
||||
<el-input
|
||||
v-model="draftNumber"
|
||||
type="tel"
|
||||
inputmode="tel"
|
||||
@@ -510,7 +510,7 @@ async function reload() {
|
||||
</label>
|
||||
<label v-for="(_, index) in extraNumbers" :key="index">
|
||||
号码 {{ index + 2 }}
|
||||
<input
|
||||
<el-input
|
||||
v-model="extraNumbers[index]"
|
||||
type="tel"
|
||||
inputmode="tel"
|
||||
@@ -534,9 +534,13 @@ async function reload() {
|
||||
<div v-if="identities.contactsLoading && !identities.contacts.length" class="picker-state">正在加载联系人</div>
|
||||
<div v-else-if="groupedContacts.length" class="picker-list" role="list" @scroll.passive="onContactScroll">
|
||||
<article v-for="group in groupedContacts" :key="group.key" class="picker-item" :class="{ 'is-open': expanded === group.key }" role="listitem">
|
||||
<label v-if="selecting" class="picker-check" @click.stop>
|
||||
<input type="checkbox" :checked="groupSelected(group)" @change="toggleGroup(group)">
|
||||
</label>
|
||||
<div v-if="selecting" class="picker-check" @click.stop>
|
||||
<el-checkbox
|
||||
:model-value="groupSelected(group)"
|
||||
:aria-label="`选择联系人 ${group.name}`"
|
||||
@change="toggleGroup(group)"
|
||||
/>
|
||||
</div>
|
||||
<button type="button" class="picker-main" :aria-label="`${selectLabel} ${group.name}`" @click="activateGroup(group)">
|
||||
<strong>{{ group.name }}</strong>
|
||||
<span v-if="group.items.length === 1">{{ group.items[0].display_number || group.items[0].number }}</span>
|
||||
@@ -556,13 +560,17 @@ async function reload() {
|
||||
</template>
|
||||
<div v-if="expanded === group.key && group.items.length > 1" class="picker-numbers">
|
||||
<template v-if="selecting">
|
||||
<label v-for="item in group.items" :key="item.number" class="picker-number is-check">
|
||||
<input type="checkbox" :checked="selected.includes(item.number)" @change="toggleNumber(item.number)">
|
||||
<div v-for="item in group.items" :key="item.number" class="picker-number is-check">
|
||||
<el-checkbox
|
||||
:model-value="selected.includes(item.number)"
|
||||
:aria-label="`选择 ${item.display_number || item.number}`"
|
||||
@change="toggleNumber(item.number)"
|
||||
/>
|
||||
<span>
|
||||
{{ item.display_number || item.number }}
|
||||
<small v-if="item.subtitle">{{ item.subtitle }}</small>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<button
|
||||
@@ -695,12 +703,13 @@ async function reload() {
|
||||
}
|
||||
.picker-form { padding: 0 18px 14px; display: grid; grid-template-columns: 1fr; gap: 10px; border-bottom: 1px solid var(--ui-border); flex: 0 0 auto; }
|
||||
.picker-form label { min-width: 0; display: grid; gap: 6px; color: var(--ui-text-muted); font-size: 12px; font-weight: 600; }
|
||||
.picker-form input { width: 100%; min-width: 0; min-height: 44px; box-sizing: border-box; padding: 0 12px; border: 1px solid var(--ui-border); border-radius: var(--ui-radius-md); background: var(--ui-surface); color: var(--ui-text); font-size: 14px; }
|
||||
.picker-form :deep(.el-input) { width: 100%; min-width: 0; }
|
||||
.picker-form :deep(.el-input__wrapper) { min-height: 44px; border-radius: var(--ui-radius-md); background: var(--ui-surface); }
|
||||
.picker-form button[type="submit"] { width: 100%; min-height: 44px; border: 1px solid var(--ui-primary); border-radius: var(--ui-radius-pill); background: var(--ui-primary-solid); color: #fff; cursor: pointer; font-size: 14px; font-weight: 650; }
|
||||
.picker-add-more { width: 100%; min-height: 44px; border: 1px dashed var(--ui-border); border-radius: var(--ui-radius-pill); background: transparent; color: var(--ui-text-muted); cursor: pointer; font-size: 13px; }
|
||||
.picker-form button:disabled { cursor: not-allowed; opacity: .45; }
|
||||
.picker-number.is-check { grid-template-columns: auto minmax(0, 1fr); align-items: center; }
|
||||
.picker-number.is-check input { width: 18px; height: 18px; }
|
||||
.picker-number.is-check :deep(.el-checkbox) { min-width: 32px; min-height: 32px; margin-right: 0; }
|
||||
.picker-number.is-add { color: var(--ui-primary); justify-items: start; }
|
||||
.picker-form small { color: var(--ui-danger); font-size: 12px; }
|
||||
.picker-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
|
||||
@@ -718,7 +727,7 @@ async function reload() {
|
||||
.picker-load-more { cursor: pointer; }
|
||||
.picker-item { min-height: 64px; padding: 8px 8px 8px 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; border-bottom: 1px solid var(--ui-border-muted); transition: background-color 120ms ease; }
|
||||
.picker-check { width: 44px; height: 44px; display: grid; place-items: center; }
|
||||
.picker-check input { width: 18px; height: 18px; }
|
||||
.picker-check :deep(.el-checkbox) { margin-right: 0; }
|
||||
.picker-numbers { flex: 1 1 100%; display: grid; gap: 6px; padding: 4px 40px 8px 0; }
|
||||
.picker-number { min-height: 44px; padding: 8px 12px; display: grid; gap: 2px; border: 1px solid var(--ui-border); border-radius: var(--ui-radius-md); background: var(--ui-surface); color: inherit; text-align: left; cursor: pointer; }
|
||||
.picker-number span { font-family: "v-mono", monospace; font-size: 13px; color: var(--ui-text); }
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
} from '@vicons/fluent'
|
||||
import { commandService } from '../../services/commands'
|
||||
import type { CommandAttachment } from '../../types/commands'
|
||||
import { formatPlaybackTime, playbackProgress } from '../../utils/audioPlayback'
|
||||
import { formatPlaybackTime } from '../../utils/audioPlayback'
|
||||
|
||||
const props = defineProps<{ attachment: CommandAttachment }>()
|
||||
const audio = ref<HTMLAudioElement | null>(null)
|
||||
@@ -23,7 +23,6 @@ const currentTime = ref(0)
|
||||
const duration = ref(0)
|
||||
const volume = ref(1)
|
||||
const muted = ref(false)
|
||||
const progress = computed(() => playbackProgress(currentTime.value, duration.value))
|
||||
const silent = computed(() => muted.value || volume.value === 0)
|
||||
let controller: AbortController | null = null
|
||||
let lastAudibleVolume = 1
|
||||
@@ -77,18 +76,23 @@ function updatePlaybackTime() {
|
||||
currentTime.value = audio.value?.currentTime || 0
|
||||
}
|
||||
|
||||
function seekPlayback(event: Event) {
|
||||
function requireSingleSliderValue(value: number | number[], control: string) {
|
||||
if (Array.isArray(value)) throw new TypeError(`${control} 不接受区间值`)
|
||||
return value
|
||||
}
|
||||
|
||||
function seekPlayback(value: number | number[]) {
|
||||
const player = audio.value
|
||||
if (!player) return
|
||||
const nextTime = Number((event.target as HTMLInputElement).value)
|
||||
const nextTime = requireSingleSliderValue(value, '录音播放进度')
|
||||
player.currentTime = nextTime
|
||||
currentTime.value = nextTime
|
||||
}
|
||||
|
||||
function updateVolume(event: Event) {
|
||||
function updateVolume(value: number | number[]) {
|
||||
const player = audio.value
|
||||
if (!player) return
|
||||
const nextVolume = Number((event.target as HTMLInputElement).value)
|
||||
const nextVolume = requireSingleSliderValue(value, '录音音量')
|
||||
volume.value = nextVolume
|
||||
player.volume = nextVolume
|
||||
if (nextVolume > 0) lastAudibleVolume = nextVolume
|
||||
@@ -152,48 +156,46 @@ function releaseRecording() {
|
||||
<div v-else-if="error" class="audio-state is-error" role="alert">
|
||||
<el-icon aria-hidden="true"><ErrorCircle24Regular /></el-icon>
|
||||
<span>{{ error }}</span>
|
||||
<button type="button" class="retry-button" @click="loadRecording(attachment.recording)">重试</button>
|
||||
<el-button class="retry-button" @click="loadRecording(attachment.recording)">重试</el-button>
|
||||
</div>
|
||||
<div v-else-if="source" class="audio-controls">
|
||||
<button
|
||||
type="button"
|
||||
<el-button
|
||||
circle
|
||||
class="audio-action is-primary"
|
||||
:aria-label="playing ? '暂停通话录音' : '播放通话录音'"
|
||||
@click="togglePlayback"
|
||||
>
|
||||
<el-icon><Pause24Regular v-if="playing" /><Play24Regular v-else /></el-icon>
|
||||
</button>
|
||||
</el-button>
|
||||
<time>{{ formatPlaybackTime(currentTime) }}</time>
|
||||
<input
|
||||
<el-slider
|
||||
v-model="currentTime"
|
||||
class="playback-range"
|
||||
type="range"
|
||||
min="0"
|
||||
:min="0"
|
||||
:max="duration || 0"
|
||||
step="0.1"
|
||||
:value="currentTime"
|
||||
:step="0.1"
|
||||
:disabled="!duration"
|
||||
:style="{ '--range-progress': `${progress}%` }"
|
||||
:show-tooltip="false"
|
||||
aria-label="录音播放进度"
|
||||
@input="seekPlayback"
|
||||
/>
|
||||
<time>{{ formatPlaybackTime(duration) }}</time>
|
||||
<div class="volume-controls">
|
||||
<button
|
||||
type="button"
|
||||
<el-button
|
||||
circle
|
||||
class="audio-action"
|
||||
:aria-label="silent ? '恢复录音声音' : '静音录音'"
|
||||
@click="toggleMuted"
|
||||
>
|
||||
<el-icon><SpeakerMute24Regular v-if="silent" /><Speaker224Regular v-else /></el-icon>
|
||||
</button>
|
||||
<input
|
||||
</el-button>
|
||||
<el-slider
|
||||
v-model="volume"
|
||||
class="volume-range"
|
||||
type="range"
|
||||
min="0"
|
||||
max="1"
|
||||
step="0.05"
|
||||
:value="volume"
|
||||
:style="{ '--range-progress': `${volume * 100}%` }"
|
||||
:min="0"
|
||||
:max="1"
|
||||
:step="0.05"
|
||||
:show-tooltip="false"
|
||||
aria-label="录音音量"
|
||||
@input="updateVolume"
|
||||
/>
|
||||
@@ -254,13 +256,14 @@ function releaseRecording() {
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
.audio-action, .retry-button {
|
||||
.audio-action.el-button, .retry-button.el-button {
|
||||
margin-left: 0;
|
||||
border: 1px solid var(--ui-border);
|
||||
background: transparent;
|
||||
color: var(--ui-text-muted);
|
||||
cursor: pointer;
|
||||
}
|
||||
.audio-action {
|
||||
.audio-action.el-button {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
padding: 0;
|
||||
@@ -274,60 +277,20 @@ function releaseRecording() {
|
||||
color: var(--ui-primary);
|
||||
}
|
||||
.audio-action:hover, .retry-button:hover { border-color: var(--ui-primary); color: var(--ui-primary); }
|
||||
.audio-action:focus-visible, .retry-button:focus-visible, input[type="range"]:focus-visible {
|
||||
.audio-action:focus-visible, .retry-button:focus-visible {
|
||||
outline: 2px solid var(--ui-primary);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
.audio-controls time { color: var(--ui-muted); font: var(--ui-font-caption) "v-mono", ui-monospace, monospace; }
|
||||
.playback-range, .volume-range {
|
||||
--range-progress: 0%;
|
||||
min-width: 0;
|
||||
height: 36px;
|
||||
margin: 0;
|
||||
appearance: none;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
}
|
||||
.playback-range::-webkit-slider-runnable-track, .volume-range::-webkit-slider-runnable-track {
|
||||
height: 4px;
|
||||
border-radius: 2px;
|
||||
background: linear-gradient(
|
||||
to right,
|
||||
var(--ui-primary) 0,
|
||||
var(--ui-primary) var(--range-progress),
|
||||
var(--ui-border) var(--range-progress),
|
||||
var(--ui-border) 100%
|
||||
);
|
||||
}
|
||||
.playback-range::-moz-range-track, .volume-range::-moz-range-track {
|
||||
height: 4px;
|
||||
border-radius: 2px;
|
||||
background: linear-gradient(
|
||||
to right,
|
||||
var(--ui-primary) 0,
|
||||
var(--ui-primary) var(--range-progress),
|
||||
var(--ui-border) var(--range-progress),
|
||||
var(--ui-border) 100%
|
||||
);
|
||||
}
|
||||
.playback-range:disabled { cursor: wait; opacity: .5; }
|
||||
.playback-range::-webkit-slider-thumb, .volume-range::-webkit-slider-thumb {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
appearance: none;
|
||||
border: 2px solid var(--ui-surface-strong);
|
||||
border-radius: 50%;
|
||||
background: var(--ui-primary);
|
||||
box-shadow: 0 0 0 1px var(--ui-border);
|
||||
margin-top: -4px;
|
||||
}
|
||||
.playback-range::-moz-range-thumb, .volume-range::-moz-range-thumb {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border: 2px solid var(--ui-surface-strong);
|
||||
border-radius: 50%;
|
||||
background: var(--ui-primary);
|
||||
}
|
||||
.playback-range.is-disabled { cursor: wait; opacity: .5; }
|
||||
.playback-range :deep(.el-slider__runway), .volume-range :deep(.el-slider__runway) { height: 4px; background: var(--ui-border); }
|
||||
.playback-range :deep(.el-slider__bar), .volume-range :deep(.el-slider__bar) { height: 4px; background: var(--ui-primary); }
|
||||
.playback-range :deep(.el-slider__button), .volume-range :deep(.el-slider__button) { width: 12px; height: 12px; border: 2px solid var(--ui-surface-strong); background: var(--ui-primary); box-shadow: 0 0 0 1px var(--ui-border); }
|
||||
.volume-controls { min-width: 0; display: grid; grid-template-columns: 36px minmax(48px, 1fr); align-items: center; gap: 7px; }
|
||||
.native-audio { display: none; }
|
||||
.audio-state { min-height: 36px; color: var(--ui-text-muted); font-size: var(--ui-font-body-sm); display: flex; align-items: center; gap: 7px; }
|
||||
|
||||
@@ -45,7 +45,7 @@ defineEmits<{
|
||||
<template #icon><el-icon><Earth24Regular /></el-icon></template>
|
||||
|
||||
<div class="proxy-probe-toolbar">
|
||||
<label><input v-model="autoProbe" type="checkbox" />每分钟自动检测</label>
|
||||
<el-checkbox v-model="autoProbe">每分钟自动检测</el-checkbox>
|
||||
<span>{{ autoProbe ? '打开此页时更新;关闭页面后停止' : '自动检测已暂停,可点击刷新重新检测' }}</span>
|
||||
</div>
|
||||
|
||||
@@ -125,8 +125,8 @@ defineEmits<{
|
||||
<style scoped>
|
||||
.proxy-table-wrap { min-width: 0; }
|
||||
.proxy-probe-toolbar { padding: 8px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; border-bottom: 1px solid var(--ui-border); color: var(--ui-text-muted); font-size: var(--ui-font-body-sm); }
|
||||
.proxy-probe-toolbar label { min-height: 44px; display: inline-flex; align-items: center; gap: 8px; color: var(--ui-text); cursor: pointer; }
|
||||
.proxy-probe-toolbar input { width: 18px; height: 18px; accent-color: var(--ui-communication); }
|
||||
.proxy-probe-toolbar :deep(.el-checkbox) { min-height: 44px; margin-right: 0; }
|
||||
.proxy-probe-toolbar :deep(.el-checkbox__label) { color: var(--ui-text); }
|
||||
.proxy-observation-meta { display: block; margin-top: 5px; color: var(--ui-text-muted); font-size: var(--ui-font-caption); line-height: 1.5; }
|
||||
.proxy-egress-ip { display: block; margin-top: 6px; }
|
||||
.proxy-egress-warning { display: block; margin-top: 6px; color: var(--ui-warning); font-size: var(--ui-font-caption); line-height: 1.5; }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { ArrowUpload24Regular } from '@vicons/fluent'
|
||||
import { Add20Regular, ArrowUpload24Regular, Subtract20Regular } from '@vicons/fluent'
|
||||
import { devicesService } from '../../services/devices'
|
||||
import {
|
||||
systemService,
|
||||
@@ -10,55 +10,69 @@ import {
|
||||
} from '../../services/system'
|
||||
|
||||
type DeviceRow = AutoAnswerDeviceSettings & { name: string }
|
||||
const DEFAULT_AUTO_ANSWER_DELAY_SECONDS = 30
|
||||
type SavedDeviceSettings = Pick<AutoAnswerDeviceSettings, 'enabled' | 'delay_seconds'>
|
||||
const DEFAULT_AUTO_ANSWER_DELAY_SECONDS = 8
|
||||
const DEVICE_SEARCH_THRESHOLD = 5
|
||||
const DEVICE_SAVE_BATCH_SIZE = 4
|
||||
|
||||
const settings = ref<AutoAnswerSettings>({ audio_ready: false, audio_name: '', devices: [] })
|
||||
const rows = ref<DeviceRow[]>([])
|
||||
const loading = ref(true)
|
||||
const loaded = ref(false)
|
||||
const loadError = ref('')
|
||||
const savingDevices = ref(new Set<string>())
|
||||
const uploading = ref(false)
|
||||
const searchQuery = ref('')
|
||||
const savedDevices = ref(new Map<string, SavedDeviceSettings>())
|
||||
const fileInput = ref<HTMLInputElement | null>(null)
|
||||
|
||||
function isSaving(deviceId: string) {
|
||||
return savingDevices.value.has(deviceId)
|
||||
const busy = computed(() => loading.value || uploading.value || savingDevices.value.size > 0)
|
||||
const enabledCount = computed(() => rows.value.filter(row => row.enabled).length)
|
||||
const dirtyRows = computed(() => rows.value.filter(isDirty))
|
||||
const filteredRows = computed(() => {
|
||||
const query = searchQuery.value.trim().toLocaleLowerCase()
|
||||
if (!query) return rows.value
|
||||
return rows.value.filter(row => `${row.name} ${row.device_id}`.toLocaleLowerCase().includes(query))
|
||||
})
|
||||
|
||||
function isDirty(row: DeviceRow) {
|
||||
const saved = savedDevices.value.get(row.device_id)
|
||||
return !saved || saved.enabled !== row.enabled || saved.delay_seconds !== row.delay_seconds
|
||||
}
|
||||
|
||||
function setSaving(deviceId: string, saving: boolean) {
|
||||
const next = new Set(savingDevices.value)
|
||||
if (saving) next.add(deviceId)
|
||||
else next.delete(deviceId)
|
||||
savingDevices.value = next
|
||||
function rememberSaved(rowsToRemember: DeviceRow[]) {
|
||||
savedDevices.value = new Map(rowsToRemember.map(row => [
|
||||
row.device_id,
|
||||
{ enabled: row.enabled, delay_seconds: row.delay_seconds }
|
||||
]))
|
||||
}
|
||||
|
||||
function applyDeviceSettings(next: AutoAnswerSettings) {
|
||||
settings.value = next
|
||||
const configured = new Map(next.devices.map(item => [item.device_id, item]))
|
||||
rows.value = rows.value.map(row => {
|
||||
const saved = configured.get(row.device_id)
|
||||
return saved ? { ...row, ...saved } : row
|
||||
})
|
||||
function adjustDelay(row: DeviceRow, amount: number) {
|
||||
row.delay_seconds = Math.max(1, row.delay_seconds + amount)
|
||||
}
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
loaded.value = false
|
||||
loadError.value = ''
|
||||
const [phoneResult, devicesResult] = await Promise.all([
|
||||
systemService.getPhoneSettings(),
|
||||
devicesService.listManaged()
|
||||
])
|
||||
loading.value = false
|
||||
if (!phoneResult.ok) {
|
||||
ElMessage.error(phoneResult.error.message || '自动接听设置加载失败')
|
||||
loadError.value = phoneResult.error.message || '自动接听设置加载失败'
|
||||
ElMessage.error(loadError.value)
|
||||
return
|
||||
}
|
||||
if (!devicesResult.ok) {
|
||||
ElMessage.error(devicesResult.error.message || '设备列表加载失败')
|
||||
loadError.value = devicesResult.error.message || '设备列表加载失败'
|
||||
ElMessage.error(loadError.value)
|
||||
return
|
||||
}
|
||||
settings.value = phoneResult.data.auto_answer
|
||||
const configured = new Map(settings.value.devices.map(item => [item.device_id, item]))
|
||||
rows.value = devicesResult.data.devices.map(device => {
|
||||
const loadedRows = devicesResult.data.devices.map(device => {
|
||||
const saved = configured.get(device.id)
|
||||
return {
|
||||
device_id: device.id,
|
||||
@@ -67,32 +81,47 @@ async function load() {
|
||||
delay_seconds: saved && saved.delay_seconds > 0 ? saved.delay_seconds : DEFAULT_AUTO_ANSWER_DELAY_SECONDS
|
||||
}
|
||||
})
|
||||
rows.value = loadedRows
|
||||
rememberSaved(loadedRows)
|
||||
loaded.value = true
|
||||
}
|
||||
|
||||
async function saveDevice(row: DeviceRow, enabled = row.enabled, delayOnly = false) {
|
||||
setSaving(row.device_id, true)
|
||||
const result = await systemService.saveAutoAnswerDevice(row.device_id, {
|
||||
enabled,
|
||||
delay_seconds: row.delay_seconds
|
||||
})
|
||||
setSaving(row.device_id, false)
|
||||
if (!result.ok) {
|
||||
ElMessage.error(result.error.message || '自动接听设置保存失败')
|
||||
await load()
|
||||
return false
|
||||
async function saveAll() {
|
||||
const pending = dirtyRows.value.map(row => ({
|
||||
row,
|
||||
payload: { enabled: row.enabled, delay_seconds: row.delay_seconds }
|
||||
}))
|
||||
if (!pending.length) return
|
||||
savingDevices.value = new Set(pending.map(item => item.row.device_id))
|
||||
const results = []
|
||||
for (let start = 0; start < pending.length; start += DEVICE_SAVE_BATCH_SIZE) {
|
||||
const batch = pending.slice(start, start + DEVICE_SAVE_BATCH_SIZE)
|
||||
results.push(...await Promise.all(batch.map(async item => ({
|
||||
...item,
|
||||
result: await systemService.saveAutoAnswerDevice(item.row.device_id, item.payload)
|
||||
}))))
|
||||
}
|
||||
row.enabled = enabled
|
||||
ElMessage.success(delayOnly ? '等待时间已保存' : enabled ? '该设备已启用自动接听' : '该设备已关闭自动接听')
|
||||
return true
|
||||
savingDevices.value = new Set()
|
||||
|
||||
const nextSaved = new Map(savedDevices.value)
|
||||
const failures: Array<{ name: string; message: string }> = []
|
||||
for (const item of results) {
|
||||
if (item.result.ok) nextSaved.set(item.row.device_id, item.payload)
|
||||
else failures.push({ name: item.row.name, message: item.result.error.message || '保存失败' })
|
||||
}
|
||||
savedDevices.value = nextSaved
|
||||
if (failures.length) {
|
||||
const first = failures[0]
|
||||
const prefix = failures.length > 1 ? `${failures.length} 台设备保存失败;第一项` : ''
|
||||
ElMessage.error(`${prefix}${first.name}:${first.message}`)
|
||||
return
|
||||
}
|
||||
ElMessage.success(`已保存 ${results.length} 台设备的自动接听设置`)
|
||||
}
|
||||
|
||||
async function toggleDevice(row: DeviceRow, value: string | number | boolean) {
|
||||
const enabled = value === true
|
||||
if (!enabled) {
|
||||
await saveDevice(row, false)
|
||||
return
|
||||
}
|
||||
if (!enabled) return
|
||||
if (!settings.value.audio_ready) {
|
||||
row.enabled = false
|
||||
ElMessage.warning('请先上传自动接听录音')
|
||||
@@ -100,15 +129,14 @@ async function toggleDevice(row: DeviceRow, value: string | number | boolean) {
|
||||
}
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`${row.name} 来电持续 ${row.delay_seconds} 秒无人接听时,HiDeck 将自动接听、播放录音、保存对方语音,并发送到 QQ、飞书、Telegram、微信或企业微信机器人。确认启用?`,
|
||||
`${row.name} 来电持续 ${row.delay_seconds} 秒无人接听时,HiDeck 将自动接听、播放录音、保存对方语音,并发送到 QQ、飞书、Telegram、微信或企业微信机器人。保存修改后生效。`,
|
||||
'启用自动接听',
|
||||
{ type: 'warning', confirmButtonText: '启用', cancelButtonText: '取消' }
|
||||
{ type: 'warning', confirmButtonText: '继续', cancelButtonText: '取消' }
|
||||
)
|
||||
} catch {
|
||||
row.enabled = false
|
||||
return
|
||||
}
|
||||
await saveDevice(row, true)
|
||||
}
|
||||
|
||||
async function upload(event: Event) {
|
||||
@@ -123,7 +151,11 @@ async function upload(event: Event) {
|
||||
ElMessage.error(result.error.message || '自动接听录音上传失败')
|
||||
return
|
||||
}
|
||||
applyDeviceSettings(result.data)
|
||||
settings.value = {
|
||||
...settings.value,
|
||||
audio_ready: result.data.audio_ready,
|
||||
audio_name: result.data.audio_name
|
||||
}
|
||||
ElMessage.success('自动接听录音已更新')
|
||||
}
|
||||
|
||||
@@ -131,7 +163,7 @@ onMounted(load)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="auto-answer-settings" :aria-busy="loading || uploading || savingDevices.size > 0">
|
||||
<div class="auto-answer-settings" :aria-busy="busy">
|
||||
<div class="auto-answer-heading">
|
||||
<div>
|
||||
<div class="text-sm font-bold text-[var(--ui-text)]">未接来电自动应答</div>
|
||||
@@ -149,7 +181,7 @@ onMounted(load)
|
||||
{{ settings.audio_ready ? `已就绪:${settings.audio_name}` : '尚未上传录音' }}
|
||||
</span>
|
||||
</div>
|
||||
<el-button :loading="uploading" :disabled="!loaded || loading || savingDevices.size > 0" @click="fileInput?.click()">
|
||||
<el-button :loading="uploading" :disabled="!loaded || busy" @click="fileInput?.click()">
|
||||
<el-icon><ArrowUpload24Regular /></el-icon>
|
||||
{{ uploading ? '正在上传' : '选择 WAV' }}
|
||||
</el-button>
|
||||
@@ -158,49 +190,105 @@ onMounted(load)
|
||||
class="auto-answer-file"
|
||||
type="file"
|
||||
accept=".wav,audio/wav,audio/x-wav"
|
||||
:disabled="!loaded || loading || uploading || savingDevices.size > 0"
|
||||
:disabled="!loaded || busy"
|
||||
@change="upload"
|
||||
>
|
||||
</div>
|
||||
|
||||
<div v-if="loaded && rows.length" class="auto-answer-devices">
|
||||
<div v-for="row in rows" :key="row.device_id" class="auto-answer-device">
|
||||
<div class="auto-answer-device-heading">
|
||||
<div class="min-w-0">
|
||||
<strong>{{ row.name }}</strong>
|
||||
<div v-if="loading" class="auto-answer-state" role="status">正在加载设备设置…</div>
|
||||
<div v-else-if="loadError" class="auto-answer-state is-error" role="alert">
|
||||
<span>{{ loadError }}</span>
|
||||
<el-button :disabled="busy" @click="load">重新加载</el-button>
|
||||
</div>
|
||||
<section v-else-if="loaded && rows.length" class="auto-answer-device-panel" aria-labelledby="auto-answer-device-title">
|
||||
<div class="auto-answer-device-toolbar">
|
||||
<div class="auto-answer-device-summary">
|
||||
<strong id="auto-answer-device-title">按设备设置</strong>
|
||||
<span>
|
||||
共 {{ rows.length }} 台,已启用 {{ enabledCount }} 台
|
||||
<template v-if="dirtyRows.length"> · {{ dirtyRows.length }} 项未保存</template>
|
||||
</span>
|
||||
</div>
|
||||
<div class="auto-answer-device-actions">
|
||||
<el-input
|
||||
v-if="rows.length >= DEVICE_SEARCH_THRESHOLD"
|
||||
v-model="searchQuery"
|
||||
clearable
|
||||
aria-label="搜索自动接听设备"
|
||||
placeholder="搜索设备"
|
||||
/>
|
||||
<el-button type="primary" :loading="savingDevices.size > 0" :disabled="busy || !dirtyRows.length" @click="saveAll">
|
||||
保存修改
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="auto-answer-list-header" aria-hidden="true">
|
||||
<span>设备</span>
|
||||
<span>自动接听</span>
|
||||
<span>无人接听后</span>
|
||||
</div>
|
||||
<div v-if="filteredRows.length" class="auto-answer-device-list" role="list">
|
||||
<div
|
||||
v-for="row in filteredRows"
|
||||
:key="row.device_id"
|
||||
class="auto-answer-device-row"
|
||||
:class="{ 'is-dirty': isDirty(row) }"
|
||||
role="listitem"
|
||||
>
|
||||
<div class="auto-answer-device-identity">
|
||||
<strong :id="`auto-answer-device-${row.device_id}`">{{ row.name }}</strong>
|
||||
<span>{{ row.device_id }}</span>
|
||||
</div>
|
||||
<el-switch
|
||||
v-model="row.enabled"
|
||||
:loading="isSaving(row.device_id)"
|
||||
:disabled="loading || uploading || isSaving(row.device_id)"
|
||||
:aria-label="`${row.name} 自动接听`"
|
||||
@change="toggleDevice(row, $event)"
|
||||
/>
|
||||
</div>
|
||||
<div class="auto-answer-delay">
|
||||
<label :for="`auto-answer-delay-${row.device_id}`">无人接听等待时间</label>
|
||||
<div class="auto-answer-delay-input">
|
||||
<el-input-number
|
||||
:id="`auto-answer-delay-${row.device_id}`"
|
||||
v-model="row.delay_seconds"
|
||||
:min="1"
|
||||
:step="5"
|
||||
:disabled="loading || uploading || isSaving(row.device_id)"
|
||||
controls-position="right"
|
||||
<div class="auto-answer-device-toggle">
|
||||
<span class="auto-answer-field-label">自动接听</span>
|
||||
<el-switch
|
||||
v-model="row.enabled"
|
||||
:disabled="busy"
|
||||
:aria-label="`${row.name} 自动接听`"
|
||||
@change="toggleDevice(row, $event)"
|
||||
/>
|
||||
<span>秒</span>
|
||||
<el-button
|
||||
:loading="isSaving(row.device_id)"
|
||||
:disabled="loading || uploading || isSaving(row.device_id)"
|
||||
@click="saveDevice(row, row.enabled, true)"
|
||||
>
|
||||
保存
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="auto-answer-delay-field">
|
||||
<span class="auto-answer-field-label">无人接听后</span>
|
||||
<div class="auto-answer-delay-stepper" role="group" :aria-label="`${row.name} 无人接听等待时间`">
|
||||
<el-button
|
||||
text
|
||||
class="auto-answer-stepper-button"
|
||||
:disabled="busy || row.delay_seconds <= 1"
|
||||
:aria-label="`${row.name} 减少等待时间`"
|
||||
@click="adjustDelay(row, -1)"
|
||||
>
|
||||
<el-icon><Subtract20Regular /></el-icon>
|
||||
</el-button>
|
||||
<div class="auto-answer-delay-value">
|
||||
<el-input-number
|
||||
:id="`auto-answer-delay-${row.device_id}`"
|
||||
v-model="row.delay_seconds"
|
||||
class="font-mono"
|
||||
:min="1"
|
||||
:step="1"
|
||||
:disabled="busy"
|
||||
:controls="false"
|
||||
:aria-label="`${row.name} 无人接听等待秒数`"
|
||||
/>
|
||||
<span class="auto-answer-delay-unit">秒</span>
|
||||
</div>
|
||||
<el-button
|
||||
text
|
||||
class="auto-answer-stepper-button"
|
||||
:disabled="busy"
|
||||
:aria-label="`${row.name} 增加等待时间`"
|
||||
@click="adjustDelay(row, 1)"
|
||||
>
|
||||
<el-icon><Add20Regular /></el-icon>
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="auto-answer-list-empty">未找到匹配设备</div>
|
||||
</section>
|
||||
<div v-else-if="loaded" class="auto-answer-empty">暂无可配置设备</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -208,28 +296,67 @@ onMounted(load)
|
||||
<style scoped>
|
||||
.auto-answer-settings { display: grid; gap: 16px; }
|
||||
.auto-answer-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
|
||||
.auto-answer-audio, .auto-answer-device { min-width: 0; padding: 16px; border: 1px solid var(--ui-border); border-radius: var(--ui-radius-md); background: var(--ui-surface-muted); }
|
||||
.auto-answer-audio { display: flex; align-items: center; gap: 12px; }
|
||||
.auto-answer-audio, .auto-answer-device-panel { min-width: 0; border: 1px solid var(--ui-border); border-radius: var(--ui-radius-md); background: var(--ui-surface-muted); }
|
||||
.auto-answer-audio { display: flex; align-items: center; gap: 12px; padding: 16px; }
|
||||
.auto-answer-audio-copy { flex: 1; min-width: 0; }
|
||||
.auto-answer-audio strong, .auto-answer-device strong, .auto-answer-delay label { font-size: var(--ui-font-body-sm); font-weight: 650; color: var(--ui-text); }
|
||||
.auto-answer-audio strong, .auto-answer-device-panel strong { font-size: var(--ui-font-body-sm); font-weight: 650; color: var(--ui-text); }
|
||||
.auto-answer-audio p { margin: 4px 0 0; color: var(--ui-text-muted); font-size: 13px; line-height: 1.5; }
|
||||
.auto-answer-audio span { display: block; margin-top: 8px; font-size: 12px; overflow-wrap: anywhere; }
|
||||
.auto-answer-audio .is-ready { color: var(--ui-success); }
|
||||
.auto-answer-audio .is-missing { color: var(--ui-warning); }
|
||||
.auto-answer-devices { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
|
||||
.auto-answer-device { display: grid; gap: 14px; }
|
||||
.auto-answer-device-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
|
||||
.auto-answer-device-heading span { display: block; margin-top: 3px; color: var(--ui-text-muted); font-size: 12px; overflow-wrap: anywhere; }
|
||||
.auto-answer-delay { display: grid; gap: 8px; }
|
||||
.auto-answer-delay-input { display: flex; align-items: center; gap: 8px; }
|
||||
.auto-answer-delay-input span { color: var(--ui-text-muted); font-size: 13px; }
|
||||
.auto-answer-empty { padding: 20px; border: 1px dashed var(--ui-border); border-radius: var(--ui-radius-md); color: var(--ui-text-muted); text-align: center; }
|
||||
.auto-answer-device-panel { container-type: inline-size; overflow: hidden; }
|
||||
.auto-answer-device-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 16px; border-bottom: 1px solid var(--ui-border); background: var(--ui-surface); }
|
||||
.auto-answer-device-summary { min-width: 0; }
|
||||
.auto-answer-device-summary span { display: block; margin-top: 3px; color: var(--ui-text-muted); font-size: 12px; }
|
||||
.auto-answer-device-actions { display: flex; align-items: center; gap: 8px; }
|
||||
.auto-answer-device-actions .el-input { width: 200px; }
|
||||
.auto-answer-list-header { display: grid; grid-template-columns: minmax(140px, 1fr) 104px 176px; align-items: center; gap: 16px; padding: 8px 16px; border-bottom: 1px solid var(--ui-border); color: var(--ui-text-muted); font-size: 12px; font-weight: 600; }
|
||||
.auto-answer-list-header span:nth-child(2) { text-align: center; }
|
||||
.auto-answer-device-list { max-height: min(440px, 55vh); overflow: auto; scrollbar-gutter: stable; }
|
||||
.auto-answer-device-row { display: grid; grid-template-columns: minmax(140px, 1fr) 104px 176px; align-items: center; gap: 16px; min-height: 60px; padding: 8px 16px; border-bottom: 1px solid var(--ui-border); }
|
||||
.auto-answer-device-row.is-dirty { box-shadow: inset 3px 0 0 var(--ui-primary); }
|
||||
.auto-answer-device-row:last-child { border-bottom: 0; }
|
||||
.auto-answer-device-identity { min-width: 0; }
|
||||
.auto-answer-device-identity strong, .auto-answer-device-identity span { display: block; overflow-wrap: anywhere; }
|
||||
.auto-answer-device-identity span { margin-top: 3px; color: var(--ui-text-muted); font-size: 12px; }
|
||||
.auto-answer-device-toggle, .auto-answer-delay-field { display: flex; align-items: center; gap: 8px; }
|
||||
.auto-answer-device-toggle { justify-content: center; }
|
||||
.auto-answer-field-label { display: none; color: var(--ui-text-muted); font-size: 13px; }
|
||||
.auto-answer-delay-stepper { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; width: 176px; min-height: 44px; box-sizing: border-box; overflow: hidden; border: 1px solid var(--ui-border); border-radius: var(--ui-radius-md); background: var(--ui-surface); }
|
||||
.auto-answer-delay-stepper:focus-within { border-color: var(--ui-primary); box-shadow: var(--ui-focus); }
|
||||
.auto-answer-delay-value { min-width: 0; display: flex; align-items: center; justify-content: center; gap: 4px; padding: 0 8px; }
|
||||
.auto-answer-delay-value .el-input-number, .auto-answer-delay-value :deep(.el-input) { width: 5ch; min-width: 0; min-height: 42px; flex: 0 1 5ch; border-radius: 0 !important; box-shadow: none !important; }
|
||||
.auto-answer-delay-value :deep(.el-input__wrapper), .auto-answer-delay-value :deep(.el-input__wrapper.is-focus) { min-height: 42px; padding: 0; border-radius: 0 !important; background: transparent; box-shadow: none !important; }
|
||||
.auto-answer-delay-stepper :deep(.el-input__inner) { min-width: 0; color: var(--ui-text); font-weight: 650; font-variant-numeric: tabular-nums; text-align: center; }
|
||||
.auto-answer-delay-unit { color: var(--ui-text-muted); font-size: 12px; white-space: nowrap; }
|
||||
.auto-answer-stepper-button.el-button { width: 44px; min-height: 44px; margin: 0; padding: 0; border: 0; border-radius: 0; color: var(--ui-text-muted); }
|
||||
.auto-answer-stepper-button:first-child { border-right: 1px solid var(--ui-border); }
|
||||
.auto-answer-stepper-button:last-child { border-left: 1px solid var(--ui-border); }
|
||||
.auto-answer-stepper-button:not(.is-disabled):hover, .auto-answer-stepper-button:not(.is-disabled):focus-visible { color: var(--ui-primary); background: var(--ui-surface-muted); }
|
||||
.auto-answer-state, .auto-answer-empty, .auto-answer-list-empty { padding: 20px; border: 1px dashed var(--ui-border); border-radius: var(--ui-radius-md); color: var(--ui-text-muted); text-align: center; }
|
||||
.auto-answer-state.is-error { display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--ui-danger); }
|
||||
.auto-answer-list-empty { border: 0; border-radius: 0; }
|
||||
.auto-answer-file { display: none; }
|
||||
:deep(.el-button), :deep(.el-input-number) { min-height: 44px; }
|
||||
.auto-answer-device-actions :deep(.el-input__wrapper), .auto-answer-delay-field :deep(.el-input__wrapper) { min-height: 36px; }
|
||||
.auto-answer-device-toggle :deep(.el-switch) { min-width: 44px; min-height: 44px; }
|
||||
@container (max-width: 620px) {
|
||||
.auto-answer-list-header { display: none; }
|
||||
.auto-answer-device-row { grid-template-columns: minmax(0, 1fr) auto; gap: 6px 16px; min-height: 0; padding-block: 12px; }
|
||||
.auto-answer-device-toggle { gap: 10px; }
|
||||
.auto-answer-field-label { display: inline; }
|
||||
.auto-answer-delay-field { grid-column: 1 / -1; justify-content: space-between; padding-top: 6px; border-top: 1px solid var(--ui-border); }
|
||||
}
|
||||
@container (max-width: 360px) {
|
||||
.auto-answer-delay-field { align-items: stretch; flex-direction: column; }
|
||||
.auto-answer-delay-stepper { grid-template-columns: 44px minmax(0, 1fr) 44px; width: 100%; }
|
||||
}
|
||||
@media (max-width: 720px) {
|
||||
.auto-answer-audio { align-items: stretch; flex-direction: column; }
|
||||
.auto-answer-audio .el-button { width: 100%; }
|
||||
.auto-answer-delay-input { align-items: stretch; flex-wrap: wrap; }
|
||||
.auto-answer-delay-input .el-input-number { flex: 1; min-width: 160px; }
|
||||
.auto-answer-device-toolbar, .auto-answer-device-actions { align-items: stretch; flex-direction: column; }
|
||||
.auto-answer-device-actions .el-input, .auto-answer-device-actions .el-button { width: 100%; }
|
||||
.auto-answer-device-list { max-height: none; overflow: visible; }
|
||||
.auto-answer-state.is-error { align-items: stretch; flex-direction: column; }
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,51 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const currentDir = path.dirname(fileURLToPath(import.meta.url))
|
||||
const source = fs.readFileSync(
|
||||
path.resolve(currentDir, '../src/components/settings/AutoAnswerSettings.vue'),
|
||||
'utf8',
|
||||
)
|
||||
|
||||
test('automatic answer settings scale as one searchable device list', () => {
|
||||
assert.match(source, /const DEFAULT_AUTO_ANSWER_DELAY_SECONDS = 8/)
|
||||
assert.match(source, /const DEVICE_SEARCH_THRESHOLD = 5/)
|
||||
assert.match(source, /v-model="searchQuery"/)
|
||||
assert.match(source, /v-for="row in filteredRows"/)
|
||||
assert.match(source, /class="auto-answer-device-list" role="list"/)
|
||||
assert.match(source, /max-height: min\(440px, 55vh\)/)
|
||||
assert.match(source, /\.auto-answer-device-list \{ max-height: none; overflow: visible; \}/)
|
||||
assert.match(source, /class="auto-answer-list-header"/)
|
||||
assert.match(source, /@container \(max-width: 620px\)/)
|
||||
assert.match(source, /\.auto-answer-list-header \{ display: none; \}/)
|
||||
})
|
||||
|
||||
test('automatic answer changes use one explicit save action with partial failure retention', () => {
|
||||
assert.match(source, /const DEVICE_SAVE_BATCH_SIZE = 4/)
|
||||
assert.match(source, /const dirtyRows = computed/)
|
||||
assert.match(source, /async function saveAll\(\)/)
|
||||
assert.match(source, /pending\.slice\(start, start \+ DEVICE_SAVE_BATCH_SIZE\)/)
|
||||
assert.match(source, /savedDevices\.value = nextSaved/)
|
||||
assert.match(source, /:disabled="busy \|\| !dirtyRows\.length"/)
|
||||
assert.doesNotMatch(source, /saveDevice\(row/)
|
||||
})
|
||||
|
||||
test('automatic answer loading and controls remain explicit and touch safe', () => {
|
||||
assert.match(source, /v-else-if="loadError"/)
|
||||
assert.match(source, /role="alert"/)
|
||||
assert.match(source, />重新加载<\/el-button>/)
|
||||
assert.match(source, /:deep\(\.el-button\), :deep\(\.el-input-number\) \{ min-height: 44px; \}/)
|
||||
assert.match(source, /class="auto-answer-delay-stepper"/)
|
||||
assert.match(source, /class="auto-answer-delay-value"/)
|
||||
assert.match(source, /grid-template-columns: 44px minmax\(0, 1fr\) 44px/)
|
||||
assert.match(source, /justify-content: center/)
|
||||
assert.match(source, /text-align: center/)
|
||||
assert.match(source, /box-shadow: none !important/)
|
||||
assert.match(source, /:controls="false"/)
|
||||
assert.match(source, /<Subtract20Regular \/>/)
|
||||
assert.match(source, /<Add20Regular \/>/)
|
||||
assert.doesNotMatch(source, /controls-position="right"/)
|
||||
})
|
||||
@@ -31,6 +31,9 @@ test('production Vue surfaces present the HiDeck brand consistently', async () =
|
||||
assert.match(login, /t\('login\.title'\)/)
|
||||
assert.match(zhCN, /login:\s*\{[\s\S]*?title:\s*'登录 HiDeck'/)
|
||||
assert.match(app, /t\('disclaimer\.title'\)/)
|
||||
assert.match(app, /<el-input[\s\S]*?v-model="confirmText"/)
|
||||
assert.match(app, /<el-button[\s\S]*?rejectDisclaimer/)
|
||||
assert.doesNotMatch(app, /<input[\s\S]*?v-model="confirmText"/)
|
||||
assert.match(zhCN, /disclaimer:\s*\{[\s\S]*?title:\s*'HiDeck 最终用户许可与免责声明'/)
|
||||
assert.match(commands, /HiDeck 命令会话/)
|
||||
assert.match(settings, /title="HiDeck Gateway"/)
|
||||
|
||||
@@ -38,7 +38,8 @@ test('VoWiFi command results render authenticated MP3 playback', () => {
|
||||
assert.doesNotMatch(commandAudioPlayer, /<audio[^>]*controls/)
|
||||
assert.match(commandAudioPlayer, /aria-label="录音播放进度"/)
|
||||
assert.match(commandAudioPlayer, /aria-label="录音音量"/)
|
||||
assert.doesNotMatch(commandAudioPlayer, /\.volume-range\s*\{\s*display:\s*none/)
|
||||
assert.equal((commandAudioPlayer.match(/<el-slider/g) || []).length, 2)
|
||||
assert.doesNotMatch(commandAudioPlayer, /type="range"/)
|
||||
assert.match(commandAudioPlayer, /\.playback-range, \.volume-range \{ height: 44px; \}/)
|
||||
assert.match(commandAudioPlayer, /\.volume-controls \{ grid-column: 1 \/ -1;/)
|
||||
assert.match(commandAudioPlayer, /togglePlayback/)
|
||||
|
||||
@@ -24,6 +24,14 @@ test('dialer remembers explicit device choices and keeps modem help concise', ()
|
||||
assert.match(phoneView, /重新准备/)
|
||||
})
|
||||
|
||||
test('contact form uses themed component-library fields and selection controls', () => {
|
||||
assert.match(contactsDrawer, /<el-input ref="nameInput"/)
|
||||
assert.match(contactsDrawer, /<el-input[\s\S]*?v-model="draftNumber"/)
|
||||
assert.match(contactsDrawer, /<el-checkbox[\s\S]*?:model-value="groupSelected\(group\)"/)
|
||||
assert.match(contactsDrawer, /<el-checkbox[\s\S]*?:model-value="selected\.includes\(item\.number\)"/)
|
||||
assert.doesNotMatch(contactsDrawer, /<input[^>]+type="checkbox"/)
|
||||
})
|
||||
|
||||
test('RF mode changes confirm first and keep full preparation errors outside device labels', () => {
|
||||
assert.match(phoneView, /await confirmPhoneModeChange\(\{/)
|
||||
assert.match(phoneView, /enableVoWiFi\(target\.id/)
|
||||
|
||||
@@ -53,6 +53,8 @@ test('proxy mode change is transform-opacity only and reduced-motion safe', () =
|
||||
test('proxy controls retain real runtime facts and accessible actions', () => {
|
||||
assert.match(modeSwitch, /aria-current/)
|
||||
assert.match(modeSwitch, /min-height: 58px/)
|
||||
assert.match(upstreamInventory, /<el-checkbox v-model="autoProbe">/)
|
||||
assert.doesNotMatch(upstreamInventory, /<input[^>]+type="checkbox"/)
|
||||
assert.match(outboundInventory, /row\.lastError/)
|
||||
assert.match(outboundInventory, /:disabled="!row\.enabled"/)
|
||||
|
||||
|
||||
Reference in new issue
Block a user