mirror of
https://github.com/kuaifan/dootask.git
synced 2026-03-17 19:23:26 +00:00
fix: 修复上传文件夹不立即显示的问题
This commit is contained in:
parent
d8d49d6b5a
commit
5d1d108811
@ -92,7 +92,7 @@ class FileController extends AbstractController
|
|||||||
}
|
}
|
||||||
// 图片直接返回预览地址
|
// 图片直接返回预览地址
|
||||||
foreach ($array as &$item) {
|
foreach ($array as &$item) {
|
||||||
File::handleImageUrl($item);
|
$item = File::handleImageUrl($item);
|
||||||
}
|
}
|
||||||
return Base::retSuccess('success', $array);
|
return Base::retSuccess('success', $array);
|
||||||
}
|
}
|
||||||
@ -663,11 +663,11 @@ class FileController extends AbstractController
|
|||||||
}
|
}
|
||||||
//
|
//
|
||||||
$dirs = explode("/", $webkitRelativePath);
|
$dirs = explode("/", $webkitRelativePath);
|
||||||
|
$addItem = [];
|
||||||
while (count($dirs) > 1) {
|
while (count($dirs) > 1) {
|
||||||
$dirName = array_shift($dirs);
|
$dirName = array_shift($dirs);
|
||||||
if ($dirName) {
|
if ($dirName) {
|
||||||
$pushMsg = [];
|
AbstractModel::transaction(function () use ($dirName, $user, $userid, &$pid, &$addItem) {
|
||||||
AbstractModel::transaction(function () use ($dirName, $user, $userid, &$pid, &$pushMsg) {
|
|
||||||
$dirRow = File::wherePid($pid)->whereType('folder')->whereName($dirName)->lockForUpdate()->first();
|
$dirRow = File::wherePid($pid)->whereType('folder')->whereName($dirName)->lockForUpdate()->first();
|
||||||
if (empty($dirRow)) {
|
if (empty($dirRow)) {
|
||||||
$dirRow = File::createInstance([
|
$dirRow = File::createInstance([
|
||||||
@ -678,7 +678,7 @@ class FileController extends AbstractController
|
|||||||
'created_id' => $user->userid,
|
'created_id' => $user->userid,
|
||||||
]);
|
]);
|
||||||
if ($dirRow->saveBeforePids()) {
|
if ($dirRow->saveBeforePids()) {
|
||||||
$pushMsg[] = File::find($dirRow->id);
|
$addItem[] = File::find($dirRow->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (empty($dirRow)) {
|
if (empty($dirRow)) {
|
||||||
@ -686,7 +686,7 @@ class FileController extends AbstractController
|
|||||||
}
|
}
|
||||||
$pid = $dirRow->id;
|
$pid = $dirRow->id;
|
||||||
});
|
});
|
||||||
foreach ($pushMsg as $tmpRow) {
|
foreach ($addItem as $tmpRow) {
|
||||||
$tmpRow->pushMsg('add', $tmpRow);
|
$tmpRow->pushMsg('add', $tmpRow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -744,7 +744,7 @@ class FileController extends AbstractController
|
|||||||
'created_id' => $user->userid,
|
'created_id' => $user->userid,
|
||||||
]);
|
]);
|
||||||
// 开始创建
|
// 开始创建
|
||||||
return AbstractModel::transaction(function () use ($webkitRelativePath, $type, $user, $data, $file) {
|
return AbstractModel::transaction(function () use ($addItem, $webkitRelativePath, $type, $user, $data, $file) {
|
||||||
$file->size = $data['size'] * 1024;
|
$file->size = $data['size'] * 1024;
|
||||||
$file->saveBeforePids();
|
$file->saveBeforePids();
|
||||||
//
|
//
|
||||||
@ -766,10 +766,11 @@ class FileController extends AbstractController
|
|||||||
$tmpRow = File::find($file->id);
|
$tmpRow = File::find($file->id);
|
||||||
$tmpRow->pushMsg('add', $tmpRow);
|
$tmpRow->pushMsg('add', $tmpRow);
|
||||||
//
|
//
|
||||||
$data = $tmpRow->toArray();
|
$data = File::handleImageUrl($tmpRow->toArray());
|
||||||
$data['full_name'] = $webkitRelativePath ?: $data['name'];
|
$data['full_name'] = $webkitRelativePath ?: $data['name'];
|
||||||
File::handleImageUrl($data);
|
//
|
||||||
return Base::retSuccess($data['name'] . ' 上传成功', $data);
|
$addItem[] = $data;
|
||||||
|
return Base::retSuccess($data['name'] . ' 上传成功', $addItem);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -294,10 +294,10 @@ class File extends AbstractModel
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理返回图片地址
|
* 处理返回图片地址
|
||||||
* @param $item
|
* @param array $item
|
||||||
* @return void
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function handleImageUrl(&$item)
|
public static function handleImageUrl($item)
|
||||||
{
|
{
|
||||||
if (in_array($item['ext'], self::imageExt) ) {
|
if (in_array($item['ext'], self::imageExt) ) {
|
||||||
$content = Base::json2array(FileContent::whereFid($item['id'])->orderByDesc('id')->value('content'));
|
$content = Base::json2array(FileContent::whereFid($item['id'])->orderByDesc('id')->value('content'));
|
||||||
@ -305,6 +305,7 @@ class File extends AbstractModel
|
|||||||
$item['image_url'] = Base::fillUrl($content['url']);
|
$item['image_url'] = Base::fillUrl($content['url']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user