作者 lyh

ggx

@@ -511,3 +511,27 @@ if (!function_exists('getAutoLoginCode')) { @@ -511,3 +511,27 @@ if (!function_exists('getAutoLoginCode')) {
511 return $encrypt->authcode(json_encode(['project_id' => $project_id]), 'ENCODE', 'autologin', 3600); 511 return $encrypt->authcode(json_encode(['project_id' => $project_id]), 'ENCODE', 'autologin', 3600);
512 } 512 }
513 } 513 }
  514 +
  515 +if (!function_exists('str_replace_url')) {
  516 + /**
  517 + * @remark :截取域名以外的部分
  518 + * @name :str_replace_url
  519 + * @author :lyh
  520 + * @method :post
  521 + * @time :2023/8/31 14:57
  522 + */
  523 + function str_replace_url($url)
  524 + {
  525 + // 使用 parse_url 函数来解析 URL
  526 + $urlParts = parse_url($url);
  527 + // 检查是否存在 host(域名)部分
  528 + if (isset($urlParts['host'])) {
  529 + $domain = $urlParts['host'];
  530 + // 使用 str_replace 函数删除域名信息
  531 + $urlWithoutDomain = str_replace($domain, '', $url);
  532 + return $urlWithoutDomain;
  533 + } else {
  534 + return $url;
  535 + }
  536 + }
  537 +}
@@ -7,6 +7,7 @@ use App\Enums\Common\Common; @@ -7,6 +7,7 @@ use App\Enums\Common\Common;
7 use App\Exceptions\BsideGlobalException; 7 use App\Exceptions\BsideGlobalException;
8 use App\Http\Logic\Logic; 8 use App\Http\Logic\Logic;
9 use App\Models\Com\UpdateNotify; 9 use App\Models\Com\UpdateNotify;
  10 +use App\Models\Project\Project;
10 use Illuminate\Support\Facades\Cache; 11 use Illuminate\Support\Facades\Cache;
11 12
12 /** 13 /**
@@ -33,11 +34,32 @@ class BaseLogic extends Logic @@ -33,11 +34,32 @@ class BaseLogic extends Logic
33 $this->requestAll = $this->getParam(); 34 $this->requestAll = $this->getParam();
34 $this->user = Cache::get(request()->header('token')); 35 $this->user = Cache::get(request()->header('token'));
35 if(!empty($this->user)){ 36 if(!empty($this->user)){
36 - $this->project = Cache::get('user-'.$this->user['project_id']); 37 + $this->project = $this->getProjectInfo();
37 } 38 }
38 } 39 }
39 40
40 /** 41 /**
  42 + * @remark :获取项目详情
  43 + * @name :getProjectInfo
  44 + * @author :lyh
  45 + * @method :post
  46 + * @time :2023/8/31 15:11
  47 + */
  48 + public function getProjectInfo(){
  49 + $info = Cache::get('user-'.$this->user['project_id']);
  50 + if($info === false){
  51 + $projectModel = new Project();
  52 + $info = $projectModel->with('payment')->with('deploy_build')
  53 + ->with('deploy_optimize')->with('online_check')->where(['id'=>$this->user['project_id']])->first();
  54 + if($info['extend_type'] != 0){
  55 + $info['type'] = $info['extend_type'];
  56 + }
  57 + Cache::add('user-'.$this->user['project_id'],$info);
  58 + }
  59 + return $this->success($info);
  60 + }
  61 +
  62 + /**
41 * @remark :请求参数处理 63 * @remark :请求参数处理
42 * @name :getParam 64 * @name :getParam
43 * @author :lyh 65 * @author :lyh
@@ -176,7 +176,7 @@ class UserLoginLogic @@ -176,7 +176,7 @@ class UserLoginLogic
176 $info['domain'] = (!empty($project['deploy_optimize']['domain']) ? 176 $info['domain'] = (!empty($project['deploy_optimize']['domain']) ?
177 $project['deploy_optimize']['domain'] : ($project['deploy_build']['test_domain'] ?? '')); 177 $project['deploy_optimize']['domain'] : ($project['deploy_build']['test_domain'] ?? ''));
178 //保存项目缓存 178 //保存项目缓存
179 - Cache::put('user-'.$info['project_id'],$project,now()->addMinutes(60)); 179 + Cache::put('user-'.$info['project_id'],$project,$minutes = null);
180 return $this->success($info); 180 return $this->success($info);
181 } 181 }
182 182
@@ -205,7 +205,7 @@ class Project extends Base @@ -205,7 +205,7 @@ class Project extends Base
205 { 205 {
206 $value = Arr::s2a($value); 206 $value = Arr::s2a($value);
207 foreach ($value as $k => $v){ 207 foreach ($value as $k => $v){
208 - $v = (int)$v; 208 + $v = (string)$v;
209 $value[$k] = $v; 209 $value[$k] = $v;
210 } 210 }
211 return $value; 211 return $value;
@@ -214,7 +214,7 @@ class Project extends Base @@ -214,7 +214,7 @@ class Project extends Base
214 public function setNoticeFileAttribute($value) 214 public function setNoticeFileAttribute($value)
215 { 215 {
216 foreach ($value as &$v) { 216 foreach ($value as &$v) {
217 - $v['url'] = basename($v['url']); 217 + $v['url'] = str_replace_url($v['url']);
218 } 218 }
219 $this->attributes['notice_file'] = Arr::a2s($value); 219 $this->attributes['notice_file'] = Arr::a2s($value);
220 } 220 }
@@ -233,7 +233,7 @@ class Project extends Base @@ -233,7 +233,7 @@ class Project extends Base
233 public function setConfirmFileAttribute($value) 233 public function setConfirmFileAttribute($value)
234 { 234 {
235 foreach ($value as &$v) { 235 foreach ($value as &$v) {
236 - $v['url'] = basename($v['url']); 236 + $v['url'] = str_replace_url($v['url']);
237 } 237 }
238 $this->attributes['confirm_file'] = Arr::a2s($value); 238 $this->attributes['confirm_file'] = Arr::a2s($value);
239 } 239 }