forked from bia-pain-bache/BPB-Worker-Panel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.js
59 lines (57 loc) · 2.22 KB
/
error.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { initializeParams, panelVersion } from "../helpers/init";
export async function renderErrorPage (request, env, message, error, refer) {
await initializeParams(request, env);
const errorPage = `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Error Page</title>
<style>
:root {
--color: black;
--header-color: #09639f;
--background-color: #fff;
--border-color: #ddd;
--header-shadow: 2px 2px 4px rgba(0, 0, 0, 0.25);
}
body, html {
height: 100%;
width: 100%;
margin: 0;
display: flex;
justify-content: center;
align-items: center;
font-family: system-ui;
color: var(--color);
background-color: var(--background-color);
}
body.dark-mode {
--color: white;
--header-color: #3498DB;
--background-color: #121212;
--header-shadow: 2px 2px 4px rgba(255, 255, 255, 0.25);
}
h1 { font-size: 2.5rem; text-align: center; color: var(--header-color); text-shadow: var(--header-shadow); }
#error-container { text-align: center; }
</style>
</head>
<body>
<div id="error-container">
<h1>BPB Panel <span style="font-size: smaller;">${panelVersion}</span> 💦</h1>
<div id="error-message">
<h2>${message} ${refer
? 'Please try again or refer to <a href="https://github.com/bia-pain-bache/BPB-Worker-Panel/blob/main/README.md">documents</a>'
: ''}
</h2>
<p><b>${error ? `⚠️ ${error.stack.toString()}` : ''}</b></p>
</div>
</div>
<script>
localStorage.getItem('darkMode') === 'enabled' && document.body.classList.add('dark-mode');
</script>
</body>
</html>`;
return new Response(errorPage, { status: 200, headers: {'Content-Type': 'text/html'}});
}