chore: update plugin sdk - add appDataPath (#492)
This commit is contained in:
parent
80c4f53927
commit
7fbb5822f7
10
core/core.ts
10
core/core.ts
@ -28,6 +28,13 @@ const downloadFile: (url: string, fileName: string) => Promise<any> = (url, file
|
||||
const deleteFile: (path: string) => Promise<any> = (path) =>
|
||||
window.coreAPI?.deleteFile(path) ?? window.electronAPI?.deleteFile(path);
|
||||
|
||||
/**
|
||||
* Retrieves the path to the app data directory using the `coreAPI` object.
|
||||
* If the `coreAPI` object is not available, the function returns `undefined`.
|
||||
* @returns A Promise that resolves with the path to the app data directory, or `undefined` if the `coreAPI` object is not available.
|
||||
*/
|
||||
const appDataPath: () => Promise<any> = () => window.coreAPI?.appDataPath();
|
||||
|
||||
/** Register extension point function type definition
|
||||
*
|
||||
*/
|
||||
@ -46,9 +53,10 @@ export const core = {
|
||||
invokePluginFunc,
|
||||
downloadFile,
|
||||
deleteFile,
|
||||
appDataPath,
|
||||
};
|
||||
|
||||
/**
|
||||
* Functions exports
|
||||
*/
|
||||
export { invokePluginFunc, downloadFile, deleteFile };
|
||||
export { invokePluginFunc, downloadFile, deleteFile, appDataPath };
|
||||
|
||||
@ -193,6 +193,15 @@ function handleIPCs() {
|
||||
return join(app.getPath("userData"), "plugins");
|
||||
});
|
||||
|
||||
/**
|
||||
* Retrieves the path to the app data directory using the `coreAPI` object.
|
||||
* If the `coreAPI` object is not available, the function returns `undefined`.
|
||||
* @returns A Promise that resolves with the path to the app data directory, or `undefined` if the `coreAPI` object is not available.
|
||||
*/
|
||||
ipcMain.handle("appDataPath", async (_event) => {
|
||||
return app.getPath("userData");
|
||||
});
|
||||
|
||||
/**
|
||||
* Returns the version of the app.
|
||||
* @param _event - The IPC event object.
|
||||
|
||||
@ -19,6 +19,8 @@ contextBridge.exposeInMainWorld("electronAPI", {
|
||||
|
||||
pluginPath: () => ipcRenderer.invoke("pluginPath"),
|
||||
|
||||
appDataPath: () => ipcRenderer.invoke("appDataPath"),
|
||||
|
||||
reloadPlugins: () => ipcRenderer.invoke("reloadPlugins"),
|
||||
|
||||
appVersion: () => ipcRenderer.invoke("appVersion"),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user