浏览代码

fix menu and submenu popup

amrbashir 9 月之前
父节点
当前提交
b01da7f3ed

文件差异内容过多而无法显示
+ 0 - 0
crates/tauri/scripts/bundle.global.js


+ 3 - 3
packages/api/src/menu/menu.ts

@@ -14,7 +14,7 @@ import { CheckMenuItem } from './checkMenuItem'
 import { IconMenuItem } from './iconMenuItem'
 import { PredefinedMenuItem } from './predefinedMenuItem'
 import { Submenu } from './submenu'
-import { type LogicalPosition, PhysicalPosition } from '../dpi'
+import { type LogicalPosition, PhysicalPosition, Position } from '../dpi'
 import { type Window } from '../window'
 import { invoke } from '../core'
 import { type ItemKind, MenuItemBase, newMenu } from './base'
@@ -240,14 +240,14 @@ export class Menu extends MenuItemBase {
    * If the position, is provided, it is relative to the window's top-left corner.
    */
   async popup(
-    at?: PhysicalPosition | LogicalPosition,
+    at?: PhysicalPosition | LogicalPosition | Position,
     window?: Window
   ): Promise<void> {
     return invoke('plugin:menu|popup', {
       rid: this.rid,
       kind: this.kind,
       window: window?.label ?? null,
-      at
+      at: at instanceof Position ? at : at ? new Position(at) : null
     })
   }
 

+ 2 - 1
packages/api/src/menu/submenu.ts

@@ -15,6 +15,7 @@ import { invoke } from '../core'
 import { type LogicalPosition, PhysicalPosition, type Window } from '../window'
 import { type ItemKind, MenuItemBase, newMenu } from './base'
 import { type MenuOptions } from './menu'
+import { Position } from '../dpi'
 
 function itemFromKind([rid, id, kind]: [number, string, ItemKind]):
   | Submenu
@@ -247,7 +248,7 @@ export class Submenu extends MenuItemBase {
       rid: this.rid,
       kind: this.kind,
       window: window?.label ?? null,
-      at
+      at: at instanceof Position ? at : at ? new Position(at) : null
     })
   }
 

+ 1 - 1
packages/api/src/window.ts

@@ -2312,7 +2312,7 @@ async function availableMonitors(): Promise<Monitor[]> {
  * The coordinates can be negative if the top-left hand corner of the window is outside of the visible screen region.
  */
 async function cursorPosition(): Promise<PhysicalPosition> {
-  return invoke<{ x: number; y: number }>('plugin:window|cursor_position').then(
+  return invoke<PhysicalPosition>('plugin:window|cursor_position').then(
     (v) => new PhysicalPosition(v)
   )
 }

部分文件因为文件数量过多而无法显示