diff --git a/package-lock.json b/package-lock.json index 05b846551..e0c5684da 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "snapmaker-luban", - "version": "4.13.1-beta.1.3", + "version": "4.14.0-alpha.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "snapmaker-luban", - "version": "4.13.1-beta.1.3", + "version": "4.14.0-alpha.1", "hasInstallScript": true, "license": "AGPL-3.0-or-later", "os": [ diff --git a/package.json b/package.json index 80bd5158b..f6bd00e70 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "snapmaker-luban", - "version": "4.13.1-beta.1.3", + "version": "4.14.0-alpha.1", "description": "A web-based interface for Snapmaker 3-in-1 3D Printer", "homepage": "https://github.com/Snapmaker/Luban", "author": "Snapmaker Software Team", diff --git a/src/app/ui/pages/HomePage/Avatar/index.tsx b/src/app/ui/pages/HomePage/Avatar/index.tsx index 98f036b3b..933590dde 100644 --- a/src/app/ui/pages/HomePage/Avatar/index.tsx +++ b/src/app/ui/pages/HomePage/Avatar/index.tsx @@ -36,6 +36,7 @@ const Avatar: React.FC = () => { const showModal = () => { setIsModalVisible(true); + setErrorTips(''); setTimeout(() => { const webviewBox = document.getElementById('webviewBox'); webviewBox?.addEventListener('will-navigate', (event) => { @@ -47,10 +48,14 @@ const Avatar: React.FC = () => { setWebviewUrl('https://snapmaker.com'); } else if (url.includes('logout')) { setWebviewUrl('https://snapmaker.com'); + } else if (url.includes('policy')) { + window.open(url); + event.preventDefault(); } }); + webviewBox?.addEventListener('did-fail-load', (event) => { - log.info(`Load failed: ${event}`); + log.info(`Load failed: ${event.errorDescription}`); const errorDescription = event.errorDescription; setErrorTips(errorDescription || 'Load Error'); }); @@ -58,6 +63,7 @@ const Avatar: React.FC = () => { }; const handleCancel = () => { setIsModalVisible(false); + setErrorTips(''); }; // define url diff --git a/src/main.js b/src/main.js index 2b5735784..ae8a88ca8 100644 --- a/src/main.js +++ b/src/main.js @@ -349,6 +349,14 @@ const showMainWindow = async () => { const windowOptions = getBrowserWindowOptions(); const window = new BrowserWindow(windowOptions); mainWindow = window; + // Monitor policy links, do not allow redirection + window.webContents.on('did-attach-webview', (e, webContent)=> { + webContent.on('will-navigate', (e, url) => { + if (url.includes('policy')) { + e.preventDefault(); + } + }); + }); powerId = powerSaveBlocker.start('prevent-display-sleep'); if (process.platform === 'win32') { diff --git a/src/package.json b/src/package.json index 58fe6a26d..93ffaee91 100755 --- a/src/package.json +++ b/src/package.json @@ -1,6 +1,6 @@ { "name": "snapmaker-luban", - "version": "4.13.1-beta.1.3", + "version": "4.14.0-alpha.1", "description": "Snapmaker 3-in-1 Software for 3D Printing, Laser Engraving and CNC Cutting.", "homepage": "https://github.com/Snapmaker/Luban", "author": "Snapmaker Software Team",