private injection() {
let hintHook = `
const hasVisited = localStorage.getItem('hasVisited') !== null;
const hintWidget = document.createElement('div');
const hintText = document.createElement('p');
hintText.id = 'hintTextDiv';
if (!hasVisited) {
hintText.textContent = '首次';
} else {
hintText.textContent = '二次';
}
hintWidget.appendChild(hintText);
document.body.appendChild(hintWidget);
localStorage.setItem('hasVisited', 'true');`;
this channelWindow = new BrowserWindow({ width: 800, height: 600 })
this.channelWindow.webContents.on('did-finish-load', () => {
this.channelWindow?.webContents.executeJavaScript(hintHook, true);}
}
这是注入盒子在某页面里来当做提示语,用来提示是否首次登录。打开登录页后提示语会显示'首次',但是加载跳转后会变成'二次',应该加载页面重新获取hasVisited再判断导致的吧,'二次'的提示语要在非首次登录提示的,要怎么解决呢