false, 'message' => 'config_json 不是有效的 JSON']);
exit;
}
if ($editId) {
$db->update('projects', [
'display_name' => $displayName,
'description' => $description,
'icon_url' => $iconUrl,
'enabled' => $enabled,
'config_json' => $configJson,
], ['id' => $editId]);
} else {
$db->insert('projects', [
'project_id' => $projectId,
'display_name' => $displayName,
'description' => $description,
'icon_url' => $iconUrl,
'enabled' => $enabled,
'config_json' => $configJson,
]);
}
echo json_encode(['success' => true]);
exit;
case 'delete_project':
$id = $_POST['id'] ?? 0;
$db->delete('projects', ['id' => $id]);
echo json_encode(['success' => true]);
exit;
case 'save_installer_config':
$filenameRules = $_POST['filename_rules'] ?? '[]';
$commandRules = $_POST['command_rules'] ?? '[]';
$defaultProject = $_POST['default_project'] ?? 'r0_arena';
$defaultMode = $_POST['default_mode'] ?? 'full';
$db->update('installer_config', [
'filename_rules' => $filenameRules,
'command_rules' => $commandRules,
'default_project' => $defaultProject,
'default_mode' => $defaultMode,
], ['config_key' => 'global']);
echo json_encode(['success' => true]);
exit;
case 'save_version':
$projectId = $_POST['project_id'] ?? '';
$version = $_POST['version'] ?? '';
$downloadUrl = $_POST['download_url'] ?? '';
$fileSize = intval($_POST['file_size'] ?? 0);
$changelog = $_POST['changelog'] ?? '';
$threads = intval($_POST['threads'] ?? 8);
$extraDownloads = $_POST['extra_downloads'] ?? '{}';
$runtimeUrls = $_POST['runtime_urls'] ?? '{}';
$isLatest = isset($_POST['is_latest']) ? 1 : 0;
$silentUpdate = isset($_POST['silent_update']) ? 1 : 0;
$editId = $_POST['edit_id'] ?? '';
if ($isLatest) {
$db->update('project_versions', ['is_latest' => 0], ['project_id' => $projectId]);
}
if ($editId) {
$db->update('project_versions', [
'version' => $version,
'download_url' => $downloadUrl,
'file_size' => $fileSize,
'changelog' => $changelog,
'threads' => $threads,
'extra_downloads' => $extraDownloads,
'runtime_urls' => $runtimeUrls,
'is_latest' => $isLatest,
'silent_update' => $silentUpdate,
], ['id' => $editId]);
} else {
$db->insert('project_versions', [
'project_id' => $projectId,
'version' => $version,
'download_url' => $downloadUrl,
'file_size' => $fileSize,
'changelog' => $changelog,
'threads' => $threads,
'extra_downloads' => $extraDownloads,
'runtime_urls' => $runtimeUrls,
'is_latest' => $isLatest,
'silent_update' => $silentUpdate,
]);
}
echo json_encode(['success' => true]);
exit;
case 'delete_version':
$id = $_POST['id'] ?? 0;
$db->delete('project_versions', ['id' => $id]);
echo json_encode(['success' => true]);
exit;
case 'save_patch':
$projectId = $_POST['project_id'] ?? '';
$fromVersion = $_POST['from_version'] ?? '';
$toVersion = $_POST['to_version'] ?? '';
$downloadUrl = $_POST['download_url'] ?? '';
$fileSize = intval($_POST['file_size'] ?? 0);
$changelog = $_POST['changelog'] ?? '';
$editId = $_POST['edit_id'] ?? '';
if ($editId) {
$db->update('project_patches', [
'from_version' => $fromVersion,
'to_version' => $toVersion,
'download_url' => $downloadUrl,
'file_size' => $fileSize,
'changelog' => $changelog,
], ['id' => $editId]);
} else {
$db->insert('project_patches', [
'project_id' => $projectId,
'from_version' => $fromVersion,
'to_version' => $toVersion,
'download_url' => $downloadUrl,
'file_size' => $fileSize,
'changelog' => $changelog,
]);
}
echo json_encode(['success' => true]);
exit;
case 'delete_patch':
$id = $_POST['id'] ?? 0;
$db->delete('project_patches', ['id' => $id]);
echo json_encode(['success' => true]);
exit;
}
echo json_encode(['success' => false, 'message' => '未知操作']);
exit;
}
// ========== 页面渲染 ==========
function showLoginPage($error = '') {
?>
R0Installer 管理后台 - 登录
R0Installer 管理后台
= htmlspecialchars($error) ?>
select('projects', '*');
?>
R0Installer 管理后台
count('project_versions');
$patchCount = $db->count('project_patches');
?>
仪表盘
= count($projects) ?>
项目总数
项目列表
| 项目ID | 名称 | 状态 |
= htmlspecialchars($p['project_id']) ?> |
= htmlspecialchars($p['display_name']) ?> |
= $p['enabled'] ? '启用' : '禁用' ?> |
项目管理
| ID | 项目ID | 名称 | 状态 | 更新时间 | 操作 |
| = $p['id'] ?> |
= htmlspecialchars($p['project_id']) ?> |
= htmlspecialchars($p['display_name']) ?> |
= $p['enabled'] ? '启用' : '禁用' ?> |
= $p['updated_at'] ?> |
|
$filterProject] : [];
$where['ORDER'] = ['id' => 'DESC'];
$versions = $db->select('project_versions', '*', $where);
?>
版本管理
| ID | 项目 | 版本 | 最新 | 静默更新 | 线程数 | 创建时间 | 操作 |
| = $v['id'] ?> |
= htmlspecialchars($v['project_id']) ?> |
= htmlspecialchars($v['version']) ?> |
= $v['is_latest'] ? '是' : '否' ?> |
= !empty($v['silent_update']) ? '静默' : '界面' ?> |
= $v['threads'] ?> |
= $v['created_at'] ?> |
|
$filterProject] : [];
$where['ORDER'] = ['id' => 'DESC'];
$patches = $db->select('project_patches', '*', $where);
?>
增量包管理
| ID | 项目 | 从版本 | 到版本 | 文件大小 | 创建时间 | 操作 |
| = $p['id'] ?> |
= htmlspecialchars($p['project_id']) ?> |
= htmlspecialchars($p['from_version']) ?> |
= htmlspecialchars($p['to_version']) ?> |
= number_format($p['file_size']) ?> |
= $p['created_at'] ?> |
|
增量包配置
get('installer_config', '*', ['config_key' => 'global']);
$filenameRules = $config ? $config['filename_rules'] : '[]';
$commandRules = $config ? $config['command_rules'] : '[]';
// 格式化 JSON 显示
$fr = json_decode($filenameRules, true);
$cr = json_decode($commandRules, true);
$frFormatted = $fr ? json_encode($fr, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT) : '[]';
$crFormatted = $cr ? json_encode($cr, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT) : '[]';
?>
安装器全局配置