From 857f16b07dc1f2585391168614aa58166328ba08 Mon Sep 17 00:00:00 2001 From: liugaowei Date: Wed, 28 Oct 2026 18:40:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(plugin):=20=E6=8C=89=E9=9C=80=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=9C=AC=E5=9C=B0=E5=88=86=E4=BA=AB=E7=9A=84=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E8=AE=BE=E5=A4=87=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liugaowei --- .../features/plugin/LocalPluginShareView.tsx | 6 ++++-- .../__tests__/LocalPluginShareView.test.tsx | 20 +++++++++++++++++++ docs/dev-rules/protocol-compatibility.md | 2 +- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/apps/desktop/src/renderer/features/plugin/LocalPluginShareView.tsx b/apps/desktop/src/renderer/features/plugin/LocalPluginShareView.tsx index 3c769e37c7..e93283e3ad 100644 --- a/apps/desktop/src/renderer/features/plugin/LocalPluginShareView.tsx +++ b/apps/desktop/src/renderer/features/plugin/LocalPluginShareView.tsx @@ -77,8 +77,10 @@ export function LocalPluginShareView({ snapshotId, onBack, onInstalled, deviceCo {snapshot.description ?

{snapshot.description}

: null}

{t('sharing.localVersionNotice')}

-

{t('sharing.localInstallTarget')}

- {deviceControl ?
: null} + {deviceControl && (deviceControl.selected || deviceControl.directory.candidates.length > 0) ? <> +

{t('sharing.localInstallTarget')}

+
+ : null} {deviceControl?.selected ? ({ selected: target, onSelect: vi.fn(), directory: { candidates: [], target: undefined, relayOnline: online, online } }); + +// A signed-in recipient with only this computer must install without a redundant +// device choice. Existing tests use no control or a selected remote target; +// neither covers the real catalog control with selected=null (unit, fake IPC). +it.each([false, true])('installs on this computer without requiring a device choice (alternative=%s)', async alternative => { + const selection: CatalogDeviceControl = { selected: null, onSelect: vi.fn(), directory: { + candidates: alternative ? [{ ...target, platform: 'darwin', appVersion: '0.0.0', lastSeenAt: null, + online: true, busy: false, remoteControlEnabled: true, controlEnabled: true, isSelf: false }] : [], + target: undefined, relayOnline: true, online: true, + } }; + const installed = vi.fn(); render(view(installed, selection)); + await screen.findByText('v1.0.0'); + expect(!!screen.queryByRole('button', { name: 'settings.ghosts.remote.device' })).toBe(alternative); + fireEvent.click(screen.getByRole('button', { name: 'sharing.localInstallButton' })); + await waitFor(() => expect(installed).toHaveBeenCalledWith(ghost)); + expect(io.install).toHaveBeenCalledWith(snapshotId, snapshot); + expect(selection.onSelect).not.toHaveBeenCalled(); + expect(io.invoke).not.toHaveBeenCalled(); +}); + function remoteHost(supported = true) { io.invoke.mockImplementation(async (_device, channel, [request]) => { if (String(channel).includes('manifest')) return { collections: [{ id: 'plugins', actions: [{ id: 'management:snapshot' }] }] }; diff --git a/docs/dev-rules/protocol-compatibility.md b/docs/dev-rules/protocol-compatibility.md index 996419a42b..9601d26b59 100644 --- a/docs/dev-rules/protocol-compatibility.md +++ b/docs/dev-rules/protocol-compatibility.md @@ -3626,7 +3626,7 @@ Share Server 在创建时保存已验签的分享者 `membershipId` 与身份权 公共 `kind=plugin`、`cindy://plugin/` 及其链接复用、版本选择和安装规则保留。 本地分享另用 `kind=local-plugin`、随机 `snapshotId` 和 `cindy://plugin-share/`;只导航,拒绝 query、fragment、包 URL 和自动安装参数, -沿原冷启动与登录续接进入独立分享详情,优先于本机/远程目录分支。接收者使用原设备选择器选择安装电脑;离线或不支持的目标不可安装,不自动切回本机。不新增 Mobile 入口。 +沿原冷启动与登录续接进入独立分享详情,优先于本机/远程目录分支。安装沿用当前所选电脑;仅在有其他候选电脑或已选远程电脑时显示原设备选择器,不额外要求选择。离线或不支持的目标不可安装,不自动切回本机。不新增 Mobile 入口。 两仓 `packages/plugin-protocol/src/localSharing.ts` 同步维护上传、固定快照与交付校验, 不修改已有 manifest、Release 或来源枚举。每次打开本地分享面板生成新操作;用户明确开始后,