|
|
|
|
@@ -609,12 +609,21 @@ INDEX_TEMPLATE = '''
|
|
|
|
|
<button class="btn btn-outline-info me-2" onclick="showAIAddModal()" title="AI自动添加">
|
|
|
|
|
<i class="bi bi-robot"></i> AI添加
|
|
|
|
|
</button>
|
|
|
|
|
<button class="btn btn-outline-secondary me-1" onclick="showAddModal('text')" title="添加文本">
|
|
|
|
|
<i class="bi bi-file-text"></i>
|
|
|
|
|
</button>
|
|
|
|
|
<button class="btn btn-outline-success me-1" onclick="showAddModal('link')" title="添加链接">
|
|
|
|
|
<i class="bi bi-link-45deg"></i>
|
|
|
|
|
</button>
|
|
|
|
|
<button class="btn btn-outline-warning me-1" onclick="showAddModal('todo')" title="添加待办">
|
|
|
|
|
<i class="bi bi-check2-square"></i>
|
|
|
|
|
</button>
|
|
|
|
|
<button class="btn btn-outline-primary me-1" onclick="showAddModal('column')" title="添加专栏">
|
|
|
|
|
<i class="bi bi-newspaper"></i>
|
|
|
|
|
</button>
|
|
|
|
|
<button class="btn btn-outline-success me-2" onclick="exportData()" title="导出JSON">
|
|
|
|
|
<i class="bi bi-download"></i> 导出
|
|
|
|
|
</button>
|
|
|
|
|
<button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addModal">
|
|
|
|
|
<i class="bi bi-plus-lg"></i> 添加
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- 统计卡片 -->
|
|
|
|
|
@@ -667,20 +676,15 @@ INDEX_TEMPLATE = '''
|
|
|
|
|
<div class="modal-dialog modal-lg">
|
|
|
|
|
<div class="modal-content">
|
|
|
|
|
<div class="modal-header">
|
|
|
|
|
<h5 class="modal-title">添加条目</h5>
|
|
|
|
|
<h5 class="modal-title">
|
|
|
|
|
<span id="addModalIcon"></span>
|
|
|
|
|
<span id="addModalTitle">添加条目</span>
|
|
|
|
|
</h5>
|
|
|
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="modal-body">
|
|
|
|
|
<form id="addForm">
|
|
|
|
|
<div class="mb-3">
|
|
|
|
|
<label class="form-label">类型</label>
|
|
|
|
|
<select id="addType" class="form-select">
|
|
|
|
|
<option value="text">📝 文本</option>
|
|
|
|
|
<option value="link">🔗 链接</option>
|
|
|
|
|
<option value="column">📰 专栏</option>
|
|
|
|
|
<option value="todo">✅ 待办</option>
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
<input type="hidden" id="addType" value="text">
|
|
|
|
|
<div class="mb-3">
|
|
|
|
|
<label class="form-label">标题</label>
|
|
|
|
|
<input type="text" id="addTitle" class="form-control" placeholder="可选">
|
|
|
|
|
@@ -691,11 +695,11 @@ INDEX_TEMPLATE = '''
|
|
|
|
|
</div>
|
|
|
|
|
<div class="mb-3" id="urlGroup" style="display:none;">
|
|
|
|
|
<label class="form-label">URL</label>
|
|
|
|
|
<input type="url" id="addUrl" class="form-control">
|
|
|
|
|
<input type="url" id="addUrl" class="form-control" placeholder="https://...">
|
|
|
|
|
</div>
|
|
|
|
|
<div class="mb-3" id="sourceGroup" style="display:none;">
|
|
|
|
|
<label class="form-label">来源</label>
|
|
|
|
|
<input type="text" id="addSource" class="form-control">
|
|
|
|
|
<input type="text" id="addSource" class="form-control" placeholder="专栏来源">
|
|
|
|
|
</div>
|
|
|
|
|
<div class="mb-3" id="todoFields" style="display:none;">
|
|
|
|
|
<div class="row">
|
|
|
|
|
@@ -1104,15 +1108,6 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|
|
|
|
// 标签搜索实时过滤
|
|
|
|
|
document.getElementById('tagSearch')?.addEventListener('input', debounce(loadTagManagerList, 300));
|
|
|
|
|
|
|
|
|
|
// 类型切换时显示/隐藏字段
|
|
|
|
|
document.getElementById('addType').addEventListener('change', (e) => {
|
|
|
|
|
const type = e.target.value;
|
|
|
|
|
document.getElementById('contentGroup').style.display = type === 'text' ? 'block' : 'none';
|
|
|
|
|
document.getElementById('urlGroup').style.display = ['link', 'column'].includes(type) ? 'block' : 'none';
|
|
|
|
|
document.getElementById('sourceGroup').style.display = type === 'column' ? 'block' : 'none';
|
|
|
|
|
document.getElementById('todoFields').style.display = type === 'todo' ? 'block' : 'none';
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 编辑时类型切换
|
|
|
|
|
document.getElementById('editType').addEventListener('change', (e) => {
|
|
|
|
|
updateEditFieldsByType(e.target.value);
|
|
|
|
|
@@ -1270,6 +1265,37 @@ async function refreshData() {
|
|
|
|
|
loadItems(currentPage);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ============ 添加功能 ============
|
|
|
|
|
|
|
|
|
|
// 快捷添加按钮
|
|
|
|
|
function showAddModal(type) {
|
|
|
|
|
// 设置类型
|
|
|
|
|
document.getElementById('addType').value = type;
|
|
|
|
|
|
|
|
|
|
// 设置弹窗标题和图标
|
|
|
|
|
const typeInfo = {
|
|
|
|
|
text: { icon: '📝', title: '添加文本' },
|
|
|
|
|
link: { icon: '🔗', title: '添加链接' },
|
|
|
|
|
column: { icon: '📰', title: '添加专栏' },
|
|
|
|
|
todo: { icon: '✅', title: '添加待办' }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
document.getElementById('addModalIcon').textContent = typeInfo[type].icon;
|
|
|
|
|
document.getElementById('addModalTitle').textContent = typeInfo[type].title;
|
|
|
|
|
|
|
|
|
|
// 显示/隐藏对应字段
|
|
|
|
|
document.getElementById('contentGroup').style.display = type === 'text' ? 'block' : 'none';
|
|
|
|
|
document.getElementById('urlGroup').style.display = ['link', 'column'].includes(type) ? 'block' : 'none';
|
|
|
|
|
document.getElementById('sourceGroup').style.display = type === 'column' ? 'block' : 'none';
|
|
|
|
|
document.getElementById('todoFields').style.display = type === 'todo' ? 'block' : 'none';
|
|
|
|
|
|
|
|
|
|
// 清空表单
|
|
|
|
|
document.getElementById('addForm').reset();
|
|
|
|
|
|
|
|
|
|
// 打开弹窗
|
|
|
|
|
new bootstrap.Modal(document.getElementById('addModal')).show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 添加条目
|
|
|
|
|
async function addItem() {
|
|
|
|
|
const type = document.getElementById('addType').value;
|
|
|
|
|
|