mirror of
https://github.com/yibaiba/hideck.git
synced 2026-12-06 00:01:20 +00:00
[sms-center-prototype-migration-SMS-03] implement Studio conversation workspace
This commit is contained in:
1 parent
aa52b8a9d9
commit
1561fa4e60
5 files changed
+437
-199
No files matched your search
@@ -0,0 +1,81 @@
|
||||
<script setup lang="ts">
|
||||
import { Send24Regular } from '@vicons/fluent'
|
||||
|
||||
defineProps<{
|
||||
modelValue: string
|
||||
encoding: string
|
||||
parts: number
|
||||
length: number
|
||||
sending: boolean
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:modelValue': [value: string]
|
||||
send: []
|
||||
}>()
|
||||
|
||||
function updateMessage(value: unknown) {
|
||||
emit('update:modelValue', String(value || ''))
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<footer class="sms-composer">
|
||||
<el-input
|
||||
:model-value="modelValue"
|
||||
type="textarea"
|
||||
:autosize="{ minRows: 1, maxRows: 6 }"
|
||||
resize="none"
|
||||
placeholder="输入回复"
|
||||
aria-label="短信回复内容"
|
||||
@update:model-value="updateMessage"
|
||||
@keydown.enter.exact.prevent="emit('send')"
|
||||
/>
|
||||
<button type="button" class="sms-send" :disabled="sending || !modelValue.trim()" @click="emit('send')">
|
||||
<el-icon><Send24Regular /></el-icon>
|
||||
<span>{{ sending ? '发送中' : '发送' }}</span>
|
||||
</button>
|
||||
<div class="sms-composer-meta">
|
||||
<span>{{ encoding }} · 预计 {{ parts }} 段 · {{ length }} 字</span>
|
||||
<span>Enter 发送 · Shift+Enter 换行</span>
|
||||
</div>
|
||||
</footer>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.sms-composer {
|
||||
padding: 12px 14px 10px;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
gap: 8px 10px;
|
||||
border-top: 1px solid var(--ui-border);
|
||||
background: var(--ui-surface);
|
||||
}
|
||||
|
||||
.sms-send {
|
||||
min-width: 82px;
|
||||
min-height: 40px;
|
||||
padding: 0 14px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 7px;
|
||||
align-self: end;
|
||||
border: 1px solid var(--ui-primary);
|
||||
border-radius: 7px;
|
||||
background: var(--ui-primary);
|
||||
color: var(--ui-surface-subtle);
|
||||
cursor: pointer;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.sms-send:disabled { cursor: not-allowed; opacity: .5; }
|
||||
.sms-composer-meta { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 12px; color: var(--ui-text-muted); font-size: 9px; }
|
||||
|
||||
@media (max-width: 520px) {
|
||||
.sms-composer { padding: 10px 9px; grid-template-columns: minmax(0, 1fr) 48px; }
|
||||
.sms-send { min-width: 48px; width: 48px; min-height: 44px; padding: 0; }
|
||||
.sms-send span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
|
||||
.sms-composer-meta span:last-child { display: none; }
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,129 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
ArrowDown24Regular,
|
||||
ArrowLeft24Regular,
|
||||
ArrowSync24Regular,
|
||||
Delete24Regular
|
||||
} from '@vicons/fluent'
|
||||
import type { SmsConversationContext } from '../../utils/smsPresentation'
|
||||
|
||||
defineProps<{
|
||||
peer: string
|
||||
context: SmsConversationContext
|
||||
loading: boolean
|
||||
showBack: boolean
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
back: []
|
||||
refresh: []
|
||||
latest: []
|
||||
delete: []
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<header class="sms-conversation-header">
|
||||
<div class="sms-conversation-identity">
|
||||
<button v-if="showBack" type="button" class="sms-header-icon sms-back" aria-label="返回会话列表" @click="emit('back')">
|
||||
<el-icon><ArrowLeft24Regular /></el-icon>
|
||||
</button>
|
||||
<div class="sms-conversation-copy">
|
||||
<strong>{{ peer || '请选择会话' }}</strong>
|
||||
<span>{{ context.deviceLabel }} · {{ context.operatorLabel }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="peer" class="sms-context-and-actions">
|
||||
<div class="sms-runtime-facts" aria-label="短信运行状态">
|
||||
<span :class="`is-${context.smsTone}`">{{ context.smsLabel }}</span>
|
||||
<span :class="`is-${context.imsTone}`">{{ context.imsLabel }}</span>
|
||||
</div>
|
||||
<nav aria-label="会话操作">
|
||||
<button type="button" class="sms-header-icon" :disabled="loading" aria-label="刷新会话" title="刷新" @click="emit('refresh')">
|
||||
<el-icon :class="{ 'is-loading': loading }"><ArrowSync24Regular /></el-icon>
|
||||
</button>
|
||||
<button type="button" class="sms-header-icon" aria-label="跳到最新短信" title="最新" @click="emit('latest')">
|
||||
<el-icon><ArrowDown24Regular /></el-icon>
|
||||
</button>
|
||||
<button type="button" class="sms-header-icon is-danger" aria-label="删除当前对话" title="删除对话" @click="emit('delete')">
|
||||
<el-icon><Delete24Regular /></el-icon>
|
||||
</button>
|
||||
</nav>
|
||||
</div>
|
||||
</header>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.sms-conversation-header {
|
||||
min-width: 0;
|
||||
min-height: 64px;
|
||||
padding: 9px 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 14px;
|
||||
border-bottom: 1px solid var(--ui-border);
|
||||
background: var(--ui-surface);
|
||||
}
|
||||
|
||||
.sms-conversation-identity,
|
||||
.sms-context-and-actions,
|
||||
.sms-runtime-facts,
|
||||
.sms-context-and-actions nav { display: flex; align-items: center; }
|
||||
|
||||
.sms-conversation-identity { min-width: 0; gap: 8px; }
|
||||
.sms-context-and-actions { min-width: 0; gap: 14px; }
|
||||
.sms-runtime-facts { gap: 6px; }
|
||||
.sms-context-and-actions nav { flex: none; gap: 4px; }
|
||||
.sms-conversation-copy { min-width: 0; }
|
||||
|
||||
.sms-conversation-copy strong,
|
||||
.sms-conversation-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.sms-conversation-copy strong { color: var(--ui-text); font-size: 14px; }
|
||||
.sms-conversation-copy span { margin-top: 3px; color: var(--ui-text-muted); font-size: 10px; }
|
||||
|
||||
.sms-runtime-facts span {
|
||||
padding: 4px 7px;
|
||||
border: 1px solid var(--ui-border);
|
||||
border-radius: 999px;
|
||||
color: var(--ui-text-muted);
|
||||
font-size: 9px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.sms-runtime-facts .is-success { border-color: color-mix(in srgb, var(--ui-success) 35%, var(--ui-border)); color: var(--ui-success); }
|
||||
.sms-runtime-facts .is-danger { border-color: color-mix(in srgb, var(--ui-danger) 35%, var(--ui-border)); color: var(--ui-danger); }
|
||||
|
||||
.sms-header-icon {
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 7px;
|
||||
background: transparent;
|
||||
color: var(--ui-text-muted);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.sms-header-icon:hover { border-color: var(--ui-border); background: var(--ui-surface-muted); color: var(--ui-text); }
|
||||
.sms-header-icon:disabled { cursor: wait; opacity: .55; }
|
||||
.sms-header-icon.is-danger:hover { color: var(--ui-danger); }
|
||||
.sms-back { display: none; }
|
||||
|
||||
@media (max-width: 1120px) {
|
||||
.sms-runtime-facts { display: none; }
|
||||
}
|
||||
|
||||
@media (max-width: 979px) {
|
||||
.sms-back { display: grid; }
|
||||
}
|
||||
|
||||
@media (max-width: 520px) {
|
||||
.sms-conversation-header { padding-inline: 8px; }
|
||||
.sms-header-icon { width: 44px; height: 44px; }
|
||||
.sms-context-and-actions nav { gap: 0; }
|
||||
.sms-conversation-copy span { max-width: 130px; }
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,164 @@
|
||||
<script setup lang="ts">
|
||||
import { onUnmounted } from 'vue'
|
||||
import { Delete24Regular } from '@vicons/fluent'
|
||||
import type { SMSMessage } from '../../types/api'
|
||||
import { formatDeviceDateTime } from '../../utils/deviceTime'
|
||||
|
||||
defineProps<{
|
||||
groups: readonly Readonly<{ date: string; items: SMSMessage[] }>[]
|
||||
canLoadMore: boolean
|
||||
loadingMore: boolean
|
||||
deletingId: number | null
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
loadMore: []
|
||||
delete: [message: SMSMessage]
|
||||
openActions: [message: SMSMessage]
|
||||
}>()
|
||||
|
||||
const LONG_PRESS_MS = 450
|
||||
const LONG_PRESS_MOVE_PX = 10
|
||||
let longPressTimer: ReturnType<typeof setTimeout> | null = null
|
||||
let startX = 0
|
||||
let startY = 0
|
||||
|
||||
function clearLongPress() {
|
||||
if (longPressTimer == null) return
|
||||
clearTimeout(longPressTimer)
|
||||
longPressTimer = null
|
||||
}
|
||||
|
||||
function beginLongPress(message: SMSMessage, event: PointerEvent) {
|
||||
if (event.pointerType === 'mouse') return
|
||||
clearLongPress()
|
||||
startX = event.clientX
|
||||
startY = event.clientY
|
||||
longPressTimer = setTimeout(() => {
|
||||
longPressTimer = null
|
||||
emit('openActions', message)
|
||||
navigator.vibrate?.(20)
|
||||
}, LONG_PRESS_MS)
|
||||
}
|
||||
|
||||
function moveLongPress(event: PointerEvent) {
|
||||
if (longPressTimer == null) return
|
||||
if (Math.abs(event.clientX - startX) > LONG_PRESS_MOVE_PX || Math.abs(event.clientY - startY) > LONG_PRESS_MOVE_PX) {
|
||||
clearLongPress()
|
||||
}
|
||||
}
|
||||
|
||||
function deliveryLabel(message: SMSMessage): string {
|
||||
if (message.type !== 2) return '已接收'
|
||||
if (message.status === 2) return '已发送'
|
||||
if (message.status === 3) return '发送失败'
|
||||
return '发送状态未确认'
|
||||
}
|
||||
|
||||
function deliveryTone(message: SMSMessage): string {
|
||||
if (message.type !== 2) return 'is-received'
|
||||
if (message.status === 2) return 'is-success'
|
||||
if (message.status === 3) return 'is-danger'
|
||||
return 'is-muted'
|
||||
}
|
||||
|
||||
onUnmounted(clearLongPress)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="sms-timeline">
|
||||
<div v-if="canLoadMore" class="sms-load-more">
|
||||
<el-button text type="primary" :loading="loadingMore" @click="emit('loadMore')">加载更多</el-button>
|
||||
</div>
|
||||
|
||||
<section v-for="group in groups" :key="group.date" class="sms-day-group">
|
||||
<time class="sms-day-label">{{ group.date }}</time>
|
||||
<article
|
||||
v-for="message in group.items"
|
||||
:key="message.id"
|
||||
class="sms-message"
|
||||
:class="message.type === 1 ? 'is-incoming' : 'is-outgoing'"
|
||||
@pointerdown="(event) => beginLongPress(message, event)"
|
||||
@pointermove="moveLongPress"
|
||||
@pointerup="clearLongPress"
|
||||
@pointercancel="clearLongPress"
|
||||
>
|
||||
<div class="sms-message-meta">
|
||||
<strong>{{ message.type === 1 ? (message.sender || '接收') : (message.device_name || '发送') }}</strong>
|
||||
<time>{{ formatDeviceDateTime(message.timestamp) }}</time>
|
||||
<span :class="deliveryTone(message)">{{ deliveryLabel(message) }}</span>
|
||||
<button
|
||||
type="button"
|
||||
class="sms-message-delete"
|
||||
:disabled="deletingId === message.id"
|
||||
:aria-label="`删除短信 ${message.id}`"
|
||||
title="删除短信"
|
||||
@click="emit('delete', message)"
|
||||
>
|
||||
<el-icon><Delete24Regular /></el-icon>
|
||||
</button>
|
||||
</div>
|
||||
<p>{{ message.content }}</p>
|
||||
</article>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.sms-timeline { padding: 18px 22px 28px; }
|
||||
.sms-load-more { display: flex; justify-content: center; margin-bottom: 12px; }
|
||||
.sms-day-group + .sms-day-group { margin-top: 22px; }
|
||||
.sms-day-label { width: max-content; margin: 0 auto 18px; padding: 4px 10px; display: block; border: 1px solid var(--ui-border); border-radius: 999px; color: var(--ui-text-muted); font: 10px "v-mono", monospace; }
|
||||
|
||||
.sms-message { width: fit-content; max-width: 64%; margin-top: 16px; }
|
||||
.sms-message.is-outgoing { margin-left: auto; }
|
||||
.sms-message-meta { min-height: 22px; margin-bottom: 5px; display: flex; align-items: center; gap: 7px; color: var(--ui-text-muted); }
|
||||
.sms-message.is-outgoing .sms-message-meta { justify-content: flex-end; }
|
||||
.sms-message-meta strong { max-width: 150px; overflow: hidden; color: var(--ui-text); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.sms-message-meta time { font: 9px "v-mono", monospace; white-space: nowrap; }
|
||||
.sms-message-meta span { font-size: 9px; white-space: nowrap; }
|
||||
.sms-message-meta .is-success { color: var(--ui-success); }
|
||||
.sms-message-meta .is-danger { color: var(--ui-danger); }
|
||||
|
||||
.sms-message p {
|
||||
min-width: 82px;
|
||||
margin: 0;
|
||||
padding: 10px 13px;
|
||||
border: 1px solid var(--ui-border);
|
||||
border-radius: 4px 12px 12px;
|
||||
background: var(--ui-surface-strong);
|
||||
color: var(--ui-text);
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
overflow-wrap: anywhere;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.sms-message.is-outgoing p {
|
||||
border-color: color-mix(in srgb, var(--ui-primary) 38%, var(--ui-border));
|
||||
border-radius: 12px 4px 12px 12px;
|
||||
background: color-mix(in srgb, var(--ui-primary) 12%, var(--ui-surface));
|
||||
}
|
||||
|
||||
.sms-message-delete { width: 26px; height: 26px; display: grid; place-items: center; border: 0; border-radius: 6px; background: transparent; color: var(--ui-danger); cursor: pointer; opacity: 0; pointer-events: none; transition: opacity 140ms var(--ui-ease-out); }
|
||||
.sms-message:hover .sms-message-delete,
|
||||
.sms-message:focus-within .sms-message-delete { opacity: 1; pointer-events: auto; }
|
||||
|
||||
@media (hover: none), (pointer: coarse) {
|
||||
.sms-message-delete { display: none; }
|
||||
}
|
||||
|
||||
@media (max-width: 820px) {
|
||||
.sms-timeline { padding: 14px 12px 22px; }
|
||||
.sms-message { max-width: 82%; }
|
||||
}
|
||||
|
||||
@media (max-width: 520px) {
|
||||
.sms-message { max-width: 94%; }
|
||||
.sms-message-meta { flex-wrap: wrap; gap: 5px; }
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.sms-message-delete { transition: none; }
|
||||
}
|
||||
</style>
|
||||
+41
-199
@@ -11,11 +11,14 @@ import EmptyState from '../components/EmptyState.vue'
|
||||
import ErrorState from '../components/ErrorState.vue'
|
||||
import SmsDeviceRail from '../components/sms/SmsDeviceRail.vue'
|
||||
import SmsThreadListPane from '../components/sms/SmsThreadListPane.vue'
|
||||
import SmsConversationHeader from '../components/sms/SmsConversationHeader.vue'
|
||||
import SmsMessageTimeline from '../components/sms/SmsMessageTimeline.vue'
|
||||
import SmsComposer from '../components/sms/SmsComposer.vue'
|
||||
import type { DeviceMgmtListItem, SMSMessage } from '../types/api'
|
||||
import { Delete24Regular, Send24Regular } from '@vicons/fluent'
|
||||
import 'vue-virtual-scroller/dist/vue-virtual-scroller.css'
|
||||
import { formatDeviceDate, formatDeviceDateTime } from '../utils/deviceTime'
|
||||
import { createSmsDeviceChannels } from '../utils/smsPresentation'
|
||||
import { formatDeviceDate } from '../utils/deviceTime'
|
||||
import { createSmsConversationContext, createSmsDeviceChannels } from '../utils/smsPresentation'
|
||||
|
||||
type SmsThread = {
|
||||
key: string
|
||||
@@ -134,7 +137,6 @@ const showSendModal = ref(false)
|
||||
const sending = ref(false)
|
||||
const deletingMessageId = ref<number | null>(null)
|
||||
const deletingThreadKey = ref<string | null>(null)
|
||||
const supportsHover = ref(false)
|
||||
const showActionSheet = ref(false)
|
||||
const actionSheetTarget = ref<{ type: 'thread'; thread: SmsThread } | { type: 'message'; message: SMSMessage } | null>(null)
|
||||
const composer = ref('')
|
||||
@@ -173,7 +175,6 @@ function estimateSegments(text: string) {
|
||||
const composerLen = computed(() => Array.from(String(composer.value || '')).length)
|
||||
const composerEstimate = computed(() => estimateSegments(String(composer.value || '')))
|
||||
const detailScrollbar = ref<HTMLElement | null>(null)
|
||||
const composerInput = ref<unknown>(null)
|
||||
|
||||
const sendForm = ref({
|
||||
device_id: '',
|
||||
@@ -186,6 +187,11 @@ const selectedSendDeviceId = ref('')
|
||||
const sendDeviceOptions = computed(() => devices.value.map(d => ({ label: `${d.name || d.id}`, value: d.id })))
|
||||
|
||||
const deviceSidebarItems = computed(() => createSmsDeviceChannels(devices.value))
|
||||
const conversationContext = computed(() => createSmsConversationContext({
|
||||
selectedDeviceId: selectedDevice.value,
|
||||
thread: selectedThread.value,
|
||||
devices: devices.value
|
||||
}))
|
||||
|
||||
function normalizeQueryDevice(device: string) {
|
||||
const v = String(device || '').trim()
|
||||
@@ -286,7 +292,6 @@ async function loadMoreHistory() {
|
||||
}
|
||||
|
||||
function onDetailScroll(e: Event) {
|
||||
clearLongPress()
|
||||
const target = e.target as HTMLElement
|
||||
if (target && target.scrollTop <= 80) {
|
||||
loadMoreHistory()
|
||||
@@ -296,47 +301,14 @@ function onDetailScroll(e: Event) {
|
||||
let devicesFetchSeq = 0
|
||||
let messagesFetchSeq = 0
|
||||
let threadFetchSeq = 0
|
||||
let longPressTimer: ReturnType<typeof setTimeout> | null = null
|
||||
let longPressStartX = 0
|
||||
let longPressStartY = 0
|
||||
|
||||
function clearLongPress() {
|
||||
if (longPressTimer != null) {
|
||||
clearTimeout(longPressTimer)
|
||||
longPressTimer = null
|
||||
}
|
||||
}
|
||||
|
||||
function startLongPress(target: { type: 'thread'; thread: SmsThread } | { type: 'message'; message: SMSMessage }, e: PointerEvent) {
|
||||
if (!isNarrowLayout.value) return
|
||||
if (e.pointerType === 'mouse') return
|
||||
clearLongPress()
|
||||
longPressStartX = e.clientX
|
||||
longPressStartY = e.clientY
|
||||
longPressTimer = setTimeout(() => {
|
||||
longPressTimer = null
|
||||
actionSheetTarget.value = target
|
||||
showActionSheet.value = true
|
||||
if (typeof navigator !== 'undefined' && typeof navigator.vibrate === 'function') {
|
||||
navigator.vibrate(20)
|
||||
}
|
||||
}, 450)
|
||||
}
|
||||
|
||||
function moveLongPress(e: PointerEvent) {
|
||||
if (longPressTimer == null) return
|
||||
if (Math.abs(e.clientX - longPressStartX) > 10 || Math.abs(e.clientY - longPressStartY) > 10) {
|
||||
clearLongPress()
|
||||
}
|
||||
}
|
||||
|
||||
function showThreadActionSheet(thread: SmsThread) {
|
||||
actionSheetTarget.value = { type: 'thread', thread }
|
||||
showActionSheet.value = true
|
||||
}
|
||||
|
||||
function openMessageActionSheet(message: SMSMessage, e: PointerEvent) {
|
||||
startLongPress({ type: 'message', message }, e)
|
||||
function showMessageActionSheet(message: SMSMessage) {
|
||||
actionSheetTarget.value = { type: 'message', message }
|
||||
showActionSheet.value = true
|
||||
}
|
||||
|
||||
function closeActionSheet() {
|
||||
@@ -538,9 +510,6 @@ watch(
|
||||
)
|
||||
|
||||
onMounted(async () => {
|
||||
if (typeof window !== 'undefined' && typeof window.matchMedia === 'function') {
|
||||
supportsHover.value = window.matchMedia('(hover: hover) and (pointer: fine)').matches
|
||||
}
|
||||
syncSmsPageWidth()
|
||||
if (typeof ResizeObserver !== 'undefined') {
|
||||
smsPageResizeObserver = new ResizeObserver(() => {
|
||||
@@ -561,7 +530,6 @@ onMounted(async () => {
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
clearLongPress()
|
||||
smsPageResizeObserver?.disconnect()
|
||||
smsPageResizeObserver = null
|
||||
window.removeEventListener('resize', syncSmsPageWidth)
|
||||
@@ -758,123 +726,42 @@ async function confirmDeleteThread(thread: SmsThread) {
|
||||
/>
|
||||
|
||||
<section v-if="showDetailPane" class="sms-conversation-pane flex flex-col min-w-0 min-h-0">
|
||||
<div class="sms-conversation-header flex items-center justify-between gap-3">
|
||||
<div class="min-w-0">
|
||||
<div class="flex items-center gap-2">
|
||||
<el-button v-if="isNarrowLayout && selectedThreadKey" text @click="backToList">返回</el-button>
|
||||
<div class="text-sm font-extrabold text-gray-900 dark:text-white truncate">
|
||||
{{ selectedThread?.peer || '请选择会话' }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-xs text-gray-400 mt-1">
|
||||
{{
|
||||
selectedDevice === 'all'
|
||||
? (selectedThread?.localPhone || selectedThread?.lastDeviceName
|
||||
? `本机:${selectedThread?.localPhone || selectedThread?.lastDeviceName}`
|
||||
: '全部设备')
|
||||
: `设备:${selectedDevice}`
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="selectedThread" class="flex items-center gap-2">
|
||||
|
||||
<el-button text @click="scrollThreadToBottom">最新</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<SmsConversationHeader
|
||||
:peer="selectedThread?.peer || ''"
|
||||
:context="conversationContext"
|
||||
:loading="threadLoading"
|
||||
:show-back="isNarrowLayout && !!selectedThreadKey"
|
||||
@back="backToList"
|
||||
@refresh="() => void fetchThreadLatest(false)"
|
||||
@latest="scrollThreadToBottom"
|
||||
@delete="selectedThread && void confirmDeleteThread(selectedThread)"
|
||||
/>
|
||||
|
||||
<div v-if="!selectedThread" class="flex-1 flex items-center justify-center p-6">
|
||||
<EmptyState title="请选择一个会话" subtitle="从左侧联系人列表进入短信明细" />
|
||||
</div>
|
||||
|
||||
<div v-else ref="detailScrollbar" class="flex-1 min-h-0 overflow-y-auto sms-detail-scroll" @scroll="onDetailScroll">
|
||||
<div class="p-5 space-y-5">
|
||||
<div v-if="canLoadMoreHistory" class="flex justify-center">
|
||||
<el-button text type="primary" :loading="loadingHistoryMore" @click="loadMoreHistory">加载更多</el-button>
|
||||
</div>
|
||||
<div v-for="g in selectedThreadGroups" :key="g.date" class="space-y-4">
|
||||
<div class="flex justify-center">
|
||||
<div class="text-[11px] font-bold text-gray-500 dark:text-gray-300 bg-gray-100/80 dark:bg-white/5 border border-gray-200/60 dark:border-white/10 px-3 py-1 rounded-full">
|
||||
{{ g.date }}
|
||||
</div>
|
||||
</div>
|
||||
<div v-for="m in g.items" :key="m.id" class="flex" :class="m.type === 1 ? 'justify-start' : 'justify-end'">
|
||||
<div
|
||||
class="sms-msg-wrapper group"
|
||||
@pointerdown="(e) => openMessageActionSheet(m, e)"
|
||||
@pointermove="moveLongPress"
|
||||
@pointerup="clearLongPress"
|
||||
@pointercancel="clearLongPress"
|
||||
>
|
||||
<div class="flex items-center gap-2 mb-1" :class="m.type === 1 ? '' : 'justify-end'">
|
||||
<span v-if="m.type === 1" class="text-xs font-bold text-gray-700 dark:text-gray-200">{{ m.sender }}</span>
|
||||
<el-button
|
||||
v-if="!isNarrowLayout && m.type === 2 && m.device_name"
|
||||
text
|
||||
class="sms-danger-ghost-btn sms-delete-trigger sms-message-delete-btn"
|
||||
size="small"
|
||||
:class="{ 'sms-delete-visible': !supportsHover }"
|
||||
:loading="deletingMessageId === m.id"
|
||||
:aria-label="`删除短信 ${m.id}`"
|
||||
title="删除短信"
|
||||
@click="void confirmDeleteMessage(m)"
|
||||
>
|
||||
<el-icon><Delete24Regular /></el-icon>
|
||||
</el-button>
|
||||
<span v-if="m.device_name" class="text-[10px] font-bold text-gray-400 bg-gray-100 dark:bg-white/5 px-1.5 py-0.5 rounded">
|
||||
{{ m.device_name }}
|
||||
</span>
|
||||
<span class="text-[11px] text-gray-400 font-mono">{{ formatDeviceDateTime(m.timestamp) }}</span>
|
||||
<span v-if="m.type === 2 && m.status === 2" class="text-green-500 text-xs" title="发送成功">✓</span>
|
||||
<span v-else-if="m.type === 2 && m.status === 3" class="text-red-500 text-xs" title="发送失败">✗</span>
|
||||
<el-button
|
||||
v-if="!isNarrowLayout && (m.type !== 2 || !m.device_name)"
|
||||
text
|
||||
class="sms-danger-ghost-btn sms-delete-trigger sms-message-delete-btn"
|
||||
size="small"
|
||||
:class="{ 'sms-delete-visible': !supportsHover }"
|
||||
:loading="deletingMessageId === m.id"
|
||||
:aria-label="`删除短信 ${m.id}`"
|
||||
title="删除短信"
|
||||
@click="void confirmDeleteMessage(m)"
|
||||
>
|
||||
<el-icon><Delete24Regular /></el-icon>
|
||||
</el-button>
|
||||
</div>
|
||||
<div
|
||||
class="px-5 py-4 rounded-lg text-sm leading-[1.75] shadow-sm border"
|
||||
:class="m.type === 1
|
||||
? 'bg-white/90 dark:bg-white/5 text-gray-700 dark:text-gray-200 border-gray-100 dark:border-white/10'
|
||||
: 'bg-blue-50 dark:bg-blue-500/10 text-gray-800 dark:text-gray-100 border-blue-100 dark:border-blue-500/20'"
|
||||
>
|
||||
{{ m.content }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="h-2" />
|
||||
</div>
|
||||
<SmsMessageTimeline
|
||||
:groups="selectedThreadGroups"
|
||||
:can-load-more="canLoadMoreHistory"
|
||||
:loading-more="loadingHistoryMore"
|
||||
:deleting-id="deletingMessageId"
|
||||
@load-more="loadMoreHistory"
|
||||
@delete="(message) => void confirmDeleteMessage(message)"
|
||||
@open-actions="showMessageActionSheet"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div v-if="selectedThread" class="p-4 border-t border-gray-100 dark:border-white/10">
|
||||
<div class="text-[11px] text-gray-400 text-left mb-2">
|
||||
{{ composerEstimate.encoding }} · 预计 {{ composerEstimate.parts }} 段 · {{ composerLen }} 字
|
||||
</div>
|
||||
<div class="flex items-end gap-3">
|
||||
<el-input
|
||||
ref="composerInput"
|
||||
v-model="composer"
|
||||
type="textarea"
|
||||
:autosize="{ minRows: 1, maxRows: 6 }"
|
||||
resize="none"
|
||||
placeholder="回复(Enter 发送)"
|
||||
@keydown.enter.exact.prevent="sendToCurrentThread"
|
||||
/>
|
||||
<el-button type="primary" :loading="sending" @click="sendToCurrentThread" class="!border-0 self-end">
|
||||
<el-icon><Send24Regular /></el-icon>
|
||||
发送
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<SmsComposer
|
||||
v-if="selectedThread"
|
||||
v-model="composer"
|
||||
:encoding="composerEstimate.encoding"
|
||||
:parts="composerEstimate.parts"
|
||||
:length="composerLen"
|
||||
:sending="sending"
|
||||
@send="sendToCurrentThread"
|
||||
/>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
@@ -956,12 +843,6 @@ async function confirmDeleteThread(thread: SmsThread) {
|
||||
background: var(--ui-surface);
|
||||
}
|
||||
|
||||
.sms-conversation-header {
|
||||
min-height: 64px;
|
||||
padding: 13px 15px;
|
||||
border-bottom: 1px solid var(--ui-border);
|
||||
}
|
||||
|
||||
@keyframes sms-workspace-enter {
|
||||
from { opacity: 0; transform: translateY(6px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
@@ -972,26 +853,6 @@ async function confirmDeleteThread(thread: SmsThread) {
|
||||
@keyframes sms-workspace-fade { from { opacity: 0; } to { opacity: 1; } }
|
||||
}
|
||||
|
||||
.sms-msg-wrapper {
|
||||
width: 100%;
|
||||
max-width: min(620px, 88%);
|
||||
}
|
||||
|
||||
.sms-delete-trigger {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.sms-message-delete-btn {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.sms-delete-visible {
|
||||
opacity: 1 !important;
|
||||
pointer-events: auto !important;
|
||||
}
|
||||
|
||||
.sms-action-sheet-mask {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
@@ -1055,25 +916,6 @@ async function confirmDeleteThread(thread: SmsThread) {
|
||||
.sms-main-layout {
|
||||
grid-template-columns: 218px 310px minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.sms-delete-trigger {
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transition: opacity 0.18s ease, transform 0.2s ease;
|
||||
}
|
||||
|
||||
.group:hover .sms-delete-trigger,
|
||||
.group:focus-within .sms-delete-trigger {
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@container (max-width: 979px) {
|
||||
.sms-msg-wrapper {
|
||||
max-width: 96%;
|
||||
}
|
||||
}
|
||||
|
||||
/* 消息详情区域原生滚动条样式 */
|
||||
|
||||
@@ -5,6 +5,9 @@ import test from 'node:test'
|
||||
const smsView = readFileSync(new URL('../src/views/Sms.vue', import.meta.url), 'utf8')
|
||||
const deviceRail = readFileSync(new URL('../src/components/sms/SmsDeviceRail.vue', import.meta.url), 'utf8')
|
||||
const threadList = readFileSync(new URL('../src/components/sms/SmsThreadListPane.vue', import.meta.url), 'utf8')
|
||||
const conversationHeader = readFileSync(new URL('../src/components/sms/SmsConversationHeader.vue', import.meta.url), 'utf8')
|
||||
const messageTimeline = readFileSync(new URL('../src/components/sms/SmsMessageTimeline.vue', import.meta.url), 'utf8')
|
||||
const composer = readFileSync(new URL('../src/components/sms/SmsComposer.vue', import.meta.url), 'utf8')
|
||||
|
||||
test('SMS workspace uses one continuous shell with dedicated navigation panes', () => {
|
||||
assert.match(smsView, /<SmsDeviceRail/)
|
||||
@@ -27,3 +30,22 @@ test('thread pane preserves virtual scrolling and all production entries', () =>
|
||||
assert.match(threadList, /emit\('delete', thread\)/)
|
||||
assert.match(threadList, /LONG_PRESS_MS = 450/)
|
||||
})
|
||||
|
||||
test('conversation pane exposes real runtime context and explicit message status', () => {
|
||||
assert.match(smsView, /createSmsConversationContext/)
|
||||
assert.match(conversationHeader, /context\.operatorLabel/)
|
||||
assert.match(conversationHeader, /context\.smsLabel/)
|
||||
assert.match(conversationHeader, /context\.imsLabel/)
|
||||
assert.match(messageTimeline, /if \(message\.status === 2\) return '已发送'/)
|
||||
assert.match(messageTimeline, /if \(message\.status === 3\) return '发送失败'/)
|
||||
assert.match(messageTimeline, /max-width: 64%/)
|
||||
})
|
||||
|
||||
test('conversation actions remain wired to production handlers', () => {
|
||||
assert.match(smsView, /@refresh="\(\) => void fetchThreadLatest\(false\)"/)
|
||||
assert.match(smsView, /@delete="selectedThread && void confirmDeleteThread\(selectedThread\)"/)
|
||||
assert.match(smsView, /@load-more="loadMoreHistory"/)
|
||||
assert.match(smsView, /@delete="\(message\) => void confirmDeleteMessage\(message\)"/)
|
||||
assert.match(smsView, /@send="sendToCurrentThread"/)
|
||||
assert.match(composer, /Shift\+Enter 换行/)
|
||||
})
|
||||
Reference in new issue
Block a user