3 Commits
Author SHA1 Message Date
hz4th_coder 9005a48bf3 GPU显卡公共参数字段全面升级为66字段+字段类别支持
- 按显卡规格9大类别整理66个公共参数字段(全部文本类型):
  图形处理器芯片基础信息(14)/显卡产品信息(12)/渲染硬件配置(8)/理论算力(5)/显存规格(5)/矩阵算力(8)/数值格式支持(2)/图形API与特性(6)/板卡设计(6)
- 每个字段新增 category 字段类别属性(对应#开头的参数类别中文名)
- 保留平台必备结构字段: name/manufacturer/official_urls/reference_urls/description
- 后台字段编辑弹框新增「字段类别」输入,字段列表显示📁类别徽标
- 子类别关键特性映射到新字段(显存容量/着色单元/首发价/FP32等)
- 修复重复FP16: 理论算力=fp16, 矩阵算力=fp16_matrix
2026-09-10 01:32:21 +08:00
hz4th_coder 850b356f89 优化审核管理:添加详情弹窗替代alert显示,改进表格显示关键参数预览 2026-07-14 23:59:22 +08:00
hz4th_coder c85a43f542 修复首页搜索功能:改为调用全局搜索API并展示结果 2026-07-11 23:10:22 +08:00
3 changed files with 900 additions and 131 deletions
+538 -112
View File
@@ -260,16 +260,16 @@
"name": "游戏显卡",
"icon": "ri-gamepad-line",
"key_features": [
"memory_gb",
"cuda_cores",
"price_usd",
"fp16_tflops"
"memory_size",
"shading_units",
"launch_price",
"fp32"
],
"feature_labels": {
"memory_gb": "显存",
"cuda_cores": "CUDA核心",
"price_usd": "价格",
"fp16_tflops": "FP16性能"
"memory_size": "显存容量",
"shading_units": "着色单元",
"launch_price": "首发价格",
"fp32": "FP32算力"
},
"extra_fields": []
},
@@ -278,16 +278,16 @@
"name": "专业显卡",
"icon": "ri-building-line",
"key_features": [
"memory_gb",
"memory_size",
"tensor_cores",
"memory_bandwidth_gbs",
"price_usd"
"bandwidth",
"launch_price"
],
"feature_labels": {
"memory_gb": "显存",
"memory_size": "显存容量",
"tensor_cores": "Tensor核心",
"memory_bandwidth_gbs": "带宽",
"price_usd": "价格"
"bandwidth": "带宽",
"launch_price": "首发价格"
},
"extra_fields": []
},
@@ -296,16 +296,16 @@
"name": "数据中心",
"icon": "ri-server-line",
"key_features": [
"memory_gb",
"memory_size",
"tensor_cores",
"memory_bandwidth_gbs",
"fp16_tflops"
"bandwidth",
"fp16_matrix"
],
"feature_labels": {
"memory_gb": "显存",
"memory_size": "显存容量",
"tensor_cores": "Tensor核心",
"memory_bandwidth_gbs": "带宽",
"fp16_tflops": "FP16性能"
"bandwidth": "带宽",
"fp16_matrix": "FP16矩阵算力"
},
"extra_fields": [
{
@@ -332,137 +332,208 @@
"key": "name",
"label": "名称",
"type": "text",
"description": "GPU名称",
"description": "GPU产品名称",
"required": true,
"input_style": "normal"
"input_style": "normal",
"category": "图形处理器芯片基础信息"
},
{
"key": "manufacturer",
"label": "厂商",
"key": "gpu_name",
"label": "GPU名称",
"type": "text",
"description": "制造商",
"required": true,
"input_style": "normal"
"description": "GPU芯片代号,核心芯片型号",
"required": false,
"input_style": "normal",
"category": "图形处理器芯片基础信息"
},
{
"key": "gpu_variant",
"label": "GPU变体型号",
"type": "text",
"description": "芯片具体版本编号",
"required": false,
"input_style": "normal",
"category": "图形处理器芯片基础信息"
},
{
"key": "architecture",
"label": "架构",
"type": "text",
"description": "GPU架构,如Ampere、Hopper",
"description": "GPU架构",
"required": false,
"input_style": "normal"
"input_style": "normal",
"category": "图形处理器芯片基础信息"
},
{
"key": "memory_gb",
"label": "显存(GB)",
"key": "foundry",
"label": "晶圆厂",
"type": "text",
"description": "显存容量",
"description": "芯片制造工厂",
"required": false,
"input_style": "normal",
"category": "图形处理器芯片基础信息"
},
{
"key": "process_type",
"label": "工艺类型",
"type": "text",
"description": "晶体管工艺类型",
"required": false,
"input_style": "normal",
"category": "图形处理器芯片基础信息"
},
{
"key": "process_size",
"label": "工艺节点",
"type": "text",
"description": "芯片制造制程,x纳米工艺",
"required": false,
"input_style": "normal",
"category": "图形处理器芯片基础信息"
},
{
"key": "transistors",
"label": "晶体管数量",
"type": "text",
"description": "芯片内晶体管总数",
"required": false,
"input_style": "normal",
"category": "图形处理器芯片基础信息"
},
{
"key": "density",
"label": "晶体管密度",
"type": "text",
"description": "每平方毫米裸片上晶体管数量",
"required": false,
"input_style": "normal",
"category": "图形处理器芯片基础信息"
},
{
"key": "die_size",
"label": "裸片面积",
"type": "text",
"description": "GPU核心硅片面积",
"required": false,
"input_style": "normal",
"category": "图形处理器芯片基础信息"
},
{
"key": "chip_package",
"label": "芯片封装",
"type": "text",
"description": "芯片封装形式",
"required": false,
"input_style": "normal",
"category": "图形处理器芯片基础信息"
},
{
"key": "package_size",
"label": "封装尺寸",
"type": "text",
"description": "芯片封装外壳长宽尺寸",
"required": false,
"input_style": "normal",
"category": "图形处理器芯片基础信息"
},
{
"key": "base_clock",
"label": "基础频率",
"type": "text",
"description": "GPU核心默认基础工作频率",
"required": false,
"input_style": "normal",
"category": "图形处理器芯片基础信息"
},
{
"key": "boost_clock",
"label": "加速频率",
"type": "text",
"description": "GPU核心可达到的最高睿频",
"required": false,
"input_style": "normal",
"category": "图形处理器芯片基础信息"
},
{
"key": "manufacturer",
"label": "厂商",
"type": "text",
"description": "显卡制造商(NVIDIA/AMD等)",
"required": true,
"input_style": "normal"
"input_style": "normal",
"category": "显卡产品信息"
},
{
"key": "cuda_cores",
"label": "CUDA核心",
"key": "release_date",
"label": "发布日期",
"type": "text",
"description": "CUDA核心数量",
"description": "产品正式上市发布时间",
"required": false,
"input_style": "normal"
"input_style": "normal",
"category": "显卡产品信息"
},
{
"key": "tensor_cores",
"label": "Tensor核心",
"key": "announced",
"label": "官宣日期",
"type": "text",
"description": "Tensor核心数量",
"description": "产品对外公布的时间",
"required": false,
"input_style": "normal"
"input_style": "normal",
"category": "显卡产品信息"
},
{
"key": "memory_bandwidth_gbs",
"label": "显存带宽(GB/s)",
"key": "generation",
"label": "产品世代",
"type": "text",
"description": "显存带宽",
"description": "产品系列",
"required": false,
"input_style": "normal"
"input_style": "normal",
"category": "显卡产品信息"
},
{
"key": "fp32_tflops",
"label": "FP32性能(TF)",
"key": "production",
"label": "生产状态",
"type": "text",
"description": "FP32浮点性能",
"description": "当前生产状态",
"required": false,
"input_style": "normal"
"input_style": "normal",
"category": "显卡产品信息"
},
{
"key": "fp16_tflops",
"label": "FP16性能(TF)",
"key": "driver_support",
"label": "驱动支持状态",
"type": "text",
"description": "FP16半精度性能",
"description": "厂商仍持续维护更新驱动程序",
"required": false,
"input_style": "normal"
"input_style": "normal",
"category": "显卡产品信息"
},
{
"key": "int8_perf_tops",
"label": "INT8性能(TOPS)",
"key": "launch_price",
"label": "首发价格",
"type": "text",
"description": "INT8整数性能",
"description": "产品上市首发售价",
"required": false,
"input_style": "normal"
"input_style": "normal",
"category": "显卡产品信息"
},
{
"key": "price_usd",
"label": "价格($)",
"key": "current_price",
"label": "当前售价",
"type": "text",
"description": "参考价格(美元)",
"description": "可购买渠道",
"required": false,
"input_style": "normal"
"input_style": "normal",
"category": "显卡产品信息"
},
{
"key": "currency",
"label": "币种",
"key": "bus_interface",
"label": "总线接口",
"type": "text",
"description": "价格币种",
"description": "主机与显卡通信总线",
"required": false,
"input_style": "normal"
},
{
"key": "min_price",
"label": "最低价",
"type": "text",
"description": "最低价格",
"required": false,
"input_style": "normal"
},
{
"key": "max_price",
"label": "最高价",
"type": "text",
"description": "最高价格",
"required": false,
"input_style": "normal"
},
{
"key": "price_unit",
"label": "价格单位",
"type": "text",
"description": "价格单位,如万",
"required": false,
"input_style": "normal"
},
{
"key": "release_year",
"label": "发布年份",
"type": "text",
"description": "发布年份",
"required": false,
"input_style": "normal"
},
{
"key": "features",
"label": "特色",
"type": "text",
"description": "产品特色/亮点,简短描述",
"required": false,
"input_style": "normal"
"input_style": "normal",
"category": "显卡产品信息"
},
{
"key": "official_urls",
@@ -470,7 +541,8 @@
"type": "json",
"description": "产品官网链接,JSON数组格式:[{\"url\":\"https://...\",\"title\":\"...\"}]",
"required": false,
"input_style": "long"
"input_style": "long",
"category": "显卡产品信息"
},
{
"key": "reference_urls",
@@ -478,7 +550,8 @@
"type": "json",
"description": "参数来源链接,JSON数组格式:[{\"url\":\"https://...\",\"title\":\"...\"}]",
"required": false,
"input_style": "long"
"input_style": "long",
"category": "显卡产品信息"
},
{
"key": "description",
@@ -486,15 +559,368 @@
"type": "text",
"description": "GPU简介",
"required": false,
"input_style": "long"
"input_style": "long",
"category": "显卡产品信息"
},
{
"key": "publish_date",
"label": "发布日期",
"key": "shading_units",
"label": "着色单元",
"type": "text",
"description": "产品发布日期,格式 YYYY-MM-DD",
"description": "GPU着色运算单元总数",
"required": false,
"input_style": "normal"
"input_style": "normal",
"category": "渲染硬件配置"
},
{
"key": "tmus",
"label": "纹理映射单元",
"type": "text",
"description": "纹理贴图采样单元数量",
"required": false,
"input_style": "normal",
"category": "渲染硬件配置"
},
{
"key": "rops",
"label": "光栅输出单元",
"type": "text",
"description": "光栅化像素输出单元数量",
"required": false,
"input_style": "normal",
"category": "渲染硬件配置"
},
{
"key": "sm_count",
"label": "流式多处理器数量",
"type": "text",
"description": "CUDA流式多处理器SM总数",
"required": false,
"input_style": "normal",
"category": "渲染硬件配置"
},
{
"key": "tensor_cores",
"label": "张量核心数量",
"type": "text",
"description": "AI张量运算专用核心数量",
"required": false,
"input_style": "normal",
"category": "渲染硬件配置"
},
{
"key": "rt_cores",
"label": "光线追踪核心数量",
"type": "text",
"description": "实时光线追踪专用核心数量",
"required": false,
"input_style": "normal",
"category": "渲染硬件配置"
},
{
"key": "l1_cache",
"label": "一级缓存",
"type": "text",
"description": "每个SM独立配备",
"required": false,
"input_style": "normal",
"category": "渲染硬件配置"
},
{
"key": "l2_cache",
"label": "二级缓存",
"type": "text",
"description": "GPU全局二级缓存总容量",
"required": false,
"input_style": "normal",
"category": "渲染硬件配置"
},
{
"key": "pixel_rate",
"label": "像素填充率",
"type": "text",
"description": "图形渲染时每秒可输出像素数量",
"required": false,
"input_style": "normal",
"category": "理论算力"
},
{
"key": "texture_rate",
"label": "纹理填充率",
"type": "text",
"description": "图形渲染时每秒可采样纹理单元数量",
"required": false,
"input_style": "normal",
"category": "理论算力"
},
{
"key": "fp16",
"label": "FP16理论算力",
"type": "text",
"description": "FP16浮点通用理论算力,1:1为完整精度",
"required": false,
"input_style": "normal",
"category": "理论算力"
},
{
"key": "fp32",
"label": "FP32理论算力",
"type": "text",
"description": "FP32单精度浮点通用理论算力",
"required": false,
"input_style": "normal",
"category": "理论算力"
},
{
"key": "fp64",
"label": "FP64理论算力",
"type": "text",
"description": "FP64双精度浮点通用理论算力,1:64为性能比例",
"required": false,
"input_style": "normal",
"category": "理论算力"
},
{
"key": "memory_size",
"label": "显存容量",
"type": "text",
"description": "板载显存总容量",
"required": false,
"input_style": "normal",
"category": "显存规格"
},
{
"key": "memory_type",
"label": "显存类型",
"type": "text",
"description": "显存型号,第7代图形显存",
"required": false,
"input_style": "normal",
"category": "显存规格"
},
{
"key": "memory_bus",
"label": "显存位宽",
"type": "text",
"description": "显存与GPU之间的数据总线位宽",
"required": false,
"input_style": "normal",
"category": "显存规格"
},
{
"key": "bandwidth",
"label": "显存带宽",
"type": "text",
"description": "显存理论最大数据吞吐带宽",
"required": false,
"input_style": "normal",
"category": "显存规格"
},
{
"key": "memory_clock",
"label": "显存频率",
"type": "text",
"description": "显存物理时钟,等效数据速率",
"required": false,
"input_style": "normal",
"category": "显存规格"
},
{
"key": "fp4",
"label": "FP4矩阵算力",
"type": "text",
"description": "FP4精度下张量矩阵理论运算性能",
"required": false,
"input_style": "normal",
"category": "矩阵算力"
},
{
"key": "fp6",
"label": "FP6矩阵算力",
"type": "text",
"description": "FP6精度下张量矩阵理论运算性能",
"required": false,
"input_style": "normal",
"category": "矩阵算力"
},
{
"key": "int8",
"label": "INT8矩阵算力",
"type": "text",
"description": "INT8整数精度张量矩阵理论运算性能",
"required": false,
"input_style": "normal",
"category": "矩阵算力"
},
{
"key": "fp8",
"label": "FP8矩阵算力",
"type": "text",
"description": "FP8精度下张量矩阵理论运算性能",
"required": false,
"input_style": "normal",
"category": "矩阵算力"
},
{
"key": "fp16_matrix",
"label": "FP16矩阵算力",
"type": "text",
"description": "FP16精度下张量矩阵理论运算性能",
"required": false,
"input_style": "normal",
"category": "矩阵算力"
},
{
"key": "bf16",
"label": "BF16矩阵算力",
"type": "text",
"description": "BF16浮点数精度张量矩阵理论运算性能",
"required": false,
"input_style": "normal",
"category": "矩阵算力"
},
{
"key": "tf32",
"label": "TF32矩阵算力",
"type": "text",
"description": "TF32张量浮点精度矩阵理论运算性能",
"required": false,
"input_style": "normal",
"category": "矩阵算力"
},
{
"key": "sparse_matrix",
"label": "稀疏矩阵算力",
"type": "text",
"description": "稀疏权重时算力可翻倍",
"required": false,
"input_style": "normal",
"category": "矩阵算力"
},
{
"key": "vector",
"label": "向量计算支持格式",
"type": "text",
"description": "向量运算支持的数据精度类型",
"required": false,
"input_style": "normal",
"category": "数值格式支持"
},
{
"key": "matrix",
"label": "矩阵计算支持格式",
"type": "text",
"description": "矩阵/张量运算支持的数据精度类型",
"required": false,
"input_style": "normal",
"category": "数值格式支持"
},
{
"key": "directx",
"label": "DirectX支持版本",
"type": "text",
"description": "支持的DirectX版本",
"required": false,
"input_style": "normal",
"category": "图形API与特性"
},
{
"key": "opengl",
"label": "OpenGL版本",
"type": "text",
"description": "支持OpenGL图形接口版本",
"required": false,
"input_style": "normal",
"category": "图形API与特性"
},
{
"key": "opencl",
"label": "OpenCL版本",
"type": "text",
"description": "支持OpenCL通用计算接口版本",
"required": false,
"input_style": "normal",
"category": "图形API与特性"
},
{
"key": "vulkan",
"label": "Vulkan版本",
"type": "text",
"description": "支持Vulkan跨平台图形API版本",
"required": false,
"input_style": "normal",
"category": "图形API与特性"
},
{
"key": "cuda",
"label": "CUDA版本",
"type": "text",
"description": "支持CUDA计算平台版本",
"required": false,
"input_style": "normal",
"category": "图形API与特性"
},
{
"key": "shader_model",
"label": "着色器模型",
"type": "text",
"description": "支持Shader Model着色器规范版本",
"required": false,
"input_style": "normal",
"category": "图形API与特性"
},
{
"key": "slot_width",
"label": "插槽占用宽度",
"type": "text",
"description": "显卡槽位,占用主板PCIe挡板位个数",
"required": false,
"input_style": "normal",
"category": "板卡设计"
},
{
"key": "tdp",
"label": "功耗上限",
"type": "text",
"description": "板卡设计热功耗",
"required": false,
"input_style": "normal",
"category": "板卡设计"
},
{
"key": "suggested_psu",
"label": "推荐电源",
"type": "text",
"description": "整机配套推荐电源功率",
"required": false,
"input_style": "normal",
"category": "板卡设计"
},
{
"key": "outputs",
"label": "视频输出接口",
"type": "text",
"description": "视频输出接口",
"required": false,
"input_style": "normal",
"category": "板卡设计"
},
{
"key": "power_connectors",
"label": "供电接口",
"type": "text",
"description": "供电接口",
"required": false,
"input_style": "normal",
"category": "板卡设计"
},
{
"key": "board_number",
"label": "板卡型号编号",
"type": "text",
"description": "PCB板卡内部编号",
"required": false,
"input_style": "normal",
"category": "板卡设计"
}
]
},
+232 -16
View File
@@ -324,12 +324,13 @@
<th class="px-4 py-3 text-left text-sm font-medium text-gray-600">产品名称</th>
<th class="px-4 py-3 text-left text-sm font-medium text-gray-600">分类</th>
<th class="px-4 py-3 text-left text-sm font-medium text-gray-600">来源</th>
<th class="px-4 py-3 text-left text-sm font-medium text-gray-600">提交者</th>
<th class="px-4 py-3 text-left text-sm font-medium text-gray-600">提交时间</th>
<th class="px-4 py-3 text-left text-sm font-medium text-gray-600">状态</th>
<th class="px-4 py-3 text-center text-sm font-medium text-gray-600">操作</th>
</tr>
</thead>
<tbody id="reviewsTable"><tr><td colspan="6" class="text-center text-gray-400 py-8">加载中...</td></tr></tbody>
<tbody id="reviewsTable"><tr><td colspan="7" class="text-center text-gray-400 py-8">加载中...</td></tr></tbody>
</table>
</div>
</section>
@@ -479,6 +480,22 @@
</div>
</div>
<!-- 审核详情弹窗 -->
<div id="reviewDetailModal" class="fixed inset-0 bg-black/50 z-50 hidden flex items-center justify-center">
<div class="bg-white rounded-xl max-w-4xl w-full mx-4 max-h-[90vh] overflow-auto">
<div class="p-6 border-b flex justify-between items-center sticky top-0 bg-white z-10">
<h2 class="text-xl font-bold text-gray-800"><i class="ri-file-search-line mr-2 text-blue-600"></i>审核详情</h2>
<button onclick="closeReviewDetailModal()" class="text-gray-400 hover:text-gray-600"><i class="ri-close-line text-2xl"></i></button>
</div>
<div id="reviewDetailContent" class="p-6">
<!-- 动态内容 -->
</div>
<div id="reviewDetailActions" class="p-6 border-t flex justify-end gap-4 sticky bottom-0 bg-white">
<!-- 操作按钮 -->
</div>
</div>
</div>
<!-- 参数字段编辑弹框 -->
<div id="fieldModal" class="fixed inset-0 bg-black/50 z-50 hidden flex items-center justify-center">
<div class="bg-white rounded-xl max-w-lg w-full mx-4">
@@ -490,6 +507,7 @@
<div class="space-y-4">
<div><label class="text-sm text-gray-600 mb-1 block">字段名 *</label><input type="text" id="field_key" class="w-full px-3 py-2 border rounded-lg" placeholder="如:context_length"></div>
<div><label class="text-sm text-gray-600 mb-1 block">显示名 *</label><input type="text" id="field_label" class="w-full px-3 py-2 border rounded-lg" placeholder="如:上下文长度"></div>
<div><label class="text-sm text-gray-600 mb-1 block">字段类别</label><input type="text" id="field_category" class="w-full px-3 py-2 border rounded-lg" placeholder="如:图形处理器芯片基础信息(参数分组,可为空)"></div>
<div><label class="text-sm text-gray-600 mb-1 block">字段类型</label><select id="field_type" class="w-full px-3 py-2 border rounded-lg">
<option value="text">文本</option>
<option value="number">数字</option>
@@ -1862,6 +1880,7 @@
${field.required ? '<span class="text-red-500">必填</span>' : '可选'}
${field.description ? ` | ${field.description}` : ''}
</div>
${field.category ? `<div class="mt-1"><span class="inline-block px-2 py-0.5 bg-indigo-50 text-indigo-600 border border-indigo-100 rounded text-xs">📁 ${field.category}</span></div>` : ''}
</div>
</div>
<div class="flex gap-2 opacity-0 group-hover:opacity-100 transition">
@@ -1883,6 +1902,7 @@
document.getElementById('fieldModalTitle').textContent = '添加参数字段';
document.getElementById('field_key').value = '';
document.getElementById('field_label').value = '';
document.getElementById('field_category').value = '';
document.getElementById('field_type').value = 'text';
document.getElementById('field_desc').value = '';
document.getElementById('field_required').checked = false;
@@ -1898,6 +1918,7 @@
document.getElementById('fieldModalTitle').textContent = '编辑参数字段';
document.getElementById('field_key').value = field.key || '';
document.getElementById('field_label').value = field.label || '';
document.getElementById('field_category').value = field.category || '';
document.getElementById('field_type').value = field.type || 'text';
document.getElementById('field_desc').value = field.description || '';
document.getElementById('field_required').checked = field.required || false;
@@ -1921,6 +1942,7 @@
function saveField() {
const key = document.getElementById('field_key').value.trim();
const label = document.getElementById('field_label').value.trim();
const category = document.getElementById('field_category').value.trim();
const type = document.getElementById('field_type').value;
const description = document.getElementById('field_desc').value.trim();
const required = document.getElementById('field_required').checked;
@@ -1931,6 +1953,7 @@
}
const field = { key, label, type, description, required };
if (category) field.category = category;
if (currentFieldTarget === 'subcategory') {
// 子类别额外字段
@@ -3194,7 +3217,7 @@
if (reviews.length === 0) {
document.getElementById('reviewsTable').innerHTML = `
<tr><td colspan="6" class="text-center text-gray-400 py-8">暂无数据</td></tr>
<tr><td colspan="7" class="text-center text-gray-400 py-8">暂无数据</td></tr>
`;
return;
}
@@ -3207,20 +3230,34 @@
const html = reviews.map(r => {
const catName = categories.find(c => c.id === r.category_id)?.name || r.category_id;
// 提取关键参数预览
const data = r.data || {};
const previewFields = [];
['organization', 'model_type', 'parameters', 'context_length', 'release_year'].forEach(key => {
if (data[key]) previewFields.push(`<span class="text-gray-500">${data[key]}</span>`);
});
const preview = previewFields.length > 0 ? previewFields.slice(0, 3).join(' · ') : '-';
return `
<tr class="border-b hover:bg-gray-50">
<td class="px-4 py-3 font-medium text-gray-800">${r.data?.name || '-'}</td>
<tr class="border-b hover:bg-gray-50 ${r.status === 'pending' ? 'bg-orange-50/30' : ''}">
<td class="px-4 py-3">
<div class="font-medium text-gray-800">${r.data?.name || '-'}</div>
<div class="text-xs text-gray-400 mt-1">${preview}</div>
</td>
<td class="px-4 py-3 text-gray-600">${catName}</td>
<td class="px-4 py-3 text-sm">
${r.source === 'api' ? '<span class="text-indigo-600">API</span>' : '<span class="text-gray-500">网页</span>'}
</td>
<td class="px-4 py-3 text-sm">
${r.submitter ? `<span class="text-gray-600">${r.submitter}</span>` : '<span class="text-gray-400">匿名</span>'}
</td>
<td class="px-4 py-3 text-sm text-gray-500">${r.created_at}</td>
<td class="px-4 py-3">${statusLabels[r.status] || r.status}</td>
<td class="px-4 py-3 text-center">
${r.status === 'pending' ? `
<button onclick="approveReview('${r.id}')" class="text-green-600 hover:text-green-800 mr-2" title="通过"><i class="ri-check-line"></i></button>
<button onclick="viewReviewDetail('${r.id}')" class="text-blue-600 hover:text-blue-800 mr-2" title="查看详情"><i class="ri-eye-line"></i></button>
<button onclick="approveReview('${r.id}')" class="text-green-600 hover:text-green-800 mr-1" title="通过"><i class="ri-check-line"></i></button>
<button onclick="rejectReview('${r.id}')" class="text-red-600 hover:text-red-800" title="拒绝"><i class="ri-close-line"></i></button>
<button onclick="viewReviewDetail('${r.id}')" class="text-blue-600 hover:text-blue-800 ml-2" title="查看详情"><i class="ri-eye-line"></i></button>
` : `
<button onclick="viewReviewDetail('${r.id}')" class="text-blue-600 hover:text-blue-800" title="查看详情"><i class="ri-eye-line"></i></button>
`}
@@ -3232,7 +3269,7 @@
document.getElementById('reviewsTable').innerHTML = html;
} catch (e) {
document.getElementById('reviewsTable').innerHTML = `
<tr><td colspan="6" class="text-center text-red-500 py-8">加载失败: ${e.message}</td></tr>
<tr><td colspan="7" class="text-center text-red-500 py-8">加载失败: ${e.message}</td></tr>
`;
}
}
@@ -3279,26 +3316,205 @@
}
}
// 当前审核详情ID
let currentReviewId = '';
// 查看审核详情
async function viewReviewDetail(reviewId) {
currentReviewId = reviewId;
try {
const res = await fetch(`/api/reviews/${reviewId}`);
const review = await res.json();
let html = '<div class="space-y-4">';
html += `<div><span class="text-gray-500">状态:</span> ${review.status}</div>`;
html += `<div><span class="text-gray-500">分类:</span> ${review.category_id}</div>`;
html += `<div><span class="text-gray-500">来源:</span> ${review.source}</div>`;
html += `<div><span class="text-gray-500">提交时间:</span> ${review.created_at}</div>`;
html += '<div class="border-t pt-4"><h3 class="font-medium mb-2">产品数据:</h3>';
html += '<pre class="bg-gray-50 p-3 rounded text-sm overflow-auto max-h-60">' + JSON.stringify(review.data, null, 2) + '</pre>';
html += '</div></div>';
const catName = categories.find(c => c.id === review.category_id)?.name || review.category_id;
const statusLabels = {
pending: '<span class="px-3 py-1 bg-orange-100 text-orange-700 rounded-full text-sm">待审核</span>',
approved: '<span class="px-3 py-1 bg-green-100 text-green-700 rounded-full text-sm">已通过</span>',
rejected: '<span class="px-3 py-1 bg-red-100 text-red-700 rounded-full text-sm">已拒绝</span>'
};
alert(html.replace(/<[^>]+>/g, ' ').replace(/\s+/g, ' ').trim());
let html = `
<div class="space-y-6">
<!-- 基本信息 -->
<div class="bg-gray-50 rounded-lg p-4">
<h3 class="text-sm font-semibold text-gray-500 mb-3"><i class="ri-information-line mr-1"></i>基本信息</h3>
<div class="grid grid-cols-2 gap-4">
<div><span class="text-gray-400 text-sm">状态:</span>${statusLabels[review.status] || review.status}</div>
<div><span class="text-gray-400 text-sm">分类:</span><span class="font-medium text-gray-800">${catName}</span></div>
<div><span class="text-gray-400 text-sm">来源:</span><span class="text-gray-800">${review.source === 'api' ? 'API提交' : '网页提交'}</span></div>
<div><span class="text-gray-400 text-sm">提交者:</span><span class="text-gray-800">${review.submitter || '匿名'}</span></div>
<div class="col-span-2"><span class="text-gray-400 text-sm">提交时间:</span><span class="text-gray-800">${review.created_at}</span></div>
</div>
${review.status === 'rejected' && review.reject_reason ? `
<div class="mt-3 pt-3 border-t border-gray-200">
<span class="text-gray-400 text-sm">拒绝原因:</span>
<span class="text-red-600">${review.reject_reason}</span>
</div>
` : ''}
${review.status === 'approved' ? `
<div class="mt-3 pt-3 border-t border-gray-200">
<span class="text-gray-400 text-sm">审核通过时间:</span>
<span class="text-green-600">${review.approved_at || '-'}</span>
</div>
` : ''}
</div>
<!-- 产品数据 -->
<div class="border rounded-lg p-4">
<h3 class="text-sm font-semibold text-gray-500 mb-3"><i class="ri-database-2-line mr-1"></i>产品数据</h3>
<div class="space-y-3">
${renderProductData(review.data, review.category_id)}
</div>
</div>
</div>
`;
document.getElementById('reviewDetailContent').innerHTML = html;
// 操作按钮
let actionsHtml = '';
if (review.status === 'pending') {
actionsHtml = `
<button onclick="closeReviewDetailModal()" class="px-4 py-2 bg-gray-200 text-gray-600 rounded-lg hover:bg-gray-300">关闭</button>
<button onclick="rejectReviewFromModal()" class="px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700"><i class="ri-close-line mr-1"></i>拒绝</button>
<button onclick="approveReviewFromModal()" class="px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700"><i class="ri-check-line mr-1"></i>通过</button>
`;
} else {
actionsHtml = `<button onclick="closeReviewDetailModal()" class="px-4 py-2 bg-gray-200 text-gray-600 rounded-lg hover:bg-gray-300">关闭</button>`;
}
document.getElementById('reviewDetailActions').innerHTML = actionsHtml;
document.getElementById('reviewDetailModal').classList.remove('hidden');
} catch (e) {
alert('加载失败: ' + e.message);
}
}
// 渲染产品数据(格式化显示)
function renderProductData(data, categoryId) {
if (!data) return '<div class="text-gray-400">无数据</div>';
// 获取分类的字段配置
const cat = categories.find(c => c.id === categoryId);
const fields = cat ? (cat.fields || []) : [];
// 排序字段:名称放第一
const sortedFields = [...fields].sort((a, b) => {
if (a.key === 'name') return -1;
if (b.key === 'name') return 1;
return 0;
});
let html = '';
// 先显示有字段配置的值
sortedFields.forEach(field => {
const value = data[field.key];
if (value !== undefined && value !== null && value !== '') {
html += renderFieldRow(field, value);
}
});
// 再显示其他没有字段配置的值
Object.keys(data).forEach(key => {
if (!fields.find(f => f.key === key)) {
const value = data[key];
if (value !== undefined && value !== null && value !== '') {
html += `<div class="flex py-2 border-b border-gray-100 last:border-0">
<div class="w-1/3 text-gray-500 text-sm">${key}</div>
<div class="w-2/3 text-gray-800">${formatValue(value)}</div>
</div>`;
}
}
});
return html || '<div class="text-gray-400">无数据</div>';
}
// 渲染单个字段行
function renderFieldRow(field, value) {
const label = field.label || field.key;
const type = field.type || 'text';
let displayValue = formatValue(value, type);
return `<div class="flex py-2 border-b border-gray-100 last:border-0">
<div class="w-1/3 text-gray-500 text-sm">${label}</div>
<div class="w-2/3 text-gray-800">${displayValue}</div>
</div>`;
}
// 格式化值
function formatValue(value, type = 'text') {
if (value === null || value === undefined) return '-';
if (typeof value === 'boolean') return value ? '<span class="text-green-600">是</span>' : '<span class="text-gray-400">否</span>';
if (typeof value === 'object') {
if (Array.isArray(value)) {
if (value.length === 0) return '-';
// 如果是图片数组
if (typeof value[0] === 'string' && (value[0].startsWith('http') || value[0].startsWith('/'))) {
return value.map(url => `<img src="${url}" class="inline-block w-16 h-16 object-cover rounded mr-2 cursor-pointer hover:opacity-80" onclick="window.open('${url}', '_blank')">`).join('');
}
return value.join(', ');
}
return `<pre class="bg-gray-50 p-2 rounded text-xs overflow-auto">${JSON.stringify(value, null, 2)}</pre>`;
}
if (type === 'url' || (typeof value === 'string' && value.startsWith('http'))) {
return `<a href="${value}" target="_blank" class="text-blue-600 hover:underline">${value}</a>`;
}
return String(value);
}
// 关闭审核详情弹窗
function closeReviewDetailModal() {
document.getElementById('reviewDetailModal').classList.add('hidden');
currentReviewId = '';
}
// 从弹窗中通过审核
async function approveReviewFromModal() {
if (!currentReviewId) return;
if (!confirm('确认通过该产品审核?')) return;
try {
const res = await fetch(`/api/reviews/${currentReviewId}/approve`, {method: 'POST'});
const data = await res.json();
if (data.error) {
alert('操作失败: ' + data.error);
} else {
alert('审核通过,产品已发布!');
closeReviewDetailModal();
loadReviews();
loadNotificationCounts();
loadOverview();
}
} catch (e) {
alert('操作失败: ' + e.message);
}
}
// 从弹窗中拒绝审核
async function rejectReviewFromModal() {
if (!currentReviewId) return;
const reason = prompt('请输入拒绝原因(可选):');
if (reason === null) return; // 用户取消
try {
const res = await fetch(`/api/reviews/${currentReviewId}/reject`, {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({reason})
});
const data = await res.json();
if (data.error) {
alert('操作失败: ' + data.error);
} else {
alert('已拒绝该产品!');
closeReviewDetailModal();
loadReviews();
loadNotificationCounts();
}
} catch (e) {
alert('操作失败: ' + e.message);
}
}
init();
</script>
+130 -3
View File
@@ -56,8 +56,20 @@
</div>
</div>
<!-- 搜索结果区域 -->
<div id="searchResults" class="hidden mb-8">
<h2 class="text-lg font-semibold text-gray-800 mb-4 flex items-center gap-2">
<i class="ri-search-line text-indigo-600"></i>
搜索结果
<span id="searchKeyword" class="text-sm text-gray-500"></span>
</h2>
<div id="searchContent">
<!-- 动态填充 -->
</div>
</div>
<!-- 热门模型 -->
<div class="bg-white rounded-xl shadow-sm p-6">
<div id="hotModels" class="bg-white rounded-xl shadow-sm p-6">
<h2 class="text-lg font-semibold text-gray-800 mb-4 flex items-center gap-2">
<i class="ri-cpu-line text-indigo-600"></i>
热门模型
@@ -241,8 +253,123 @@
// 搜索
async function search() {
const keyword = document.getElementById('searchInput').value.trim();
if (!keyword) return;
window.location.href = `/models?q=${encodeURIComponent(keyword)}`;
if (!keyword) {
// 清空搜索时恢复原页面
document.getElementById('searchResults').classList.add('hidden');
document.getElementById('hotModels').classList.remove('hidden');
document.getElementById('statsCards').classList.remove('hidden');
document.getElementById('categoryCards').parentElement.classList.remove('hidden');
return;
}
// 调用全局搜索 API
const res = await fetch(`/api/search?q=${encodeURIComponent(keyword)}`);
const data = await res.json();
// 显示搜索结果区域
document.getElementById('searchResults').classList.remove('hidden');
document.getElementById('searchKeyword').textContent = `"${keyword}"`;
document.getElementById('hotModels').classList.add('hidden');
// 渲染搜索结果
renderSearchResults(data, keyword);
}
// 渲染搜索结果
function renderSearchResults(data, keyword) {
const models = data.models || [];
const gpus = data.gpus || [];
const cpus = data.cpus || [];
const total = models.length + gpus.length + cpus.length;
if (total === 0) {
document.getElementById('searchContent').innerHTML = `
<div class="bg-white rounded-xl shadow-sm p-8 text-center">
<i class="ri-search-line text-4xl text-gray-300 mb-4"></i>
<p class="text-gray-500">未找到与 "${keyword}" 相关的结果</p>
</div>
`;
return;
}
let html = `<div class="bg-white rounded-xl shadow-sm p-4 mb-4 text-sm text-gray-600">找到 ${total} 条结果</div>`;
// AI模型结果
if (models.length > 0) {
html += `
<div class="bg-white rounded-xl shadow-sm p-6 mb-4">
<h3 class="font-semibold text-gray-800 mb-4 flex items-center gap-2">
<i class="ri-robot-line text-blue-500"></i>
AI模型 (${models.length})
</h3>
<div class="grid grid-cols-2 gap-3">
${models.map(m => `
<a href="/models" class="flex items-center gap-3 p-3 rounded-lg hover:bg-gray-50 transition">
<div class="w-10 h-10 rounded-full bg-blue-100 flex items-center justify-center text-blue-600 font-bold text-sm">
${m.name.substring(0, 2)}
</div>
<div class="flex-1">
<div class="font-medium text-gray-800">${m.name}</div>
<div class="text-xs text-gray-500">${m.organization || ''}</div>
</div>
</a>
`).join('')}
</div>
</div>
`;
}
// GPU结果
if (gpus.length > 0) {
html += `
<div class="bg-white rounded-xl shadow-sm p-6 mb-4">
<h3 class="font-semibold text-gray-800 mb-4 flex items-center gap-2">
<i class="ri-cpu-line text-green-500"></i>
GPU显卡 (${gpus.length})
</h3>
<div class="grid grid-cols-2 gap-3">
${gpus.map(g => `
<a href="/gpus" class="flex items-center gap-3 p-3 rounded-lg hover:bg-gray-50 transition">
<div class="w-10 h-10 rounded-full bg-green-100 flex items-center justify-center text-green-600 font-bold text-sm">
${g.name.substring(0, 2)}
</div>
<div class="flex-1">
<div class="font-medium text-gray-800">${g.name}</div>
<div class="text-xs text-gray-500">${g.manufacturer || ''} | ${g.memory_gb || ''}GB</div>
</div>
</a>
`).join('')}
</div>
</div>
`;
}
// CPU结果
if (cpus.length > 0) {
html += `
<div class="bg-white rounded-xl shadow-sm p-6 mb-4">
<h3 class="font-semibold text-gray-800 mb-4 flex items-center gap-2">
<i class="ri-cpu-line text-purple-500"></i>
CPU处理器 (${cpus.length})
</h3>
<div class="grid grid-cols-2 gap-3">
${cpus.map(c => `
<a href="/cpus" class="flex items-center gap-3 p-3 rounded-lg hover:bg-gray-50 transition">
<div class="w-10 h-10 rounded-full bg-purple-100 flex items-center justify-center text-purple-600 font-bold text-sm">
${c.name.substring(0, 2)}
</div>
<div class="flex-1">
<div class="font-medium text-gray-800">${c.name}</div>
<div class="text-xs text-gray-500">${c.manufacturer || ''} | ${c.cores || ''}核</div>
</div>
</a>
`).join('')}
</div>
</div>
`;
}
document.getElementById('searchContent').innerHTML = html;
}
// 初始化