diff --git a/data/categories.json b/data/categories.json index df3d127..5d9be86 100644 --- a/data/categories.json +++ b/data/categories.json @@ -29,7 +29,8 @@ "icon": "ri-smartphone-line", "color": "orange", "description": "各品牌手机参数规格", - "order": 4 + "order": 4, + "visible": false }, { "id": "laptops", diff --git a/templates/admin.html b/templates/admin.html index b86396f..6083b41 100644 --- a/templates/admin.html +++ b/templates/admin.html @@ -395,21 +395,28 @@ GPT-4是OpenAI发布的大语言模型,参数量约1.8万亿,支持128K上 document.getElementById('dynamic-title').textContent = cat.name + '管理'; - // 加载该分类的数据 - const res = await fetch(`/api/items/${categoryId}`); + // 加载该分类的数据(后台显示全部,包括隐藏的) + const res = await fetch(`/api/items/${categoryId}?all=1`); const items = await res.json(); if (items.length === 0) { document.getElementById('admin-dynamic-table').innerHTML = '暂无数据,点击上方"添加数据"按钮添加'; } else { - const keys = Object.keys(items[0]).filter(k => !['id', 'created_at', 'updated_at'].includes(k)); + const keys = Object.keys(items[0]).filter(k => !['id', 'created_at', 'updated_at', 'visible', 'raw_text'].includes(k)); let html = ``; keys.forEach(k => { html += `${k}`; }); + html += `显示`; html += `操作`; items.forEach(item => { - html += ``; + html += ``; keys.forEach(k => { html += `${item[k] || '-'}`; }); + html += ` + + ${item.raw_text ? `` : ''} + `; html += ` @@ -499,7 +506,7 @@ GPT-4是OpenAI发布的大语言模型,参数量约1.8万亿,支持128K上 // 加载分类列表 async function loadAdminCategories() { - const res = await fetch('/api/categories'); + const res = await fetch('/api/categories?all=1'); categories = await res.json(); if (categories.length === 0) { @@ -514,7 +521,7 @@ GPT-4是OpenAI发布的大语言模型,参数量约1.8万亿,支持128K上 ${c.name} ${c.description || '-'} - @@ -539,7 +546,7 @@ GPT-4是OpenAI发布的大语言模型,参数量约1.8万亿,支持128K上 ${m.context_length || '-'} ${m.is_open_source ? '开源' : '商业'} - ${m.raw_text ? `` : ''} @@ -565,7 +572,7 @@ GPT-4是OpenAI发布的大语言模型,参数量约1.8万亿,支持128K上 ${g.architecture || '-'} ${formatPrice(g)} - ${g.raw_text ? `` : ''} @@ -591,7 +598,7 @@ GPT-4是OpenAI发布的大语言模型,参数量约1.8万亿,支持128K上 ${c.base_clock_ghz || '-'}-${c.boost_clock_ghz || '-'}GHz ${formatPrice(c)} - ${c.raw_text ? `` : ''} @@ -958,6 +965,7 @@ GPT-4是OpenAI发布的大语言模型,参数量约1.8万亿,支持128K上 if (type === 'model') endpoint = `/api/models/${id}`; else if (type === 'gpu') endpoint = `/api/gpus/${id}`; else if (type === 'cpu') endpoint = `/api/cpus/${id}`; + else if (type === 'dynamic') endpoint = `/api/items/${dynamicCategoryId}/${id}`; try { const res = await fetch(endpoint);