-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add tray and menu javascript APIs and events, closes #6617 #7709
Conversation
Updated and removed dependencies detected. Learn more about Socket for GitHub ↗︎
🚮 Removed packages: [email protected] |
Now that the implementation is done without depending on the Also the All this could be solved by just adding them all into one single package in core. These are essential to any tauri app and so should be provided by default in core. |
use super::ResourceId; | ||
|
||
#[command(root = "crate")] | ||
fn close<R: Runtime>(app: AppHandle<R>, rid: ResourceId) -> crate::Result<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is problematic, an attacker can close all resources by iterating on IDs until an error is returned.
maybe we should make the ID random instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Closing resource is not that bad right?
Also for reference, deno is using the same ID strategy and though they also provide .close()
you can't really invoke the underlying mechanism of it (compared to invoke("plugin:resources|close"
).
So in order to simplify the implementation and keep using incrementing ID numbers, we can hide the invoke endpoint and randomize it on each launch of the app.
Co-authored-by: Lucas Fernandes Nogueira <[email protected]>
Co-authored-by: Lucas Fernandes Nogueira <[email protected]>
Co-authored-by: Lucas Fernandes Nogueira <[email protected]>
Co-authored-by: Lucas Fernandes Nogueira <[email protected]>
Co-authored-by: Lucas Fernandes Nogueira <[email protected]>
Co-authored-by: Lucas Fernandes Nogueira <[email protected]>
allows something like: ```javascript await Menu.new({ items: [ { item: 'Copy' }, { text: 'Something', action: () => console.log('something clicked') }, { id: 'x', icon: '/home/lucas/projects/tauri/tauri/examples/.icons/32x32.png', text: 'Tauris', action: () => console.log('tauri clicked') }, { checked: true, text: 'chec', action: () => console.log('chec clicked') }, { text: 'Sub', items: [ { item: 'Paste' }, { text: 'subsubsub', action: () => console.log('sub clicked') } ] } ] }) ```
We're missing a lot of documentation here, but I wanna merge it anyway because we need to do a complete pass on API examples. I like how this can be dynamic with the MenuItem classes (so you can update, share items), or static with raw objects after d0eeaba |
closes #6617
TODOs:
What kind of change does this PR introduce?
Does this PR introduce a breaking change?
Checklist
fix: remove a typo, closes #___, #___
)Other information