Skip to content

Commit

Permalink
Merge pull request #68 from BakaFT/feat/Folder
Browse files Browse the repository at this point in the history
Add optional `path` param to `OpenPluginsFolder`
  • Loading branch information
nomi-san committed Aug 5, 2023
2 parents 751bd63 + df18c9b commit b98f0b8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
13 changes: 10 additions & 3 deletions core/src/renderer/renderer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,17 @@ static V8Value *native_OpenAssetsFolder(const vec<V8Value *> &args)
}

static V8Value *native_OpenPluginsFolder(const vec<V8Value *> &args)
{
utils::openLink(config::pluginsDir());
{
wstr destPath = config::pluginsDir();
if (args.size()) {
destPath = destPath + L"\\" + args[0]->asString()->str;
if (!utils::isDir(destPath)) {
return V8Value::boolean(false);
}
}
utils::openLink(destPath);

return nullptr;
return V8Value::boolean(true);
}

static V8Value *native_ReloadClient(const vec<V8Value *> &args)
Expand Down
11 changes: 9 additions & 2 deletions plugins/src/preload/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@ window.openAssetsFolder = function () {
native.OpenAssetsFolder();
};

window.openPluginsFolder = function () {
native.OpenPluginsFolder();
window.openPluginsFolder = function (path?: string) {
if(arguments.length > 1) return false;
if (path === undefined) return native.OpenPluginsFolder();
if(typeof path !== 'string') return false;

if(path.includes('..')) return false;
if(path === "") path = ".";

return native.OpenPluginsFolder(path);
};

window.reloadClient = function () {
Expand Down
2 changes: 1 addition & 1 deletion plugins/src/preload/api/native.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
interface Native {
OpenDevTools: (remote: boolean) => void;
OpenAssetsFolder: () => void;
OpenPluginsFolder: () => void;
OpenPluginsFolder: (path?: string) => boolean;
ReloadClient: () => void;

GetWindowEffect: () => string;
Expand Down
2 changes: 1 addition & 1 deletion plugins/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ declare const Effect: Effect;

declare const openDevTools: (remote?: boolean) => void;
declare const openAssetsFolder: () => void;
declare const openPluginsFolder: () => void;
declare const openPluginsFolder: (path?: string) => boolean;
declare const reloadClient: () => void;
declare const restartClient: () => void;
declare const getScriptPath: () => string | undefined;
Expand Down

0 comments on commit b98f0b8

Please sign in to comment.