Support first case: 1. Add filters in website; 2. Add export all file in admin
This commit is contained in:
@@ -258,6 +258,18 @@
|
||||
{% if selected_website and selected_website.id == website.id %}class="active" {% endif %}>{{ website.name }}</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<!-- 修改:按媒体类型筛选 -->
|
||||
<div class="filters">
|
||||
<strong>按媒体类型筛选:</strong>
|
||||
<a href="?{% if selected_website %}website={{ selected_website.id }}&{% endif %}{% if search_query %}q={{ search_query }}&{% endif %}media_type=all"
|
||||
{% if not request.GET.media_type or request.GET.media_type == 'all' %}class="active"{% endif %}>全部</a>
|
||||
<a href="?{% if selected_website %}website={{ selected_website.id }}&{% endif %}{% if search_query %}q={{ search_query }}&{% endif %}media_type=text_only"
|
||||
{% if request.GET.media_type == 'text_only' %}class="active"{% endif %}>纯文本</a>
|
||||
<a href="?{% if selected_website %}website={{ selected_website.id }}&{% endif %}{% if search_query %}q={{ search_query }}&{% endif %}media_type=with_images"
|
||||
{% if request.GET.media_type == 'with_images' %}class="active"{% endif %}>图片</a>
|
||||
<a href="?{% if selected_website %}website={{ selected_website.id }}&{% endif %}{% if search_query %}q={{ search_query }}&{% endif %}media_type=with_videos"
|
||||
{% if request.GET.media_type == 'with_videos' %}class="active"{% endif %}>视频</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 主内容区域 -->
|
||||
@@ -278,6 +290,10 @@
|
||||
<button id="exportCsvBtn" class="export-btn" disabled>导出为CSV</button>
|
||||
<!-- 新增:导出为ZIP包按钮 -->
|
||||
<button id="exportZipBtn" class="export-btn" disabled>导出为ZIP包</button>
|
||||
<!-- 删除:按类型导出按钮 -->
|
||||
<!-- <button id="exportTextOnlyBtn" class="export-btn">导出纯文本</button>
|
||||
<button id="exportWithImagesBtn" class="export-btn">导出含图片</button>
|
||||
<button id="exportWithVideosBtn" class="export-btn">导出含视频</button> -->
|
||||
</div>
|
||||
|
||||
<ul>
|
||||
@@ -361,6 +377,10 @@
|
||||
const deselectAllBtn = document.getElementById('deselectAllBtn');
|
||||
// 新增:获取ZIP导出按钮元素
|
||||
const exportZipBtn = document.getElementById('exportZipBtn');
|
||||
|
||||
// const exportTextOnlyBtn = document.getElementById('exportTextOnlyBtn');
|
||||
// const exportWithImagesBtn = document.getElementById('exportWithImagesBtn');
|
||||
// const exportWithVideosBtn = document.getElementById('exportWithVideosBtn');
|
||||
|
||||
// 更新导出按钮状态
|
||||
function updateExportButtons() {
|
||||
@@ -504,9 +524,56 @@
|
||||
alert('导出失败: ' + error);
|
||||
});
|
||||
});
|
||||
|
||||
// exportTextOnlyBtn.addEventListener('click', () => {
|
||||
// exportByMediaType('text_only');
|
||||
// });
|
||||
|
||||
// exportWithImagesBtn.addEventListener('click', () => {
|
||||
// exportByMediaType('with_images');
|
||||
// });
|
||||
|
||||
// exportWithVideosBtn.addEventListener('click', () => {
|
||||
// exportByMediaType('with_videos');
|
||||
// });
|
||||
|
||||
// function exportByMediaType(mediaType) {
|
||||
// // 发送POST请求按类型导出文章
|
||||
// fetch('{% url "export_articles_by_type" %}', {
|
||||
// method: 'POST',
|
||||
// headers: {
|
||||
// 'Content-Type': 'application/json',
|
||||
// 'X-CSRFToken': '{{ csrf_token }}'
|
||||
// },
|
||||
// body: JSON.stringify({
|
||||
// media_type: mediaType,
|
||||
// format: 'zip'
|
||||
// })
|
||||
// })
|
||||
// .then(response => {
|
||||
// if (response.ok) {
|
||||
// return response.blob();
|
||||
// }
|
||||
// throw new Error('导出失败');
|
||||
// })
|
||||
// .then(blob => {
|
||||
// const url = window.URL.createObjectURL(blob);
|
||||
// const a = document.createElement('a');
|
||||
// a.href = url;
|
||||
// a.download = `articles_${mediaType}.zip`;
|
||||
// document.body.appendChild(a);
|
||||
// a.click();
|
||||
// window.URL.revokeObjectURL(url);
|
||||
// document.body.removeChild(a);
|
||||
// })
|
||||
// .catch(error => {
|
||||
// alert('导出失败: ' + error);
|
||||
// });
|
||||
// }
|
||||
|
||||
// 初始化导出按钮状态
|
||||
updateExportButtons();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user