合并分支 'akun' 到 'master'
Akun 查看合并请求 !72
正在显示
1 个修改的文件
包含
18 行增加
和
7 行删除
| @@ -140,7 +140,7 @@ class ProjectUpdate extends Command | @@ -140,7 +140,7 @@ class ProjectUpdate extends Command | ||
| 140 | 'seo_keywords' => $item['seo_keywords'] ?? '', | 140 | 'seo_keywords' => $item['seo_keywords'] ?? '', |
| 141 | 'seo_description' => $item['seo_description'] ?? '', | 141 | 'seo_description' => $item['seo_description'] ?? '', |
| 142 | ]); | 142 | ]); |
| 143 | - $route = RouteMap::setRoute($item['url'] ? $this->get_url_route($item['url']) : $item['name'], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $project_id); | 143 | + $route = RouteMap::setRoute($this->get_url_route($item['url']) ?: $item['name'], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $project_id); |
| 144 | $model->edit(['route' => $route], ['id' => $id]); | 144 | $model->edit(['route' => $route], ['id' => $id]); |
| 145 | } catch (\Exception $e) { | 145 | } catch (\Exception $e) { |
| 146 | echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL; | 146 | echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL; |
| @@ -273,7 +273,7 @@ class ProjectUpdate extends Command | @@ -273,7 +273,7 @@ class ProjectUpdate extends Command | ||
| 273 | ]), | 273 | ]), |
| 274 | 'status' => Product::STATUS_ON | 274 | 'status' => Product::STATUS_ON |
| 275 | ]); | 275 | ]); |
| 276 | - $route = RouteMap::setRoute($item['url'] ? $this->get_url_route($item['url']) : $item['ttile'], RouteMap::SOURCE_PRODUCT, $id, $project_id); | 276 | + $route = RouteMap::setRoute($this->get_url_route($item['url']) ?: $item['ttile'], RouteMap::SOURCE_PRODUCT, $id, $project_id); |
| 277 | $model->edit(['route' => $route], ['id' => $id]); | 277 | $model->edit(['route' => $route], ['id' => $id]); |
| 278 | } catch (\Exception $e) { | 278 | } catch (\Exception $e) { |
| 279 | echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL; | 279 | echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL; |
| @@ -328,7 +328,7 @@ class ProjectUpdate extends Command | @@ -328,7 +328,7 @@ class ProjectUpdate extends Command | ||
| 328 | 'image' => $item['images'][0] ?? '', | 328 | 'image' => $item['images'][0] ?? '', |
| 329 | 'status' => $api_type == 'news' ? News::STATUS_ONE : Blog::STATUS_ONE | 329 | 'status' => $api_type == 'news' ? News::STATUS_ONE : Blog::STATUS_ONE |
| 330 | ]); | 330 | ]); |
| 331 | - $route = RouteMap::setRoute($item['url'] ? $this->get_url_route($item['url']) : $item['ttile'], $api_type == 'news' ? RouteMap::SOURCE_NEWS : RouteMap::SOURCE_BLOG, $id, $project_id); | 331 | + $route = RouteMap::setRoute($this->get_url_route($item['url']) ?: $item['ttile'], $api_type == 'news' ? RouteMap::SOURCE_NEWS : RouteMap::SOURCE_BLOG, $id, $project_id); |
| 332 | $model->edit(['url' => $route], ['id' => $id]); | 332 | $model->edit(['url' => $route], ['id' => $id]); |
| 333 | } catch (\Exception $e) { | 333 | } catch (\Exception $e) { |
| 334 | echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL; | 334 | echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL; |
| @@ -377,7 +377,7 @@ class ProjectUpdate extends Command | @@ -377,7 +377,7 @@ class ProjectUpdate extends Command | ||
| 377 | 'html' => $item['content'] ?? '', | 377 | 'html' => $item['content'] ?? '', |
| 378 | 'status' => 1 | 378 | 'status' => 1 |
| 379 | ]); | 379 | ]); |
| 380 | - $route = RouteMap::setRoute($item['url'] ? $this->get_url_route($item['url']) : $item['ttile'], RouteMap::SOURCE_PAGE, $id, $project_id); | 380 | + $route = RouteMap::setRoute($this->get_url_route($item['url']) ?: $item['ttile'], RouteMap::SOURCE_PAGE, $id, $project_id); |
| 381 | $model->edit(['url' => $route], ['id' => $id]); | 381 | $model->edit(['url' => $route], ['id' => $id]); |
| 382 | } catch (\Exception $e) { | 382 | } catch (\Exception $e) { |
| 383 | echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL; | 383 | echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL; |
| @@ -433,8 +433,19 @@ class ProjectUpdate extends Command | @@ -433,8 +433,19 @@ class ProjectUpdate extends Command | ||
| 433 | //获取地址路由 | 433 | //获取地址路由 |
| 434 | protected function get_url_route($url) | 434 | protected function get_url_route($url) |
| 435 | { | 435 | { |
| 436 | - $arr = explode('/', $url); | ||
| 437 | - return $arr[count($arr) - 2]; | 436 | + $arr = parse_url($url); |
| 437 | + if (empty($arr['path'])) { | ||
| 438 | + return ''; | ||
| 439 | + } | ||
| 440 | + $path = $arr['path']; | ||
| 441 | + | ||
| 442 | + if (strpos($path, '.') !== false) { | ||
| 443 | + $path = substr($path, 0, strpos($path, '.')); | ||
| 444 | + } | ||
| 445 | + | ||
| 446 | + $path_arr = explode('/', $path); | ||
| 447 | + | ||
| 448 | + return end($path_arr) ? end($path_arr) : $path_arr[count($path_arr) - 2]; | ||
| 438 | } | 449 | } |
| 439 | 450 | ||
| 440 | //多级分类入库 | 451 | //多级分类入库 |
| @@ -454,7 +465,7 @@ class ProjectUpdate extends Command | @@ -454,7 +465,7 @@ class ProjectUpdate extends Command | ||
| 454 | 'keywords' => $item['keywords'] ?? '', | 465 | 'keywords' => $item['keywords'] ?? '', |
| 455 | 'describe' => $item['description'] ?? '' | 466 | 'describe' => $item['description'] ?? '' |
| 456 | ]); | 467 | ]); |
| 457 | - $route = RouteMap::setRoute($item['url'] ? $this->get_url_route($item['url']) : $item['name'], RouteMap::SOURCE_PRODUCT_CATE, $parent_id, $project_id); | 468 | + $route = RouteMap::setRoute($this->get_url_route($item['url']) ?: $item['name'], RouteMap::SOURCE_PRODUCT_CATE, $parent_id, $project_id); |
| 458 | $model->edit(['route' => $route], ['id' => $parent_id]); | 469 | $model->edit(['route' => $route], ['id' => $parent_id]); |
| 459 | } catch (\Exception $e) { | 470 | } catch (\Exception $e) { |
| 460 | echo 'date:' . date('Y-m-d H:i:s') . ', category_insert error: ' . $e->getMessage() . PHP_EOL; | 471 | echo 'date:' . date('Y-m-d H:i:s') . ', category_insert error: ' . $e->getMessage() . PHP_EOL; |
-
请 注册 或 登录 后发表评论