交付 Windows 与 Web 端到端加密附件预览

This commit is contained in:
xhgit committed 2026-11-13 19:14:44 +08:00
1 parent d1efdedc57
commit c24960d22a
19 files changed
+421 -58

No files matched your search

+22 -1
View File
@@ -3,6 +3,8 @@ import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
import { useRoute } from 'vue-router'
import { useSession } from '../session'
import { enableChat, send, synchronize, trust } from '../chat/chat'
import { downloadAttachment } from '../chat/attachments'
import type { Attachment } from '../chat/attachments'
const session = useSession()
const route = useRoute()
@@ -69,6 +71,22 @@ function submit() {
})
}
function attach(event: Event) {
const input = event.target as HTMLInputElement
const file = input.files?.[0]
input.value = ''
if (!file) return
void execute(async () => {
if (!session.identity || !peer.value) return
await send(session.identity, target.value, peer.value, file, session.authorized)
await refresh()
})
}
function saveAttachment(attachment: Attachment) {
void execute(() => downloadAttachment(attachment, session.authorized))
}
function sync() {
if (ownCode.value) void execute(refresh)
}
@@ -119,10 +137,13 @@ onBeforeUnmount(() => clearInterval(timer))
<p v-if="view?.rejected" class="muted">已拒绝 {{ view.rejected }} 个无法验证的封包。</p>
<ol class="chat-lines" aria-label="消息记录" aria-live="polite">
<li v-for="line in lines" :key="line.id" :class="{ own: line.own }">
<span>{{ line.text }}</span><small v-if="view?.unsent.includes(line.id)">待发送</small>
<button v-if="line.attachment" type="button" class="plain" :disabled="busy"
@click="saveAttachment(line.attachment)">下载 {{ line.attachment.name }}</button>
<span v-else>{{ line.text }}</span><small v-if="view?.unsent.includes(line.id)">待发送</small>
</li>
</ol>
<form class="chat-compose" @submit.prevent="submit">
<label>发送附件<input type="file" :disabled="busy" @change="attach"></label>
<label>消息<textarea v-model="draft" required rows="3" maxlength="4000"></textarea></label>
<button class="primary" :disabled="busy || !draft.trim()">发送</button>
</form>