你能检查用户是否正在使用 Electron 查看网页吗?
Can you check if a user is viewing a webpage using Electron?
假设我想构建一个简单的 Electron 应用程序,当用户到达 example.com
时提醒用户
这可能吗?如果是这样,我如何检测用户是否正在查看某个网页?
Electron 有 did-navigate
事件,当页面在 BrowserWindow
中重定向时会被触发。
参考上面post我觉得,
const { BrowserWindow, dialog } = require('electron')
const win = new BrowserWindow({ width: 800, height: 600 })
win.webContents.on('did-navigate', (event, url, httpResponseCode, httpStatusText) => {
if(url == "example.com") {
dialog.showMessageBox({ type: "info", message: `You visited ${url}` });
//dialog docs at https://www.electronjs.org/docs/api/dialog#dialogshowmessageboxbrowserwindow-options
}
})
假设我想构建一个简单的 Electron 应用程序,当用户到达 example.com
时提醒用户这可能吗?如果是这样,我如何检测用户是否正在查看某个网页?
Electron 有 did-navigate
事件,当页面在 BrowserWindow
中重定向时会被触发。
参考上面post我觉得,
const { BrowserWindow, dialog } = require('electron')
const win = new BrowserWindow({ width: 800, height: 600 })
win.webContents.on('did-navigate', (event, url, httpResponseCode, httpStatusText) => {
if(url == "example.com") {
dialog.showMessageBox({ type: "info", message: `You visited ${url}` });
//dialog docs at https://www.electronjs.org/docs/api/dialog#dialogshowmessageboxbrowserwindow-options
}
})