fix: 获取系统url
This commit is contained in:
@@ -8,6 +8,7 @@ use app\admin\model\v1\ArticleModel;
|
|||||||
use app\admin\model\v1\ProductCategoryModel;
|
use app\admin\model\v1\ProductCategoryModel;
|
||||||
use app\admin\model\v1\ProductModel;
|
use app\admin\model\v1\ProductModel;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
|
use think\facade\Route;
|
||||||
|
|
||||||
class System
|
class System
|
||||||
{
|
{
|
||||||
@@ -225,14 +226,27 @@ class System
|
|||||||
if ('custom' == $link_to) return [];
|
if ('custom' == $link_to) return [];
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
|
$params = [];
|
||||||
$url = parse_url($link, PHP_URL_QUERY);
|
$url = parse_url($link, PHP_URL_QUERY);
|
||||||
if (empty($url)) return [];
|
if (empty($url)) {
|
||||||
|
$parts = explode('/', trim($link, '/'));
|
||||||
|
$params['id'] = (int)str_replace('.html', '', end($parts));
|
||||||
|
} else {
|
||||||
parse_str($url, $params);
|
parse_str($url, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($params['id'])) return [];
|
||||||
|
|
||||||
switch ($link_to) {
|
switch ($link_to) {
|
||||||
|
case 'article_category':
|
||||||
|
$data = ArticleCategoryModel::field(['id', 'name'])->bypk($params['id'])->find();
|
||||||
|
break;
|
||||||
case 'article':
|
case 'article':
|
||||||
$data = ArticleModel::field(['id', 'title' => 'name'])->bypk($params['id'])->find();
|
$data = ArticleModel::field(['id', 'title' => 'name'])->bypk($params['id'])->find();
|
||||||
break;
|
break;
|
||||||
|
case 'product_category':
|
||||||
|
$data = ProductCategoryModel::field(['id', 'name'])->bypk($params['id'])->find();
|
||||||
|
break;
|
||||||
case 'product':
|
case 'product':
|
||||||
$data = ProductModel::field(['id', 'name'])->bypk($params['id'])->find();
|
$data = ProductModel::field(['id', 'name'])->bypk($params['id'])->find();
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user