hookehuyr

fix 在 handleImageUpload 之前 清空 fileInput.value,这样每次选择文件时都会触发 change 事件

1 <!-- 1 <!--
2 * @Date: 2025-01-22 11:40:12 2 * @Date: 2025-01-22 11:40:12
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2025-02-08 14:42:00 4 + * @LastEditTime: 2025-02-08 15:08:33
5 * @FilePath: /map-demo/src/views/mapCutter.vue 5 * @FilePath: /map-demo/src/views/mapCutter.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
...@@ -157,7 +157,6 @@ const triggerFileInput = () => { ...@@ -157,7 +157,6 @@ const triggerFileInput = () => {
157 }; 157 };
158 158
159 const handleKeydown = (e) => { // 键盘控制 159 const handleKeydown = (e) => { // 键盘控制
160 - console.log(`按键: ${e.key}, Shift 是否按下: ${e.shiftKey}`) // 调试信息
161 if (e.shiftKey && e.key === '=') { 160 if (e.shiftKey && e.key === '=') {
162 // 一些键盘可能需要 Shift 才能输入 `+`,但 `e.key` 实际上是 `=` 161 // 一些键盘可能需要 Shift 才能输入 `+`,但 `e.key` 实际上是 `=`
163 scaleImage(1.01) 162 scaleImage(1.01)
...@@ -261,6 +260,9 @@ function handleImageUpload(event) { ...@@ -261,6 +260,9 @@ function handleImageUpload(event) {
261 addImageToMap(imageURL.value); 260 addImageToMap(imageURL.value);
262 }; 261 };
263 reader.readAsDataURL(file); 262 reader.readAsDataURL(file);
263 +
264 + // **解决问题:清空 input,让下次选择同一文件也能触发 change**
265 + event.target.value = "";
264 } 266 }
265 267
266 async function addImageToMap(url) { 268 async function addImageToMap(url) {
...@@ -397,8 +399,10 @@ const onZoomChange = (value) => { // 调整地图图层 ...@@ -397,8 +399,10 @@ const onZoomChange = (value) => { // 调整地图图层
397 399
398 const onLBRangeBlur = () => { 400 const onLBRangeBlur = () => {
399 const str = map_left_bottom_range.value; 401 const str = map_left_bottom_range.value;
402 + if (map_left_bottom_range.value) {
400 const formattedArray = str?.split(',').map(Number); 403 const formattedArray = str?.split(',').map(Number);
401 map_left_bottom_range.value = formattedArray; 404 map_left_bottom_range.value = formattedArray;
405 + }
402 } 406 }
403 const onRTRangeBlur = () => { 407 const onRTRangeBlur = () => {
404 const str = map_right_top_range.value; 408 const str = map_right_top_range.value;
......