diff --git a/README-EN.md b/README-EN.md index c45a14d9..26ea0ac1 100644 --- a/README-EN.md +++ b/README-EN.md @@ -1,6 +1,6 @@ English | [中文](/) -Complete PT website building solution. Based on NexusPHP + Laravel Framework + Filament. +Complete PT website building solution. Based on NexusPHP + Laravel + Filament. ## Functional Features diff --git a/README.md b/README.md index bc272443..41ad6857 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ 中文 | [English](/README-EN.md) -完整的 PT 建站解决方案。基于 NexusPHP + Laravel Framework + Filament。 +完整的 PT 建站解决方案。基于 NexusPHP + Laravel + Filament。 ## 功能特性 - 发种 diff --git a/app/Auth/NexusWebGuard.php b/app/Auth/NexusWebGuard.php index db33162a..03ade560 100644 --- a/app/Auth/NexusWebGuard.php +++ b/app/Auth/NexusWebGuard.php @@ -42,7 +42,13 @@ class NexusWebGuard implements Guard if (! is_null($this->user)) { return $this->user; } - return $this->user = $this->provider->retrieveByCredentials($this->request->cookie()); + $credentials = $this->request->cookie(); + if ($this->validate($credentials)) { + $user = $this->user; + if ($this->provider->validateCredentials($user, $credentials)) { + return $user; + } + } } @@ -65,7 +71,9 @@ class NexusWebGuard implements Guard if (!$id || !is_valid_id($id) || strlen($credentials["c_secure_pass"]) != 32) { return false; } - if ($this->provider->retrieveById($id)) { + $user = $this->provider->retrieveById($id); + if ($user) { + $this->user = $user; return true; } return false; diff --git a/app/Filament/Resources/Torrent/TorrentResource.php b/app/Filament/Resources/Torrent/TorrentResource.php index c0debe0c..ad00bf95 100644 --- a/app/Filament/Resources/Torrent/TorrentResource.php +++ b/app/Filament/Resources/Torrent/TorrentResource.php @@ -61,10 +61,10 @@ class TorrentResource extends Resource '
%s
', Str::limit($record->name, 40) ); - $tags = sprintf('
%s
', $record->tagsFormatted); + $tags = sprintf(' 
%s
', $record->tagsFormatted); return new HtmlString('
' . $name . $tags . '
'); - }), + })->label(__('label.name')), Tables\Columns\TextColumn::make('posStateText')->label(__('label.torrent.pos_state')), Tables\Columns\TextColumn::make('spStateText')->label(__('label.torrent.sp_state')), Tables\Columns\TextColumn::make('size')->label(__('label.torrent.size'))->formatStateUsing(fn ($state) => mksize($state)), @@ -77,7 +77,7 @@ class TorrentResource extends Resource ->formatStateUsing(fn ($record) => $record->approvalStatusText), Tables\Columns\TextColumn::make('added')->label(__('label.added'))->dateTime(), Tables\Columns\TextColumn::make('user.username') - ->label(__('label.user.label')) + ->label(__('label.torrent.owner')) ->url(fn ($record) => sprintf('/userdetails.php?id=%s', $record->owner)) ->openUrlInNewTab(true) , diff --git a/app/Filament/Resources/User/ClaimResource.php b/app/Filament/Resources/User/ClaimResource.php index 35c77403..6a1eda51 100644 --- a/app/Filament/Resources/User/ClaimResource.php +++ b/app/Filament/Resources/User/ClaimResource.php @@ -48,7 +48,7 @@ class ClaimResource extends Resource ->columns([ Tables\Columns\TextColumn::make('id')->sortable(), Tables\Columns\TextColumn::make('user.username')->label(__('label.user.label'))->searchable(), - Tables\Columns\TextColumn::make('torrent.name')->limit(50)->label(__('label.torrent.label'))->searchable(), + Tables\Columns\TextColumn::make('torrent.name')->limit(40)->label(__('label.torrent.label'))->searchable(), Tables\Columns\TextColumn::make('torrent.size')->label(__('label.torrent.size'))->formatStateUsing(fn (Model $record) => mksize($record->torrent->size)), Tables\Columns\TextColumn::make('torrent.added')->label(__('label.torrent.ttl'))->formatStateUsing(fn (Model $record) => mkprettytime($record->torrent->added->diffInSeconds())), Tables\Columns\TextColumn::make('created_at')->label(__('label.created_at'))->dateTime(), diff --git a/app/Filament/Resources/User/HitAndRunResource.php b/app/Filament/Resources/User/HitAndRunResource.php index e3fa7051..fb2c30b5 100644 --- a/app/Filament/Resources/User/HitAndRunResource.php +++ b/app/Filament/Resources/User/HitAndRunResource.php @@ -55,7 +55,7 @@ class HitAndRunResource extends Resource ->columns([ Tables\Columns\TextColumn::make('id')->sortable(), Tables\Columns\TextColumn::make('user.username')->searchable()->label(__('label.username')), - Tables\Columns\TextColumn::make('torrent.name')->limit(50)->label(__('label.torrent.label')), + Tables\Columns\TextColumn::make('torrent.name')->limit(40)->label(__('label.torrent.label')), Tables\Columns\TextColumn::make('snatch.uploadText')->label(__('label.uploaded')), Tables\Columns\TextColumn::make('snatch.downloadText')->label(__('label.downloaded')), Tables\Columns\TextColumn::make('snatch.shareRatio')->label(__('label.ratio')), diff --git a/app/Filament/Resources/User/UserResource.php b/app/Filament/Resources/User/UserResource.php index 3a1b77ae..dc18b197 100644 --- a/app/Filament/Resources/User/UserResource.php +++ b/app/Filament/Resources/User/UserResource.php @@ -70,7 +70,7 @@ class UserResource extends Resource Tables\Columns\BadgeColumn::make('status')->colors(['success' => 'confirmed', 'warning' => 'pending'])->label(__("label.user.status")), Tables\Columns\BadgeColumn::make('enabled')->colors(['success' => 'yes', 'danger' => 'no'])->label(__("label.user.enabled")), Tables\Columns\TextColumn::make('added')->sortable()->dateTime('Y-m-d H:i')->label(__("label.added")), - Tables\Columns\TextColumn::make('last_access')->dateTime('Y-m-d H:i')->label(__("label.last_access")), + Tables\Columns\TextColumn::make('last_access')->dateTime()->label(__("label.last_access")), ]) ->defaultSort('added', 'desc') ->filters([ diff --git a/app/Filament/Widgets/LatestTorrents.php b/app/Filament/Widgets/LatestTorrents.php index 2446329b..af5f8d54 100644 --- a/app/Filament/Widgets/LatestTorrents.php +++ b/app/Filament/Widgets/LatestTorrents.php @@ -30,10 +30,10 @@ class LatestTorrents extends BaseWidget protected function getTableColumns(): array { return [ - Tables\Columns\TextColumn::make('name')->limit(30), - Tables\Columns\TextColumn::make('user.username'), - Tables\Columns\TextColumn::make('size')->formatStateUsing(fn ($state) => mksize($state)), - Tables\Columns\TextColumn::make('added')->dateTime(), + Tables\Columns\TextColumn::make('name')->limit(30)->label(__('label.name')), + Tables\Columns\TextColumn::make('user.username')->label(__('label.torrent.owner')), + Tables\Columns\TextColumn::make('size')->formatStateUsing(fn ($state) => mksize($state))->label(__('label.torrent.size')), + Tables\Columns\TextColumn::make('added')->dateTime()->label(__('label.added')), ]; } } diff --git a/app/Filament/Widgets/LatestUsers.php b/app/Filament/Widgets/LatestUsers.php index 15e896fb..683288c9 100644 --- a/app/Filament/Widgets/LatestUsers.php +++ b/app/Filament/Widgets/LatestUsers.php @@ -30,10 +30,10 @@ class LatestUsers extends BaseWidget protected function getTableColumns(): array { return [ - Tables\Columns\TextColumn::make('username'), - Tables\Columns\TextColumn::make('email'), - Tables\Columns\BadgeColumn::make('status')->colors(['success' => 'confirmed', 'danger' => 'pending']), - Tables\Columns\TextColumn::make('added')->dateTime(), + Tables\Columns\TextColumn::make('username')->label(__('label.user.username')), + Tables\Columns\TextColumn::make('email')->label(__('label.email')), + Tables\Columns\BadgeColumn::make('status')->colors(['success' => 'confirmed', 'danger' => 'pending'])->label(__('label.status')), + Tables\Columns\TextColumn::make('added')->dateTime()->label(__('label.added')), ]; } } diff --git a/app/Filament/Widgets/TorrentTrend.php b/app/Filament/Widgets/TorrentTrend.php index 2ddff983..e1509571 100644 --- a/app/Filament/Widgets/TorrentTrend.php +++ b/app/Filament/Widgets/TorrentTrend.php @@ -33,7 +33,7 @@ class TorrentTrend extends LineChartWidget return [ 'datasets' => [ [ - 'label' => 'Torrent', + 'label' => __('label.torrent.label'), 'data' => $data->map(fn (TrendValue $value) => $value->aggregate), ], ], diff --git a/app/Filament/Widgets/UserTrend.php b/app/Filament/Widgets/UserTrend.php index 290583f8..6d1c2d40 100644 --- a/app/Filament/Widgets/UserTrend.php +++ b/app/Filament/Widgets/UserTrend.php @@ -35,7 +35,7 @@ class UserTrend extends LineChartWidget return [ 'datasets' => [ [ - 'label' => 'User', + 'label' => __('label.user.label'), 'data' => $data->map(fn (TrendValue $value) => $value->aggregate), ], ], diff --git a/app/Models/Medal.php b/app/Models/Medal.php index 797b580e..0d58209a 100644 --- a/app/Models/Medal.php +++ b/app/Models/Medal.php @@ -36,7 +36,7 @@ class Medal extends NexusModel public function getGetTypeTextAttribute($value): string { - return self::$getTypeText[$this->get_type]['text'] ?? ''; + return nexus_trans("medal.get_types." . $this->get_type); } public function users(): \Illuminate\Database\Eloquent\Relations\BelongsToMany diff --git a/include/constants.php b/include/constants.php index e6e31ed8..220cab56 100644 --- a/include/constants.php +++ b/include/constants.php @@ -1,6 +1,6 @@ [ 'label' => 'Torrent', + 'owner' => 'Owner', 'size' => 'Size', 'ttl' => 'TTL', 'seeders' => 'Seeders', diff --git a/resources/lang/zh_CN/label.php b/resources/lang/zh_CN/label.php index d30b2feb..3a82de67 100644 --- a/resources/lang/zh_CN/label.php +++ b/resources/lang/zh_CN/label.php @@ -108,6 +108,7 @@ return [ ], 'torrent' => [ 'label' => '种子', + 'owner' => '发布者', 'size' => '大小', 'ttl' => '存活时间', 'seeders' => '做种', diff --git a/resources/lang/zh_TW/label.php b/resources/lang/zh_TW/label.php index b4dbb30d..a253f7fa 100644 --- a/resources/lang/zh_TW/label.php +++ b/resources/lang/zh_TW/label.php @@ -109,6 +109,7 @@ return [ ], 'torrent' => [ 'label' => '種子', + 'owner' => '發布者', 'size' => '大小', 'ttl' => '存活時間', 'seeders' => '做种',