Skip to content

Commit cf15550

Browse files
committed
优化:新增 GitHub API 连通性检查
1 parent d2a32b5 commit cf15550

File tree

2 files changed

+36
-20
lines changed

2 files changed

+36
-20
lines changed

doctor.php

+34-15
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,20 @@ function console($item, $result, $err = '')
3939

4040
// MySQL 连接
4141
try {
42-
$err = '';
42+
$dberr = '';
4343
$dsn = "mysql:host={$env['DB_HOST']}:{$env['DB_PORT']};dbname={$env['DB_DATABASE']}";
4444
$db = new PDO($dsn, $env['DB_USERNAME'], $env['DB_PASSWORD'], [PDO::ATTR_TIMEOUT => 3]);
4545
} catch (Exception $e) {
46-
$err = $e->getMessage();
46+
$dberr = $e->getMessage();
4747
}
48-
console('MySQL 连接', $err ? '失败' : '成功', $err);
48+
console('MySQL 连接', $dberr ? '失败' : '成功', $dberr);
4949

5050
// MySQL 数据表
5151
try {
52-
if ($err) {
53-
throw new Exception($err);
52+
if ($dberr) {
53+
throw new Exception($dberr);
5454
}
55-
$err = '';
55+
$err = false;
5656
$tables = $db->query("show tables like 'code_leak'")->fetchAll(PDO::FETCH_ASSOC)[0];
5757
if (!count($tables)) {
5858
throw new Exception('请执行 php artisan migrate 导入数据表');
@@ -62,7 +62,34 @@ function console($item, $result, $err = '')
6262
}
6363
console('MySQL 数据表', $err ? '未导入' : '已导入', $err);
6464

65-
echo DIVIDER."[ 其他信息 ]\n";
65+
// GitHub API
66+
try {
67+
$apierr = false;
68+
$url = 'https://api.github.com';
69+
$ch = curl_init($url);
70+
curl_setopt($ch, CURLOPT_HEADER, 0);
71+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
72+
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
73+
curl_setopt($ch, CURLOPT_USERAGENT, 'code6');
74+
$result = json_decode(curl_exec($ch), true);
75+
if (empty($result)) {
76+
throw new Exception("请求 $url 错误");
77+
}
78+
curl_close($ch);
79+
} catch (Exception $e) {
80+
$apierr = $e->getMessage();
81+
}
82+
console('GitHub API', $apierr ? '请求错误' : '请求成功', $apierr);
83+
84+
// PHP 禁用函数
85+
$disFuns = get_cfg_var('disable_functions') ?: '';
86+
echo "PHP 禁用函数:$disFuns\n";
87+
88+
// PHP 已编译模块
89+
$exts = implode(',', get_loaded_extensions());
90+
echo "PHP 已编译模块:$exts\n";
91+
92+
echo DIVIDER."[ 系统信息 ]\n";
6693

6794
// 码小六版本
6895
$version = trim(file_get_contents(ROOT.'/version'));
@@ -76,12 +103,4 @@ function console($item, $result, $err = '')
76103
$appDebug = $env['APP_DEBUG'] ?? '';
77104
echo "框架调试开关:$appDebug\n";
78105

79-
// PHP 禁用函数
80-
$disFuns = get_cfg_var('disable_functions') ?: '';
81-
echo "PHP 禁用函数:$disFuns\n";
82-
83-
// PHP 已编译模块
84-
$exts = implode(',', get_loaded_extensions());
85-
echo "PHP 已编译模块:$exts\n";
86-
87106
echo DIVIDER."\n有任何问题和建议请联系-> https://github.com/4x99/code6/issues\n\n";

resources/views/mobile/home.blade.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,8 @@
117117
me.page.count = rsp.data.last_page ? rsp.data.last_page : 0;
118118
me.list.data = rsp.data.data;
119119
me.loading = false;
120-
history.pushState({
121-
page: me.page,
122-
data: me.list.data,
123-
tab: me.tab,
124-
}, '', '/mobile?page=' + page + '&tab=' + me.tab.current);
120+
var data = {page: me.page, data: me.list.data, tab: me.tab};
121+
history.pushState(data, '', '/mobile?page=' + page + '&tab=' + me.tab.current);
125122
}).catch(function (rsp) {
126123
me.$toast.fail(rsp.message);
127124
me.loading = false;

0 commit comments

Comments
 (0)