Upload 2 files
Browse files- github-advanced-test.php +106 -32
- storage.php +1 -1
github-advanced-test.php
CHANGED
|
@@ -23,28 +23,44 @@ function testGitHubAPI($token, $endpoint, $method = 'GET', $data = null) {
|
|
| 23 |
curl_setopt($ch, CURLOPT_URL, $endpoint);
|
| 24 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
| 25 |
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
|
| 26 |
-
curl_setopt($ch, CURLOPT_TIMEOUT,
|
| 27 |
-
curl_setopt($ch,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
'Authorization: token ' . $token,
|
| 29 |
-
'User-Agent: VvvebJs-
|
| 30 |
-
'Accept: application/vnd.github.v3+json'
|
| 31 |
-
|
|
|
|
| 32 |
|
| 33 |
if ($data) {
|
| 34 |
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
|
| 35 |
-
|
| 36 |
}
|
| 37 |
|
|
|
|
|
|
|
| 38 |
$result = curl_exec($ch);
|
| 39 |
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
| 40 |
$error = curl_error($ch);
|
| 41 |
curl_close($ch);
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
return [
|
| 44 |
'success' => $httpCode >= 200 && $httpCode < 300,
|
| 45 |
'http_code' => $httpCode,
|
| 46 |
'response' => $result,
|
| 47 |
-
'error' => $error
|
|
|
|
|
|
|
| 48 |
];
|
| 49 |
}
|
| 50 |
|
|
@@ -62,15 +78,29 @@ if ($_POST['run_diagnostics'] ?? false) {
|
|
| 62 |
$branchUrl = "https://api.github.com/repos/{$github['owner']}/{$github['repo']}/branches/{$github['branch']}";
|
| 63 |
$diagnostics['branch_test'] = testGitHubAPI($github['token'], $branchUrl);
|
| 64 |
|
| 65 |
-
// 测试 4:
|
| 66 |
-
$testFile = 'diagnostic-test-' . time() . '.txt';
|
| 67 |
-
$testContent = 'VvvebJs Diagnostic Test - ' . date('Y-m-d H:i:s');
|
| 68 |
$createUrl = "https://api.github.com/repos/{$github['owner']}/{$github['repo']}/contents/{$github['path']}{$testFile}";
|
| 69 |
$diagnostics['create_test'] = testGitHubAPI($github['token'], $createUrl, 'PUT', [
|
| 70 |
-
'message' => 'VvvebJs diagnostic test',
|
| 71 |
'content' => base64_encode($testContent),
|
| 72 |
'branch' => $github['branch']
|
| 73 |
]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
}
|
| 75 |
?>
|
| 76 |
|
|
@@ -86,12 +116,13 @@ if ($_POST['run_diagnostics'] ?? false) {
|
|
| 86 |
.status-ok { color: #28a745; }
|
| 87 |
.status-error { color: #dc3545; }
|
| 88 |
.status-warning { color: #ffc107; }
|
|
|
|
| 89 |
</style>
|
| 90 |
</head>
|
| 91 |
<body>
|
| 92 |
<div class="container mt-5">
|
| 93 |
<div class="row">
|
| 94 |
-
<div class="col-md-
|
| 95 |
<h1 class="mb-4">🔍 VvvebJs GitHub 高级诊断</h1>
|
| 96 |
|
| 97 |
<!-- 当前配置 -->
|
|
@@ -102,14 +133,28 @@ if ($_POST['run_diagnostics'] ?? false) {
|
|
| 102 |
<div class="card-body">
|
| 103 |
<div class="row">
|
| 104 |
<div class="col-md-6">
|
| 105 |
-
<p><strong>Token:</strong>
|
| 106 |
-
|
| 107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
</div>
|
| 109 |
<div class="col-md-6">
|
| 110 |
-
<p><strong>Branch:</strong>
|
| 111 |
-
|
| 112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
</div>
|
| 114 |
</div>
|
| 115 |
</div>
|
|
@@ -149,8 +194,10 @@ if ($_POST['run_diagnostics'] ?? false) {
|
|
| 149 |
<?php $user = json_decode($test['response'], true); ?>
|
| 150 |
<br><strong>用户信息:</strong> <?= htmlspecialchars($user['login'] ?? 'Unknown') ?>
|
| 151 |
<br><strong>用户名:</strong> <?= htmlspecialchars($user['name'] ?? 'N/A') ?>
|
|
|
|
| 152 |
<?php elseif (!$test['success']): ?>
|
| 153 |
-
<br><strong
|
|
|
|
| 154 |
<?php endif; ?>
|
| 155 |
</div>
|
| 156 |
</div>
|
|
@@ -171,8 +218,17 @@ if ($_POST['run_diagnostics'] ?? false) {
|
|
| 171 |
<br><strong>仓库全名:</strong> <?= htmlspecialchars($repo['full_name'] ?? 'Unknown') ?>
|
| 172 |
<br><strong>私有仓库:</strong> <?= $repo['private'] ? '是' : '否' ?>
|
| 173 |
<br><strong>默认分支:</strong> <?= htmlspecialchars($repo['default_branch'] ?? 'Unknown') ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
<?php elseif ($test['http_code'] == 404): ?>
|
| 175 |
<br><strong>错误:</strong> 仓库不存在或无访问权限
|
|
|
|
|
|
|
|
|
|
| 176 |
<?php endif; ?>
|
| 177 |
</div>
|
| 178 |
</div>
|
|
@@ -192,6 +248,7 @@ if ($_POST['run_diagnostics'] ?? false) {
|
|
| 192 |
<?php $branch = json_decode($test['response'], true); ?>
|
| 193 |
<br><strong>分支名:</strong> <?= htmlspecialchars($branch['name'] ?? 'Unknown') ?>
|
| 194 |
<br><strong>最��提交:</strong> <?= htmlspecialchars(substr($branch['commit']['sha'] ?? '', 0, 7)) ?>
|
|
|
|
| 195 |
<?php endif; ?>
|
| 196 |
</div>
|
| 197 |
</div>
|
|
@@ -209,9 +266,13 @@ if ($_POST['run_diagnostics'] ?? false) {
|
|
| 209 |
|
| 210 |
<?php if ($test['success']): ?>
|
| 211 |
<br><strong>✅ 成功创建测试文件!GitHub 保存功能正常。</strong>
|
|
|
|
|
|
|
|
|
|
| 212 |
<?php else: ?>
|
| 213 |
<br><strong>错误详情:</strong>
|
| 214 |
<pre class="diagnostic-result mt-2"><?= htmlspecialchars($test['response']) ?></pre>
|
|
|
|
| 215 |
<?php endif; ?>
|
| 216 |
</div>
|
| 217 |
</div>
|
|
@@ -227,7 +288,9 @@ if ($_POST['run_diagnostics'] ?? false) {
|
|
| 227 |
<div class="card-body">
|
| 228 |
<?php
|
| 229 |
$hasErrors = false;
|
| 230 |
-
|
|
|
|
|
|
|
| 231 |
if (!$test['success']) {
|
| 232 |
$hasErrors = true;
|
| 233 |
break;
|
|
@@ -238,12 +301,16 @@ if ($_POST['run_diagnostics'] ?? false) {
|
|
| 238 |
<?php if (!$hasErrors): ?>
|
| 239 |
<div class="alert alert-success">
|
| 240 |
<h5>🎉 所有测试通过!</h5>
|
| 241 |
-
<p>GitHub
|
| 242 |
<ul>
|
| 243 |
-
<li
|
| 244 |
-
<li
|
| 245 |
<li>网络连接是否稳定</li>
|
|
|
|
| 246 |
</ul>
|
|
|
|
|
|
|
|
|
|
| 247 |
</div>
|
| 248 |
<?php else: ?>
|
| 249 |
<div class="alert alert-warning">
|
|
@@ -255,7 +322,8 @@ if ($_POST['run_diagnostics'] ?? false) {
|
|
| 255 |
<ul>
|
| 256 |
<li>检查 <code>GITHUB_TOKEN</code> 环境变量是否正确设置</li>
|
| 257 |
<li>访问 <a href="https://github.com/settings/tokens" target="_blank">GitHub Token 设置</a> 重新生成</li>
|
| 258 |
-
<li>确保 Token 有 <code>repo</code>
|
|
|
|
| 259 |
</ul>
|
| 260 |
</div>
|
| 261 |
<?php endif; ?>
|
|
@@ -264,9 +332,10 @@ if ($_POST['run_diagnostics'] ?? false) {
|
|
| 264 |
<div class="mb-3">
|
| 265 |
<h6>📁 仓库问题</h6>
|
| 266 |
<ul>
|
| 267 |
-
<li>检查 <code>GITHUB_OWNER</code>
|
| 268 |
-
<li>检查 <code>GITHUB_REPO</code>
|
| 269 |
<li>确保仓库存在且 Token 有访���权限</li>
|
|
|
|
| 270 |
</ul>
|
| 271 |
</div>
|
| 272 |
<?php endif; ?>
|
|
@@ -277,6 +346,7 @@ if ($_POST['run_diagnostics'] ?? false) {
|
|
| 277 |
<ul>
|
| 278 |
<li>检查 <code>GITHUB_BRANCH</code> 是否正确(通常是 <code>main</code> 或 <code>master</code>)</li>
|
| 279 |
<li>在 GitHub 仓库中创建对应的分支</li>
|
|
|
|
| 280 |
</ul>
|
| 281 |
</div>
|
| 282 |
<?php endif; ?>
|
|
@@ -285,9 +355,11 @@ if ($_POST['run_diagnostics'] ?? false) {
|
|
| 285 |
<div class="mb-3">
|
| 286 |
<h6>✏️ 写入权限问题</h6>
|
| 287 |
<ul>
|
| 288 |
-
<li>确保 Token 有 <code>repo</code> 的完整权限</li>
|
| 289 |
-
<li
|
| 290 |
-
<li>检查 <code>GITHUB_PATH</code>
|
|
|
|
|
|
|
| 291 |
</ul>
|
| 292 |
</div>
|
| 293 |
<?php endif; ?>
|
|
@@ -295,9 +367,11 @@ if ($_POST['run_diagnostics'] ?? false) {
|
|
| 295 |
<?php endif; ?>
|
| 296 |
|
| 297 |
<div class="mt-4">
|
| 298 |
-
<a href="config.php" class="btn btn-secondary"
|
| 299 |
-
<a href="github-test.php" class="btn btn-info"
|
| 300 |
-
|
|
|
|
|
|
|
| 301 |
</div>
|
| 302 |
</div>
|
| 303 |
</div>
|
|
|
|
| 23 |
curl_setopt($ch, CURLOPT_URL, $endpoint);
|
| 24 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
| 25 |
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
|
| 26 |
+
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
| 27 |
+
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
| 28 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
|
| 29 |
+
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
| 30 |
+
|
| 31 |
+
// 修复:正确设置HTTP头部,包含必需的User-Agent
|
| 32 |
+
$headers = [
|
| 33 |
'Authorization: token ' . $token,
|
| 34 |
+
'User-Agent: VvvebJs-WebBuilder/1.0 (https://github.com/givanz/VvvebJs)',
|
| 35 |
+
'Accept: application/vnd.github.v3+json',
|
| 36 |
+
'X-GitHub-Api-Version: 2022-11-28'
|
| 37 |
+
];
|
| 38 |
|
| 39 |
if ($data) {
|
| 40 |
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
|
| 41 |
+
$headers[] = 'Content-Type: application/json';
|
| 42 |
}
|
| 43 |
|
| 44 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
| 45 |
+
|
| 46 |
$result = curl_exec($ch);
|
| 47 |
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
| 48 |
$error = curl_error($ch);
|
| 49 |
curl_close($ch);
|
| 50 |
|
| 51 |
+
// 详细日志记录
|
| 52 |
+
error_log("GitHub API Test: $method $endpoint - HTTP $httpCode");
|
| 53 |
+
if ($error) {
|
| 54 |
+
error_log("GitHub API cURL Error: $error");
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
return [
|
| 58 |
'success' => $httpCode >= 200 && $httpCode < 300,
|
| 59 |
'http_code' => $httpCode,
|
| 60 |
'response' => $result,
|
| 61 |
+
'error' => $error,
|
| 62 |
+
'endpoint' => $endpoint,
|
| 63 |
+
'method' => $method
|
| 64 |
];
|
| 65 |
}
|
| 66 |
|
|
|
|
| 78 |
$branchUrl = "https://api.github.com/repos/{$github['owner']}/{$github['repo']}/branches/{$github['branch']}";
|
| 79 |
$diagnostics['branch_test'] = testGitHubAPI($github['token'], $branchUrl);
|
| 80 |
|
| 81 |
+
// 测试 4: 测试文件创建权限(使用更安全的测试文件名)
|
| 82 |
+
$testFile = 'test/diagnostic-test-' . time() . '.txt';
|
| 83 |
+
$testContent = 'VvvebJs Diagnostic Test - ' . date('Y-m-d H:i:s') . "\nThis is a test file created by VvvebJs diagnostic tool.";
|
| 84 |
$createUrl = "https://api.github.com/repos/{$github['owner']}/{$github['repo']}/contents/{$github['path']}{$testFile}";
|
| 85 |
$diagnostics['create_test'] = testGitHubAPI($github['token'], $createUrl, 'PUT', [
|
| 86 |
+
'message' => 'VvvebJs diagnostic test - ' . date('Y-m-d H:i:s'),
|
| 87 |
'content' => base64_encode($testContent),
|
| 88 |
'branch' => $github['branch']
|
| 89 |
]);
|
| 90 |
+
|
| 91 |
+
// 如果创建成功,尝试删除测试文件以保持整洁
|
| 92 |
+
if ($diagnostics['create_test']['success']) {
|
| 93 |
+
// 获取创建的文件的SHA以便删除
|
| 94 |
+
$createdFile = json_decode($diagnostics['create_test']['response'], true);
|
| 95 |
+
if (isset($createdFile['content']['sha'])) {
|
| 96 |
+
$deleteData = [
|
| 97 |
+
'message' => 'Clean up diagnostic test file - ' . date('Y-m-d H:i:s'),
|
| 98 |
+
'sha' => $createdFile['content']['sha'],
|
| 99 |
+
'branch' => $github['branch']
|
| 100 |
+
];
|
| 101 |
+
$diagnostics['cleanup_test'] = testGitHubAPI($github['token'], $createUrl, 'DELETE', $deleteData);
|
| 102 |
+
}
|
| 103 |
+
}
|
| 104 |
}
|
| 105 |
?>
|
| 106 |
|
|
|
|
| 116 |
.status-ok { color: #28a745; }
|
| 117 |
.status-error { color: #dc3545; }
|
| 118 |
.status-warning { color: #ffc107; }
|
| 119 |
+
.config-value { background-color: #f8f9fa; padding: 2px 6px; border-radius: 3px; }
|
| 120 |
</style>
|
| 121 |
</head>
|
| 122 |
<body>
|
| 123 |
<div class="container mt-5">
|
| 124 |
<div class="row">
|
| 125 |
+
<div class="col-md-10 mx-auto">
|
| 126 |
<h1 class="mb-4">🔍 VvvebJs GitHub 高级诊断</h1>
|
| 127 |
|
| 128 |
<!-- 当前配置 -->
|
|
|
|
| 133 |
<div class="card-body">
|
| 134 |
<div class="row">
|
| 135 |
<div class="col-md-6">
|
| 136 |
+
<p><strong>Token:</strong>
|
| 137 |
+
<span class="diagnostic-result config-value">
|
| 138 |
+
<?= !empty($github['token']) ? substr($github['token'], 0, 8) . '...' : '❌ 缺失' ?>
|
| 139 |
+
</span>
|
| 140 |
+
</p>
|
| 141 |
+
<p><strong>Owner:</strong>
|
| 142 |
+
<span class="diagnostic-result config-value"><?= htmlspecialchars($github['owner']) ?></span>
|
| 143 |
+
</p>
|
| 144 |
+
<p><strong>Repo:</strong>
|
| 145 |
+
<span class="diagnostic-result config-value"><?= htmlspecialchars($github['repo']) ?></span>
|
| 146 |
+
</p>
|
| 147 |
</div>
|
| 148 |
<div class="col-md-6">
|
| 149 |
+
<p><strong>Branch:</strong>
|
| 150 |
+
<span class="diagnostic-result config-value"><?= htmlspecialchars($github['branch']) ?></span>
|
| 151 |
+
</p>
|
| 152 |
+
<p><strong>Path:</strong>
|
| 153 |
+
<span class="diagnostic-result config-value"><?= htmlspecialchars($github['path']) ?></span>
|
| 154 |
+
</p>
|
| 155 |
+
<p><strong>API URL:</strong>
|
| 156 |
+
<span class="diagnostic-result config-value">https://api.github.com/repos/<?= htmlspecialchars($github['owner']) ?>/<?= htmlspecialchars($github['repo']) ?></span>
|
| 157 |
+
</p>
|
| 158 |
</div>
|
| 159 |
</div>
|
| 160 |
</div>
|
|
|
|
| 194 |
<?php $user = json_decode($test['response'], true); ?>
|
| 195 |
<br><strong>用户信息:</strong> <?= htmlspecialchars($user['login'] ?? 'Unknown') ?>
|
| 196 |
<br><strong>用户名:</strong> <?= htmlspecialchars($user['name'] ?? 'N/A') ?>
|
| 197 |
+
<br><strong>API Rate Limit:</strong> <?= isset($user['id']) ? '✅ 正常' : '⚠️ 可能受限' ?>
|
| 198 |
<?php elseif (!$test['success']): ?>
|
| 199 |
+
<br><strong>错误详情:</strong>
|
| 200 |
+
<pre class="diagnostic-result mt-2"><?= htmlspecialchars($test['error'] ?: $test['response']) ?></pre>
|
| 201 |
<?php endif; ?>
|
| 202 |
</div>
|
| 203 |
</div>
|
|
|
|
| 218 |
<br><strong>仓库全名:</strong> <?= htmlspecialchars($repo['full_name'] ?? 'Unknown') ?>
|
| 219 |
<br><strong>私有仓库:</strong> <?= $repo['private'] ? '是' : '否' ?>
|
| 220 |
<br><strong>默认分支:</strong> <?= htmlspecialchars($repo['default_branch'] ?? 'Unknown') ?>
|
| 221 |
+
<br><strong>权限:</strong>
|
| 222 |
+
<?php
|
| 223 |
+
$permissions = $repo['permissions'] ?? [];
|
| 224 |
+
$canPush = $permissions['push'] ?? false;
|
| 225 |
+
echo $canPush ? '✅ 可写入' : '⚠️ 只读';
|
| 226 |
+
?>
|
| 227 |
<?php elseif ($test['http_code'] == 404): ?>
|
| 228 |
<br><strong>错误:</strong> 仓库不存在或无访问权限
|
| 229 |
+
<?php else: ?>
|
| 230 |
+
<br><strong>错误详情:</strong>
|
| 231 |
+
<pre class="diagnostic-result mt-2"><?= htmlspecialchars($test['response']) ?></pre>
|
| 232 |
<?php endif; ?>
|
| 233 |
</div>
|
| 234 |
</div>
|
|
|
|
| 248 |
<?php $branch = json_decode($test['response'], true); ?>
|
| 249 |
<br><strong>分支名:</strong> <?= htmlspecialchars($branch['name'] ?? 'Unknown') ?>
|
| 250 |
<br><strong>最��提交:</strong> <?= htmlspecialchars(substr($branch['commit']['sha'] ?? '', 0, 7)) ?>
|
| 251 |
+
<br><strong>提交信息:</strong> <?= htmlspecialchars(substr($branch['commit']['commit']['message'] ?? '', 0, 50)) ?><?= strlen($branch['commit']['commit']['message'] ?? '') > 50 ? '...' : '' ?>
|
| 252 |
<?php endif; ?>
|
| 253 |
</div>
|
| 254 |
</div>
|
|
|
|
| 266 |
|
| 267 |
<?php if ($test['success']): ?>
|
| 268 |
<br><strong>✅ 成功创建测试文件!GitHub 保存功能正常。</strong>
|
| 269 |
+
<?php if (isset($diagnostics['cleanup_test']) && $diagnostics['cleanup_test']['success']): ?>
|
| 270 |
+
<br><small class="text-muted">🧹 测试文件已自动清理</small>
|
| 271 |
+
<?php endif; ?>
|
| 272 |
<?php else: ?>
|
| 273 |
<br><strong>错误详情:</strong>
|
| 274 |
<pre class="diagnostic-result mt-2"><?= htmlspecialchars($test['response']) ?></pre>
|
| 275 |
+
<br><strong>请求信息:</strong> <?= $test['method'] ?> <?= htmlspecialchars($test['endpoint']) ?>
|
| 276 |
<?php endif; ?>
|
| 277 |
</div>
|
| 278 |
</div>
|
|
|
|
| 288 |
<div class="card-body">
|
| 289 |
<?php
|
| 290 |
$hasErrors = false;
|
| 291 |
+
$hasWarnings = false;
|
| 292 |
+
foreach ($diagnostics as $key => $test) {
|
| 293 |
+
if ($key === 'cleanup_test') continue; // 跳过清理测试
|
| 294 |
if (!$test['success']) {
|
| 295 |
$hasErrors = true;
|
| 296 |
break;
|
|
|
|
| 301 |
<?php if (!$hasErrors): ?>
|
| 302 |
<div class="alert alert-success">
|
| 303 |
<h5>🎉 所有测试通过!</h5>
|
| 304 |
+
<p>GitHub 配置完全正常,可以正常保存文件。如果编辑器保存仍有问题,请检查:</p>
|
| 305 |
<ul>
|
| 306 |
+
<li>编辑器中的用户认证是否正确</li>
|
| 307 |
+
<li>浏览器控制台是否有JavaScript错误</li>
|
| 308 |
<li>网络连接是否稳定</li>
|
| 309 |
+
<li>防火墙是否阻止了API请求</li>
|
| 310 |
</ul>
|
| 311 |
+
<div class="mt-3">
|
| 312 |
+
<a href="editor.html" class="btn btn-success">🚀 开始使用编辑器</a>
|
| 313 |
+
</div>
|
| 314 |
</div>
|
| 315 |
<?php else: ?>
|
| 316 |
<div class="alert alert-warning">
|
|
|
|
| 322 |
<ul>
|
| 323 |
<li>检查 <code>GITHUB_TOKEN</code> 环境变量是否正确设置</li>
|
| 324 |
<li>访问 <a href="https://github.com/settings/tokens" target="_blank">GitHub Token 设置</a> 重新生成</li>
|
| 325 |
+
<li>确保 Token 有 <code>repo</code> 权限(不仅是 <code>public_repo</code>)</li>
|
| 326 |
+
<li>如果是私有仓库,确保 Token 有完整的私有仓库访问权限</li>
|
| 327 |
</ul>
|
| 328 |
</div>
|
| 329 |
<?php endif; ?>
|
|
|
|
| 332 |
<div class="mb-3">
|
| 333 |
<h6>📁 仓库问题</h6>
|
| 334 |
<ul>
|
| 335 |
+
<li>检查 <code>GITHUB_OWNER</code> 是否是正确的用户名或组织名(区分大小写)</li>
|
| 336 |
+
<li>检查 <code>GITHUB_REPO</code> 是否是正确的仓库名(区分大小写)</li>
|
| 337 |
<li>确保仓库存在且 Token 有访���权限</li>
|
| 338 |
+
<li>如果是组织仓库,确保 Token 有组织权限</li>
|
| 339 |
</ul>
|
| 340 |
</div>
|
| 341 |
<?php endif; ?>
|
|
|
|
| 346 |
<ul>
|
| 347 |
<li>检查 <code>GITHUB_BRANCH</code> 是否正确(通常是 <code>main</code> 或 <code>master</code>)</li>
|
| 348 |
<li>在 GitHub 仓库中创建对应的分支</li>
|
| 349 |
+
<li>确保分支存在且不是空分支</li>
|
| 350 |
</ul>
|
| 351 |
</div>
|
| 352 |
<?php endif; ?>
|
|
|
|
| 355 |
<div class="mb-3">
|
| 356 |
<h6>✏️ 写入权限问题</h6>
|
| 357 |
<ul>
|
| 358 |
+
<li><strong>确保 Token 有 <code>repo</code> 的完整权限</strong>(这是最常见的问题)</li>
|
| 359 |
+
<li>检查仓库是否允许写入(不是只读状态)</li>
|
| 360 |
+
<li>检查 <code>GITHUB_PATH</code> 路径格式是否正确(应以 <code>/</code> 结尾)</li>
|
| 361 |
+
<li>确保目标路径在仓库中存在或可以创建</li>
|
| 362 |
+
<li>检查是否有分支保护规则阻止直接推送</li>
|
| 363 |
</ul>
|
| 364 |
</div>
|
| 365 |
<?php endif; ?>
|
|
|
|
| 367 |
<?php endif; ?>
|
| 368 |
|
| 369 |
<div class="mt-4">
|
| 370 |
+
<a href="config.php" class="btn btn-secondary">⚙️ 返回配置页面</a>
|
| 371 |
+
<a href="github-test.php" class="btn btn-info">🧪 基础测试</a>
|
| 372 |
+
<?php if (!$hasErrors): ?>
|
| 373 |
+
<a href="editor.html" class="btn btn-primary">📝 返回编辑器</a>
|
| 374 |
+
<?php endif; ?>
|
| 375 |
</div>
|
| 376 |
</div>
|
| 377 |
</div>
|
storage.php
CHANGED
|
@@ -359,7 +359,7 @@ class GitHubStorage {
|
|
| 359 |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
|
| 360 |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
| 361 |
|
| 362 |
-
//
|
| 363 |
$headers = [
|
| 364 |
'Authorization: token ' . $this->config['token'],
|
| 365 |
'User-Agent: VvvebJs-WebBuilder/1.0 (https://github.com/givanz/VvvebJs)',
|
|
|
|
| 359 |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
|
| 360 |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
| 361 |
|
| 362 |
+
// 修复:添加GitHub API必需的User-Agent头部和其他必要头部
|
| 363 |
$headers = [
|
| 364 |
'Authorization: token ' . $this->config['token'],
|
| 365 |
'User-Agent: VvvebJs-WebBuilder/1.0 (https://github.com/givanz/VvvebJs)',
|