作者 刘锟

合并分支 'akun' 到 'master'

Akun



查看合并请求 !250
... ... @@ -10,6 +10,7 @@ use App\Models\RouteMap\RouteMap;
use App\Services\CosService;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis;
... ... @@ -78,8 +79,8 @@ class HtmlLanguageCollect extends Command
$collect_info->save();
//获取站点正式和测试域名
//TODO:小语种域名获取英文站的
$old_info = UpdateOldInfo::getOldDomain($project_id, $collect_info->domain);
$domain_en = $this->get_domain_en($project_id);
$old_info = UpdateOldInfo::getOldDomain($project_id, $domain_en);
//采集html页面,下载资源到本地并替换
try {
... ... @@ -100,10 +101,10 @@ class HtmlLanguageCollect extends Command
$new_html = str_replace($v64, '', $new_html);
}
$source_list = $this->html_preg($new_html, $project_id, $collect_info->domain, $old_info['web_url_domain'], $old_info['home_url']);
$source_list = $this->html_preg($new_html, $project_id, $domain_en, $old_info['web_url_domain'], $old_info['home_url']);
if ($source_list) {
$html = $this->upload_source($html, $source_list, $project_id, $collect_info->domain, $old_info['web_url_domain'], $old_info['home_url']);
$html = $this->upload_source($html, $source_list, $project_id, $domain_en, $old_info['web_url_domain'], $old_info['home_url']);
}
} catch (\Exception $e) {
$collect_info->status = CollectTask::STATUS_FAIL;
... ... @@ -184,6 +185,20 @@ class HtmlLanguageCollect extends Command
return $task_id;
}
//获取英文站域名
protected function get_domain_en($project_id)
{
$key = 'console_html_language_domain_en';
$domain = Cache::get($key);
if (!$domain) {
$domain = CollectTask::where('project_id', $project_id)->where('language', '')->value('domain');
Cache::add($key, $domain, 3600);
}
return $domain;
}
//正则匹配html资源
protected function html_preg($html, $project_id, $domain, $web_url_domain, $home_url)
{
... ...