docs(opener): add basic usage guide to readme

pull/2167/head
Tony 8 months ago
parent 5b8efde906
commit b3084300de
No known key found for this signature in database
GPG Key ID: 34BDD3EA27824956

@ -70,7 +70,41 @@ fn main() {
Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
```javascript
import { openUrl, openPath, revealItemInDir } from '@tauri-apps/plugin-opener'
// Opens the URL in the default browser
await openUrl('https://example.com')
// Or with a specific browser/app
await openUrl('https://example.com', 'firefox')
// Opens the path with the system's default app
await openPath('/path/to/file')
// Or with a specific app
await openPath('/path/to/file', 'firefox')
// Reveal a path with the system's default explorer
await revealItemInDir('/path/to/file')
```
### Usage from Rust
You can also use those APIs from Rust:
```rust
use tauri_plugin_opener::OpenerExt;
fn main() {
tauri::Builder::default()
.setup(|app| {
let opener = app.opener();
opener.open_url("https://example.com", Some("firefox"));
opener.open_path("/path/to/file", Some("firefox"));
opener.reveal_item_in_dir("/path/to/file");
})
.plugin(tauri_plugin_opener::init())
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
```
## Contributing

@ -71,7 +71,7 @@ export async function openPath(path: string, openWith?: string): Promise<void> {
}
/**
* Reveal a path the system's default explorer.
* Reveal a path with the system's default explorer.
*
* #### Platform-specific:
*

Loading…
Cancel
Save