-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Expand file tree
/
Copy pathindex.php
More file actions
227 lines (197 loc) · 6 KB
/
index.php
File metadata and controls
227 lines (197 loc) · 6 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<?php
/**
* ShowDoc安装脚本
*/
include("common.php");
// 执行环境检查
$checkResult = check_environment();
if (!$checkResult['status']) {
echo implode('<br>', $checkResult['messages']);
exit();
}
?>
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<title>ShowDoc</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="ShowDoc installation page">
<meta name="author" content="ShowDoc">
<style>
:root {
--primary-color: #24292e;
--text-white: #fff;
--text-dark: #000;
--transition-time: 0.5s;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html, body {
height: 100%;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.container {
display: flex;
height: 100%;
width: 100%;
position: absolute;
}
.flex-item {
display: inline-flex;
justify-content: center;
align-items: center;
flex-direction: column;
height: 100%;
transition: all var(--transition-time) ease;
}
.left {
width: 50%;
background-color: var(--text-white);
}
.right {
width: 50%;
background-color: var(--primary-color);
color: var(--text-white);
}
.lang-text {
font-size: 30px;
cursor: pointer;
padding: 20px;
border-radius: 4px;
transition: all 0.3s ease;
}
.lang-text:hover {
transform: scale(1.05);
}
.left a {
color: var(--text-dark);
}
.right a {
color: var(--text-white);
}
.en-tips, .zh-tips {
display: none;
font-size: 20px;
line-height: 1.5;
text-align: center;
padding: 20px;
}
a {
text-decoration: none;
font-weight: bold;
}
a:hover {
text-decoration: underline;
}
@media (max-width: 768px) {
.container {
flex-direction: column;
}
.left, .right {
width: 100%;
height: 50%;
}
}
</style>
</head>
<body>
<div class="container">
<div class="flex-item left">
<div class="lang-text" id="en">
Choose language: English →
</div>
<div class="en-tips">
Initialization successful. The default administrator account password is showdoc / 123456.<br>
After logging in, you can see the management background entrance in the upper right corner.<br>
<a href="../web/">Click to enter the home page</a>
</div>
</div>
<div class="flex-item right">
<div class="lang-text" id="zh">
选择语言:中文 →
</div>
<div class="zh-tips">
初始化成功。默认管理员账户密码是showdoc/123456。<br>
登录后,在右上角可以看到管理后台入口。<a href="../web/">点击进入首页</a>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
// 获取DOM元素
const enButton = document.getElementById('en');
const zhButton = document.getElementById('zh');
const leftPane = document.querySelector('.left');
const rightPane = document.querySelector('.right');
const enTips = document.querySelector('.en-tips');
const zhTips = document.querySelector('.zh-tips');
// 事件监听
enButton.addEventListener('click', function() {
handleInstall('en');
});
zhButton.addEventListener('click', function() {
handleInstall('zh');
});
/**
* 处理安装请求
* @param {string} lang - 语言代码
*/
function handleInstall(lang) {
// 显示加载状态
const button = lang === 'en' ? enButton : zhButton;
const originalText = button.innerHTML;
button.innerHTML = lang === 'en' ? 'Installing...' : '正在安装...';
button.style.opacity = '0.7';
// 创建XHR请求
const xhr = new XMLHttpRequest();
xhr.open('GET', `ajax.php?lang=${lang}`, true);
xhr.responseType = 'json';
xhr.onload = function() {
if (xhr.status === 200) {
const data = xhr.response;
if (data.error_code === 0) {
lang === 'en' ? showEnTips() : showZhTips();
} else {
button.innerHTML = originalText;
button.style.opacity = '1';
alert(data.error_message);
}
} else {
button.innerHTML = originalText;
button.style.opacity = '1';
alert(lang === 'en' ? 'Request failed, please try again' : '请求失败,请重试');
}
};
xhr.onerror = function() {
button.innerHTML = originalText;
button.style.opacity = '1';
alert(lang === 'en' ? 'Network error, please check your connection' : '网络错误,请检查连接');
};
xhr.send();
}
/**
* 显示英文提示
*/
function showEnTips() {
rightPane.style.display = 'none';
leftPane.style.width = '100%';
enButton.style.display = 'none';
enTips.style.display = 'block';
}
/**
* 显示中文提示
*/
function showZhTips() {
leftPane.style.display = 'none';
rightPane.style.width = '100%';
zhButton.style.display = 'none';
zhTips.style.display = 'block';
}
});
</script>
</body>
</html>