mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-12-15 21:53:59 +03:00
feat(api): add resolveResource
API to the path module (#4234)
This commit is contained in:
parent
3f998ca294
commit
7bba8db83e
5
.changes/resolve-resource-api.md
Normal file
5
.changes/resolve-resource-api.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"api": patch
|
||||
---
|
||||
|
||||
Added the `resolveResource` API to the path module.
|
File diff suppressed because one or more lines are too long
@ -331,7 +331,8 @@ async function publicDir(): Promise<string> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path to the user's resource directory.
|
||||
* Returns the path to the application's resource directory.
|
||||
* To resolve a resource path, see the [[resolveResource | `resolveResource API`]].
|
||||
*
|
||||
* @returns
|
||||
*/
|
||||
@ -346,6 +347,24 @@ async function resourceDir(): Promise<string> {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the path to a resource file.
|
||||
*
|
||||
* @param resourcePath The path to the resource.
|
||||
* Must follow the same syntax as defined in `tauri.conf.json > tauri > bundle > resources`, i.e. keeping subfolders and parent dir components (`../`).
|
||||
* @returns The full path to the resource.
|
||||
*/
|
||||
async function resolveResource(resourcePath: string): Promise<string> {
|
||||
return invokeTauriCommand<string>({
|
||||
__tauriModule: 'Path',
|
||||
message: {
|
||||
cmd: 'resolvePath',
|
||||
path: resourcePath,
|
||||
directory: BaseDirectory.Resource
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path to the user's runtime directory.
|
||||
*
|
||||
@ -559,6 +578,7 @@ export {
|
||||
pictureDir,
|
||||
publicDir,
|
||||
resourceDir,
|
||||
resolveResource,
|
||||
runtimeDir,
|
||||
templateDir,
|
||||
videoDir,
|
||||
|
Loading…
Reference in New Issue
Block a user