feat: v1.2.0 新增网站配置管理功能
新功能: - 后台管理新增'网站配置'菜单 - 支持配置:网站名称、副标题、备案号、联系邮箱、GitHub、页脚文字 - 前台页面自动读取配置显示 - 页脚支持备案号链接 配置存储在 data/config.json
This commit is contained in:
@@ -52,6 +52,49 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 网站配置 -->
|
||||
<section id="section-config" class="hidden">
|
||||
<h1 class="text-2xl font-bold text-gray-800 mb-6">网站配置</h1>
|
||||
<div class="bg-white rounded-xl shadow-sm p-6">
|
||||
<form id="configForm" class="space-y-6">
|
||||
<div class="grid grid-cols-2 gap-6">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-2">网站名称</label>
|
||||
<input type="text" name="site_name" id="config_site_name" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" placeholder="ParamHub">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-2">网站副标题</label>
|
||||
<input type="text" name="site_subtitle" id="config_site_subtitle" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" placeholder="参数百科">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-2">备案号</label>
|
||||
<input type="text" name="icp_number" id="config_icp_number" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" placeholder="如:京ICP备12345678号">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-2">联系邮箱</label>
|
||||
<input type="email" name="contact_email" id="config_contact_email" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" placeholder="admin@example.com">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-2">GitHub地址</label>
|
||||
<input type="url" name="github_url" id="config_github_url" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" placeholder="https://github.com/...">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-2">版权年份</label>
|
||||
<input type="text" name="copyright_year" id="config_copyright_year" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" placeholder="2024">
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-2">页脚文字</label>
|
||||
<textarea name="footer_text" id="config_footer_text" rows="3" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" placeholder="网站底部的版权信息等"></textarea>
|
||||
</div>
|
||||
<div class="flex justify-end gap-4">
|
||||
<button type="button" onclick="loadSiteConfig()" class="px-4 py-2 bg-gray-200 text-gray-700 rounded-lg hover:bg-gray-300"><i class="ri-refresh-line mr-1"></i>重置</button>
|
||||
<button type="button" onclick="saveSiteConfig()" class="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700"><i class="ri-save-line mr-1"></i>保存配置</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 分类管理 -->
|
||||
<section id="section-categories" class="hidden">
|
||||
<div class="flex justify-between items-center mb-6">
|
||||
@@ -326,6 +369,7 @@ GPT-4是OpenAI发布的大语言模型,参数量约1.8万亿,支持128K上
|
||||
function renderSidebar() {
|
||||
const fixedItems = [
|
||||
{id: 'overview', name: '概览', icon: 'ri-home-4-line'},
|
||||
{id: 'config', name: '网站配置', icon: 'ri-settings-3-line'},
|
||||
{id: 'categories', name: '分类管理', icon: 'ri-folder-line'},
|
||||
];
|
||||
|
||||
@@ -443,12 +487,53 @@ GPT-4是OpenAI发布的大语言模型,参数量约1.8万亿,支持128K上
|
||||
}
|
||||
|
||||
if (section === 'categories') loadAdminCategories();
|
||||
if (section === 'config') loadSiteConfig();
|
||||
if (section === 'models') loadAdminModels();
|
||||
if (section === 'gpus') loadAdminGpus();
|
||||
if (section === 'cpus') loadAdminCpus();
|
||||
if (section === 'knowledge') loadAdminKnowledge();
|
||||
}
|
||||
|
||||
// 加载网站配置
|
||||
async function loadSiteConfig() {
|
||||
const res = await fetch('/api/config');
|
||||
const config = await res.json();
|
||||
|
||||
document.getElementById('config_site_name').value = config.site_name || '';
|
||||
document.getElementById('config_site_subtitle').value = config.site_subtitle || '';
|
||||
document.getElementById('config_icp_number').value = config.icp_number || '';
|
||||
document.getElementById('config_contact_email').value = config.contact_email || '';
|
||||
document.getElementById('config_github_url').value = config.github_url || '';
|
||||
document.getElementById('config_copyright_year').value = config.copyright_year || '';
|
||||
document.getElementById('config_footer_text').value = config.footer_text || '';
|
||||
}
|
||||
|
||||
// 保存网站配置
|
||||
async function saveSiteConfig() {
|
||||
const config = {
|
||||
site_name: document.getElementById('config_site_name').value,
|
||||
site_subtitle: document.getElementById('config_site_subtitle').value,
|
||||
icp_number: document.getElementById('config_icp_number').value,
|
||||
contact_email: document.getElementById('config_contact_email').value,
|
||||
github_url: document.getElementById('config_github_url').value,
|
||||
copyright_year: document.getElementById('config_copyright_year').value,
|
||||
footer_text: document.getElementById('config_footer_text').value,
|
||||
};
|
||||
|
||||
try {
|
||||
const res = await fetch('/api/config', {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(config)
|
||||
});
|
||||
|
||||
const data = await res.json();
|
||||
alert('配置已保存!');
|
||||
} catch (e) {
|
||||
alert('保存失败: ' + e.message);
|
||||
}
|
||||
}
|
||||
|
||||
// 加载概览统计
|
||||
async function loadOverview() {
|
||||
const res = await fetch('/api/stats');
|
||||
|
||||
Reference in New Issue
Block a user