|
|
|
|
@@ -246,6 +246,9 @@ INDEX_TEMPLATE = '''
|
|
|
|
|
<option value="todo">待办</option>
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
<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>
|
|
|
|
|
@@ -295,7 +298,7 @@ INDEX_TEMPLATE = '''
|
|
|
|
|
|
|
|
|
|
<!-- 添加模态框 -->
|
|
|
|
|
<div class="modal fade" id="addModal" tabindex="-1">
|
|
|
|
|
<div class="modal-dialog">
|
|
|
|
|
<div class="modal-dialog modal-lg">
|
|
|
|
|
<div class="modal-content">
|
|
|
|
|
<div class="modal-header">
|
|
|
|
|
<h5 class="modal-title">添加条目</h5>
|
|
|
|
|
@@ -398,7 +401,7 @@ INDEX_TEMPLATE = '''
|
|
|
|
|
|
|
|
|
|
<!-- 编辑模态框 -->
|
|
|
|
|
<div class="modal fade" id="editModal" tabindex="-1">
|
|
|
|
|
<div class="modal-dialog">
|
|
|
|
|
<div class="modal-dialog modal-lg">
|
|
|
|
|
<div class="modal-content">
|
|
|
|
|
<div class="modal-header">
|
|
|
|
|
<h5 class="modal-title">编辑条目</h5>
|
|
|
|
|
@@ -948,6 +951,29 @@ async function deleteTagManager(id, name) {
|
|
|
|
|
loadItems();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 导出数据
|
|
|
|
|
async function exportData() {
|
|
|
|
|
const res = await fetch(`${API_BASE}/items?limit=1000`);
|
|
|
|
|
const data = await res.json();
|
|
|
|
|
|
|
|
|
|
if (!data.success) {
|
|
|
|
|
alert('导出失败');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 格式化JSON
|
|
|
|
|
const jsonStr = JSON.stringify(data.data, null, 2);
|
|
|
|
|
|
|
|
|
|
// 创建下载
|
|
|
|
|
const blob = new Blob([jsonStr], { type: 'application/json' });
|
|
|
|
|
const url = URL.createObjectURL(blob);
|
|
|
|
|
const a = document.createElement('a');
|
|
|
|
|
a.href = url;
|
|
|
|
|
a.download = `xian_favor_export_${new Date().toISOString().slice(0,10)}.json`;
|
|
|
|
|
a.click();
|
|
|
|
|
URL.revokeObjectURL(url);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function debounce(fn, delay) {
|
|
|
|
|
let timer;
|
|
|
|
|
return function(...args) {
|
|
|
|
|
|