Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions zbw.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,41 @@ declare namespace BrowserWindow {
closeDevTools: () => void
copy: () => void
copyImageAt: (x: number, y: number) => void
/**
* 读取当前 webContents 关联 session 的 Cookie。
*
* 通过主进程 `session.fromPartition(partition).cookies.get()` 实现,
* 可读取 `document.cookie` 无法获取的 HttpOnly Cookie(如登录态 sessionid)。
*
* @example
* // 读取指定 URL 的所有 cookie(含 HttpOnly)
* const cookies = await win.webContents.cookies.get({ url: 'https://example.com' })
* const sessionId = cookies.find(c => c.name === 'sessionid')?.value
*
* @param filter 可选过滤条件,与 Electron Cookies.get filter 一致
*/
cookies: {
get: (filter?: {
url?: string
name?: string
domain?: string
path?: string
secure?: boolean
session?: boolean
httpOnly?: boolean
}) => Promise<
Array<{
name: string
value: string
domain?: string
path?: string
secure?: boolean
httpOnly?: boolean
expirationDate?: number
sameSite?: 'unspecified' | 'no_restriction' | 'lax' | 'strict'
}>
>
}
cut: () => void
/**
* @deprecated
Expand Down