Explorar o código

fix: remove save button, use long-press (800ms) to save plot

nonvioce hai 3 meses
pai
achega
03cc8acab7
Modificáronse 1 ficheiros con 14 adicións e 10 borrados
  1. 14 10
      app/src/main/assets/console.js

+ 14 - 10
app/src/main/assets/console.js

@@ -538,11 +538,10 @@ class SymjaConsole {
             if (legendEl) container.appendChild(legendEl);
             if (legendEl) container.appendChild(legendEl);
         }
         }
 
 
-        // 保存按钮 + 图例开关
-        const actions = document.createElement('div');
-        actions.className = 'plot-actions';
-
+        // 图例开关(仅在多曲线时显示)
         if (legendEl) {
         if (legendEl) {
+            const actions = document.createElement('div');
+            actions.className = 'plot-actions';
             const legendBtn = document.createElement('button');
             const legendBtn = document.createElement('button');
             legendBtn.className = 'plot-save-btn';
             legendBtn.className = 'plot-save-btn';
             legendBtn.textContent = '🏷 图例';
             legendBtn.textContent = '🏷 图例';
@@ -552,14 +551,19 @@ class SymjaConsole {
                 legendBtn.style.opacity = legendVisible ? '1' : '0.5';
                 legendBtn.style.opacity = legendVisible ? '1' : '0.5';
             };
             };
             actions.appendChild(legendBtn);
             actions.appendChild(legendBtn);
+            container.appendChild(actions);
         }
         }
 
 
-        const saveBtn = document.createElement('button');
-        saveBtn.className = 'plot-save-btn';
-        saveBtn.textContent = '💾 保存图片';
-        saveBtn.onclick = () => this.savePlot(canvas);
-        actions.appendChild(saveBtn);
-        container.appendChild(actions);
+        // 长按保存(单指静止800ms触发)
+        let longPressTimer;
+        canvas.addEventListener('touchstart', (e) => {
+            clearTimeout(longPressTimer);
+            if (e.touches.length === 1) {
+                longPressTimer = setTimeout(() => this.savePlot(canvas), 800);
+            }
+        });
+        canvas.addEventListener('touchend', () => clearTimeout(longPressTimer));
+        canvas.addEventListener('touchmove', () => clearTimeout(longPressTimer));
 
 
         line.appendChild(container);
         line.appendChild(container);
         this.output.appendChild(line);
         this.output.appendChild(line);