diff --git a/.idea/misc.xml b/.idea/misc.xml index 33fe132..1f3de73 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -4,8 +4,16 @@ diff --git a/app/FileViewer.php b/app/FileViewer.php index 5a72d3c..e90b65b 100644 --- a/app/FileViewer.php +++ b/app/FileViewer.php @@ -4,6 +4,8 @@ namespace MingTsay\Akanyan; abstract class FileViewer { + protected static bool $orderDesc = false; + protected abstract static function directory(): string; protected abstract static function whitelist(): ?array; @@ -13,10 +15,13 @@ abstract class FileViewer $directory = static::directory(); $whitelist = static::whitelist(); - return array_values(array_filter( + $list = array_values(array_filter( scandir($directory), fn($file) => ($whitelist === null || in_array($file, $whitelist)) && is_file("$directory/$file") )); + + if (static::$orderDesc) rsort($list); + return $list; } public static function read($file): ?string diff --git a/app/LogsViewer.php b/app/LogsViewer.php index 5835706..911532d 100644 --- a/app/LogsViewer.php +++ b/app/LogsViewer.php @@ -4,6 +4,7 @@ namespace MingTsay\Akanyan; class LogsViewer extends FileViewer { + protected static bool $orderDesc = true; protected static function directory(): string { diff --git a/templates/index.php b/templates/index.php index ce92289..28192f9 100644 --- a/templates/index.php +++ b/templates/index.php @@ -50,6 +50,10 @@

【更新紀錄】