mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-01-31 00:35:19 +01:00
feat(api): implement getIdentifier() to access tauri.conf.json identifier (#12837)
* feat(api): implement getIdentifier() to access tauri.conf.json identifier * updated * chore(api): update change file and rebuild bundle * Update to @since 2.4.0 * added tag * Update .changes/get-identifier.md Co-authored-by: Fabian-Lars <github@fabianlars.de> --------- Co-authored-by: Fabian-Lars <github@fabianlars.de>
This commit is contained in:
6
.changes/get-identifier.md
Normal file
6
.changes/get-identifier.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"tauri": "minor:feat"
|
||||
"@tauri-apps/api": "minor:feat"
|
||||
---
|
||||
|
||||
Added `getIdentifier()` function to get the application identifier configured in tauri.conf.json
|
||||
@@ -148,6 +148,7 @@ const PLUGINS: &[(&str, &[(&str, bool)])] = &[
|
||||
("version", true),
|
||||
("name", true),
|
||||
("tauri_version", true),
|
||||
("identifier", true),
|
||||
("app_show", false),
|
||||
("app_hide", false),
|
||||
("default_window_icon", false),
|
||||
|
||||
@@ -5,6 +5,7 @@ Default permissions for the plugin.
|
||||
- `allow-version`
|
||||
- `allow-name`
|
||||
- `allow-tauri-version`
|
||||
- `allow-identifier`
|
||||
|
||||
## Permission Table
|
||||
|
||||
@@ -96,6 +97,32 @@ Denies the default_window_icon command without any pre-configured scope.
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
`core:app:allow-identifier`
|
||||
|
||||
</td>
|
||||
<td>
|
||||
|
||||
Enables the identifier command without any pre-configured scope.
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
`core:app:deny-identifier`
|
||||
|
||||
</td>
|
||||
<td>
|
||||
|
||||
Denies the identifier command without any pre-configured scope.
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
`core:app:allow-name`
|
||||
|
||||
</td>
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -25,6 +25,11 @@ pub fn tauri_version() -> &'static str {
|
||||
crate::VERSION
|
||||
}
|
||||
|
||||
#[command(root = "crate")]
|
||||
pub fn identifier<R: Runtime>(app: AppHandle<R>) -> String {
|
||||
app.config().identifier.clone()
|
||||
}
|
||||
|
||||
#[command(root = "crate")]
|
||||
#[allow(unused_variables)]
|
||||
pub fn app_show<R: Runtime>(app: AppHandle<R>) -> crate::Result<()> {
|
||||
@@ -63,6 +68,7 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
version,
|
||||
name,
|
||||
tauri_version,
|
||||
identifier,
|
||||
app_show,
|
||||
app_hide,
|
||||
default_window_icon,
|
||||
|
||||
@@ -55,6 +55,22 @@ async function getTauriVersion(): Promise<string> {
|
||||
return invoke('plugin:app|tauri_version')
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the application identifier.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { getIdentifier } from '@tauri-apps/api/app';
|
||||
* const identifier = await getIdentifier();
|
||||
* ```
|
||||
*
|
||||
* @returns The application identifier as configured in `tauri.conf.json`.
|
||||
*
|
||||
* @since 2.4.0
|
||||
*/
|
||||
async function getIdentifier(): Promise<string> {
|
||||
return invoke('plugin:app|identifier')
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the application on macOS. This function does not automatically focus any specific app window.
|
||||
*
|
||||
@@ -125,6 +141,7 @@ export {
|
||||
getName,
|
||||
getVersion,
|
||||
getTauriVersion,
|
||||
getIdentifier,
|
||||
show,
|
||||
hide,
|
||||
defaultWindowIcon,
|
||||
|
||||
Reference in New Issue
Block a user