diff --git a/.trae/rules/project_rules.md b/.trae/rules/project_rules.md index cc1782e..5bd81e5 100644 --- a/.trae/rules/project_rules.md +++ b/.trae/rules/project_rules.md @@ -1 +1,7 @@ -弹窗都用Sweet Alert弹窗 \ No newline at end of file +弹窗都用Sweet Alert弹窗 + +说中文!!! + +不要用通用顶栏方式搞顶栏 + +不要出现EndOfFile错误! \ No newline at end of file diff --git a/developer/dashboard.php b/developer/dashboard.php index ceca2a4..cef8ec9 100644 --- a/developer/dashboard.php +++ b/developer/dashboard.php @@ -200,7 +200,8 @@ if (!($conn instanceof mysqli)) {

- 编辑 + 编辑 + 版本控制
diff --git a/developer/version_control.php b/developer/version_control.php new file mode 100644 index 0000000..49dcaa6 --- /dev/null +++ b/developer/version_control.php @@ -0,0 +1,232 @@ +prepare($getAppSql); +if (!$stmt) { + log_error("应用所有权验证查询准备失败: " . $conn->error, __FILE__, __LINE__); + header('Location: dashboard.php?error=验证应用所有权失败'); + exit; +} +$stmt->bind_param("ii", $appId, $developerId); +$stmt->execute(); +$result = $stmt->get_result(); +if ($result->num_rows === 0) { + header('Location: dashboard.php?error=App不存在或无权访问'); + exit; +} +$app = $result->fetch_assoc(); +$platforms = json_decode($app['platforms'], true); + +$success = ''; +$error = ''; +// 处理版本上传请求 +if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['upload_version'])) { + // 验证版本信息 + if (empty($_POST['version']) || empty($_FILES['app_file']['name'])) { + $error = '版本号和安装包不能为空'; + } else { + // 处理App文件上传 + $uploadDir = '../files/'; + if (!is_dir($uploadDir)) { + mkdir($uploadDir, 0755, true); + } + $fileName = basename($_FILES['app_file']['name']); + $targetPath = $uploadDir . $fileName; + + if (move_uploaded_file($_FILES['app_file']['tmp_name'], $targetPath)) { + $version = $_POST['version']; + $changelog = $_POST['changelog'] ?? ''; + + // 插入新版本记录 + $insertVersionSql = "INSERT INTO app_versions (app_id, version, changelog, file_path) VALUES (?, ?, ?, ?)"; + $verStmt = $conn->prepare($insertVersionSql); + if (!$verStmt) { + log_error("版本插入准备失败: " . $conn->error, __FILE__, __LINE__); + $error = '版本保存失败,请稍后再试'; + unlink($targetPath); // 清理已上传文件 + } else { + $verStmt->bind_param("isss", $appId, $version, $changelog, $targetPath); + + if ($verStmt->execute()) { + // 更新应用表中的最新版本 + // 更新应用表中的最新版本 + $updateAppSql = "UPDATE apps SET version = ? WHERE id = ?"; + $updStmt = $conn->prepare($updateAppSql); + if (!$updStmt) { + log_error("应用版本更新准备失败: " . $conn->error, __FILE__, __LINE__); + $error = '更新应用版本失败,请稍后再试'; + unlink($targetPath); // 数据库更新失败,删除文件 + } else { + $updStmt->bind_param("si", $version, $appId); + $updStmt->execute(); + $success = '版本上传成功'; + } + } else { + $error = '版本保存失败: '. $conn->error; + unlink($targetPath); // 数据库更新失败,删除文件 + } + } + } else { + $error = '文件上传失败'; + } + } +} + +// 获取现有版本列表 +$versions = []; +$getVersionsSql = "SELECT * FROM app_versions WHERE app_id = ? ORDER BY id DESC"; +$verStmt = $conn->prepare($getVersionsSql); +if (!$verStmt) { + log_error("版本查询准备失败: " . $conn->error, __FILE__, __LINE__); + $error = '获取版本列表失败,请稍后再试'; +} else { + $verStmt->bind_param("i", $appId); + $verStmt->execute(); + $versionsResult = $verStmt->get_result(); + while ($ver = $versionsResult->fetch_assoc()) { + $versions[] = $ver; + } +} +?> + + + + + + 版本控制 - <?php echo htmlspecialchars($app['name']); ?> + + + + + + + + +
+ + + + + + + +
+
+

应用版本控制:

+
+
+

上传新版本

+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+ + 返回 +
+ +
+ +

版本历史

+ +
暂无版本记录
+ +
+ + + + + + + + + + + + + + + + + + + +
版本号上传时间更新日志操作
+ 下载 + + 当前版本 + +
+
+ +
+
+
+ + + + \ No newline at end of file diff --git a/files/fabric-installer-1.0.1.jar b/files/fabric-installer-1.0.1.jar deleted file mode 100644 index a85af08..0000000 Binary files a/files/fabric-installer-1.0.1.jar and /dev/null differ