File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -178,6 +178,27 @@ export const addRecordButton = () => {
178178
179179 // 添加到页面
180180 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+ } ) ;
181202} ;
182203
183204
You can’t perform that action at this time.
0 commit comments