diff --git a/zbw.d.ts b/zbw.d.ts index 2f84260..18d6c68 100644 --- a/zbw.d.ts +++ b/zbw.d.ts @@ -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