fix: restore terminal paste and square workbar chrome
Terminal paste previously relied on the Renderer browser Clipboard API, which could be denied by Electron and leave the toolbar action unusable. Text clipboard access now goes through the trusted Main/Preload bridge, and the workbar tabs plus terminal toolbar use straight corners for a continuous docked appearance. Release note: 修复终端工具栏粘贴可能因剪贴板权限被拒绝而失败的问题,并将工作栏页签与终端工具栏调整为直角样式。
This commit is contained in:
@@ -242,6 +242,11 @@ describe('terminal IPC boundary', () => {
|
||||
snapshot.sessionId
|
||||
)
|
||||
|
||||
expect(
|
||||
electronMocks.handlers.get(ipcChannels.clipboardReadText)?.(event)
|
||||
).toBe('Get-Location\r')
|
||||
expect(electronMocks.readClipboardText).toHaveBeenCalledOnce()
|
||||
|
||||
electronMocks.handlers.get(ipcChannels.clipboardWriteText)?.(
|
||||
event,
|
||||
'## Copied response'
|
||||
@@ -249,6 +254,12 @@ describe('terminal IPC boundary', () => {
|
||||
expect(electronMocks.writeClipboardText).toHaveBeenCalledWith(
|
||||
'## Copied response'
|
||||
)
|
||||
expect(() =>
|
||||
electronMocks.handlers.get(ipcChannels.clipboardReadText)?.({
|
||||
sender: { ...webContents, id: 99 },
|
||||
senderFrame: webContents.mainFrame
|
||||
})
|
||||
).toThrow('拒绝来自未知窗口的 IPC 请求')
|
||||
expect(() =>
|
||||
electronMocks.handlers.get(ipcChannels.clipboardWriteText)?.(
|
||||
event,
|
||||
@@ -319,6 +330,7 @@ const electronMocks = vi.hoisted(() => {
|
||||
openPath: vi.fn(async () => ''),
|
||||
showItemInFolder: vi.fn(),
|
||||
openExternal: vi.fn(async () => undefined),
|
||||
readClipboardText: vi.fn(() => 'Get-Location\r'),
|
||||
writeClipboardText: vi.fn()
|
||||
}
|
||||
})
|
||||
@@ -1131,6 +1143,7 @@ vi.mock('electron', () => ({
|
||||
},
|
||||
BrowserWindow: class {},
|
||||
clipboard: {
|
||||
readText: electronMocks.readClipboardText,
|
||||
writeText: electronMocks.writeClipboardText
|
||||
},
|
||||
dialog: {
|
||||
|
||||
@@ -3300,6 +3300,11 @@ export function registerIpcHandlers(
|
||||
}
|
||||
})
|
||||
|
||||
registerHandler(ipcChannels.clipboardReadText, (event) => {
|
||||
assertTrustedSender(event, window)
|
||||
return clipboardTextSchema.parse(clipboard.readText())
|
||||
})
|
||||
|
||||
registerHandler(ipcChannels.clipboardWriteText, (event, input) => {
|
||||
assertTrustedSender(event, window)
|
||||
clipboard.writeText(clipboardTextSchema.parse(input))
|
||||
|
||||
Reference in New Issue
Block a user