diff --git a/README.md b/README.md index ce0c5da..e903e7e 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ | 加密附件 | 两端可在私聊和群聊多选或拖入文件,每批最多 8 个,每个最大 8 MiB。图片、视频在本机预览,群聊支持按附件类型查看。 | | 加密语音 | 两端可在私聊和群聊录制、取消或发送最长 60 秒的语音消息,接收方在本机解密播放。 | | 消息管理 | 私聊和群聊支持引用回复、编辑文字、撤回、本机搜索、收藏和本机删除。可打开消息里的网页链接,并将消息转发到加密群或已核验的联系人设备。私聊支持可选加密已读回执。 | +| 本机收藏 | 在同一个入口查看私聊与群聊收藏,按来源和内容类型筛选。支持本机搜索、预览媒体、播放语音、下载加密附件和取消收藏。 | | Chromium 浏览器 | Windows 端支持独立窗口、多标签、导航、搜索、书签、历史、下载和隐私窗口,网页运行在独立会话中。 | 当前为开发预览。大文件分片、音视频和多设备历史同步仍在开发,Windows 安装包尚未发布。 [开发进度与验收记录](docs/progress.md) diff --git a/docs/progress.md b/docs/progress.md index 0027d01..c7035f8 100644 --- a/docs/progress.md +++ b/docs/progress.md @@ -222,3 +222,7 @@ Windows Electron 与 Edge 实测通知 API 调用、提醒跳转及免打扰后 Windows 和 Web 可以多选或拖入待发送附件,移除单项或清空列表。每批最多 8 个,单个文件最大 8 MiB。客户端逐个加密、上传并提交。上传中断时,未进入加密发件箱的文件保留在当前待发列表,由用户继续发送。已进入发件箱的封包沿用原消息 ID 进行投递重试。待发列表在切换联系人或对方设备时重置。 Windows 与 Edge 验证多选、拖拽、移除、清空和数量上限。第二个上传请求中断后仅重试剩余文件,接收端只收到一份先前已送达的文件。 + +## 本机收藏中心 + +Windows 和 Web 可从工作区进入收藏,查看当前设备本机密文库中的私聊和群聊收藏,按消息时间倒序分页。可按来源和文字、网页、图片、视频、语音、文件筛选。本机搜索匹配消息文字、引用、文件名及会话名称。复用聊天内的安全链接处理、媒体解密预览、语音播放和附件下载,附件仍受服务端访问权限和保留期限约束。取消收藏保留原消息,收藏状态按本机设备隔离。 diff --git a/tests/encrypted-chat.test.mjs b/tests/encrypted-chat.test.mjs index d2ab35d..8b06233 100644 --- a/tests/encrypted-chat.test.mjs +++ b/tests/encrypted-chat.test.mjs @@ -388,6 +388,48 @@ test('Web 与 Windows 安全码校验、加密互发、离线接收和状态恢 const address = toolbar.getByRole('textbox', { name: '网址或搜索关键词' }) await toolbar.waitForFunction((expected) => document.querySelector('#address')?.value === expected, link) assert.equal(await address.inputValue(), link) + await toolbar.close() + + async function addFavorite(page, locator) { + const line = page.getByRole('list', { name: '消息记录' }).getByRole('listitem').filter({ has: locator }) + await line.getByRole('button', { name: '收藏', exact: true }).click() + await line.getByRole('button', { name: '取消收藏', exact: true }).waitFor() + } + await addFavorite(web, webLink) + await addFavorite(web, web.getByRole('button', { name: '下载 ' + remainingFile, exact: true })) + await addFavorite(windows, windows.getByRole('button', { name: '预览 加密预览.png', exact: true })) + await addFavorite(windows, windows.getByRole('button', { name: '播放语音', exact: true })) + await Promise.all([web, windows].map((page) => work(page).getByRole('link', { name: '收藏', exact: true }).click())) + const webFavorites = web.getByRole('list', { name: '本机收藏' }) + const windowsFavorites = windows.getByRole('list', { name: '本机收藏' }) + await webFavorites.getByRole('link', { name: link, exact: true }).waitFor() + assert.equal(await webFavorites.getByRole('listitem').count(), 2) + const tracked = [] + const trackFavorites = (request) => tracked.push([request.url(), request.method(), request.postData()]) + web.on('request', trackFavorites) + await web.getByLabel('内容类型').selectOption('link') + assert.equal(await webFavorites.getByRole('listitem').count(), 1) + const search = web.getByRole('searchbox', { name: '搜索本机收藏' }) + const marker = '本机收藏验收 ' + randomBytes(8).toString('hex') + await search.fill(marker) + await web.getByText('没有匹配的收藏。', { exact: true }).waitFor() + await search.clear() + await web.getByLabel('内容类型').selectOption('file') + const favoriteDownload = web.waitForEvent('download') + await webFavorites.getByRole('button', { name: '下载 ' + remainingFile, exact: true }).click() + assert.deepEqual(await readFile(await (await favoriteDownload).path()), Buffer.from(remainingFile)) + await webFavorites.getByRole('button', { name: '取消收藏', exact: true }).click() + await web.getByText('没有匹配的收藏。', { exact: true }).waitFor() + web.off('request', trackFavorites) + assert.ok(tracked.every(([url, method, body]) => method === 'GET' && !body && !url.includes(encodeURIComponent(marker)))) + + await windows.getByLabel('内容类型').selectOption('image') + await windowsFavorites.getByRole('button', { name: '预览 加密预览.png', exact: true }).click() + await windowsFavorites.getByRole('img', { name: '加密预览.png' }).waitFor() + await windows.getByLabel('内容类型').selectOption('voice') + await windowsFavorites.getByRole('button', { name: '播放语音', exact: true }).click() + await windows.waitForFunction(() => document.querySelector('.favorite-card audio')?.currentTime > 0) + assert.equal(await windowsFavorites.getByRole('link', { name: link, exact: true }).count(), 0) } finally { await desktop?.close() await browser.close() diff --git a/tests/group-chat.test.mjs b/tests/group-chat.test.mjs index cd9ecc0..24aab22 100644 --- a/tests/group-chat.test.mjs +++ b/tests/group-chat.test.mjs @@ -638,6 +638,9 @@ test('Windows 与 Web 加密群聊支持消息操作、附件、语音和成员 assert.ok(originalBytes && originalBytes.length === contents.length + 16) await windows.getByRole('listitem').filter({ hasText: privateFile }).getByRole('button', { name: '转发', exact: true }).click() + const privateLine = windows.getByRole('list', { name: '消息记录' }).getByRole('listitem').filter({ hasText: privateFile }) + await privateLine.getByRole('button', { name: '收藏', exact: true }).click() + await privateLine.getByRole('button', { name: '取消收藏', exact: true }).waitFor() const desktopForward = windows.getByRole('form', { name: '转发私聊消息' }) const writes = [] const recordWrite = (req) => { if (req.method() === 'POST' && req.url().includes('/groups/')) writes.push(req.url()) } @@ -710,6 +713,23 @@ test('Windows 与 Web 加密群聊支持消息操作、附件、语音和成员 } await windows.getByRole('button', { name: '消息系统通知', pressed: true }).click() await windows.getByText('已在本设备关闭消息系统通知', { exact: true }).waitFor() + + await work(windows).getByRole('link', { name: '群组', exact: true }).click() + await windows.getByRole('link', { name: new RegExp(targetGroup) }).click() + await chat(windows).getByRole('button', { name: '启用本机群聊' }).click() + const groupFile = chat(windows).getByRole('listitem').filter({ has: windows.getByRole('button', { name: '下载 ' + privateFile, exact: true }) }) + await groupFile.getByRole('button', { name: '收藏', exact: true }).click() + await groupFile.getByRole('button', { name: '取消收藏', exact: true }).waitFor() + await work(windows).getByRole('link', { name: '收藏', exact: true }).click() + const collection = windows.getByRole('list', { name: '本机收藏' }) + await windows.getByRole('searchbox', { name: '搜索本机收藏' }).fill(privateFile) + const downloads = collection.getByRole('button', { name: '下载 ' + privateFile, exact: true }) + await downloads.nth(1).waitFor() + await windows.getByLabel('来源', { exact: true }).selectOption('group') + assert.equal(await downloads.count(), 1) + await collection.getByText(new RegExp(targetGroup)).waitFor() + await windows.getByLabel('来源', { exact: true }).selectOption('private') + assert.equal(await downloads.count(), 1) } catch (error) { const status = await Promise.all(pages.map((page) => page.locator('[role=alert], .group-chat [role=status]').allTextContents())) throw new Error(JSON.stringify(status), { cause: error }) diff --git a/web/src/chat/MessageText.vue b/web/src/chat/MessageText.vue index 375a0bc..85f455b 100644 --- a/web/src/chat/MessageText.vue +++ b/web/src/chat/MessageText.vue @@ -1,31 +1,12 @@ + + + + diff --git a/web/src/views/Workspace.vue b/web/src/views/Workspace.vue index f24bd5c..e74a4bf 100644 --- a/web/src/views/Workspace.vue +++ b/web/src/views/Workspace.vue @@ -130,6 +130,7 @@ async function act(action: () => Promise) { ◇ 人 + ☆ ▣ @@ -142,6 +143,7 @@ async function act(action: () => Promise) { 消息 联系人 群组 + 收藏 设备管理