From 50c0bb6eb93dc8b7e79251385576ed6a376e1c60 Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Tue, 15 Jul 2025 09:54:38 +0800 Subject: [PATCH 01/11] fix: mobile subcategory.html --- app/index/view/mobile/product/subcategory.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/index/view/mobile/product/subcategory.html b/app/index/view/mobile/product/subcategory.html index 2a520cf1..56572128 100644 --- a/app/index/view/mobile/product/subcategory.html +++ b/app/index/view/mobile/product/subcategory.html @@ -19,6 +19,7 @@
{notempty name="categorys_data"}
+ {if condition="in_array('products', array_keys($categorys_data[0]))"} + {/if}
{/notempty}
From b3a77a21caf7ea8b3c95299d172f94015bfee4f7 Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Tue, 15 Jul 2025 09:54:38 +0800 Subject: [PATCH 02/11] fix: mobile subcategory.html --- app/index/view/mobile/product/subcategory.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/index/view/mobile/product/subcategory.html b/app/index/view/mobile/product/subcategory.html index 2a520cf1..56572128 100644 --- a/app/index/view/mobile/product/subcategory.html +++ b/app/index/view/mobile/product/subcategory.html @@ -19,6 +19,7 @@
{notempty name="categorys_data"}
+ {if condition="in_array('products', array_keys($categorys_data[0]))"} + {/if}
{/notempty}
From 8bddc67ab0d29550884b06727e2a697a21bbbde2 Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Tue, 15 Jul 2025 10:46:17 +0800 Subject: [PATCH 03/11] perf: .gitignore --- .env | 5 ----- .gitignore | 2 ++ 2 files changed, 2 insertions(+), 5 deletions(-) delete mode 100644 .env diff --git a/.env b/.env deleted file mode 100644 index ad59e47f..00000000 --- a/.env +++ /dev/null @@ -1,5 +0,0 @@ - -[JWT] -TTL=3600 -REFRESH_TTL=20160 -SECRET=b43e6276644ed60e65c50d1b324ba10b diff --git a/.gitignore b/.gitignore index e4ce095a..8a6bec25 100644 --- a/.gitignore +++ b/.gitignore @@ -3,8 +3,10 @@ composer.phar composer.lock .DS_Store Thumbs.db +.env .env.dev .env.local +.env.prod /.idea /.vscode From c9ddea862760d47e315e614af901409aa4565d52 Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Tue, 15 Jul 2025 13:50:50 +0800 Subject: [PATCH 04/11] =?UTF-8?q?fix:=20admapi=20=E8=A7=92=E8=89=B2?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E6=9D=83=E5=8A=9Bmodel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/model/SysRoleAuthorityBaseModel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/common/model/SysRoleAuthorityBaseModel.php b/app/common/model/SysRoleAuthorityBaseModel.php index b7cf723b..25da7cc3 100644 --- a/app/common/model/SysRoleAuthorityBaseModel.php +++ b/app/common/model/SysRoleAuthorityBaseModel.php @@ -18,6 +18,6 @@ class SysRoleAuthorityBaseModel extends Model protected $schema = [ 'role_id' => 'int', 'menu_id' => 'int', - 'permission' => 'int', + 'permission' => 'string', ]; } From 9f57f7a5ad0160b0b205b47de215f0f5be34dc17 Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Tue, 15 Jul 2025 14:20:36 +0800 Subject: [PATCH 05/11] =?UTF-8?q?perf:=20openapi=20client=E6=8E=88?= =?UTF-8?q?=E6=9D=83=E8=BF=87=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/openapi/model/OAuthClientModel.php | 2 ++ extend/oauth/OAuthStorage.php | 14 ++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/openapi/model/OAuthClientModel.php b/app/openapi/model/OAuthClientModel.php index dc126189..7a00c1ef 100644 --- a/app/openapi/model/OAuthClientModel.php +++ b/app/openapi/model/OAuthClientModel.php @@ -20,6 +20,8 @@ class OAuthClientModel extends Model 'client_secret' => 'string', 'redirect_uri' => 'string', 'enabled' => 'int', + 'expired_at' => 'datetime', + 'remark' => 'string', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'deleted_at' => 'datetime' diff --git a/extend/oauth/OAuthStorage.php b/extend/oauth/OAuthStorage.php index ade0f5d7..a303fb33 100644 --- a/extend/oauth/OAuthStorage.php +++ b/extend/oauth/OAuthStorage.php @@ -78,15 +78,18 @@ class OAuthStorage implements IOAuth2GrantCode, IOAuth2RefreshTokens, IOAuth2Gra public function getClient($client_id): IOAuth2Client { // 实现获取客户端的逻辑 - $ret = OAuthClientModel::clientId($client_id)->find(); - if (is_null($ret)) { + $client = OAuthClientModel::clientId($client_id)->find(); + if (is_null($client)) { throw new \Exception('客户端不存在'); } - if ($ret->enabled != 1) { + if ($client->enabled != 1) { throw new \Exception('客户端已禁用'); } + if (strtotime($client->expired_at) < time()) { + throw new \Exception('client_id 授权已过期'); + } - return new OAuth2Client($ret->client_id, $ret->client_secret, [$ret->redirect_uri]); + return new OAuth2Client($client->client_id, $client->client_secret, [$client->redirect_uri]); } public function checkClientCredentials(IOAuth2Client $client, $client_secret = null): bool @@ -96,6 +99,9 @@ class OAuthStorage implements IOAuth2GrantCode, IOAuth2RefreshTokens, IOAuth2Gra if (is_null($client)) { return false; } + if (strtotime($client->expired_at) < time()) { + throw new \Exception('client_id 授权已过期'); + } return $client->client_secret == hash('sha1', $client->client_id . $client_secret . $this->salt); } From 2078df8f86705f59738e9941cdb53c0a82a842e6 Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Tue, 15 Jul 2025 13:50:50 +0800 Subject: [PATCH 06/11] =?UTF-8?q?fix:=20admapi=20=E8=A7=92=E8=89=B2?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E6=9D=83=E5=8A=9Bmodel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/model/SysRoleAuthorityBaseModel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/common/model/SysRoleAuthorityBaseModel.php b/app/common/model/SysRoleAuthorityBaseModel.php index b7cf723b..25da7cc3 100644 --- a/app/common/model/SysRoleAuthorityBaseModel.php +++ b/app/common/model/SysRoleAuthorityBaseModel.php @@ -18,6 +18,6 @@ class SysRoleAuthorityBaseModel extends Model protected $schema = [ 'role_id' => 'int', 'menu_id' => 'int', - 'permission' => 'int', + 'permission' => 'string', ]; } From 1b3ed0026b5dd1e69c762731d08d2ae2e5946261 Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Tue, 15 Jul 2025 14:20:36 +0800 Subject: [PATCH 07/11] =?UTF-8?q?perf:=20openapi=20client=E6=8E=88?= =?UTF-8?q?=E6=9D=83=E8=BF=87=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/openapi/model/OAuthClientModel.php | 2 ++ extend/oauth/OAuthStorage.php | 14 ++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/openapi/model/OAuthClientModel.php b/app/openapi/model/OAuthClientModel.php index dc126189..7a00c1ef 100644 --- a/app/openapi/model/OAuthClientModel.php +++ b/app/openapi/model/OAuthClientModel.php @@ -20,6 +20,8 @@ class OAuthClientModel extends Model 'client_secret' => 'string', 'redirect_uri' => 'string', 'enabled' => 'int', + 'expired_at' => 'datetime', + 'remark' => 'string', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'deleted_at' => 'datetime' diff --git a/extend/oauth/OAuthStorage.php b/extend/oauth/OAuthStorage.php index ade0f5d7..a303fb33 100644 --- a/extend/oauth/OAuthStorage.php +++ b/extend/oauth/OAuthStorage.php @@ -78,15 +78,18 @@ class OAuthStorage implements IOAuth2GrantCode, IOAuth2RefreshTokens, IOAuth2Gra public function getClient($client_id): IOAuth2Client { // 实现获取客户端的逻辑 - $ret = OAuthClientModel::clientId($client_id)->find(); - if (is_null($ret)) { + $client = OAuthClientModel::clientId($client_id)->find(); + if (is_null($client)) { throw new \Exception('客户端不存在'); } - if ($ret->enabled != 1) { + if ($client->enabled != 1) { throw new \Exception('客户端已禁用'); } + if (strtotime($client->expired_at) < time()) { + throw new \Exception('client_id 授权已过期'); + } - return new OAuth2Client($ret->client_id, $ret->client_secret, [$ret->redirect_uri]); + return new OAuth2Client($client->client_id, $client->client_secret, [$client->redirect_uri]); } public function checkClientCredentials(IOAuth2Client $client, $client_secret = null): bool @@ -96,6 +99,9 @@ class OAuthStorage implements IOAuth2GrantCode, IOAuth2RefreshTokens, IOAuth2Gra if (is_null($client)) { return false; } + if (strtotime($client->expired_at) < time()) { + throw new \Exception('client_id 授权已过期'); + } return $client->client_secret == hash('sha1', $client->client_id . $client_secret . $this->salt); } From 3a99c9e079f90e020ab011d016ee24936aac8f63 Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Tue, 15 Jul 2025 14:45:16 +0800 Subject: [PATCH 08/11] =?UTF-8?q?perf:=20openapi=20token=E6=9C=89=E6=95=88?= =?UTF-8?q?=E6=9C=9F=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .example.env | 2 ++ app/openapi/controller/v1/Authorize.php | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.example.env b/.example.env index 9f004047..b96002f5 100644 --- a/.example.env +++ b/.example.env @@ -42,6 +42,8 @@ MAX_ATTACHMENT_SIZE = 100mb # 附件上传最大限制 # 开放API [OPENAPI] +ACCESS_TOKEN_LIFETIME = 3600 # 访问令牌有效期 +REFRESH_TOKEN_LIFETIME = 1209600 # 刷新令牌有效期 RESOURCE_IMAGES_DOMAIN = http://local.orico.com; # 图片资源服务器地址 RESOURCE_VIDEOS_DOMAIN = http://local.orico.com; # 视频资源服务器地址 diff --git a/app/openapi/controller/v1/Authorize.php b/app/openapi/controller/v1/Authorize.php index 13bd8c02..262273c8 100644 --- a/app/openapi/controller/v1/Authorize.php +++ b/app/openapi/controller/v1/Authorize.php @@ -25,7 +25,10 @@ class Authorize $server = request()->server(); $request = new Request([], $post, [], [], [], $server); $storage = new OAuthStorage; - $oauth = new OAuth2($storage); + $oauth = new OAuth2($storage, [ + 'access_token_lifetime' => env('OPENAPI.ACCESS_TOKEN_LIFETIME', 3600), + 'refresh_token_lifetime' => env('OPENAPI.REFRESH_TOKEN_LIFETIME', 1209600), + ]); $token = $oauth->grantAccessToken($request); return success('success', json_decode($token->getContent(), true)); } catch (OAuth2ServerException $e) { From 80d2549316c6129ed23168c44ae237485e60aafb Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Tue, 15 Jul 2025 14:45:16 +0800 Subject: [PATCH 09/11] =?UTF-8?q?perf:=20openapi=20token=E6=9C=89=E6=95=88?= =?UTF-8?q?=E6=9C=9F=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .example.env | 2 ++ app/openapi/controller/v1/Authorize.php | 5 ++++- app/openapi/middleware/Auth.php | 5 ++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.example.env b/.example.env index 9f004047..b96002f5 100644 --- a/.example.env +++ b/.example.env @@ -42,6 +42,8 @@ MAX_ATTACHMENT_SIZE = 100mb # 附件上传最大限制 # 开放API [OPENAPI] +ACCESS_TOKEN_LIFETIME = 3600 # 访问令牌有效期 +REFRESH_TOKEN_LIFETIME = 1209600 # 刷新令牌有效期 RESOURCE_IMAGES_DOMAIN = http://local.orico.com; # 图片资源服务器地址 RESOURCE_VIDEOS_DOMAIN = http://local.orico.com; # 视频资源服务器地址 diff --git a/app/openapi/controller/v1/Authorize.php b/app/openapi/controller/v1/Authorize.php index 13bd8c02..262273c8 100644 --- a/app/openapi/controller/v1/Authorize.php +++ b/app/openapi/controller/v1/Authorize.php @@ -25,7 +25,10 @@ class Authorize $server = request()->server(); $request = new Request([], $post, [], [], [], $server); $storage = new OAuthStorage; - $oauth = new OAuth2($storage); + $oauth = new OAuth2($storage, [ + 'access_token_lifetime' => env('OPENAPI.ACCESS_TOKEN_LIFETIME', 3600), + 'refresh_token_lifetime' => env('OPENAPI.REFRESH_TOKEN_LIFETIME', 1209600), + ]); $token = $oauth->grantAccessToken($request); return success('success', json_decode($token->getContent(), true)); } catch (OAuth2ServerException $e) { diff --git a/app/openapi/middleware/Auth.php b/app/openapi/middleware/Auth.php index 5df2c101..5b439684 100644 --- a/app/openapi/middleware/Auth.php +++ b/app/openapi/middleware/Auth.php @@ -19,7 +19,10 @@ class Auth public function handle($request, \Closure $next) { try { - $oauth = new OAuth2(new OAuthStorage); + $oauth = new OAuth2(new OAuthStorage, [ + 'access_token_lifetime' => env('OPENAPI.ACCESS_TOKEN_LIFETIME', 3600), + 'refresh_token_lifetime' => env('OPENAPI.REFRESH_TOKEN_LIFETIME', 1209600), + ]); $token = $oauth->getBearerToken(); $oauth->verifyAccessToken($token); } catch (OAuth2ServerException $e) { From c51d97d5100746e1a723739f5e2dba182ac912cd Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Tue, 15 Jul 2025 14:59:25 +0800 Subject: [PATCH 10/11] =?UTF-8?q?fix:=20openapi=20token=E6=9C=89=E6=95=88?= =?UTF-8?q?=E6=9C=9F=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .example.env | 10 +++++----- app/openapi/controller/v1/Authorize.php | 4 ++-- app/openapi/middleware/Auth.php | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.example.env b/.example.env index b96002f5..93e5c287 100644 --- a/.example.env +++ b/.example.env @@ -36,14 +36,14 @@ WHITE_LIST[] = receive_sync/product # 不需记录日志的接口 [ADMIN_API] IGNORE_LOGGING_LIST[] = v1/OperateLog/index -MAX_IMAGE_SIZE = 5mb # 图片上传最大限制 -MAX_VIDEO_SIZE = 150mb # 视频上传最大限制 -MAX_ATTACHMENT_SIZE = 100mb # 附件上传最大限制 +MAX_IMAGE_SIZE = 5mb; # 图片上传最大限制 +MAX_VIDEO_SIZE = 150mb; # 视频上传最大限制 +MAX_ATTACHMENT_SIZE = 100mb; # 附件上传最大限制 # 开放API [OPENAPI] -ACCESS_TOKEN_LIFETIME = 3600 # 访问令牌有效期 -REFRESH_TOKEN_LIFETIME = 1209600 # 刷新令牌有效期 +ACCESS_TOKEN_LIFETIME = 3600; # 访问令牌有效期 +REFRESH_TOKEN_LIFETIME = 1209600; # 刷新令牌有效期 RESOURCE_IMAGES_DOMAIN = http://local.orico.com; # 图片资源服务器地址 RESOURCE_VIDEOS_DOMAIN = http://local.orico.com; # 视频资源服务器地址 diff --git a/app/openapi/controller/v1/Authorize.php b/app/openapi/controller/v1/Authorize.php index 262273c8..03833c3b 100644 --- a/app/openapi/controller/v1/Authorize.php +++ b/app/openapi/controller/v1/Authorize.php @@ -26,8 +26,8 @@ class Authorize $request = new Request([], $post, [], [], [], $server); $storage = new OAuthStorage; $oauth = new OAuth2($storage, [ - 'access_token_lifetime' => env('OPENAPI.ACCESS_TOKEN_LIFETIME', 3600), - 'refresh_token_lifetime' => env('OPENAPI.REFRESH_TOKEN_LIFETIME', 1209600), + 'access_token_lifetime' => intval(env('OPENAPI.ACCESS_TOKEN_LIFETIME', 3600)), + 'refresh_token_lifetime' => intval(env('OPENAPI.REFRESH_TOKEN_LIFETIME', 1209600)), ]); $token = $oauth->grantAccessToken($request); return success('success', json_decode($token->getContent(), true)); diff --git a/app/openapi/middleware/Auth.php b/app/openapi/middleware/Auth.php index 5b439684..07a652ee 100644 --- a/app/openapi/middleware/Auth.php +++ b/app/openapi/middleware/Auth.php @@ -20,8 +20,8 @@ class Auth { try { $oauth = new OAuth2(new OAuthStorage, [ - 'access_token_lifetime' => env('OPENAPI.ACCESS_TOKEN_LIFETIME', 3600), - 'refresh_token_lifetime' => env('OPENAPI.REFRESH_TOKEN_LIFETIME', 1209600), + 'access_token_lifetime' => intval(env('OPENAPI.ACCESS_TOKEN_LIFETIME', 3600)), + 'refresh_token_lifetime' => intval(env('OPENAPI.REFRESH_TOKEN_LIFETIME', 1209600)), ]); $token = $oauth->getBearerToken(); $oauth->verifyAccessToken($token); From 28014795a8f04531ce2c656d6379f19b1a9e0fe9 Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Tue, 15 Jul 2025 14:59:25 +0800 Subject: [PATCH 11/11] =?UTF-8?q?fix:=20openapi=20token=E6=9C=89=E6=95=88?= =?UTF-8?q?=E6=9C=9F=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .example.env | 10 +++++----- app/openapi/controller/v1/Authorize.php | 4 ++-- app/openapi/middleware/Auth.php | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.example.env b/.example.env index b96002f5..93e5c287 100644 --- a/.example.env +++ b/.example.env @@ -36,14 +36,14 @@ WHITE_LIST[] = receive_sync/product # 不需记录日志的接口 [ADMIN_API] IGNORE_LOGGING_LIST[] = v1/OperateLog/index -MAX_IMAGE_SIZE = 5mb # 图片上传最大限制 -MAX_VIDEO_SIZE = 150mb # 视频上传最大限制 -MAX_ATTACHMENT_SIZE = 100mb # 附件上传最大限制 +MAX_IMAGE_SIZE = 5mb; # 图片上传最大限制 +MAX_VIDEO_SIZE = 150mb; # 视频上传最大限制 +MAX_ATTACHMENT_SIZE = 100mb; # 附件上传最大限制 # 开放API [OPENAPI] -ACCESS_TOKEN_LIFETIME = 3600 # 访问令牌有效期 -REFRESH_TOKEN_LIFETIME = 1209600 # 刷新令牌有效期 +ACCESS_TOKEN_LIFETIME = 3600; # 访问令牌有效期 +REFRESH_TOKEN_LIFETIME = 1209600; # 刷新令牌有效期 RESOURCE_IMAGES_DOMAIN = http://local.orico.com; # 图片资源服务器地址 RESOURCE_VIDEOS_DOMAIN = http://local.orico.com; # 视频资源服务器地址 diff --git a/app/openapi/controller/v1/Authorize.php b/app/openapi/controller/v1/Authorize.php index 262273c8..03833c3b 100644 --- a/app/openapi/controller/v1/Authorize.php +++ b/app/openapi/controller/v1/Authorize.php @@ -26,8 +26,8 @@ class Authorize $request = new Request([], $post, [], [], [], $server); $storage = new OAuthStorage; $oauth = new OAuth2($storage, [ - 'access_token_lifetime' => env('OPENAPI.ACCESS_TOKEN_LIFETIME', 3600), - 'refresh_token_lifetime' => env('OPENAPI.REFRESH_TOKEN_LIFETIME', 1209600), + 'access_token_lifetime' => intval(env('OPENAPI.ACCESS_TOKEN_LIFETIME', 3600)), + 'refresh_token_lifetime' => intval(env('OPENAPI.REFRESH_TOKEN_LIFETIME', 1209600)), ]); $token = $oauth->grantAccessToken($request); return success('success', json_decode($token->getContent(), true)); diff --git a/app/openapi/middleware/Auth.php b/app/openapi/middleware/Auth.php index 5b439684..07a652ee 100644 --- a/app/openapi/middleware/Auth.php +++ b/app/openapi/middleware/Auth.php @@ -20,8 +20,8 @@ class Auth { try { $oauth = new OAuth2(new OAuthStorage, [ - 'access_token_lifetime' => env('OPENAPI.ACCESS_TOKEN_LIFETIME', 3600), - 'refresh_token_lifetime' => env('OPENAPI.REFRESH_TOKEN_LIFETIME', 1209600), + 'access_token_lifetime' => intval(env('OPENAPI.ACCESS_TOKEN_LIFETIME', 3600)), + 'refresh_token_lifetime' => intval(env('OPENAPI.REFRESH_TOKEN_LIFETIME', 1209600)), ]); $token = $oauth->getBearerToken(); $oauth->verifyAccessToken($token);