From ea0f49bc460660bd3da2b25c7b196f2a0bec2e3d Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Tue, 6 May 2025 11:18:48 +0700 Subject: [PATCH] update php Dockerfile --- .docker/php/Dockerfile | 12 ++++++++++-- .../Resources/System/PluginStoreResource.php | 2 +- app/Models/PluginStore.php | 12 +++++++++++- app/Models/User.php | 8 ++++++-- resources/lang/zh_CN/user.php | 2 +- 5 files changed, 29 insertions(+), 7 deletions(-) diff --git a/.docker/php/Dockerfile b/.docker/php/Dockerfile index 49836f76..ed25678b 100644 --- a/.docker/php/Dockerfile +++ b/.docker/php/Dockerfile @@ -12,7 +12,8 @@ RUN apk add --no-cache \ libwebp-dev \ gmp-dev \ oniguruma-dev \ - linux-headers + linux-headers \ + curl RUN docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp @@ -28,8 +29,15 @@ RUN docker-php-ext-install -j$(nproc) \ intl \ opcache +# 检查 pecl.php.net 可用性 +RUN curl -Is https://pecl.php.net | head -n 1 | grep "200" \ + || (echo "❌ pecl.php.net unreachable, aborting build." && exit 1) + + # 安装 redis 扩展 -RUN pecl install redis && docker-php-ext-enable redis +RUN pecl channel-update pecl.php.net \ + && pecl install redis \ + && docker-php-ext-enable redis # 👨‍🍳 第二阶段:运行阶段,仅包含必要运行环境 FROM php:8.2-fpm-alpine diff --git a/app/Filament/Resources/System/PluginStoreResource.php b/app/Filament/Resources/System/PluginStoreResource.php index 0b01e3a9..011284e8 100644 --- a/app/Filament/Resources/System/PluginStoreResource.php +++ b/app/Filament/Resources/System/PluginStoreResource.php @@ -34,7 +34,7 @@ class PluginStoreResource extends Resource public static function getNavigationBadge(): ?string { - return PluginStore::getHasNewVersionCount(); + return PluginStore::getHasNewVersionCount() ?: ''; } public static function form(Form $form): Form diff --git a/app/Models/PluginStore.php b/app/Models/PluginStore.php index 7f073c02..816b6a19 100644 --- a/app/Models/PluginStore.php +++ b/app/Models/PluginStore.php @@ -4,6 +4,8 @@ namespace App\Models; use Illuminate\Contracts\Support\Htmlable; use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\Gate; use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Route; use Illuminate\Support\HtmlString; @@ -102,7 +104,12 @@ class PluginStore extends Model private static function listAllFromRemote() { - $list = Http::get(self::PLUGIN_LIST_API)->json(); + $response = Http::get(self::PLUGIN_LIST_API); + if ($response->getStatusCode() != 200) { + do_log(sprintf("status code: %d, body: %s", $response->getStatusCode(), $response->getBody()), 'error'); + return []; + } + $list = $response->json(); foreach ($list as &$row) { foreach ($row as $key => $value) { if (is_array($value)) { @@ -115,6 +122,9 @@ class PluginStore extends Model public static function getHasNewVersionCount(): int { + if (!Gate::allows('viewAny', PluginStore::class)) { + return 0; + } $currentRouteName = Route::currentRouteName(); $withoutCacheRouteName = ['filament.admin.resources.system.plugin-stores.index', 'filament.admin.pages.dashboard']; $list = self::listAll(in_array($currentRouteName, $withoutCacheRouteName)); diff --git a/app/Models/User.php b/app/Models/User.php index 870c7f60..48bcc0ec 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -277,11 +277,15 @@ class User extends Authenticatable implements FilamentUser, HasName public function checkIsNormal(array $fields = ['status', 'enabled']): bool { + $params = [ + 'user_id' => $this->id, + 'username' => $this->username, + ]; if (in_array('status', $fields) && $this->getAttribute('status') != self::STATUS_CONFIRMED) { - throw new NexusException(nexus_trans("user.user_is_not_confirmed", ['user_id' => $this->id, 'username' => $this->username])); + throw new NexusException(nexus_trans("user.user_is_not_confirmed", $params)); } if (in_array('enabled', $fields) && $this->getAttribute('enabled') != self::ENABLED_YES) { - throw new NexusException(nexus_trans("user.user_is_disabled", ['user_id' => $this->id, 'username' => $this->username])); + throw new NexusException(nexus_trans("user.user_is_disabled", $params)); } return true; } diff --git a/resources/lang/zh_CN/user.php b/resources/lang/zh_CN/user.php index 2ba204bf..47747990 100644 --- a/resources/lang/zh_CN/user.php +++ b/resources/lang/zh_CN/user.php @@ -109,6 +109,6 @@ return [ 'msg_invited_user_has_registered' => "你邀请的用户已注册", 'msg_user_you_invited' => "你邀请的用户 ", 'msg_has_registered' => " 刚刚已注册。", - 'user_is_disabled' => '用户::username(ID: :user_id) 已被封禁', + 'user_is_not_disabled' => '用户::username(ID: :user_id) 已被封禁', 'user_is_not_confirmed' => '用户::username(ID: :user_id) 未确认', ];