fix: 获取系统url

This commit is contained in:
2025-05-24 11:15:48 +08:00
parent 3d28b10f89
commit 91762a9045

View File

@@ -8,6 +8,7 @@ use app\admin\model\v1\ArticleModel;
use app\admin\model\v1\ProductCategoryModel;
use app\admin\model\v1\ProductModel;
use think\facade\Db;
use think\facade\Route;
class System
{
@@ -224,15 +225,28 @@ class System
{
if ('custom' == $link_to) return [];
$data = [];
$url = parse_url($link, PHP_URL_QUERY);
if (empty($url)) return [];
parse_str($url, $params);
$data = [];
$params = [];
$url = parse_url($link, PHP_URL_QUERY);
if (empty($url)) {
$parts = explode('/', trim($link, '/'));
$params['id'] = (int)str_replace('.html', '', end($parts));
} else {
parse_str($url, $params);
}
if (empty($params['id'])) return [];
switch ($link_to) {
case 'article_category':
$data = ArticleCategoryModel::field(['id', 'name'])->bypk($params['id'])->find();
break;
case 'article':
$data = ArticleModel::field(['id', 'title' => 'name'])->bypk($params['id'])->find();
break;
case 'product_category':
$data = ProductCategoryModel::field(['id', 'name'])->bypk($params['id'])->find();
break;
case 'product':
$data = ProductModel::field(['id', 'name'])->bypk($params['id'])->find();
break;