Skip to content

Commit 3324e23

Browse files
feat: add splash screen and error handling for URLs
1 parent aec73cb commit 3324e23

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

src/app/error.html

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<link rel="icon" href="../assets/icons/icon_32.png" />
7+
<meta http-equiv="Content-Security-Policy" content="script-src 'self'" />
8+
<link rel="preconnect" href="https://fonts.googleapis.com" />
9+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
10+
<link
11+
href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600;900&family=Poppins:wght@300;400;700&family=Roboto+Mono&family=Ubuntu:wght@300;500;700&display=swap"
12+
rel="stylesheet"
13+
/>
14+
<link rel="stylesheet" href="./css/index.css" />
15+
<title>Proxy Manager | Error</title>
16+
</head>
17+
<body>
18+
<!-- <h1>Error During URL Load</h1> -->
19+
<h2>This service uses <span>Internet Connection</span></h2>
20+
<h2>Possible Reasons for Connection drop :</h2>
21+
<ol>
22+
<li>Usage of Incorrect Proxy</li>
23+
<li>No Internet Connection</li>
24+
<li>No Proxy used</li>
25+
</ol>
26+
<!-- <div class="spinner"></div> -->
27+
</body>
28+
</html>

src/index.js

+35
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,11 @@ const createWindow = () => {
7777
};
7878
// create dynamic window
7979
const createDynamicWindow = (file) => {
80+
createSplashScreen();
8081
dynamicWindow = new BrowserWindow({
8182
width: isDev ? 1000 : 550,
8283
height: 600,
84+
show: false,
8385
webPreferences: {
8486
preload: path.join(__dirname, "preload.js"),
8587
nodeIntegration: true,
@@ -98,6 +100,19 @@ const createDynamicWindow = (file) => {
98100
if (isDev) {
99101
dynamicWindow.webContents.openDevTools();
100102
}
103+
104+
dynamicWindow.once("ready-to-show", () => {
105+
// dynamicWindow.show();
106+
// if (splashScreen) {
107+
// splashScreen.close();
108+
// }
109+
setTimeout(() => {
110+
dynamicWindow.show();
111+
if (splashScreen) {
112+
splashScreen.close();
113+
}
114+
}, 500);
115+
});
101116
};
102117

103118
function createSplashScreen() {
@@ -110,6 +125,7 @@ function createSplashScreen() {
110125
webPreferences: {
111126
nodeIntegration: true,
112127
},
128+
icon: path.join(__dirname, "./assets/icons/icon_512.png"),
113129
roundedCorners: true,
114130
transparent: true, // Set the window to be transparent
115131
});
@@ -122,9 +138,11 @@ function createSplashScreen() {
122138
}
123139

124140
const createURLWindow = (file) => {
141+
createSplashScreen();
125142
dynamicWindow = new BrowserWindow({
126143
width: isDev ? 1000 : 550,
127144
height: 600,
145+
show: false,
128146
webPreferences: {
129147
preload: path.join(__dirname, "preload.js"),
130148
nodeIntegration: true,
@@ -140,9 +158,26 @@ const createURLWindow = (file) => {
140158
dynamicWindow.setIcon(path.join(__dirname, "./assets/icons/icon_512.png"));
141159
// and load the index.html of the app.
142160
dynamicWindow.loadURL("https://aethernex.vercel.app");
161+
// did-fail-load
162+
dynamicWindow.webContents.on(
163+
"did-fail-load",
164+
(event, errorCode, errorDescription, validatedURL, isMainFrame) => {
165+
// Load a local HTML file if URL loading fails
166+
dynamicWindow.loadFile(path.join(__dirname, "./app/error.html"));
167+
// console.log({event,errorCode,errorDescription,validatedURL,isMainFrame});
168+
}
169+
);
143170
if (isDev) {
144171
dynamicWindow.webContents.openDevTools();
145172
}
173+
dynamicWindow.once("ready-to-show", () => {
174+
setTimeout(() => {
175+
dynamicWindow.show();
176+
if (splashScreen) {
177+
splashScreen.close();
178+
}
179+
}, 500);
180+
});
146181
};
147182

148183
function showNotification({ title, body }) {

0 commit comments

Comments
 (0)