mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-11 18:42:54 +00:00
fix: 1. 修复 windows端 右键发送 是直接发送了,没有出现使用md格式发送 2.其他bug修复
This commit is contained in:
parent
6db82c8176
commit
b644a65f22
@ -975,49 +975,7 @@ class FileController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {get} api/file/download/check 19. 检测下载
|
* @api {get} api/file/download/pack 19. 打包文件
|
||||||
*
|
|
||||||
* @apiDescription 需要token身份
|
|
||||||
* @apiVersion 1.0.0
|
|
||||||
* @apiGroup file
|
|
||||||
* @apiName download__check
|
|
||||||
*
|
|
||||||
* @apiParam {Array} [ids] 文件ID,格式: [id, id2, id3]
|
|
||||||
*
|
|
||||||
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
|
|
||||||
* @apiSuccess {String} msg 返回信息(错误描述)
|
|
||||||
* @apiSuccess {Object} data 返回数据
|
|
||||||
*/
|
|
||||||
public function download__check(){
|
|
||||||
$user = User::auth();
|
|
||||||
$ids = Request::input('ids');
|
|
||||||
|
|
||||||
if (!is_array($ids) || empty($ids)) {
|
|
||||||
return Base::retError('请选择下载的文件或文件夹');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count($ids) > 100) {
|
|
||||||
return Base::retError('一次最多只能下载100个文件或文件夹');
|
|
||||||
}
|
|
||||||
|
|
||||||
$files = [];
|
|
||||||
$totalSize = 0;
|
|
||||||
AbstractModel::transaction(function() use ($user, $ids, &$files, &$totalSize) {
|
|
||||||
foreach ($ids as $k => $id) {
|
|
||||||
$files[] = File::getFilesTree(intval($id), $user, 1);
|
|
||||||
$totalSize += $files[$k]->totalSize;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if ($totalSize > File::zipMaxSize) {
|
|
||||||
throw new ApiException('文件总大小已超过1GB,请分批下载');
|
|
||||||
}
|
|
||||||
|
|
||||||
return Base::retSuccess('success');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @api {get} api/file/download/pack 20. 打包文件
|
|
||||||
*
|
*
|
||||||
* @apiDescription 需要token身份
|
* @apiDescription 需要token身份
|
||||||
* @apiVersion 1.0.0
|
* @apiVersion 1.0.0
|
||||||
@ -1038,31 +996,66 @@ class FileController extends AbstractController
|
|||||||
$downName = Request::input('name');
|
$downName = Request::input('name');
|
||||||
|
|
||||||
if (!is_array($ids) || empty($ids)) {
|
if (!is_array($ids) || empty($ids)) {
|
||||||
abort(403, "Please select the file or folder to download.");
|
return Base::retError('请选择下载的文件或文件夹');
|
||||||
}
|
}
|
||||||
if (count($ids) > 100) {
|
if (count($ids) > 100) {
|
||||||
abort(403, "You can download a maximum of 100 files or folders at a time.");
|
return Base::retError('一次最多可以下载100个文件或文件夹');
|
||||||
|
}
|
||||||
|
if (count($ids) > 100) {
|
||||||
|
return Base::retError('一次最多可以下载100个文件或文件夹');
|
||||||
}
|
}
|
||||||
|
|
||||||
$files = [];
|
$files = [];
|
||||||
$totalSize = 0;
|
$totalSize = 0;
|
||||||
AbstractModel::transaction(function() use ($user, $ids, &$files, &$totalSize) {
|
|
||||||
foreach ($ids as $k => $id) {
|
foreach ($ids as $k => $id) {
|
||||||
$files[] = File::getFilesTree(intval($id), $user, 1);
|
$files[] = File::getFilesTree(intval($id), $user, 1);
|
||||||
$totalSize += $files[$k]->totalSize;
|
$totalSize += $files[$k]->totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($totalSize > File::zipMaxSize) {
|
||||||
|
return Base::retError('文件总大小已超过1GB,请分批下载');
|
||||||
|
}
|
||||||
|
|
||||||
|
$zip = new \ZipArchive();
|
||||||
|
$zipName = 'temp/download/' . date("Ym") . '/' . $user->userid . '/' . $downName;
|
||||||
|
$zipPath = storage_path('app/'.$zipName);
|
||||||
|
Base::makeDir(dirname($zipPath));
|
||||||
|
|
||||||
|
if ($zip->open($zipPath, ZipArchive::CREATE | ZipArchive::OVERWRITE) !== true) {
|
||||||
|
return Base::retError('创建压缩文件失败');
|
||||||
|
}
|
||||||
|
|
||||||
|
go(function() use ($zip, $files, $downName) {
|
||||||
|
Coroutine::sleep(0.1);
|
||||||
|
// 压缩进度
|
||||||
|
$progress = 0;
|
||||||
|
$zip->registerProgressCallback(0.05, function($ratio) use ($downName, &$progress) {
|
||||||
|
$progress = round($ratio * 100);
|
||||||
|
File::filePushMsg('compress', [
|
||||||
|
'name'=> $downName,
|
||||||
|
'progress' => $progress
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
//
|
||||||
|
foreach ($files as $file) {
|
||||||
|
File::addFileTreeToZip($zip, $file);
|
||||||
|
}
|
||||||
|
$zip->close();
|
||||||
|
//
|
||||||
|
if ($progress < 100) {
|
||||||
|
File::filePushMsg('compress', [
|
||||||
|
'name'=> $downName,
|
||||||
|
'progress' => 100
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if ($totalSize > File::zipMaxSize) {
|
|
||||||
abort(403, "The total size of the file exceeds 1GB. Please download it in batches.");
|
|
||||||
}
|
|
||||||
|
|
||||||
Task::deliver(new FilePackTask($user, $files, $downName));
|
|
||||||
return Base::retSuccess('success');
|
return Base::retSuccess('success');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {get} api/file/download/confirm 21. 确认下载
|
* @api {get} api/file/download/confirm 20. 确认下载
|
||||||
*
|
*
|
||||||
* @apiDescription 需要token身份
|
* @apiDescription 需要token身份
|
||||||
* @apiVersion 1.0.0
|
* @apiVersion 1.0.0
|
||||||
|
|||||||
@ -172,8 +172,11 @@ class WebSocketService implements WebSocketHandlerInterface
|
|||||||
*/
|
*/
|
||||||
public function onClose(Server $server, $fd, $reactorId)
|
public function onClose(Server $server, $fd, $reactorId)
|
||||||
{
|
{
|
||||||
Task::deliver(new LineTask($this->getUserid($fd), false)); // 通知离线
|
$userid = $this->getUserid($fd);
|
||||||
$this->deleteUser($fd);
|
if($userid){
|
||||||
|
Task::deliver(new LineTask($userid, false)); // 通知离线
|
||||||
|
$this->deleteUser($fd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** ****************************************************************************** */
|
/** ****************************************************************************** */
|
||||||
|
|||||||
@ -306,7 +306,7 @@ return [
|
|||||||
'reload_async' => true,
|
'reload_async' => true,
|
||||||
'max_wait_time' => 60,
|
'max_wait_time' => 60,
|
||||||
'enable_reuse_port' => true,
|
'enable_reuse_port' => true,
|
||||||
'enable_coroutine' => false,
|
'enable_coroutine' => true,
|
||||||
'upload_tmp_dir' => @is_writable('/dev/shm/') ? '/dev/shm' : '/tmp',
|
'upload_tmp_dir' => @is_writable('/dev/shm/') ? '/dev/shm' : '/tmp',
|
||||||
'http_compression' => false,
|
'http_compression' => false,
|
||||||
],
|
],
|
||||||
|
|||||||
@ -479,4 +479,4 @@ Api接口文档
|
|||||||
文件总大小已超过1GB,请分批下载
|
文件总大小已超过1GB,请分批下载
|
||||||
保存任务详情至文件失败
|
保存任务详情至文件失败
|
||||||
保存任务详情至文件失败,请重试
|
保存任务详情至文件失败,请重试
|
||||||
移动成功
|
移动成功
|
||||||
|
|||||||
@ -1030,6 +1030,9 @@ export default {
|
|||||||
if ((event.button === undefined || event.button === 0) && this.startRecord()) {
|
if ((event.button === undefined || event.button === 0) && this.startRecord()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (event.button === 2){
|
||||||
|
this.showMenu = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'move':
|
case 'move':
|
||||||
|
|||||||
@ -1477,10 +1477,12 @@ export default {
|
|||||||
updatePackProgress () {
|
updatePackProgress () {
|
||||||
this.packList.forEach(file=>{
|
this.packList.forEach(file=>{
|
||||||
const pack = this.filePackLists.find(({name}) => name == file.name)
|
const pack = this.filePackLists.find(({name}) => name == file.name)
|
||||||
file.percentage = Math.max(1, pack.progress);
|
if(pack){
|
||||||
if (file.status != 'finished' && file.percentage >= 100) {
|
file.percentage = Math.max(1, pack.progress);
|
||||||
file.status = 'finished';
|
if (file.status != 'finished' && file.percentage >= 100) {
|
||||||
this.downloadPackFile(file.name);
|
file.status = 'finished';
|
||||||
|
this.downloadPackFile(file.name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@ -1514,16 +1516,16 @@ export default {
|
|||||||
content: `你确定要打包下载${fileName}吗?`,
|
content: `你确定要打包下载${fileName}吗?`,
|
||||||
okText: '确定',
|
okText: '确定',
|
||||||
onOk: async () => {
|
onOk: async () => {
|
||||||
|
if( this.packList.find(({ status }) => status === 'packing') ){
|
||||||
|
$A.messageWarning("请等待打包完成");
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
await this.$store.dispatch("call", {
|
|
||||||
url: 'file/download/check',
|
|
||||||
data: { ids },
|
|
||||||
});
|
|
||||||
this.startPack(filePackName);
|
|
||||||
await this.$store.dispatch("call", {
|
await this.$store.dispatch("call", {
|
||||||
url: 'file/download/pack',
|
url: 'file/download/pack',
|
||||||
data: { ids, name: filePackName },
|
data: { ids, name: filePackName },
|
||||||
});
|
});
|
||||||
|
this.startPack(filePackName);
|
||||||
} catch ({ msg }) {
|
} catch ({ msg }) {
|
||||||
$A.modalError(msg);
|
$A.modalError(msg);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user