MCPcopy
hub / github.com/Bistutu/FluentRead / handleFloatingBallClick

Function handleFloatingBallClick

entrypoints/utils/floatingBall.ts:120–146  ·  view source on GitHub ↗

* 处理悬浮球点击事件

()

Source from the content-addressed store, hash-verified

118 * 处理悬浮球点击事件
119 */
120function 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// 悬浮球动画效果
149function addFloatingBallAnimation(type: 'translate' | 'restore') {

Callers

nothing calls this directly

Calls 2

autoTranslateEnglishPageFunction · 0.90
restoreOriginalContentFunction · 0.90

Tested by

no test coverage detected