-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsprite.html
More file actions
218 lines (207 loc) · 5.9 KB
/
sprite.html
File metadata and controls
218 lines (207 loc) · 5.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Sprite</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html, body {
width: 100%;
height: 100%;
overflow: hidden;
background: transparent;
user-select: none;
-webkit-user-select: none;
}
/* 悬浮球容器 */
.sprite-container {
position: relative;
width: 64px;
height: 64px;
}
.sprite-ball {
width: 56px;
height: 56px;
position: absolute;
top: 4px;
left: 4px;
border-radius: 50%;
background: linear-gradient(
135deg,
#667eea 0%,
#764ba2 25%,
#f093fb 50%,
#f5576c 75%,
#667eea 100%
);
background-size: 400% 400%;
animation: flow 8s ease infinite;
border: 2px solid rgba(255,255,255,0.3);
display: flex;
align-items: center;
justify-content: center;
cursor: grab;
transition: transform 0.15s, border-color 0.15s;
z-index: 2;
}
.sprite-ball:hover {
transform: scale(1.08);
border-color: rgba(255,255,255,0.6);
}
.sprite-ball.dragging {
cursor: grabbing;
transform: scale(1.0);
}
/* 录音中状态 */
.sprite-ball.recording {
background: linear-gradient(
135deg,
#e53935 0%,
#d32f2f 25%,
#ff5252 50%,
#ff1744 75%,
#e53935 100%
);
animation: flow 2s ease infinite, pulse 1s ease-in-out infinite;
}
@keyframes pulse {
0%, 100% { box-shadow: 0 0 0 0 rgba(229, 57, 53, 0.6); }
50% { box-shadow: 0 0 0 8px rgba(229, 57, 53, 0); }
}
.sprite-icon {
width: 32px;
height: 32px;
pointer-events: none;
}
/* 录音图标 */
.recording-icon {
display: none;
width: 24px;
height: 24px;
background: white;
border-radius: 4px;
}
.sprite-ball.recording .sprite-icon {
display: none;
}
.sprite-ball.recording .recording-icon {
display: block;
}
@keyframes flow {
0% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
100% { background-position: 0% 50%; }
}
/* 旋转光环 */
.orbit-ring {
position: absolute;
top: 0;
left: 0;
width: 64px;
height: 64px;
border-radius: 50%;
border: 2px solid transparent;
border-top-color: rgba(102, 126, 234, 0.8);
border-right-color: rgba(102, 126, 234, 0.4);
animation: orbit 4s linear infinite;
z-index: 1;
}
/* 录音状态:快速旋转红色光环 */
.sprite-container.recording .orbit-ring {
border-top-color: rgba(229, 57, 53, 0.8);
border-right-color: rgba(229, 57, 53, 0.4);
animation: orbit 1.2s linear infinite;
}
@keyframes orbit {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
</style>
</head>
<body>
<div class="sprite-container" id="container">
<div class="orbit-ring"></div>
<div class="sprite-ball" id="sprite">
<img id="sprite-icon" class="sprite-icon" src="" alt="icon">
<div class="recording-icon"></div>
</div>
</div>
<script>
const { ipcRenderer } = require('electron');
const container = document.getElementById('container');
const sprite = document.getElementById('sprite');
// 双击检测时间阈值(毫秒)
const DOUBLE_CLICK_THRESHOLD = 300;
// 接收图标
ipcRenderer.on('set-sprite-icon', (event, dataUrl) => {
document.getElementById('sprite-icon').src = dataUrl;
});
// 监听录音状态变化
ipcRenderer.on('meeting-recording-state', (event, isRecording) => {
if (isRecording) {
sprite.classList.add('recording');
container.classList.add('recording');
} else {
sprite.classList.remove('recording');
container.classList.remove('recording');
}
});
// ========== 拖拽逻辑 ==========
let isDragging = false;
let dragOffsetX = 0;
let dragOffsetY = 0;
container.addEventListener('mousedown', (e) => {
if (e.button === 0) {
ipcRenderer.invoke('sprite-get-position').then(winPos => {
isDragging = true;
dragOffsetX = e.screenX - winPos.x;
dragOffsetY = e.screenY - winPos.y;
sprite.classList.add('dragging');
});
}
});
document.addEventListener('mousemove', (e) => {
if (isDragging) {
const newX = e.screenX - dragOffsetX;
const newY = e.screenY - dragOffsetY;
ipcRenderer.send('sprite-set-position', newX, newY);
}
});
document.addEventListener('mouseup', (e) => {
if (e.button === 0) {
isDragging = false;
sprite.classList.remove('dragging');
}
});
// 双击检测 - 打开会议助手窗口(需要检查可用性)
let lastClickTime = 0;
container.addEventListener('click', async (e) => {
if (e.button === 0 && !isDragging) {
const now = Date.now();
if (now - lastClickTime < DOUBLE_CLICK_THRESHOLD) {
// 双击:检查会议助手是否可用
const available = await ipcRenderer.invoke('meeting-assistant-available');
if (available) {
ipcRenderer.send('open-meeting-assistant');
} else {
// 不可用时恢复主窗口
ipcRenderer.send('sprite-restore');
}
lastClickTime = 0;
} else {
lastClickTime = now;
}
}
});
// 右键菜单
container.addEventListener('contextmenu', (e) => {
e.preventDefault();
ipcRenderer.send('sprite-context-menu');
});
</script>
</body>
</html>