1
0
Fork 0

fix: add os.platform to support macOS (#10)

master
Gu 2023-11-01 14:26:19 +08:00 committed by GitHub
parent 3fcd47bc33
commit af033fdea8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 3 deletions

View File

@ -1,4 +1,5 @@
const koffi = require('koffi'); const koffi = require('koffi');
const os = require('os');
const finclip = {}; const finclip = {};
let lib; let lib;
@ -14,7 +15,9 @@ const loadLibrary = libraryPath => {
finclip.finclip_params_set = lib.func('finclip_params_set', 'int', ['POINT', 'string', 'string']); 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_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 = lib.func('finclip_start_applet', 'int', ['string', 'string']);
if (os.platform() === 'win32') {
finclip.finclip_start_applet_embed = lib.func('finclip_start_applet_embed', 'int', ['string', 'string', 'POINT', 'int']); 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_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_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']); finclip.finclip_callback_success = lib.func('finclip_callback_success', 'int', ['int', 'POINT']);

View File

@ -12,8 +12,16 @@ let embed = { x: 300, y: 0 };
let isOpen = false; let isOpen = false;
let isEmbed = false; let isEmbed = false;
const finclipPath = path.resolve(__dirname, '../../../vendor/win/x64/FinClip/FinClip.exe'); let finclipPath;
const libraryPath = path.resolve(__dirname, '../../../vendor/win/x64', 'FinClipSDKWrapper.dll'); 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); finclip.load_library(libraryPath);
@ -62,6 +70,7 @@ const openFinClipWindow = (arg) => {
const embedFinClipWindow = () => { const embedFinClipWindow = () => {
if (!isOpen) return; if (!isOpen) return;
if (os.platform() !== 'win32') return;
createChildWindow(); createChildWindow();
finclip.finclip_start_applet_embed("1", appid_, config_, hwnd); finclip.finclip_start_applet_embed("1", appid_, config_, hwnd);
resizeChildWindow(); resizeChildWindow();

2
vendor/mac/.gitignore vendored 100644
View File

@ -0,0 +1,2 @@
arm/
x64/