类:ServiceWorkerMain
类:ServiceWorkerMain
🌐 Class: ServiceWorkerMain
Service Worker 的一个实例,表示给定作用域下脚本的一个版本。
进程: 主进程
此类未从 'electron' 模块导出。它仅作为 Electron API 中其他方法的返回值提供。
实例方法
🌐 Instance Methods
serviceWorker.isDestroyed() 实验性
🌐 serviceWorker.isDestroyed() Experimental
返回 boolean - 服务工作线程是否已被销毁。
🌐 Returns boolean - Whether the service worker has been destroyed.
serviceWorker.send(channel, ...args) 实验性
🌐 serviceWorker.send(channel, ...args) Experimental
channel字符串...argsany[]
通过 channel 向服务工作者进程发送异步消息,同时附带参数。参数将使用 结构化克隆算法 序列化,就像 postMessage 一样,因此原型链不会被包含。发送函数、Promise、Symbol、WeakMap 或 WeakSet 会抛出异常。
🌐 Send an asynchronous message to the service worker process via channel, along with
arguments. Arguments will be serialized with the Structured Clone Algorithm,
just like postMessage, so prototype chains will not be included.
Sending Functions, Promises, Symbols, WeakMaps, or WeakSets will throw an exception.
服务工作线程进程可以通过使用ipcRenderer模块监听channel来处理消息。
🌐 The service worker process can handle the message by listening to channel with the
ipcRenderer module.
serviceWorker.startTask() 实验性
🌐 serviceWorker.startTask() Experimental
返回 Object:
🌐 Returns Object:
end函数 - 任务结束时调用的方法。如果从未调用,服务在其他情况下空闲时也不会终止。
启动任务以保持服务工作线程处于活动状态直到结束。
🌐 Initiate a task to keep the service worker alive until ended.
实例属性
🌐 Instance Properties
serviceWorker.ipc 只读 实验性
🌐 serviceWorker.ipc Readonly Experimental
一个作用域为服务工作线程的 IpcMainServiceWorker 实例。
🌐 An IpcMainServiceWorker instance scoped to the service worker.
serviceWorker.scope 只读 实验性
🌐 serviceWorker.scope Readonly Experimental
一个 string,表示服务工作线程的作用域 URL。
🌐 A string representing the scope URL of the service worker.
serviceWorker.scriptURL 只读 实验性
🌐 serviceWorker.scriptURL Readonly Experimental
一个 string,表示服务工作线程的脚本 URL。
🌐 A string representing the script URL of the service worker.
serviceWorker.versionId 只读 实验性
🌐 serviceWorker.versionId Readonly Experimental
number 表示其作用域内特定版本的服务工作线程脚本的 ID。
🌐 A number representing the ID of the specific version of the service worker script in its scope.