mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-12 03:01:12 +00:00
fix: 目录拼错的情况
This commit is contained in:
parent
df8fdd56ba
commit
cfda858d87
@ -237,13 +237,13 @@ class IndexController extends InvokeController
|
|||||||
if (str_ends_with($file, '.yml') || str_ends_with($file, '.yaml') || str_ends_with($file, '.blockmap')) {
|
if (str_ends_with($file, '.yml') || str_ends_with($file, '.yaml') || str_ends_with($file, '.blockmap')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$fileName = Base::leftDelete($file, $dirPath);
|
$fileName = basename($file, $dirPath);
|
||||||
$fileSize = filesize($file);
|
$fileSize = filesize($file);
|
||||||
$files[] = [
|
$files[] = [
|
||||||
'name' => substr($fileName, 1),
|
'name' => $fileName,
|
||||||
'time' => date("Y-m-d H:i:s", filemtime($file)),
|
'time' => date("Y-m-d H:i:s", filemtime($file)),
|
||||||
'size' => $fileSize > 0 ? Base::readableBytes($fileSize) : 0,
|
'size' => $fileSize > 0 ? Base::readableBytes($fileSize) : 0,
|
||||||
'url' => Base::fillUrl($path . $fileName),
|
'url' => Base::fillUrl(Base::joinPath($path, $fileName)),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
|||||||
@ -2671,10 +2671,14 @@ class Base
|
|||||||
*/
|
*/
|
||||||
public static function joinPath(...$segments)
|
public static function joinPath(...$segments)
|
||||||
{
|
{
|
||||||
$trimmedSegments = array_map(function ($segment) {
|
if (count($segments) === 0) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
$array = array_map(function ($segment) {
|
||||||
return trim($segment, DIRECTORY_SEPARATOR);
|
return trim($segment, DIRECTORY_SEPARATOR);
|
||||||
}, $segments);
|
}, $segments);
|
||||||
return implode(DIRECTORY_SEPARATOR, $trimmedSegments);
|
$prefix = str_starts_with($segments[0], DIRECTORY_SEPARATOR) ? DIRECTORY_SEPARATOR : "";
|
||||||
|
return $prefix . implode(DIRECTORY_SEPARATOR, $array);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user