diff --git a/app/Http/Controllers/IndexController.php b/app/Http/Controllers/IndexController.php index c51b63195..97f75ebd3 100755 --- a/app/Http/Controllers/IndexController.php +++ b/app/Http/Controllers/IndexController.php @@ -222,6 +222,7 @@ class IndexController extends InvokeController public function desktop__publish($name = '') { $publishVersion = Request::header('publish-version'); + $fileNum = Request::get('file_num', 1); $latestFile = public_path("uploads/desktop/latest"); $latestVersion = file_exists($latestFile) ? trim(file_get_contents($latestFile)) : "0.0.1"; if (strtolower($name) === 'latest') { @@ -229,6 +230,7 @@ class IndexController extends InvokeController } // 上传 if (preg_match("/^\d+\.\d+\.\d+$/", $publishVersion)) { + $uploadSuccessFileNum = (int)Cache::get($publishVersion, 0); $publishKey = Request::header('publish-key'); if ($publishKey !== env('APP_KEY')) { return Base::retError("key error"); @@ -243,6 +245,20 @@ class IndexController extends InvokeController ]); if (Base::isSuccess($res)) { file_put_contents($latestFile, $publishVersion); + $uploadSuccessFileNum = $uploadSuccessFileNum + 1; + Cache::set($publishVersion, $uploadSuccessFileNum, 720); + } + if ($uploadSuccessFileNum >= $fileNum){ + $directoryPath = public_path("uploads/desktop"); + $files = array_filter(scandir($directoryPath), function($file) use($directoryPath) { + return is_dir($directoryPath . '/' . $file) && $file != '.' && $file != '..'; + }); + sort($files); + foreach ($files as $key => $file) { + if ($file != $publishVersion && $key < count($files) - 2) { + Base::deleteDirAndFile($directoryPath . '/' . $file); + } + } } return $res; } @@ -254,7 +270,7 @@ class IndexController extends InvokeController $lists = Base::readDir($dirPath); $files = []; foreach ($lists as $file) { - if (str_ends_with($file, '.yml') || str_ends_with($file, '.yaml')) { + if (str_ends_with($file, '.yml') || str_ends_with($file, '.yaml') || str_ends_with($file, '.blockmap')) { continue; } $fileName = Base::leftDelete($file, $dirPath); diff --git a/docker-compose.yml b/docker-compose.yml index 7bb097cd6..62299c412 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -178,7 +178,7 @@ services: okr: container_name: "dootask-okr-${APP_ID}" - image: "kuaifan/doookr:0.0.34" + image: "kuaifan/doookr:0.0.35" environment: TZ: "${TIMEZONE:-PRC}" DOO_TASK_URL: "http://${APP_IPPR}.3" diff --git a/electron/build.js b/electron/build.js index 062d03535..ac094a32a 100644 --- a/electron/build.js +++ b/electron/build.js @@ -126,6 +126,16 @@ function genericPublish({url, key, version, output}) { if (err) { console.warn(err) } else { + let uploadFileNum = 0; + for (const filename of files) { + const localFile = path.join(filePath, filename) + if (fs.existsSync(localFile)) { + const fileStat = fs.statSync(localFile) + if (fileStat.isFile()) { + uploadFileNum += 1; + } + } + } const uploadOras = {} for (const filename of files) { const localFile = path.join(filePath, filename) @@ -135,6 +145,7 @@ function genericPublish({url, key, version, output}) { uploadOras[filename] = ora(`Upload [0%] ${filename}`).start() const formData = new FormData() formData.append("file", fs.createReadStream(localFile)); + formData.append("file_num", uploadFileNum); await axiosAutoTry({ axios: { method: 'post', diff --git a/resources/views/desktop.blade.php b/resources/views/desktop.blade.php index ef7c0d76f..a3f4e0907 100755 --- a/resources/views/desktop.blade.php +++ b/resources/views/desktop.blade.php @@ -30,7 +30,9 @@ .mirror-nav { width: 1180px; - margin: 20px auto 10px + margin: 20px auto 10px; + display: flex; + justify-content: space-between; } .table { @@ -81,6 +83,21 @@ padding: 0; } + .fileName { + position: relative; + } + + .download-other-btn { + padding: 2px 12px; + color: #088acb; + border-radius: 8px; + margin-top: 2px; + border: 1px solid #088acb; + font-size: 14px; + height: 30px; + line-height: 30px; + } + .fileDate, .fileName, .fileSize { padding-left: 8px } @@ -162,7 +179,10 @@ @extends('ie') -

Download of v{{ $version }}

+

+

Download of v{{ $version }}

+ Other Versions +