Signed-off-by: 吴文峰 <kevin@lmve.net>
This commit is contained in:
@@ -12,32 +12,28 @@ if (empty($apkFiles)) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// 解析 APK 文件名中的日期,格式: __UNI__8A0DE5E__20260424215857.apk
|
||||
// 日期部分: 20260424215857 (YYYYMMDDHHmmss)
|
||||
// 按文件修改时间排序,取最新的
|
||||
$latestFile = null;
|
||||
$latestDate = 0;
|
||||
$latestMtime = 0;
|
||||
|
||||
foreach ($apkFiles as $file) {
|
||||
$filename = basename($file);
|
||||
|
||||
// 提取日期部分 (文件名最后一段,移除 .apk 后缀)
|
||||
if (preg_match('/(\d{14})\.apk$/i', $filename, $matches)) {
|
||||
$date = intval($matches[1]);
|
||||
if ($date > $latestDate) {
|
||||
$latestDate = $date;
|
||||
$latestFile = $file;
|
||||
}
|
||||
$mtime = filemtime($file);
|
||||
if ($mtime > $latestMtime) {
|
||||
$latestMtime = $mtime;
|
||||
$latestFile = $file;
|
||||
}
|
||||
}
|
||||
|
||||
if ($latestFile && file_exists($latestFile)) {
|
||||
// 返回当前目录下的 APK 文件路径
|
||||
$relativePath = './' . basename($latestFile);
|
||||
|
||||
$filename = basename($latestFile);
|
||||
$dateStr = date('Y-m-d H:i:s', $latestMtime);
|
||||
|
||||
// 返回相对于 download_app 目录的路径(需要上跳一级)
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'file' => $relativePath,
|
||||
'date' => substr($latestDate, 0, 8) . ' ' . substr($latestDate, 8, 2) . ':' . substr($latestDate, 10, 2) . ':' . substr($latestDate, 12, 2)
|
||||
'file' => '../' . rawurlencode($filename),
|
||||
'filename' => $filename,
|
||||
'date' => $dateStr
|
||||
]);
|
||||
} else {
|
||||
echo json_encode([
|
||||
|
||||
Reference in New Issue
Block a user