@@ -223,20 +223,58 @@ function createQuickButton(editor, name, code) {
223223 // eda.sys_Message.showToastMessage(`已加载:${name}`, 'info', 1);
224224 } ;
225225
226- // 右键:删除按钮
226+ // 右键:删除按钮 2026.1.5 修改增加一个新的菜单项
227227 btn . oncontextmenu = ( e ) => {
228228 e . preventDefault ( ) ;
229- if ( confirm ( `确定要删除快捷按钮 "${ name } " 吗?\n(此操作不可逆)` ) ) {
229+ const menu =
230+ document . getElementById ( 'ctx-menu' ) ||
231+ ( ( ) => {
232+ const m = document . createElement ( 'div' ) ;
233+ m . id = 'ctx-menu' ;
234+ m . style . cssText =
235+ 'position:fixed;z-index:10000;background:white;border:1px solid #ccc;box-shadow:2px 2px 6px rgba(0,0,0,0.2);display:none;font-size:14px;min-width:80px' ;
236+ document . body . appendChild ( m ) ;
237+ document . addEventListener ( 'click' , ( ) => ( m . style . display = 'none' ) ) ;
238+ return m ;
239+ } ) ( ) ;
240+ const showItem = ( text , color , action ) => {
241+ const item = document . createElement ( 'div' ) ;
242+ item . textContent = text ;
243+ item . style . cssText = `padding:6px 12px;cursor:pointer;color:${ color || '#000' } ;user-select:none` ;
244+ item . onmouseenter = ( ) => ( item . style . backgroundColor = color ? '#ffebee' : '#f0f0f0' ) ;
245+ item . onmouseleave = ( ) => ( item . style . backgroundColor = '' ) ;
246+ item . onclick = ( ) => {
247+ menu . style . display = 'none' ;
248+ action ( ) ;
249+ } ;
250+ menu . appendChild ( item ) ;
251+ } ;
252+ menu . innerHTML = '' ;
253+ showItem ( '加载' , '' , ( ) => {
254+ editor . setValue ( code , - 1 ) ;
255+ editor . clearSelection ( ) ;
256+ eda . sys_Message . showToastMessage ( `已加载:${ name } ` , 'info' , 1 ) ;
257+ } ) ;
258+ showItem ( '删除' , '#d32f2f' , ( ) => {
230259 deleteBtnFromDB ( name )
231260 . then ( ( ) => {
232- li . remove ( ) ; // 移除整个 <li>
261+ li . remove ( ) ;
233262 eda . sys_Message . showToastMessage ( `已删除快捷按钮 "${ name } "` , 'info' , 1 ) ;
234263 } )
235264 . catch ( ( err ) => {
236265 console . error ( '删除失败:' , err ) ;
237266 eda . sys_Message . showToastMessage ( `删除失败: ${ err . message } ` , 'error' , 1 ) ;
238267 } ) ;
239- }
268+ } ) ;
269+ const x = e . pageX ;
270+ const y = e . pageY ;
271+ const w = window . innerWidth ;
272+ const h = window . innerHeight ;
273+ const mw = 100 ;
274+ const mh = 50 ;
275+ menu . style . left = `${ Math . min ( x , w - mw - 5 ) } px` ;
276+ menu . style . top = `${ Math . min ( y , h - mh - 5 ) } px` ;
277+ menu . style . display = 'block' ;
240278 } ;
241279
242280 li . appendChild ( btn ) ;
0 commit comments