From a87e6e485308931919c2ab9410da4d6aa255a1c1 Mon Sep 17 00:00:00 2001 From: HuangHai <10402852@qq.com> Date: Wed, 10 Sep 2025 08:23:55 +0800 Subject: [PATCH] 'commit' --- .../FenJingTouGenerator.cpython-310.pyc | Bin 3132 -> 3119 bytes dsLightRag/static/XingJun/js/script.js | 165 +++++++++++------- .../XingJun/json/arrow_data_2025-09-10.json | 27 +-- .../XingJun/json/arrow_data_20250909.json | 36 ---- dsLightRag/static/XingJun/move.html | 22 ++- dsLightRag/static/js/jquery-3.6.0.min.js | 2 - dsLightRag/static/js/jquery-3.7.1.min.js | 2 + 7 files changed, 135 insertions(+), 119 deletions(-) delete mode 100644 dsLightRag/static/XingJun/json/arrow_data_20250909.json delete mode 100644 dsLightRag/static/js/jquery-3.6.0.min.js create mode 100644 dsLightRag/static/js/jquery-3.7.1.min.js diff --git a/dsLightRag/JiMeng/Kit/__pycache__/FenJingTouGenerator.cpython-310.pyc b/dsLightRag/JiMeng/Kit/__pycache__/FenJingTouGenerator.cpython-310.pyc index 83eb012cd84b6de3facac473c3a9dd0bbbfb6758..1c5ea5270830d962ecf337b6e90667dcf7d20e3e 100644 GIT binary patch delta 181 zcmdlZv0j2VpO=@50SI;-+LN(pBCne|;{w)HwuOvQ?5T`d9I5Q_oT-cpxE3-*ai?-G z-~ov(WMpJWWt>=5$;uPv@8i7jcLEcm(B>HC&n%2llLI)mFv?G6az(n6Z*f~QGEElaQ3C)m-!pyy delta 194 zcmZ24u}6Y8pO=@50SMNWEX&w1k=IR~X#s00+d{@D_Ee@Uj#Tz|&QzuaTnibZxKp_o z@PNb?GBPrxGEJAG;rALW-W%{P(rR#ZTmgt4$=OicQ { + alert(`文件请求状态: ${response.status}`); // 网络请求反馈 + if (!response.ok) { + throw new Error(`网络响应错误: ${response.status}`); + } + return response.json(); + }) + .then(data => { + alert('JSON文件解析成功,准备保存数据...'); + console.log('JSON文件解析成功:', data); + + // 保存数据到localStorage + if (data.elements) { + localStorage.setItem('savedElements', JSON.stringify(data.elements)); + } + if (data.centerPoint) { + localStorage.setItem('centerPoint', JSON.stringify(data.centerPoint)); + } + + layer.close(loadIndex); + alert('数据导入成功,页面将刷新'); + layer.msg('数据导入成功,页面将刷新', {icon: 1, time: 1500}, function() { + location.reload(); + }); + }) + .catch(error => { + layer.close(loadIndex); + alert(`导入失败: ${error.message}`); // 错误反馈 + console.error('文件加载/解析错误:', error); + layer.msg('导入失败: ' + error.message, {icon: 5}); + }); + }); }); }); // 保存数据到JSON文件并下载 function saveDataToFile() { - // 获取所有箭头元素数据 + // 获取所有箭头元素数据 - 完全匹配localStorage格式 const arrows = document.querySelectorAll('.arrow-container'); const elements = Array.from(arrows).map(arrow => ({ + type: 'arrow', // 添加缺失的type字段 imagePath: arrow.dataset.imagePath, - left: arrow.style.left, - top: arrow.style.top, + left: arrow.style.left, // 保留px单位和字符串类型 + top: arrow.style.top, // 保留px单位和字符串类型 text: arrow.dataset.text || '', referencePoint: arrow.dataset.referencePoint || 'top-left', - stopDistance: parseInt(arrow.dataset.stopDistance) || 50 + stopDistance: arrow.dataset.stopDistance || '50' // 保留字符串类型 })); - // 获取中心点数据 + // 获取中心点数据 - 保留px单位和字符串类型 const centerPoint = centerDot ? { left: centerDot.style.left, top: centerDot.style.top @@ -500,12 +495,10 @@ function saveDataToFile() { }; try { - // 生成JSON字符串,确保正确处理特殊字符 const jsonData = JSON.stringify(exportData, null, 2); const blob = new Blob([jsonData], { type: 'application/json;charset=utf-8' }); const url = URL.createObjectURL(blob); - // 创建下载链接 const a = document.createElement('a'); a.href = url; const dateStr = new Date().toISOString().slice(0, 10); @@ -513,13 +506,13 @@ function saveDataToFile() { document.body.appendChild(a); a.click(); - // 清理 setTimeout(() => { document.body.removeChild(a); URL.revokeObjectURL(url); }, 0); console.log('数据已成功导出'); + layer.msg('数据导出成功', {icon: 1}); } catch (error) { console.error('导出数据失败:', error); layer.msg('导出失败: ' + error.message, {icon: 2}); @@ -527,4 +520,50 @@ function saveDataToFile() { } // 为保存数据按钮添加点击事件 -document.getElementById('saveDataBtn').addEventListener('click', saveDataToFile); \ No newline at end of file +document.getElementById('saveDataBtn').addEventListener('click', saveDataToFile); + + +// 清空数据功能实现 +function clearAllData() { + // 显示确认对话框 + layer.confirm('确定要清空所有数据吗?此操作不可恢复!', { + icon: 3, + title: '警告', + btn: ['确认清空', '取消'] + }, function(index) { + // 确认清空数据 + try { + // 1. 清除localStorage数据 + localStorage.removeItem('savedElements'); + localStorage.removeItem('centerPoint'); + + // 2. 清除DOM中的箭头元素 + document.querySelectorAll('.arrow-container').forEach(arrow => { + arrow.remove(); + }); + + // 3. 清除中心点 + if (centerDot) { + centerDot.remove(); + centerDot = null; + } + + // 4. 刷新页面或更新UI + layer.msg('所有数据已成功清空', {icon: 1, time: 1500}, function() { + location.reload(); // 简单粗暴的刷新,确保UI完全重置 + }); + } catch (error) { + console.error('清空数据失败:', error); + layer.msg('清空失败: ' + error.message, {icon: 2}); + } + layer.close(index); + }); +} + +// 为清空数据按钮添加点击事件 +document.addEventListener('DOMContentLoaded', function() { + const clearDataBtn = document.getElementById('clearDataBtn'); + if (clearDataBtn) { + clearDataBtn.addEventListener('click', clearAllData); + } +}); \ No newline at end of file diff --git a/dsLightRag/static/XingJun/json/arrow_data_2025-09-10.json b/dsLightRag/static/XingJun/json/arrow_data_2025-09-10.json index ff897a6a..3d3faf39 100644 --- a/dsLightRag/static/XingJun/json/arrow_data_2025-09-10.json +++ b/dsLightRag/static/XingJun/json/arrow_data_2025-09-10.json @@ -1,33 +1,36 @@ { "elements": [ { + "type": "arrow", "imagePath": "images/1.png", - "left": "687.469px", - "top": "259.891px", + "left": "645.469px", + "top": "210.891px", "text": "", "referencePoint": "top-left", - "stopDistance": 50 + "stopDistance": "50" }, { + "type": "arrow", "imagePath": "images/2.png", - "left": "922.891px", - "top": "-79.625px", + "left": "838.891px", + "top": "-87.625px", "text": "", "referencePoint": "top-left", - "stopDistance": 50 + "stopDistance": "50" }, { + "type": "arrow", "imagePath": "images/4.png", - "left": "1024.7px", - "top": "271.344px", + "left": "960.688px", + "top": "208.344px", "text": "", "referencePoint": "top-left", - "stopDistance": 50 + "stopDistance": "50" } ], "centerPoint": { - "left": "931px", - "top": "209px" + "left": "871px", + "top": "172px" }, - "exportTime": "2025-09-10T00:08:19.377Z" + "exportTime": "2025-09-10T00:13:39.941Z" } \ No newline at end of file diff --git a/dsLightRag/static/XingJun/json/arrow_data_20250909.json b/dsLightRag/static/XingJun/json/arrow_data_20250909.json deleted file mode 100644 index 925b02c9..00000000 --- a/dsLightRag/static/XingJun/json/arrow_data_20250909.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "elements": [ - { - "type": "arrow", - "imagePath": "images/./1.png", - "left": "739.422px", - "top": "315.391px", - "text": "17集团军", - "referencePoint": "top-left", - "stopDistance": "110" - }, - { - "type": "arrow", - "imagePath": "images/./2.png", - "left": "1007.05px", - "top": "-66.75px", - "text": "第4野战军8纵", - "referencePoint": "top-left", - "stopDistance": "90" - }, - { - "type": "arrow", - "imagePath": "images/./5.png", - "left": "1100.61px", - "top": "320.766px", - "text": "第4野战军2纵", - "referencePoint": "null", - "stopDistance": "120" - } - ], - "centerPoint": { - "left": "963px", - "top": "237px" - }, - "exportTime": "2025-09-09T23:53:11.571Z" -} \ No newline at end of file diff --git a/dsLightRag/static/XingJun/move.html b/dsLightRag/static/XingJun/move.html index 0cd269c0..118d787f 100644 --- a/dsLightRag/static/XingJun/move.html +++ b/dsLightRag/static/XingJun/move.html @@ -6,7 +6,7 @@ 箭头动画 - +