chore: 忽略 tools/ 目录并从版本库移除历史脚本

这个提交包含在:
2026-10-30 14:05:29 +08:00
父节点 66b9abe089
当前提交 aab5f7ae41
共有 748 个文件被更改,包括 2651 次插入 和 2736 次删除

查看文件

@@ -83,6 +83,7 @@ class Home extends V1
'color' => (string)$row['color'],
'kind' => isset($row['kind']) && $row['kind'] === 'farm' ? 'farm' : 'general',
'count' => (int)$row['post_count'],
'isHome' => isset($row['is_home']) ? (int)$row['is_home'] : 0,
];
if ($pid === 0) {
@@ -115,6 +116,67 @@ class Home extends V1
$this->ok($list);
}
/**
* 获取首页金刚区推荐二级分类列表
* GET /api/v1/home/nav-categories → [{id,pid,name,iconKey,icon,image,color,isHome}]
* 规则:优先取后台设置 is_home=1 且 enabled=1 的二级分类,不足8个时智能补充热门果蔬二级分类,输出精准8宫格
*
* @return void
*/
public function navCategories()
{
// 1. 优先获取后台标记为推荐至首页金刚区的二级分类 (is_home=1, pid>0)
$homeRows = \think\Db::name('fc_category')
->where('enabled', 1)
->where('pid', '>', 0)
->where('is_home', 1)
->order('sort asc, id asc')
->limit(8)
->select();
$selectedIds = array_column($homeRows, 'id');
$list = $homeRows;
// 2. 若配置不足8个,则从高频果蔬二级分类中自动补齐至8个
if (count($list) < 8) {
$needed = 8 - count($list);
$query = \think\Db::name('fc_category')
->where('enabled', 1)
->where('pid', 'in', [1, 2]); // 优先从蔬菜(1)和水果(2)中补充
if (!empty($selectedIds)) {
$query->whereNotIn('id', $selectedIds);
}
$moreRows = $query->order('sort asc, post_count desc, id asc')
->limit($needed)
->select();
$list = array_merge($list, $moreRows);
}
$res = [];
foreach ($list as $row) {
$id = (int)$row['id'];
$pid = (int)$row['pid'];
$iconKey = (string)$row['icon_key'];
$rawImage = isset($row['image']) ? (string)$row['image'] : '';
$iconPath = $this->resolveCategoryIconPath($id, $iconKey, $rawImage);
$imagePath = $rawImage !== '' ? $rawImage : $iconPath;
$res[] = [
'id' => $id,
'pid' => $pid,
'name' => (string)$row['name'],
'iconKey' => $iconKey,
'icon' => $iconPath,
'image' => $imagePath,
'color' => (string)$row['color'],
'kind' => isset($row['kind']) && $row['kind'] === 'farm' ? 'farm' : 'general',
'isHome' => isset($row['is_home']) ? (int)$row['is_home'] : 0,
];
}
$this->ok($res);
}
/**
* H3 热门搜索
* GET /api/v1/home/search/hot → [string]