saveFile('README.md', $pagesReadme); $setupResults['pages_dir'] = [ 'success' => $result1, 'path' => 'pages/README.md', 'message' => $result1 ? 'Pages directory created successfully' : 'Failed to create pages directory' ]; // 2. 创建 users 目录 if ($result1) { $usersReadme = "# VvvebJs Users Directory This directory contains individual user folders for VvvebJs. ## User Isolation Each user gets their own directory to store HTML pages: - User directories are named after the username - Files are automatically organized by user - No user can access another user's files Generated: " . date('Y-m-d H:i:s') . " UTC "; $result2 = $githubStorage->saveFile('users/README.md', $usersReadme); $setupResults['users_dir'] = [ 'success' => $result2, 'path' => 'pages/users/README.md', 'message' => $result2 ? 'Users directory created successfully' : 'Failed to create users directory' ]; // 3. 创建当前用户目录 if ($result2) { $userReadme = "# VvvebJs User Directory: $currentUser This is your personal directory for HTML pages created with VvvebJs. ## Your Information - Username: $currentUser - Directory: pages/$userPath - Created: " . date('Y-m-d H:i:s') . " UTC ## Usage All your HTML files will be saved in this directory automatically. You can only access and modify files in your own directory. Happy building! 🚀 "; $result3 = $githubStorage->saveFile($userPath . 'README.md', $userReadme); $setupResults['user_dir'] = [ 'success' => $result3, 'path' => 'pages/' . $userPath . 'README.md', 'message' => $result3 ? "Personal directory created for user: $currentUser" : 'Failed to create personal directory' ]; // 4. 创建一个示例 HTML 文件 if ($result3) { $sampleHtml = ' Welcome to VvvebJs - ' . htmlspecialchars($currentUser) . '

🎉 Welcome to VvvebJs!

Hello, ' . htmlspecialchars($currentUser) . '!

✅ Your VvvebJs environment is now ready!

📁 Your Directory Setup

Personal Directory: pages/' . htmlspecialchars($userPath) . '

Repository: ' . htmlspecialchars($github['owner']) . '/' . htmlspecialchars($github['repo']) . '

Branch: ' . htmlspecialchars($github['branch']) . '

🚀 What\'s Next?

📊 Setup Information

Created: ' . date('Y-m-d H:i:s') . ' UTC

File: welcome-sample.html

Status: Active

🎨 Start Creating 📁 View Repository
'; $result4 = $githubStorage->saveFile($userPath . 'welcome-sample.html', $sampleHtml); $setupResults['sample_file'] = [ 'success' => $result4, 'path' => 'pages/' . $userPath . 'welcome-sample.html', 'message' => $result4 ? 'Sample HTML file created successfully' : 'Failed to create sample file' ]; } } } // 汇总结果 $allSuccess = true; foreach ($setupResults as $result) { if (!$result['success']) { $allSuccess = false; break; } } $setupResults['overall'] = [ 'success' => $allSuccess, 'message' => $allSuccess ? 'All directories and files created successfully!' : 'Some operations failed - check details below' ]; } catch (Exception $e) { error_log("GitHub Directory Setup Error: " . $e->getMessage()); $setupResults['error'] = [ 'success' => false, 'message' => 'Setup failed: ' . $e->getMessage() ]; } } // 检查当前目录状态 function checkDirectoryStatus($githubStorage, $path) { $url = "https://api.github.com/repos/{$githubStorage->owner}/{$githubStorage->repo}/contents/{$path}"; $response = $githubStorage->makeRequest($url, 'GET'); return $response !== false; } $currentStatus = []; if (!empty($github['token'])) { try { $githubStorage = new GitHubStorage($github); $currentStatus = [ 'pages' => checkDirectoryStatus($githubStorage, 'pages'), 'users' => checkDirectoryStatus($githubStorage, 'pages/users'), 'user_dir' => checkDirectoryStatus($githubStorage, 'pages/' . trim($userPath, '/')) ]; } catch (Exception $e) { $currentStatus['error'] = $e->getMessage(); } } ?> VvvebJs GitHub 目录设置

🏗️ VvvebJs GitHub 目录设置工具

🔍 问题诊断

根据日志信息,GitHub API 返回 404 错误,表示 pages/ 目录在仓库中不存在。

此工具将自动创建所需的目录结构来解决这个问题。

📋 当前配置

GitHub 仓库: /

分支:

基础路径:

当前用户:

用户路径:

完整路径:

📁 当前目录状态

检查失败:
基础目录

pages/
用户目录

pages/users/
个人目录

pages//

🛠️ 目录设置工具

🚀 即将创建的目录结构
/ ├── pages/ │ ├── README.md # 目录说明文件 │ └── users/ │ ├── README.md # 用户目录说明 │ └── / │ ├── README.md # 个人目录说明 │ └── welcome-sample.html # 示例HTML文件
设置结果

$result): ?>


错误详情

🎉 设置完成!

GitHub 目录结构已成功创建,现在可以正常使用 VvvebJs 编辑器了。

📖 使用说明

GitHub API 在访问不存在的路径时会返回 404 错误。VvvebJs 需要特定的目录结构:

  • pages/ - 所有HTML页面的基础目录
  • pages/users/ - 用户隔离目录
  • pages/users/用户名/ - 每个用户的个人目录

创建这些目录后,VvvebJs 就能正常保存和读取文件了。

  1. 目录创建成功后,返回 VvvebJs 编辑器
  2. 创建或编辑HTML页面
  3. 点击保存按钮
  4. 文件将自动保存到你的GitHub仓库个人目录中
  5. 可以在GitHub上查看和管理你的文件

常见原因和解决方案:

  • GitHub Token权限不足: 确保Token有repo权限
  • 仓库不存在: 检查仓库名称和所有者名称是否正确
  • 分支不存在: 确认分支名称正确(通常是main或master)
  • 网络问题: 重试设置过程

可以使用其他测试工具进一步诊断问题。