合并分支 'akun' 到 'master'
Akun 查看合并请求 !250
正在显示
1 个修改的文件
包含
19 行增加
和
4 行删除
| @@ -10,6 +10,7 @@ use App\Models\RouteMap\RouteMap; | @@ -10,6 +10,7 @@ use App\Models\RouteMap\RouteMap; | ||
| 10 | use App\Services\CosService; | 10 | use App\Services\CosService; |
| 11 | use App\Services\ProjectServer; | 11 | use App\Services\ProjectServer; |
| 12 | use Illuminate\Console\Command; | 12 | use Illuminate\Console\Command; |
| 13 | +use Illuminate\Support\Facades\Cache; | ||
| 13 | use Illuminate\Support\Facades\DB; | 14 | use Illuminate\Support\Facades\DB; |
| 14 | use Illuminate\Support\Facades\Redis; | 15 | use Illuminate\Support\Facades\Redis; |
| 15 | 16 | ||
| @@ -78,8 +79,8 @@ class HtmlLanguageCollect extends Command | @@ -78,8 +79,8 @@ class HtmlLanguageCollect extends Command | ||
| 78 | $collect_info->save(); | 79 | $collect_info->save(); |
| 79 | 80 | ||
| 80 | //获取站点正式和测试域名 | 81 | //获取站点正式和测试域名 |
| 81 | - //TODO:小语种域名获取英文站的 | ||
| 82 | - $old_info = UpdateOldInfo::getOldDomain($project_id, $collect_info->domain); | 82 | + $domain_en = $this->get_domain_en($project_id); |
| 83 | + $old_info = UpdateOldInfo::getOldDomain($project_id, $domain_en); | ||
| 83 | 84 | ||
| 84 | //采集html页面,下载资源到本地并替换 | 85 | //采集html页面,下载资源到本地并替换 |
| 85 | try { | 86 | try { |
| @@ -100,10 +101,10 @@ class HtmlLanguageCollect extends Command | @@ -100,10 +101,10 @@ class HtmlLanguageCollect extends Command | ||
| 100 | $new_html = str_replace($v64, '', $new_html); | 101 | $new_html = str_replace($v64, '', $new_html); |
| 101 | } | 102 | } |
| 102 | 103 | ||
| 103 | - $source_list = $this->html_preg($new_html, $project_id, $collect_info->domain, $old_info['web_url_domain'], $old_info['home_url']); | 104 | + $source_list = $this->html_preg($new_html, $project_id, $domain_en, $old_info['web_url_domain'], $old_info['home_url']); |
| 104 | 105 | ||
| 105 | if ($source_list) { | 106 | if ($source_list) { |
| 106 | - $html = $this->upload_source($html, $source_list, $project_id, $collect_info->domain, $old_info['web_url_domain'], $old_info['home_url']); | 107 | + $html = $this->upload_source($html, $source_list, $project_id, $domain_en, $old_info['web_url_domain'], $old_info['home_url']); |
| 107 | } | 108 | } |
| 108 | } catch (\Exception $e) { | 109 | } catch (\Exception $e) { |
| 109 | $collect_info->status = CollectTask::STATUS_FAIL; | 110 | $collect_info->status = CollectTask::STATUS_FAIL; |
| @@ -184,6 +185,20 @@ class HtmlLanguageCollect extends Command | @@ -184,6 +185,20 @@ class HtmlLanguageCollect extends Command | ||
| 184 | return $task_id; | 185 | return $task_id; |
| 185 | } | 186 | } |
| 186 | 187 | ||
| 188 | + //获取英文站域名 | ||
| 189 | + protected function get_domain_en($project_id) | ||
| 190 | + { | ||
| 191 | + $key = 'console_html_language_domain_en'; | ||
| 192 | + $domain = Cache::get($key); | ||
| 193 | + if (!$domain) { | ||
| 194 | + $domain = CollectTask::where('project_id', $project_id)->where('language', '')->value('domain'); | ||
| 195 | + | ||
| 196 | + Cache::add($key, $domain, 3600); | ||
| 197 | + } | ||
| 198 | + | ||
| 199 | + return $domain; | ||
| 200 | + } | ||
| 201 | + | ||
| 187 | //正则匹配html资源 | 202 | //正则匹配html资源 |
| 188 | protected function html_preg($html, $project_id, $domain, $web_url_domain, $home_url) | 203 | protected function html_preg($html, $project_id, $domain, $web_url_domain, $home_url) |
| 189 | { | 204 | { |
-
请 注册 或 登录 后发表评论