Skip to content

Commit

Permalink
Fix/login error tips (#2535)
Browse files Browse the repository at this point in the history
* Fix: Add policy url open

* Feature: Add version alpha
  • Loading branch information
Raywh authored Nov 14, 2024
1 parent 3a98aeb commit a501264
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 7 additions & 1 deletion src/app/ui/pages/HomePage/Avatar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const Avatar: React.FC = () => {

const showModal = () => {
setIsModalVisible(true);
setErrorTips('');
setTimeout(() => {
const webviewBox = document.getElementById('webviewBox');
webviewBox?.addEventListener('will-navigate', (event) => {
Expand All @@ -47,17 +48,22 @@ 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');
});
}, 0);
};
const handleCancel = () => {
setIsModalVisible(false);
setErrorTips('');
};

// define url
Expand Down
8 changes: 8 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit a501264

Please sign in to comment.