Skip to content

Commit

Permalink
fix: add os.platform to support macOS (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
gyteng authored Nov 1, 2023
1 parent 3fcd47b commit af033fd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
5 changes: 4 additions & 1 deletion examples/electron/src/finclip.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const koffi = require('koffi');
const os = require('os');

const finclip = {};
let lib;
Expand All @@ -14,7 +15,9 @@ const loadLibrary = libraryPath => {
finclip.finclip_params_set = lib.func('finclip_params_set', 'int', ['POINT', 'string', 'string']);
finclip.finclip_init_with_config = lib.func('finclip_init_with_config', 'int', ['string', 'POINT']);
finclip.finclip_start_applet = lib.func('finclip_start_applet', 'int', ['string', 'string']);
finclip.finclip_start_applet_embed = lib.func('finclip_start_applet_embed', 'int', ['string', 'string', 'POINT', 'int']);
if (os.platform() === 'win32') {
finclip.finclip_start_applet_embed = lib.func('finclip_start_applet_embed', 'int', ['string', 'string', 'POINT', 'int']);
}
finclip.finclip_close_applet = lib.func('finclip_close_applet', 'int', ['string']);
finclip.finclip_set_position = lib.func('finclip_set_position', 'int', ['string', 'int', 'int', 'int', 'int']);
finclip.finclip_callback_success = lib.func('finclip_callback_success', 'int', ['int', 'POINT']);
Expand Down
13 changes: 11 additions & 2 deletions examples/electron/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,16 @@ let embed = { x: 300, y: 0 };
let isOpen = false;
let isEmbed = false;

const finclipPath = path.resolve(__dirname, '../../../vendor/win/x64/FinClip/FinClip.exe');
const libraryPath = path.resolve(__dirname, '../../../vendor/win/x64', 'FinClipSDKWrapper.dll');
let finclipPath;
let libraryPath;

if (os.platform() === 'win32') {
finclipPath = path.resolve(__dirname, '../../../vendor/win/x64/FinClip/FinClip.exe');
libraryPath = path.resolve(__dirname, '../../../vendor/win/x64', 'FinClipSDKWrapper.dll');
} else if (os.platform() === 'darwin') {
finclipPath = path.resolve(__dirname, '../../../vendor/mac/x64/FinClip.app');
libraryPath = path.resolve(__dirname, '../../../vendor/mac/x64', 'libFinClipSDKWrapper.so');
}

finclip.load_library(libraryPath);

Expand Down Expand Up @@ -62,6 +70,7 @@ const openFinClipWindow = (arg) => {

const embedFinClipWindow = () => {
if (!isOpen) return;
if (os.platform() !== 'win32') return;
createChildWindow();
finclip.finclip_start_applet_embed("1", appid_, config_, hwnd);
resizeChildWindow();
Expand Down
2 changes: 2 additions & 0 deletions vendor/mac/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
arm/
x64/

0 comments on commit af033fd

Please sign in to comment.