mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-06-06 13:53:54 +02:00
fix(positioner): pass correct values through IPC (#1858)
* fix(positioner): pass correct values through IPC followup to https://github.com/tauri-apps/plugins-workspace/pull/1822 * build api & remove packageManager field
This commit is contained in:
@@ -102,8 +102,8 @@ import {
|
||||
const action = async (event: TrayIconEvent) => {
|
||||
// add the handle in the action to update the state
|
||||
await handleIconState(event);
|
||||
if ("click" in event) {
|
||||
const { click } = event;
|
||||
|
||||
if (event.type === "Click") {
|
||||
// note this option requires enabling the `tray-icon`
|
||||
// feature in the Cargo.toml
|
||||
await moveWindow(Position.TrayLeft);
|
||||
|
||||
@@ -1 +1 @@
|
||||
if("__TAURI__"in window){var __TAURI_PLUGIN_POSITIONER__=function(t){"use strict";async function o(t,o={},e){return window.__TAURI_INTERNALS__.invoke(t,o,e)}var e;return"function"==typeof SuppressedError&&SuppressedError,t.Position=void 0,(e=t.Position||(t.Position={}))[e.TopLeft=0]="TopLeft",e[e.TopRight=1]="TopRight",e[e.BottomLeft=2]="BottomLeft",e[e.BottomRight=3]="BottomRight",e[e.TopCenter=4]="TopCenter",e[e.BottomCenter=5]="BottomCenter",e[e.LeftCenter=6]="LeftCenter",e[e.RightCenter=7]="RightCenter",e[e.Center=8]="Center",e[e.TrayLeft=9]="TrayLeft",e[e.TrayBottomLeft=10]="TrayBottomLeft",e[e.TrayRight=11]="TrayRight",e[e.TrayBottomRight=12]="TrayBottomRight",e[e.TrayCenter=13]="TrayCenter",e[e.TrayBottomCenter=14]="TrayBottomCenter",t.handleIconState=async function(t){await async function(t){await o("plugin:positioner|set_tray_icon_state",{position:t.position,size:t.size})}(t.rect)},t.moveWindow=async function(t){await o("plugin:positioner|move_window",{position:t})},t}({});Object.defineProperty(window.__TAURI__,"positioner",{value:__TAURI_PLUGIN_POSITIONER__})}
|
||||
if("__TAURI__"in window){var __TAURI_PLUGIN_POSITIONER__=function(t){"use strict";async function e(t,e={},o){return window.__TAURI_INTERNALS__.invoke(t,e,o)}var o;return"function"==typeof SuppressedError&&SuppressedError,t.Position=void 0,(o=t.Position||(t.Position={}))[o.TopLeft=0]="TopLeft",o[o.TopRight=1]="TopRight",o[o.BottomLeft=2]="BottomLeft",o[o.BottomRight=3]="BottomRight",o[o.TopCenter=4]="TopCenter",o[o.BottomCenter=5]="BottomCenter",o[o.LeftCenter=6]="LeftCenter",o[o.RightCenter=7]="RightCenter",o[o.Center=8]="Center",o[o.TrayLeft=9]="TrayLeft",o[o.TrayBottomLeft=10]="TrayBottomLeft",o[o.TrayRight=11]="TrayRight",o[o.TrayBottomRight=12]="TrayBottomRight",o[o.TrayCenter=13]="TrayCenter",o[o.TrayBottomCenter=14]="TrayBottomCenter",t.handleIconState=async function(t){const o={};o[`${t.rect.size.type}`]={width:t.rect.size.width,height:t.rect.size.height};const i={};i[`${t.rect.position.type}`]={x:t.rect.position.x,y:t.rect.position.y},await e("plugin:positioner|set_tray_icon_state",{position:i,size:o})},t.moveWindow=async function(t){await e("plugin:positioner|move_window",{position:t})},t}({});Object.defineProperty(window.__TAURI__,"positioner",{value:__TAURI_PLUGIN_POSITIONER__})}
|
||||
|
||||
@@ -40,12 +40,20 @@ export async function moveWindow(to: Position): Promise<void> {
|
||||
}
|
||||
|
||||
export async function handleIconState(event: TrayIconEvent): Promise<void> {
|
||||
await invokeSetTrayIconState(event.rect)
|
||||
}
|
||||
const size = {} as Record<string, unknown>
|
||||
size[`${event.rect.size.type}`] = {
|
||||
width: event.rect.size.width,
|
||||
height: event.rect.size.height
|
||||
}
|
||||
|
||||
const position = {} as Record<string, unknown>
|
||||
position[`${event.rect.position.type}`] = {
|
||||
x: event.rect.position.x,
|
||||
y: event.rect.position.y
|
||||
}
|
||||
|
||||
async function invokeSetTrayIconState(rect: TrayIconEvent['rect']) {
|
||||
await invoke('plugin:positioner|set_tray_icon_state', {
|
||||
position: rect.position,
|
||||
size: rect.size
|
||||
position,
|
||||
size
|
||||
})
|
||||
}
|
||||
|
||||
@@ -25,6 +25,6 @@
|
||||
"LICENSE"
|
||||
],
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "^2.0.0-rc.4"
|
||||
"@tauri-apps/api": "^2.0.0-rc.6"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user