mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-12 03:01:12 +00:00
feat: 发布接口只保留最近两个版本
This commit is contained in:
parent
f2538884ea
commit
02bd022c62
@ -222,6 +222,7 @@ class IndexController extends InvokeController
|
|||||||
public function desktop__publish($name = '')
|
public function desktop__publish($name = '')
|
||||||
{
|
{
|
||||||
$publishVersion = Request::header('publish-version');
|
$publishVersion = Request::header('publish-version');
|
||||||
|
$fileNum = Request::get('file_num', 1);
|
||||||
$latestFile = public_path("uploads/desktop/latest");
|
$latestFile = public_path("uploads/desktop/latest");
|
||||||
$latestVersion = file_exists($latestFile) ? trim(file_get_contents($latestFile)) : "0.0.1";
|
$latestVersion = file_exists($latestFile) ? trim(file_get_contents($latestFile)) : "0.0.1";
|
||||||
if (strtolower($name) === 'latest') {
|
if (strtolower($name) === 'latest') {
|
||||||
@ -229,6 +230,7 @@ class IndexController extends InvokeController
|
|||||||
}
|
}
|
||||||
// 上传
|
// 上传
|
||||||
if (preg_match("/^\d+\.\d+\.\d+$/", $publishVersion)) {
|
if (preg_match("/^\d+\.\d+\.\d+$/", $publishVersion)) {
|
||||||
|
$uploadSuccessFileNum = (int)Cache::get($publishVersion, 0);
|
||||||
$publishKey = Request::header('publish-key');
|
$publishKey = Request::header('publish-key');
|
||||||
if ($publishKey !== env('APP_KEY')) {
|
if ($publishKey !== env('APP_KEY')) {
|
||||||
return Base::retError("key error");
|
return Base::retError("key error");
|
||||||
@ -243,6 +245,20 @@ class IndexController extends InvokeController
|
|||||||
]);
|
]);
|
||||||
if (Base::isSuccess($res)) {
|
if (Base::isSuccess($res)) {
|
||||||
file_put_contents($latestFile, $publishVersion);
|
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;
|
return $res;
|
||||||
}
|
}
|
||||||
@ -254,7 +270,7 @@ class IndexController extends InvokeController
|
|||||||
$lists = Base::readDir($dirPath);
|
$lists = Base::readDir($dirPath);
|
||||||
$files = [];
|
$files = [];
|
||||||
foreach ($lists as $file) {
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
$fileName = Base::leftDelete($file, $dirPath);
|
$fileName = Base::leftDelete($file, $dirPath);
|
||||||
|
|||||||
@ -178,7 +178,7 @@ services:
|
|||||||
|
|
||||||
okr:
|
okr:
|
||||||
container_name: "dootask-okr-${APP_ID}"
|
container_name: "dootask-okr-${APP_ID}"
|
||||||
image: "kuaifan/doookr:0.0.34"
|
image: "kuaifan/doookr:0.0.35"
|
||||||
environment:
|
environment:
|
||||||
TZ: "${TIMEZONE:-PRC}"
|
TZ: "${TIMEZONE:-PRC}"
|
||||||
DOO_TASK_URL: "http://${APP_IPPR}.3"
|
DOO_TASK_URL: "http://${APP_IPPR}.3"
|
||||||
|
|||||||
11
electron/build.js
vendored
11
electron/build.js
vendored
@ -126,6 +126,16 @@ function genericPublish({url, key, version, output}) {
|
|||||||
if (err) {
|
if (err) {
|
||||||
console.warn(err)
|
console.warn(err)
|
||||||
} else {
|
} 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 = {}
|
const uploadOras = {}
|
||||||
for (const filename of files) {
|
for (const filename of files) {
|
||||||
const localFile = path.join(filePath, filename)
|
const localFile = path.join(filePath, filename)
|
||||||
@ -135,6 +145,7 @@ function genericPublish({url, key, version, output}) {
|
|||||||
uploadOras[filename] = ora(`Upload [0%] ${filename}`).start()
|
uploadOras[filename] = ora(`Upload [0%] ${filename}`).start()
|
||||||
const formData = new FormData()
|
const formData = new FormData()
|
||||||
formData.append("file", fs.createReadStream(localFile));
|
formData.append("file", fs.createReadStream(localFile));
|
||||||
|
formData.append("file_num", uploadFileNum);
|
||||||
await axiosAutoTry({
|
await axiosAutoTry({
|
||||||
axios: {
|
axios: {
|
||||||
method: 'post',
|
method: 'post',
|
||||||
|
|||||||
@ -30,7 +30,9 @@
|
|||||||
|
|
||||||
.mirror-nav {
|
.mirror-nav {
|
||||||
width: 1180px;
|
width: 1180px;
|
||||||
margin: 20px auto 10px
|
margin: 20px auto 10px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
|
|
||||||
.table {
|
.table {
|
||||||
@ -81,6 +83,21 @@
|
|||||||
padding: 0;
|
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 {
|
.fileDate, .fileName, .fileSize {
|
||||||
padding-left: 8px
|
padding-left: 8px
|
||||||
}
|
}
|
||||||
@ -162,7 +179,10 @@
|
|||||||
<body>
|
<body>
|
||||||
@extends('ie')
|
@extends('ie')
|
||||||
|
|
||||||
<h1 class="mirror-nav">Download of v{{ $version }}</h1>
|
<h1 class="mirror-nav">
|
||||||
|
<p>Download of v{{ $version }}</p>
|
||||||
|
<a class="download-other-btn" href="https://www.dootask.com/desktop/publish/latest" target="_blank">Other Versions</a>
|
||||||
|
</h1>
|
||||||
<div class="mirror">
|
<div class="mirror">
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user