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\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
{ {
@@ -224,15 +225,28 @@ class System
{ {
if ('custom' == $link_to) return []; if ('custom' == $link_to) return [];
$data = []; $data = [];
$url = parse_url($link, PHP_URL_QUERY); $params = [];
if (empty($url)) return []; $url = parse_url($link, PHP_URL_QUERY);
if (empty($url)) {
parse_str($url, $params); $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) { 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;