Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2c981cb363 | |||
| ae23ec42ad | |||
| 080e00b6c6 | |||
| 6e69f09842 | |||
| 2dd45854c1 | |||
| 72de68e1ff | |||
| 6844d73c9d |
6
app.py
6
app.py
@@ -163,7 +163,7 @@ def get_parse_prompt_template(category_type, category_id=None, subcategory_id=No
|
||||
重要要求:
|
||||
1. 图片中可能包含1个或多个产品,请识别所有产品
|
||||
2. 如果是多张图片,请综合分析所有图片内容
|
||||
3. 数字字段只返回数字,不带单位
|
||||
3. **提取数据时保留原始单位**:字段标签中如有单位标注(如($)、(GB)、(MHz)等),提取时请带上对应单位,保持数据完整性
|
||||
4. 如果某字段没有提及,返回null
|
||||
5. 返回格式:如果识别到多个产品,返回数组 [对象列表]; 如果只有一个产品,返回单个对象
|
||||
6. 只返回JSON数据,不要其他内容"""
|
||||
@@ -255,7 +255,7 @@ def parse_with_llm(text, category_type, images=None, category_id=None, subcatego
|
||||
重要要求:
|
||||
1. 图片中可能包含1个或多个产品,请识别所有产品
|
||||
2. 如果是多张图片,请综合分析所有图片内容
|
||||
3. 数字字段只返回数字,不带单位
|
||||
3. **提取数据时保留原始单位**:字段标签中如有单位标注(如($)、(GB)、(MHz)等),提取时请带上对应单位,保持数据完整性
|
||||
4. 如果某字段没有提及,返回null
|
||||
5. 返回格式:如果识别到多个产品,返回数组 [对象列表]; 如果只有一个产品,返回单个对象
|
||||
6. 只返回JSON数据,不要其他内容"""
|
||||
@@ -307,7 +307,7 @@ def parse_with_llm(text, category_type, images=None, category_id=None, subcatego
|
||||
|
||||
要求:
|
||||
1. 根据文本内容智能提取各个字段的值
|
||||
2. 数字字段只返回数字,不带单位
|
||||
2. **提取数据时保留原始单位**:字段标签中如有单位标注(如($)、(GB)、(MHz)等),提取时请带上对应单位,保持数据完整性
|
||||
3. 如果某字段在文本中没有提及,返回null
|
||||
4. 返回JSON格式,不要包含任何其他内容
|
||||
|
||||
|
||||
@@ -213,6 +213,22 @@
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "official_urls",
|
||||
"label": "官网地址",
|
||||
"type": "json",
|
||||
"description": "产品官网链接,JSON数组格式:[{\"url\":\"https://...\",\"title\":\"...\"}]",
|
||||
"required": false,
|
||||
"input_style": "long"
|
||||
},
|
||||
{
|
||||
"key": "reference_urls",
|
||||
"label": "数据参考",
|
||||
"type": "json",
|
||||
"description": "参数来源链接,JSON数组格式:[{\"url\":\"https://...\",\"title\":\"...\"}]",
|
||||
"required": false,
|
||||
"input_style": "long"
|
||||
},
|
||||
{
|
||||
"key": "description",
|
||||
"label": "描述",
|
||||
@@ -448,6 +464,22 @@
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "official_urls",
|
||||
"label": "官网地址",
|
||||
"type": "json",
|
||||
"description": "产品官网链接,JSON数组格式:[{\"url\":\"https://...\",\"title\":\"...\"}]",
|
||||
"required": false,
|
||||
"input_style": "long"
|
||||
},
|
||||
{
|
||||
"key": "reference_urls",
|
||||
"label": "数据参考",
|
||||
"type": "json",
|
||||
"description": "参数来源链接,JSON数组格式:[{\"url\":\"https://...\",\"title\":\"...\"}]",
|
||||
"required": false,
|
||||
"input_style": "long"
|
||||
},
|
||||
{
|
||||
"key": "description",
|
||||
"label": "描述",
|
||||
@@ -668,6 +700,22 @@
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "official_urls",
|
||||
"label": "官网地址",
|
||||
"type": "json",
|
||||
"description": "产品官网链接,JSON数组格式:[{\"url\":\"https://...\",\"title\":\"...\"}]",
|
||||
"required": false,
|
||||
"input_style": "long"
|
||||
},
|
||||
{
|
||||
"key": "reference_urls",
|
||||
"label": "数据参考",
|
||||
"type": "json",
|
||||
"description": "参数来源链接,JSON数组格式:[{\"url\":\"https://...\",\"title\":\"...\"}]",
|
||||
"required": false,
|
||||
"input_style": "long"
|
||||
},
|
||||
{
|
||||
"key": "description",
|
||||
"label": "描述",
|
||||
@@ -697,34 +745,46 @@
|
||||
"subcategories": [
|
||||
{
|
||||
"feature_labels": {
|
||||
"price": "价格",
|
||||
"processor": "处理器",
|
||||
"ram_gb": "内存",
|
||||
"storage_gb": "存储"
|
||||
"soc": "处理器",
|
||||
"ram": "内存",
|
||||
"rom": "存储",
|
||||
"screen_size": "屏幕",
|
||||
"battery": "电池",
|
||||
"fast_charge": "快充",
|
||||
"rear_main_cam": "主摄",
|
||||
"price": "价格"
|
||||
},
|
||||
"icon": "ri-star-line",
|
||||
"id": "flagship",
|
||||
"key_features": [
|
||||
"processor",
|
||||
"ram_gb",
|
||||
"storage_gb",
|
||||
"soc",
|
||||
"ram",
|
||||
"rom",
|
||||
"screen_size",
|
||||
"battery",
|
||||
"fast_charge",
|
||||
"rear_main_cam",
|
||||
"price"
|
||||
],
|
||||
"name": "旗舰手机"
|
||||
},
|
||||
{
|
||||
"feature_labels": {
|
||||
"battery_mah": "电池",
|
||||
"price": "价格",
|
||||
"processor": "处理器",
|
||||
"ram_gb": "内存"
|
||||
"soc": "处理器",
|
||||
"ram": "内存",
|
||||
"rom": "存储",
|
||||
"battery": "电池",
|
||||
"rear_main_cam": "主摄",
|
||||
"price": "价格"
|
||||
},
|
||||
"icon": "ri-price-tag-3-line",
|
||||
"id": "midrange",
|
||||
"key_features": [
|
||||
"processor",
|
||||
"ram_gb",
|
||||
"battery_mah",
|
||||
"soc",
|
||||
"ram",
|
||||
"rom",
|
||||
"battery",
|
||||
"rear_main_cam",
|
||||
"price"
|
||||
],
|
||||
"name": "中端手机"
|
||||
@@ -732,92 +792,420 @@
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"description": "手机型号",
|
||||
"key": "name",
|
||||
"label": "名称",
|
||||
"required": true,
|
||||
"label": "型号",
|
||||
"type": "text",
|
||||
"description": "手机型号名称",
|
||||
"required": true,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"description": "手机品牌",
|
||||
"key": "brand",
|
||||
"label": "品牌",
|
||||
"type": "text",
|
||||
"description": "小米/华为/Apple/荣耀等",
|
||||
"required": true,
|
||||
"type": "text",
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"description": "CPU型号",
|
||||
"key": "processor",
|
||||
"label": "处理器",
|
||||
"key": "release_date",
|
||||
"label": "发布日期",
|
||||
"type": "text",
|
||||
"description": "产品发布日期,格式YYYY年MM月DD日",
|
||||
"required": false,
|
||||
"type": "text",
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"description": "RAM容量",
|
||||
"key": "ram_gb",
|
||||
"label": "内存(GB)",
|
||||
"key": "market_date",
|
||||
"label": "上市时间",
|
||||
"type": "text",
|
||||
"description": "产品上市日期,格式YYYY年MM月DD日",
|
||||
"required": false,
|
||||
"type": "text",
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"description": "存储容量",
|
||||
"key": "storage_gb",
|
||||
"label": "存储(GB)",
|
||||
"key": "product_level",
|
||||
"label": "产品级别",
|
||||
"type": "text",
|
||||
"description": "入门/中端/旗舰等",
|
||||
"required": false,
|
||||
"type": "text",
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"description": "屏幕尺寸(英寸)",
|
||||
"key": "screen_size",
|
||||
"label": "屏幕尺寸",
|
||||
"required": false,
|
||||
"type": "text",
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"description": "电池容量",
|
||||
"key": "battery_mah",
|
||||
"label": "电池(mAh)",
|
||||
"required": false,
|
||||
"type": "text",
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"description": "参考价格",
|
||||
"key": "price",
|
||||
"label": "价格",
|
||||
"required": false,
|
||||
"type": "text",
|
||||
"description": "参考价格",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "os",
|
||||
"label": "操作系统",
|
||||
"type": "text",
|
||||
"description": "Android/iOS/HarmonyOS等",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "soc",
|
||||
"label": "处理器",
|
||||
"type": "text",
|
||||
"description": "SoC/CPU型号,如骁龙8至尊版、天玑9400、A18 Pro",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "gpu",
|
||||
"label": "GPU",
|
||||
"type": "text",
|
||||
"description": "图形处理芯片",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "ram",
|
||||
"label": "运行内存",
|
||||
"type": "text",
|
||||
"description": "如8GB/12GB/16GB",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "rom",
|
||||
"label": "存储空间",
|
||||
"type": "text",
|
||||
"description": "如128GB/256GB/512GB/1TB",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "storage_expand",
|
||||
"label": "存储扩展",
|
||||
"type": "text",
|
||||
"description": "TF卡等扩展方式",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "screen_size",
|
||||
"label": "屏幕尺寸",
|
||||
"type": "text",
|
||||
"description": "如6.3英寸",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "screen_type",
|
||||
"label": "屏幕类型",
|
||||
"type": "text",
|
||||
"description": "OLED/LCD/AMOLED",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "resolution",
|
||||
"label": "分辨率",
|
||||
"type": "text",
|
||||
"description": "1080P/1.5K/2K",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "refresh_rate",
|
||||
"label": "刷新率",
|
||||
"type": "text",
|
||||
"description": "60Hz/90Hz/120Hz/144Hz",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "ltpo",
|
||||
"label": "LTPO",
|
||||
"type": "text",
|
||||
"description": "自适应刷新率,省电",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "brightness",
|
||||
"label": "亮度",
|
||||
"type": "text",
|
||||
"description": "峰值亮度(nit)",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "screen_feature",
|
||||
"label": "屏幕特色",
|
||||
"type": "text",
|
||||
"description": "直屏/曲面屏、护眼调光等",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "rear_main_cam",
|
||||
"label": "后置主摄",
|
||||
"type": "text",
|
||||
"description": "像素、传感器型号、光圈",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "rear_ultra_wide",
|
||||
"label": "超广角",
|
||||
"type": "text",
|
||||
"description": "像素、视角",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "rear_telephoto",
|
||||
"label": "长焦",
|
||||
"type": "text",
|
||||
"description": "倍率(3x/5x/10x)",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "front_cam",
|
||||
"label": "前置摄像头",
|
||||
"type": "text",
|
||||
"description": "像素",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "video_record",
|
||||
"label": "视频录制",
|
||||
"type": "text",
|
||||
"description": "4K/8K、帧率",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "cam_feature",
|
||||
"label": "摄像头特色",
|
||||
"type": "text",
|
||||
"description": "徕卡/蔡司/哈苏、OIS光学防抖等",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "battery",
|
||||
"label": "电池容量",
|
||||
"type": "text",
|
||||
"description": "mAh(4000-7000+)",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "fast_charge",
|
||||
"label": "有线快充",
|
||||
"type": "text",
|
||||
"description": "功率(33W/67W/100W/120W+)",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "wireless_charge",
|
||||
"label": "无线充电",
|
||||
"type": "text",
|
||||
"description": "功率(15W/50W等)",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "battery_feature",
|
||||
"label": "电池特色",
|
||||
"type": "text",
|
||||
"description": "反向充电等",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "network",
|
||||
"label": "运营商网络",
|
||||
"type": "text",
|
||||
"description": "5G/4G支持",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "wifi",
|
||||
"label": "Wi-Fi",
|
||||
"type": "text",
|
||||
"description": "Wi-Fi 6/6E/7",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "bluetooth",
|
||||
"label": "蓝牙",
|
||||
"type": "text",
|
||||
"description": "5.3/5.4",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "nfc",
|
||||
"label": "NFC",
|
||||
"type": "text",
|
||||
"description": "刷公交、门禁、支付",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "ir_remote",
|
||||
"label": "红外遥控",
|
||||
"type": "text",
|
||||
"description": "是/否",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "gps",
|
||||
"label": "定位系统",
|
||||
"type": "text",
|
||||
"description": "GPS等",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "usb_interface",
|
||||
"label": "USB接口",
|
||||
"type": "text",
|
||||
"description": "Type-C/USB 3.0/2.0",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "sim_card",
|
||||
"label": "SIM卡",
|
||||
"type": "text",
|
||||
"description": "单卡/双卡",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "fingerprint",
|
||||
"label": "指纹识别",
|
||||
"type": "text",
|
||||
"description": "侧边/屏下超声波/屏下光学",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "waterproof",
|
||||
"label": "防水防尘等级",
|
||||
"type": "text",
|
||||
"description": "IP68/IP69/IP54等",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "face_id",
|
||||
"label": "面部识别",
|
||||
"type": "text",
|
||||
"description": "Face ID/3D结构光",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "weight",
|
||||
"label": "重量",
|
||||
"type": "text",
|
||||
"description": "克(g)",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "thickness",
|
||||
"label": "厚度",
|
||||
"type": "text",
|
||||
"description": "毫米(mm)",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "body_material",
|
||||
"label": "机身材质",
|
||||
"type": "text",
|
||||
"description": "玻璃/陶瓷/金属/素皮",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "colors",
|
||||
"label": "颜色",
|
||||
"type": "text",
|
||||
"description": "可选颜色",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "frame_material",
|
||||
"label": "中框材质",
|
||||
"type": "text",
|
||||
"description": "铝合金/钛合金",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "speaker",
|
||||
"label": "扬声器",
|
||||
"type": "text",
|
||||
"description": "单扬声器/立体声双扬声器",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "headphone_jack",
|
||||
"label": "耳机接口",
|
||||
"type": "text",
|
||||
"description": "3.5mm耳机孔",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "vibration",
|
||||
"label": "震动反馈",
|
||||
"type": "text",
|
||||
"description": "X轴线性马达",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "features",
|
||||
"label": "特色",
|
||||
"type": "text",
|
||||
"description": "产品特色/亮点,简短描述",
|
||||
"description": "产品特色/亮点",
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"description": "产品简介",
|
||||
"key": "description",
|
||||
"label": "描述",
|
||||
"key": "official_urls",
|
||||
"label": "官网地址",
|
||||
"type": "json",
|
||||
"description": "产品官网链接",
|
||||
"required": false,
|
||||
"type": "text",
|
||||
"input_style": "long"
|
||||
},
|
||||
{
|
||||
"description": "产品发布日期,格式 YYYY-MM-DD",
|
||||
"key": "publish_date",
|
||||
"label": "发布日期",
|
||||
"key": "reference_urls",
|
||||
"label": "数据参考",
|
||||
"type": "json",
|
||||
"description": "参数来源链接",
|
||||
"required": false,
|
||||
"input_style": "long"
|
||||
},
|
||||
{
|
||||
"key": "description",
|
||||
"label": "描述",
|
||||
"type": "text",
|
||||
"input_style": "normal"
|
||||
"description": "产品简介",
|
||||
"required": false,
|
||||
"input_style": "long"
|
||||
}
|
||||
],
|
||||
"updated_at": "2026-04-28 18:28:01"
|
||||
@@ -962,6 +1350,22 @@
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "official_urls",
|
||||
"label": "官网地址",
|
||||
"type": "json",
|
||||
"description": "产品官网链接,JSON数组格式:[{\"url\":\"https://...\",\"title\":\"...\"}]",
|
||||
"required": false,
|
||||
"input_style": "long"
|
||||
},
|
||||
{
|
||||
"key": "reference_urls",
|
||||
"label": "数据参考",
|
||||
"type": "json",
|
||||
"description": "参数来源链接,JSON数组格式:[{\"url\":\"https://...\",\"title\":\"...\"}]",
|
||||
"required": false,
|
||||
"input_style": "long"
|
||||
},
|
||||
{
|
||||
"description": "产品简介",
|
||||
"input_style": "long",
|
||||
@@ -1079,6 +1483,22 @@
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "official_urls",
|
||||
"label": "官网地址",
|
||||
"type": "json",
|
||||
"description": "产品官网链接,JSON数组格式:[{\"url\":\"https://...\",\"title\":\"...\"}]",
|
||||
"required": false,
|
||||
"input_style": "long"
|
||||
},
|
||||
{
|
||||
"key": "reference_urls",
|
||||
"label": "数据参考",
|
||||
"type": "json",
|
||||
"description": "参数来源链接,JSON数组格式:[{\"url\":\"https://...\",\"title\":\"...\"}]",
|
||||
"required": false,
|
||||
"input_style": "long"
|
||||
},
|
||||
{
|
||||
"description": "车型简介",
|
||||
"input_style": "long",
|
||||
@@ -1225,6 +1645,22 @@
|
||||
"required": false,
|
||||
"input_style": "normal"
|
||||
},
|
||||
{
|
||||
"key": "official_urls",
|
||||
"label": "官网地址",
|
||||
"type": "json",
|
||||
"description": "产品官网链接,JSON数组格式:[{\"url\":\"https://...\",\"title\":\"...\"}]",
|
||||
"required": false,
|
||||
"input_style": "long"
|
||||
},
|
||||
{
|
||||
"key": "reference_urls",
|
||||
"label": "数据参考",
|
||||
"type": "json",
|
||||
"description": "参数来源链接,JSON数组格式:[{\"url\":\"https://...\",\"title\":\"...\"}]",
|
||||
"required": false,
|
||||
"input_style": "long"
|
||||
},
|
||||
{
|
||||
"key": "description",
|
||||
"label": "描述",
|
||||
|
||||
@@ -534,11 +534,30 @@
|
||||
container.innerHTML = '';
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取当前筛选值 - 根据容器ID判断
|
||||
let currentFilter = '';
|
||||
if (containerId === 'model-subcategory-filters') currentFilter = modelSubcategoryFilter;
|
||||
else if (containerId === 'gpu-subcategory-filters') currentFilter = gpuSubcategoryFilter;
|
||||
else if (containerId === 'cpu-subcategory-filters') currentFilter = cpuSubcategoryFilter;
|
||||
else if (containerId === 'dynamic-subcategory-filters') currentFilter = dynamicSubcategoryFilter;
|
||||
|
||||
// 渲染子类别按钮
|
||||
container.innerHTML = cat.subcategories.map(sub => `
|
||||
<button onclick="${filterFunction}('${sub.id}')" class="px-3 py-1 rounded text-sm bg-white border text-gray-600 hover:bg-gray-100">
|
||||
<i class="${sub.icon} mr-1"></i>${sub.name}
|
||||
<button onclick="${filterFunction}('${sub.id}')" class="px-3 py-1 rounded text-sm ${currentFilter === sub.id ? 'bg-indigo-600 text-white' : 'bg-white border text-gray-600 hover:bg-gray-100'}">
|
||||
<i class="${sub.icon || 'ri-folder-line'} mr-1"></i>${sub.name}
|
||||
</button>
|
||||
`).join('');
|
||||
|
||||
// 更新"全部"按钮的样式 - 它是容器前面的那个按钮
|
||||
const allBtn = container.previousElementSibling;
|
||||
if (allBtn && allBtn.tagName === 'BUTTON') {
|
||||
if (currentFilter === '') {
|
||||
allBtn.className = 'px-3 py-1 rounded text-sm bg-indigo-600 text-white';
|
||||
} else {
|
||||
allBtn.className = 'px-3 py-1 rounded text-sm bg-white border text-gray-600 hover:bg-gray-100';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const colorMap = {
|
||||
@@ -647,7 +666,7 @@
|
||||
} else {
|
||||
// 动态分类
|
||||
html += `
|
||||
<a href="#cat-${cat.id}" onclick="showDynamicCategory('${cat.id}')" class="sidebar-link flex items-center gap-2 px-3 py-2 rounded-lg text-gray-300" data-section="cat-${cat.id}">
|
||||
<a href="#cat-${cat.id}" onclick="dynamicSubcategoryFilter='';showDynamicCategory('${cat.id}')" class="sidebar-link flex items-center gap-2 px-3 py-2 rounded-lg text-gray-300" data-section="cat-${cat.id}">
|
||||
<i class="${cat.icon}"></i>
|
||||
<span>${cat.name}管理</span>
|
||||
</a>
|
||||
@@ -669,7 +688,8 @@
|
||||
// 显示动态分类数据
|
||||
async function showDynamicCategory(categoryId) {
|
||||
dynamicCategoryId = categoryId;
|
||||
dynamicSubcategoryFilter = '';
|
||||
// 不要每次都重置筛选值,除非是新切换的分类
|
||||
// dynamicSubcategoryFilter = ''; // 移除这行
|
||||
const cat = categories.find(c => c.id === categoryId);
|
||||
const fields = cat ? (cat.fields || []) : [];
|
||||
const fixedFields = ['id', 'created_at', 'updated_at', 'visible', 'raw_text', 'category_id', 'subcategory_id', 'is_pinned', 'images'];
|
||||
|
||||
Reference in New Issue
Block a user