set order to desc for logs viewer
This commit is contained in:
parent
db313f5eef
commit
976e10659f
4 changed files with 21 additions and 3 deletions
12
.idea/misc.xml
generated
12
.idea/misc.xml
generated
|
|
@ -4,8 +4,16 @@
|
||||||
<option name="openedFilesInfos">
|
<option name="openedFilesInfos">
|
||||||
<list>
|
<list>
|
||||||
<OpenedFileInfo>
|
<OpenedFileInfo>
|
||||||
<option name="caretOffset" value="163" />
|
<option name="caretOffset" value="166" />
|
||||||
<option name="fileUrl" value="file://$PROJECT_DIR$/templates/partials/menu.php" />
|
<option name="fileUrl" value="file://$PROJECT_DIR$/app/Auth.php" />
|
||||||
|
</OpenedFileInfo>
|
||||||
|
<OpenedFileInfo>
|
||||||
|
<option name="caretOffset" value="1004" />
|
||||||
|
<option name="fileUrl" value="file://$PROJECT_DIR$/app/App.php" />
|
||||||
|
</OpenedFileInfo>
|
||||||
|
<OpenedFileInfo>
|
||||||
|
<option name="caretOffset" value="0" />
|
||||||
|
<option name="fileUrl" value="file://$PROJECT_DIR$/templates/template.php" />
|
||||||
</OpenedFileInfo>
|
</OpenedFileInfo>
|
||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@ namespace MingTsay\Akanyan;
|
||||||
|
|
||||||
abstract class FileViewer
|
abstract class FileViewer
|
||||||
{
|
{
|
||||||
|
protected static bool $orderDesc = false;
|
||||||
|
|
||||||
protected abstract static function directory(): string;
|
protected abstract static function directory(): string;
|
||||||
|
|
||||||
protected abstract static function whitelist(): ?array;
|
protected abstract static function whitelist(): ?array;
|
||||||
|
|
@ -13,10 +15,13 @@ abstract class FileViewer
|
||||||
$directory = static::directory();
|
$directory = static::directory();
|
||||||
$whitelist = static::whitelist();
|
$whitelist = static::whitelist();
|
||||||
|
|
||||||
return array_values(array_filter(
|
$list = array_values(array_filter(
|
||||||
scandir($directory),
|
scandir($directory),
|
||||||
fn($file) => ($whitelist === null || in_array($file, $whitelist)) && is_file("$directory/$file")
|
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
|
public static function read($file): ?string
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ namespace MingTsay\Akanyan;
|
||||||
|
|
||||||
class LogsViewer extends FileViewer
|
class LogsViewer extends FileViewer
|
||||||
{
|
{
|
||||||
|
protected static bool $orderDesc = true;
|
||||||
|
|
||||||
protected static function directory(): string
|
protected static function directory(): string
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,10 @@
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<p class="fs-5">【更新紀錄】</p>
|
<p class="fs-5">【更新紀錄】</p>
|
||||||
<ul class="list-group">
|
<ul class="list-group">
|
||||||
|
<li class="list-group-item">
|
||||||
|
<p>檢視日誌時最新的檔案將出現於最前面。</p>
|
||||||
|
<p>更新日期:2022/10/20 20:48:00</p>
|
||||||
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<p>首頁現在可以看到伺服器版本與線上人數等資訊了。</p>
|
<p>首頁現在可以看到伺服器版本與線上人數等資訊了。</p>
|
||||||
<p>更新日期:2022/07/05 02:02:02</p>
|
<p>更新日期:2022/07/05 02:02:02</p>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue