mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
Display error/retry in case of failure
This commit is contained in:
50
error.html
Normal file
50
error.html
Normal file
@ -0,0 +1,50 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Cannot load YouTube Music</title>
|
||||
<style>
|
||||
body {
|
||||
background: #000;
|
||||
}
|
||||
|
||||
.container {
|
||||
margin: 0;
|
||||
font-family: Roboto, Arial, sans-serif;
|
||||
font-size: 20px;
|
||||
font-weight: 500;
|
||||
color: rgba(255, 255, 255, 0.5);
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
margin-right: -50%;
|
||||
transform: translate(-50%, -50%);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.button {
|
||||
background: #065fd4;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
color: white;
|
||||
font: inherit;
|
||||
text-transform: uppercase;
|
||||
text-decoration: none;
|
||||
border-radius: 2px;
|
||||
font-size: 16px;
|
||||
font-weight: normal;
|
||||
text-align: center;
|
||||
padding: 8px 22px;
|
||||
display: inline-block;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
<p>Cannot load YouTube Music… Internet disconnected?</p>
|
||||
<a href="#" class="button" onclick="reload()">Retry</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
7
index.js
7
index.js
@ -72,6 +72,13 @@ function createMainWindow() {
|
||||
});
|
||||
});
|
||||
|
||||
win.webContents.on("did-fail-load", () => {
|
||||
if (isDev) {
|
||||
console.log("did fail load");
|
||||
}
|
||||
win.webContents.loadFile(path.join(__dirname, "error.html"));
|
||||
});
|
||||
|
||||
win.webContents.on("did-navigate-in-page", () => {
|
||||
const url = win.webContents.getURL();
|
||||
if (url.startsWith("https://music.youtube.com")) {
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
const path = require("path");
|
||||
|
||||
const { getEnabledPlugins } = require("./store");
|
||||
const { getCurrentWindow } = require("electron").remote;
|
||||
|
||||
const { getEnabledPlugins, store } = require("./store");
|
||||
const { fileExists } = require("./plugins/utils");
|
||||
|
||||
const plugins = getEnabledPlugins();
|
||||
@ -23,4 +25,8 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
run();
|
||||
});
|
||||
});
|
||||
|
||||
// Add action for reloading
|
||||
global.reload = () =>
|
||||
getCurrentWindow().webContents.loadURL(store.get("url"));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user