File tree 1 file changed +21
-0
lines changed
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -178,6 +178,27 @@ export const addRecordButton = () => {
178
178
179
179
// 添加到页面
180
180
document . body . appendChild ( button ) ;
181
+
182
+ // 添加窗口大小变化监听器
183
+ window . addEventListener ( 'resize' , ( ) => {
184
+ const buttonRect = button . getBoundingClientRect ( ) ;
185
+ const maxRight = window . innerWidth - button . offsetWidth - 10 ;
186
+ const maxBottom = window . innerHeight - button . offsetHeight - 10 ;
187
+
188
+ // 如果按钮超出可视区域,调整位置
189
+ if ( parseInt ( button . style . right ) > maxRight ) {
190
+ button . style . right = `${ maxRight } px` ;
191
+ }
192
+ if ( parseInt ( button . style . bottom ) > maxBottom ) {
193
+ button . style . bottom = `${ maxBottom } px` ;
194
+ }
195
+
196
+ // 保存调整后的位置
197
+ localStorage . setItem ( 'LMS_rateButtonPosition' , JSON . stringify ( {
198
+ bottom : parseInt ( button . style . bottom ) ,
199
+ right : parseInt ( button . style . right )
200
+ } ) ) ;
201
+ } ) ;
181
202
} ;
182
203
183
204
You can’t perform that action at this time.
0 commit comments