fix: 1. 修复 windows端 右键发送 是直接发送了,没有出现使用md格式发送 2.其他bug修复

This commit is contained in:
weifashi 2023-11-20 15:19:29 +08:00
parent 6db82c8176
commit b644a65f22
6 changed files with 69 additions and 68 deletions

View File

@ -975,49 +975,7 @@ class FileController extends AbstractController
}
/**
* @api {get} api/file/download/check 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. 打包文件
* @api {get} api/file/download/pack 19. 打包文件
*
* @apiDescription 需要token身份
* @apiVersion 1.0.0
@ -1038,31 +996,66 @@ class FileController extends AbstractController
$downName = Request::input('name');
if (!is_array($ids) || empty($ids)) {
abort(403, "Please select the file or folder to download.");
return Base::retError('请选择下载的文件或文件夹');
}
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 = [];
$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;
foreach ($ids as $k => $id) {
$files[] = File::getFilesTree(intval($id), $user, 1);
$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');
}
/**
* @api {get} api/file/download/confirm 21. 确认下载
* @api {get} api/file/download/confirm 20. 确认下载
*
* @apiDescription 需要token身份
* @apiVersion 1.0.0

View File

@ -172,8 +172,11 @@ class WebSocketService implements WebSocketHandlerInterface
*/
public function onClose(Server $server, $fd, $reactorId)
{
Task::deliver(new LineTask($this->getUserid($fd), false)); // 通知离线
$this->deleteUser($fd);
$userid = $this->getUserid($fd);
if($userid){
Task::deliver(new LineTask($userid, false)); // 通知离线
$this->deleteUser($fd);
}
}
/** ****************************************************************************** */

View File

@ -306,7 +306,7 @@ return [
'reload_async' => true,
'max_wait_time' => 60,
'enable_reuse_port' => true,
'enable_coroutine' => false,
'enable_coroutine' => true,
'upload_tmp_dir' => @is_writable('/dev/shm/') ? '/dev/shm' : '/tmp',
'http_compression' => false,
],

View File

@ -479,4 +479,4 @@ Api接口文档
文件总大小已超过1GB请分批下载
保存任务详情至文件失败
保存任务详情至文件失败,请重试
移动成功
移动成功

View File

@ -1030,6 +1030,9 @@ export default {
if ((event.button === undefined || event.button === 0) && this.startRecord()) {
return;
}
if (event.button === 2){
this.showMenu = true;
}
break;
case 'move':

View File

@ -1477,10 +1477,12 @@ export default {
updatePackProgress () {
this.packList.forEach(file=>{
const pack = this.filePackLists.find(({name}) => name == file.name)
file.percentage = Math.max(1, pack.progress);
if (file.status != 'finished' && file.percentage >= 100) {
file.status = 'finished';
this.downloadPackFile(file.name);
if(pack){
file.percentage = Math.max(1, pack.progress);
if (file.status != 'finished' && file.percentage >= 100) {
file.status = 'finished';
this.downloadPackFile(file.name);
}
}
})
},
@ -1514,16 +1516,16 @@ export default {
content: `你确定要打包下载${fileName}吗?`,
okText: '确定',
onOk: async () => {
if( this.packList.find(({ status }) => status === 'packing') ){
$A.messageWarning("请等待打包完成");
return;
}
try {
await this.$store.dispatch("call", {
url: 'file/download/check',
data: { ids },
});
this.startPack(filePackName);
await this.$store.dispatch("call", {
url: 'file/download/pack',
data: { ids, name: filePackName },
});
this.startPack(filePackName);
} catch ({ msg }) {
$A.modalError(msg);
}