* 处理悬浮球点击事件
()
| 118 | * 处理悬浮球点击事件 |
| 119 | */ |
| 120 | function handleFloatingBallClick() { |
| 121 | if (!floatingBallInstance) return; |
| 122 | |
| 123 | // 切换悬浮球翻译状态 |
| 124 | const newState = !floatingBallInstance.isTranslating; |
| 125 | floatingBallInstance.isTranslating = newState; |
| 126 | |
| 127 | // 触发对应的自定义事件 |
| 128 | if (newState) { |
| 129 | document.dispatchEvent(new CustomEvent('fluentread-translation-started')); |
| 130 | } else { |
| 131 | document.dispatchEvent(new CustomEvent('fluentread-translation-ended')); |
| 132 | } |
| 133 | |
| 134 | // 更新UI状态 - 使用Vue实例的$el属性 |
| 135 | if (floatingBallInstance.$el) { |
| 136 | if (newState) { |
| 137 | floatingBallInstance.$el.classList.add('fluent-read-floating-ball-active'); |
| 138 | // 开始翻译 |
| 139 | autoTranslateEnglishPage(); |
| 140 | } else { |
| 141 | floatingBallInstance.$el.classList.remove('fluent-read-floating-ball-active'); |
| 142 | // 恢复原文 |
| 143 | restoreOriginalContent(); |
| 144 | } |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | // 悬浮球动画效果 |
| 149 | function addFloatingBallAnimation(type: 'translate' | 'restore') { |
nothing calls this directly
no test coverage detected