Compare commits

...

2 Commits

Author SHA1 Message Date
ffe7adcad2 feat: 编辑收藏时支持更改类型,动态显示对应字段 2026-04-13 16:45:48 +08:00
963dd1846b docs: 更新版本历史 2026-04-13 16:35:35 +08:00
2 changed files with 24 additions and 11 deletions

View File

@@ -136,6 +136,7 @@ xian-favor/
## 版本历史
- v1.6.0 (2026-04-13): 标签管理添加编辑功能,支持修改标签名称
- v1.5.1 (2026-04-13): 标签管理添加搜索功能,实时过滤标签列表
- v1.5.0 (2026-04-13): 首页添加分页功能每页20条记录
- v1.4.0 (2026-04-13): 首页添加导出按钮一键导出所有收藏为JSON文件

View File

@@ -432,7 +432,12 @@ INDEX_TEMPLATE = '''
<input type="hidden" id="editId">
<div class="mb-3">
<label class="form-label">类型</label>
<input type="text" id="editType" class="form-control" readonly>
<select id="editType" class="form-select">
<option value="text">📝 文本</option>
<option value="link">🔗 链接</option>
<option value="column">📰 专栏</option>
<option value="todo">✅ 待办</option>
</select>
</div>
<div class="mb-3">
<label class="form-label">标题</label>
@@ -555,6 +560,11 @@ document.addEventListener('DOMContentLoaded', async () => {
document.getElementById('todoFields').style.display = type === 'todo' ? 'block' : 'none';
});
// 编辑时类型切换
document.getElementById('editType').addEventListener('change', (e) => {
updateEditFieldsByType(e.target.value);
});
// 搜索
document.getElementById('searchInput').addEventListener('input', debounce(loadItems, 300));
@@ -815,14 +825,11 @@ async function openEditModal(id) {
const type = item.type;
document.getElementById('editId').value = id;
document.getElementById('editType').value = getTypeLabel(type);
document.getElementById('editType').value = type;
document.getElementById('editTitle').value = item.title || '';
// 根据类型显示/隐藏字段
document.getElementById('editContentGroup').style.display = type === 'text' ? 'block' : 'none';
document.getElementById('editUrlGroup').style.display = ['link', 'column'].includes(type) ? 'block' : 'none';
document.getElementById('editSourceGroup').style.display = type === 'column' ? 'block' : 'none';
document.getElementById('editTodoFields').style.display = type === 'todo' ? 'block' : 'none';
updateEditFieldsByType(type);
document.getElementById('editContent').value = item.content || '';
document.getElementById('editUrl').value = item.url || '';
@@ -839,16 +846,21 @@ async function openEditModal(id) {
new bootstrap.Modal(document.getElementById('editModal')).show();
}
// 根据类型更新编辑表单字段显示
function updateEditFieldsByType(type) {
document.getElementById('editContentGroup').style.display = type === 'text' ? 'block' : 'none';
document.getElementById('editUrlGroup').style.display = ['link', 'column'].includes(type) ? 'block' : 'none';
document.getElementById('editSourceGroup').style.display = type === 'column' ? 'block' : 'none';
document.getElementById('editTodoFields').style.display = type === 'todo' ? 'block' : 'none';
}
// 保存编辑
async function saveEdit() {
const id = document.getElementById('editId').value;
// 获取当前条目的类型
const detailRes = await fetch(`${API_BASE}/items/${currentDetailId}`);
const detailData = await detailRes.json();
const type = detailData.data.type;
const type = document.getElementById('editType').value; // 从下拉框获取新类型
const data = {
type: type, // 包含类型变更
title: document.getElementById('editTitle').value,
content: type === 'text' ? document.getElementById('editContent').value : null,
url: ['link', 'column'].includes(type) ? document.getElementById('editUrl').value : null,