diff --git a/web/src/components/sms/SmsComposer.vue b/web/src/components/sms/SmsComposer.vue new file mode 100644 index 00000000..c8b89606 --- /dev/null +++ b/web/src/components/sms/SmsComposer.vue @@ -0,0 +1,81 @@ + + + + + diff --git a/web/src/components/sms/SmsConversationHeader.vue b/web/src/components/sms/SmsConversationHeader.vue new file mode 100644 index 00000000..0bb4cb2b --- /dev/null +++ b/web/src/components/sms/SmsConversationHeader.vue @@ -0,0 +1,129 @@ + + + + + diff --git a/web/src/components/sms/SmsMessageTimeline.vue b/web/src/components/sms/SmsMessageTimeline.vue new file mode 100644 index 00000000..6f803110 --- /dev/null +++ b/web/src/components/sms/SmsMessageTimeline.vue @@ -0,0 +1,164 @@ + + + + + diff --git a/web/src/views/Sms.vue b/web/src/views/Sms.vue index d0db9caa..8bbdf7cd 100644 --- a/web/src/views/Sms.vue +++ b/web/src/views/Sms.vue @@ -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(null) const deletingThreadKey = ref(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(null) -const composerInput = ref(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 | 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) { />
-
-
-
- 返回 -
- {{ selectedThread?.peer || '请选择会话' }} -
-
-
- {{ - selectedDevice === 'all' - ? (selectedThread?.localPhone || selectedThread?.lastDeviceName - ? `本机:${selectedThread?.localPhone || selectedThread?.lastDeviceName}` - : '全部设备') - : `设备:${selectedDevice}` - }} -
-
-
- - 最新 -
-
+
-
-
- 加载更多 -
-
-
-
- {{ g.date }} -
-
-
-
-
- {{ m.sender }} - - - - - {{ m.device_name }} - - {{ formatDeviceDateTime(m.timestamp) }} - ✓ - ✗ - - - -
-
- {{ m.content }} -
-
-
-
-
-
+
-
-
- {{ composerEstimate.encoding }} · 预计 {{ composerEstimate.parts }} 段 · {{ composerLen }} 字 -
-
- - - - 发送 - -
-
+
@@ -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%; - } } /* 消息详情区域原生滚动条样式 */ diff --git a/web/tests/smsWorkspaceSource.test.ts b/web/tests/smsWorkspaceSource.test.ts index 91df285b..62c0b296 100644 --- a/web/tests/smsWorkspaceSource.test.ts +++ b/web/tests/smsWorkspaceSource.test.ts @@ -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, / 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 换行/) +})