api/page: add reload

This commit is contained in:
CanadaHonk 2023-01-27 20:40:19 +00:00
parent 74ebd51ad1
commit 925cd87b83
3 changed files with 19 additions and 2 deletions

13
gluon.d.ts vendored
View File

@ -70,7 +70,18 @@ type PageApi = {
title(
/** Set the page title to a new title. */
newTitle: string
): Promise<string>
): Promise<string>,
/**
* Reload the page.
*/
reload(
/**
* Optionally ignore the cache for the reload.
* @default false
*/
ignoreCache?: Boolean
)
};
type IPCStoreApi = {

View File

@ -18,10 +18,10 @@
## v0.12.0
- [X] Add new freezing API to Idle API
- [X] Minor stability/edge-case improvements
- [X] Some API tweaks
- [X] Local improvements
- [X] Experimental V8 Cache API
- [X] Massive startup time speedup (~1s -> ~0.4s)
- [X] Tweak and add to Page API
- [ ] Initial system tray API (Windows only for WIP)
- [ ] Frameless windows (Windows only for WIP)
- [ ] Hide window completely (Windows only for WIP)

View File

@ -103,6 +103,12 @@ export default async (CDP, proc, injectionType = 'browser', { dataPath, browserN
title: val => {
if (!val) return evalInWindow('document.title');
return evalInWindow(`document.title = \`${val}\``);
},
reload: async (ignoreCache = false) => {
await Window.cdp.send('Page.reload', {
ignoreCache
});
}
},