Update electron and node demo (#5)
* new js demo * embed window * utf8 * fix c4819 * remove json libmaster
parent
611c2309f3
commit
c469fd102b
File diff suppressed because it is too large
Load Diff
|
@ -3,6 +3,8 @@ const os = require('os');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const finclip = require('finclip');
|
const finclip = require('finclip');
|
||||||
|
|
||||||
|
let hwnd = 0;
|
||||||
|
|
||||||
const createMainWindow = () => {
|
const createMainWindow = () => {
|
||||||
const win = new BrowserWindow({
|
const win = new BrowserWindow({
|
||||||
width: 800,
|
width: 800,
|
||||||
|
@ -12,6 +14,8 @@ const createMainWindow = () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
win.loadFile('../view/index.html');
|
win.loadFile('../view/index.html');
|
||||||
|
const handleBuffer = win.getNativeWindowHandle();
|
||||||
|
hwnd = os.endianness() == 'LE' ? handleBuffer.readInt32LE() : handleBuffer.readInt32BE();
|
||||||
};
|
};
|
||||||
|
|
||||||
const openFinClipWindow = (arg) => {
|
const openFinClipWindow = (arg) => {
|
||||||
|
@ -25,7 +29,10 @@ const openFinClipWindow = (arg) => {
|
||||||
handle: 0,
|
handle: 0,
|
||||||
finclipPath,
|
finclipPath,
|
||||||
});
|
});
|
||||||
console.log(result);
|
};
|
||||||
|
|
||||||
|
const embedFinClipWindow = () => {
|
||||||
|
finclip.embed({ handle: hwnd });
|
||||||
};
|
};
|
||||||
|
|
||||||
const closeFinClipWindow = () => {
|
const closeFinClipWindow = () => {
|
||||||
|
@ -37,6 +44,10 @@ ipcMain.on('OPEN_FINCLIP_WINDOW', (event, arg) => {
|
||||||
openFinClipWindow(arg);
|
openFinClipWindow(arg);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ipcMain.on('EMBED_FINCLIP_WINDOW', (event, arg) => {
|
||||||
|
embedFinClipWindow(arg);
|
||||||
|
});
|
||||||
|
|
||||||
ipcMain.on('CLOSE_FINCLIP_WINDOW', (event, arg) => {
|
ipcMain.on('CLOSE_FINCLIP_WINDOW', (event, arg) => {
|
||||||
closeFinClipWindow();
|
closeFinClipWindow();
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,6 +4,7 @@ contextBridge.exposeInMainWorld(
|
||||||
'finclip',
|
'finclip',
|
||||||
{
|
{
|
||||||
open: (payload) => ipcRenderer.send('OPEN_FINCLIP_WINDOW', payload),
|
open: (payload) => ipcRenderer.send('OPEN_FINCLIP_WINDOW', payload),
|
||||||
|
embed: () => ipcRenderer.send('EMBED_FINCLIP_WINDOW'),
|
||||||
close: () => ipcRenderer.send('CLOSE_FINCLIP_WINDOW'),
|
close: () => ipcRenderer.send('CLOSE_FINCLIP_WINDOW'),
|
||||||
setPosition: (payload) => ipcRenderer.send('SET_FINCLIP_POSITION', payload),
|
setPosition: (payload) => ipcRenderer.send('SET_FINCLIP_POSITION', payload),
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,10 @@ window.openFinClipWindow = () => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
window.embedFinClipWindow = () => {
|
||||||
|
finclip.embed();
|
||||||
|
};
|
||||||
|
|
||||||
window.closeFinClipWindow = () => {
|
window.closeFinClipWindow = () => {
|
||||||
finclip.close();
|
finclip.close();
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,20 +6,21 @@
|
||||||
启动参数
|
启动参数
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
domain<input type="string" id="domain" name="domain" value="https://finchat-mop-b.finogeeks.club">
|
domain<input type="string" id="domain" name="domain" value="https://finclip-testing.finogeeks.club">
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
appkey<input type="string" id="appkey" name="appkey" value="22LyZEib0gLTQdU3MUauAQVLIkNNhTSGIN42gXzlAsk=">
|
appkey<input type="string" id="appkey" name="appkey" value="22LyZEib0gLTQdU3MUauAfJ/xujwNfM6OvvEqQyH4igA">
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
appid<input type="string" id="appid" name="appid" value="60e3c059949a5300014d0c07">
|
appid<input type="string" id="appid" name="appid" value="6152b5dbfcfb4e0001448e6e">
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
secret<input type="string" id="secret" name="secret" value="ae55433be2f62915">
|
secret<input type="string" id="secret" name="secret" value="703b9026be3d6bc5">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<button onclick="openFinClipWindow()">open</button>
|
<button onclick="openFinClipWindow()">open</button>
|
||||||
|
<button onclick="embedFinClipWindow()">embed</button>
|
||||||
<button onclick="closeFinClipWindow()">close</button>
|
<button onclick="closeFinClipWindow()">close</button>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef WRAPPER_SRC_PUBLIC_FINCLIP_API_H_
|
#ifndef WRAPPER_SRC_PUBLIC_FINCLIP_API_H_
|
||||||
#define WRAPPER_SRC_PUBLIC_FINCLIP_API_H_
|
#define WRAPPER_SRC_PUBLIC_FINCLIP_API_H_
|
||||||
|
|
||||||
#include "finclip_api_const.h"
|
#include "finclip_api_const.h"
|
||||||
|
@ -17,29 +17,30 @@ typedef struct IKnown IKnown;
|
||||||
typedef struct IResultSet IResultSet;
|
typedef struct IResultSet IResultSet;
|
||||||
typedef struct IEvent IEvent;
|
typedef struct IEvent IEvent;
|
||||||
typedef struct IFinPacker IFinPacker;
|
typedef struct IFinPacker IFinPacker;
|
||||||
typedef struct IFinConfig IFinConfig;
|
typedef struct FinclipParams FinclipParams;
|
||||||
typedef struct IFinConfigPacker IFinConfigPacker;
|
typedef struct IFinConfigPacker IFinConfigPacker;
|
||||||
typedef struct IPackerFactory IPackerFactory;
|
typedef struct IPackerFactory IPackerFactory;
|
||||||
typedef struct Callback Callback;
|
typedef struct FinclipCallback FinclipCallback;
|
||||||
typedef void (*FinClipSDKCallback)(IEvent*);
|
typedef void (*FinClipSDKCallback)(IEvent*);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief SDK初始化
|
||||||
*/
|
*/
|
||||||
DLL_EXPORT int FINSTDMETHODCALLTYPE
|
DLL_EXPORT int FINSTDMETHODCALLTYPE
|
||||||
finclip_initialize(IFinConfigPacker* configpacker);
|
finclip_initialize(IFinConfigPacker* configpacker);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief 获取配置工厂
|
||||||
*/
|
*/
|
||||||
DLL_EXPORT IPackerFactory* FINSTDMETHODCALLTYPE finclip_get_packer_factory();
|
DLL_EXPORT IPackerFactory* FINSTDMETHODCALLTYPE finclip_get_packer_factory();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief 启动
|
||||||
*/
|
*/
|
||||||
DLL_EXPORT int FINSTDMETHODCALLTYPE finclip_start_applet(int appstore,
|
DLL_EXPORT int FINSTDMETHODCALLTYPE finclip_start_applet(const char* appstore,
|
||||||
const char* appid);
|
const char* appid);
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief 关闭所有小程序
|
||||||
*/
|
*/
|
||||||
DLL_EXPORT int FINSTDMETHODCALLTYPE finclip_close_all_applet();
|
DLL_EXPORT int FINSTDMETHODCALLTYPE finclip_close_all_applet();
|
||||||
|
|
||||||
|
@ -49,8 +50,7 @@ DLL_EXPORT int FINSTDMETHODCALLTYPE finclip_close_all_applet();
|
||||||
DLL_EXPORT int FINSTDMETHODCALLTYPE finclip_close_applet(const char* appid);
|
DLL_EXPORT int FINSTDMETHODCALLTYPE finclip_close_applet(const char* appid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 设置小程序主程序位置
|
* @brief 设置小程序窗口位置
|
||||||
* 需要设置
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
DLL_EXPORT void FINSTDMETHODCALLTYPE finclip_set_position(const char* appid,
|
DLL_EXPORT void FINSTDMETHODCALLTYPE finclip_set_position(const char* appid,
|
||||||
|
@ -65,107 +65,73 @@ DLL_EXPORT IFinConfigPacker* FINSTDMETHODCALLTYPE
|
||||||
finclip_packer_factory_get_config_packer(IPackerFactory* factory);
|
finclip_packer_factory_get_config_packer(IPackerFactory* factory);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief 新建配置
|
||||||
*/
|
*/
|
||||||
DLL_EXPORT IFinConfig* FINSTDMETHODCALLTYPE
|
DLL_EXPORT FinclipParams* FINSTDMETHODCALLTYPE
|
||||||
finclip_config_packer_new_config(IFinConfigPacker* packer);
|
finclip_config_packer_new_config(IFinConfigPacker* packer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief 获取配置, 如果获取失败, 则返回NULL
|
||||||
*/
|
*/
|
||||||
DLL_EXPORT IFinConfig* FINSTDMETHODCALLTYPE
|
DLL_EXPORT FinclipParams* FINSTDMETHODCALLTYPE
|
||||||
finclip_config_packer_get_config(IFinConfigPacker* packer, int appstore);
|
finclip_config_packer_get_config(IFinConfigPacker* packer, char* appstore);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief 增加配置
|
||||||
*/
|
*/
|
||||||
DLL_EXPORT int FINSTDMETHODCALLTYPE
|
DLL_EXPORT int FINSTDMETHODCALLTYPE finclip_config_packer_add_config(
|
||||||
finclip_config_packer_add_config(IFinConfigPacker* packer, IFinConfig* config);
|
IFinConfigPacker* packer, FinclipParams* config);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief 注册自定义api, 供小程序或h5调用
|
||||||
|
* @param packer
|
||||||
|
* @param type 类型, 区分h5与小程序
|
||||||
|
* @param apis api名称
|
||||||
|
* @param handle 处理函数
|
||||||
|
* @param input 自定义参数, 透传给handle
|
||||||
*/
|
*/
|
||||||
DLL_EXPORT void FINSTDMETHODCALLTYPE
|
DLL_EXPORT void FINSTDMETHODCALLTYPE
|
||||||
finclip_register_callback(IFinConfigPacker* packer, FinClipApiType type,
|
finclip_register_api(IFinConfigPacker* packer, FinClipApiType type,
|
||||||
const char* apis, FinclipApiHandle handle);
|
const char* apis, FinclipApiHandle handle, void* input);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief 创建启动参数
|
||||||
*/
|
*/
|
||||||
DLL_EXPORT void FINSTDMETHODCALLTYPE
|
DLL_EXPORT FinclipParams* FINSTDMETHODCALLTYPE finclip_create_params();
|
||||||
finclip_config_set_app_store(IFinConfig* config, int app_store);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief 销毁启动参数
|
||||||
*/
|
*/
|
||||||
DLL_EXPORT void FINSTDMETHODCALLTYPE
|
DLL_EXPORT void FINSTDMETHODCALLTYPE
|
||||||
finclip_config_set_app_key(IFinConfig* config, const char* app_key);
|
finclip_destory_params(FinclipParams* params);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief 设置启动参数
|
||||||
*/
|
*/
|
||||||
DLL_EXPORT void FINSTDMETHODCALLTYPE
|
DLL_EXPORT void FINSTDMETHODCALLTYPE finclip_params_set(FinclipParams* params,
|
||||||
finclip_config_set_secret(IFinConfig* config, const char* secret);
|
const char* key,
|
||||||
|
const char* value);
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief 根据key删除启动启动参数
|
||||||
*/
|
*/
|
||||||
DLL_EXPORT void FINSTDMETHODCALLTYPE
|
DLL_EXPORT void FINSTDMETHODCALLTYPE finclip_params_del(FinclipParams* params,
|
||||||
finclip_config_set_domain(IFinConfig* config, const char* domain);
|
const char* key);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief
|
|
||||||
*/
|
|
||||||
DLL_EXPORT void FINSTDMETHODCALLTYPE
|
|
||||||
finclip_config_set_app_window_style(IFinConfig* config, int type);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 设置启动模式, 参见: StartFlags
|
|
||||||
* 全同步模式: kBaseLibrarySync | kAppletSync
|
|
||||||
*/
|
|
||||||
DLL_EXPORT void FINSTDMETHODCALLTYPE
|
|
||||||
finclip_config_set_start_flag(IFinConfig* config, int flag);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 是否展示loading动画
|
|
||||||
*/
|
|
||||||
DLL_EXPORT void FINSTDMETHODCALLTYPE
|
|
||||||
finclip_config_set_show_loading(IFinConfig* config, bool show_loading);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 设置小程序主程序执行文件的位置, 当宿主程序和exe不在同一目录时,
|
|
||||||
* 需要设置
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
DLL_EXPORT void FINSTDMETHODCALLTYPE
|
|
||||||
finclip_config_set_exe_path(IFinConfig* config, const char* exe_path);
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
*/
|
*/
|
||||||
DLL_EXPORT int FINSTDMETHODCALLTYPE
|
DLL_EXPORT int FINSTDMETHODCALLTYPE finclip_start_applet_embed(
|
||||||
finclip_start_applet_embed(int appstore, const char* appid, HWND container);
|
const char* appstore, const char* appid, HWND container);
|
||||||
|
|
||||||
|
DLL_EXPORT int FINSTDMETHODCALLTYPE finclip_embed_applet(const char* appstore,
|
||||||
|
const char* appid,
|
||||||
|
HWND container);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
DLL_EXPORT int FINSTDMETHODCALLTYPE finclip_invoke_api(
|
||||||
|
FinClipApiType type, const char* app_id, const char* api_name,
|
||||||
/**
|
const char* params, FinclipApiCallback callback, void* input);
|
||||||
* @brief
|
|
||||||
*/
|
|
||||||
DLL_EXPORT void FINSTDMETHODCALLTYPE
|
|
||||||
finclip_register_callback_cpp(IFinConfigPacker* packer, FinClipApiType type,
|
|
||||||
const char* apis, Callback* callback);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief
|
|
||||||
*/
|
|
||||||
DLL_EXPORT int FINSTDMETHODCALLTYPE finclip_invoke_api_cpp(FinClipApiType type,
|
|
||||||
const char* app_id,
|
|
||||||
const char* api_name,
|
|
||||||
const char* params,
|
|
||||||
Callback* callback);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
#ifndef SRC_FINCLIP_API_CONST_H_
|
#ifndef WRAPPER_SRC_PUBLIC_FINCLIP_API_CONST_H_
|
||||||
#define SRC_FINCLIP_API_CONST_H_
|
|
||||||
#ifndef WRAPPER_SRC_PUBLIC_FINCLIP_API_CONST_H_
|
|
||||||
#define WRAPPER_SRC_PUBLIC_FINCLIP_API_CONST_H_
|
#define WRAPPER_SRC_PUBLIC_FINCLIP_API_CONST_H_
|
||||||
|
|
||||||
#define FIN_SID const char*
|
#define FIN_SID const char*
|
||||||
|
@ -31,6 +29,22 @@ typedef struct objc_object* FINCLIP_WINDOW_HANDLE;
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define FINCLIP_CONFIG_APPSTORE "appstore"
|
||||||
|
// appkey, secret, domain 从管理后台获取, 必填
|
||||||
|
#define FINCLIP_CONFIG_APPKEY "appkey"
|
||||||
|
#define FINCLIP_CONFIG_SECRET "secret"
|
||||||
|
#define FINCLIP_CONFIG_DOMAIN "domain"
|
||||||
|
//
|
||||||
|
#define FINCLIP_CONFIG_WINDOW_STYLE "window_style"
|
||||||
|
// 是否展示loading动画, 1: 展示, 0: 不展示
|
||||||
|
#define FINCLIP_CONFIG_SHOW_LOADING "show_loading"
|
||||||
|
// windows: finclip.exe位置, 默认为 ./finclip, 即当前目录下的finclip文件夹
|
||||||
|
// macos: finclip.app的位置, 默认为
|
||||||
|
#define FINCLIP_CONFIG_EXE_PATH "exe_path"
|
||||||
|
// finclip.exe位置, 默认到当前目录的finclip文件夹下找
|
||||||
|
#define FINCLIP_CONFIG_PAGE_PATH "page_path"
|
||||||
|
// 启动参数, 值为序列化后的json
|
||||||
|
#define FINCLIP_CONFIG_START_PARAMS "start_params"
|
||||||
/**
|
/**
|
||||||
* @brief 启动机制设置
|
* @brief 启动机制设置
|
||||||
* kAsync: 异步启动
|
* kAsync: 异步启动
|
||||||
|
@ -48,22 +62,19 @@ enum StartFlags {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
typedef enum { kApplet, kWebView } FinClipApiType;
|
typedef enum { kApplet, kWebView } FinClipApiType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 自定义api返回值回调
|
* @brief 调用h5方法后的返回值回调
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
typedef void (*FinclipApiCallback)(const char* res);
|
typedef void (*FinclipApiCallback)(const char* res, void* input);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 自定义api
|
* @brief 自定义api
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
typedef void (*FinclipApiHandle)(const char* event, const char* param,
|
typedef void (*FinclipApiHandle)(const char* event, const char* param,
|
||||||
FinclipApiCallback callback);
|
void* input, void* res);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif /* WRAPPER_SRC_PUBLIC_FINCLIP_API_CONST_H_ */
|
#endif /* WRAPPER_SRC_PUBLIC_FINCLIP_API_CONST_H_ */
|
||||||
|
|
||||||
#endif /* SRC_FINCLIP_API_CONST_H_ */
|
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
#include "../finclip_api.h"
|
#include "../finclip_api.h"
|
||||||
#include "resource.h"
|
#include "./finclip.h"
|
||||||
// Windows Header Files
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
// #include <node_api.h>
|
|
||||||
#include <napi.h>
|
#include <napi.h>
|
||||||
// C RunTime Header Files
|
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
|
@ -17,97 +14,56 @@
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include "json.hpp"
|
|
||||||
|
|
||||||
#pragma comment(lib, "FinClipSDKWrapper.lib")
|
#pragma comment(lib, "FinClipSDKWrapper.lib")
|
||||||
|
|
||||||
#define MAX_LOADSTRING 100
|
|
||||||
#define IDM_SENDMESSAGE_1 32784
|
|
||||||
#define IDM_SENDMESSAGE_2 32785
|
|
||||||
#define IDC_FINCLIP 109
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using json = nlohmann::json;
|
|
||||||
|
|
||||||
std::string Utf8Encode(const std::wstring& wstr, int cp = CP_UTF8) {
|
|
||||||
if (wstr.empty()) return std::string();
|
|
||||||
int size_needed =
|
|
||||||
WideCharToMultiByte(cp, 0, &wstr[0], static_cast<int>(wstr.size()),
|
|
||||||
nullptr, 0, nullptr, nullptr);
|
|
||||||
std::string str(size_needed, 0);
|
|
||||||
WideCharToMultiByte(cp, 0, &wstr[0], static_cast<int>(wstr.size()), &str[0],
|
|
||||||
size_needed, nullptr, nullptr);
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert an UTF8 string to a wide Unicode String
|
|
||||||
std::wstring Utf8Decode(const std::string& str, int cp = CP_UTF8) {
|
|
||||||
if (str.empty()) return std::wstring();
|
|
||||||
int size_needed = MultiByteToWideChar(
|
|
||||||
cp, 0, &str[0], static_cast<int>(str.size()), nullptr, 0);
|
|
||||||
std::wstring wstr(size_needed, 0);
|
|
||||||
MultiByteToWideChar(cp, 0, &str[0], static_cast<int>(str.size()), &wstr[0],
|
|
||||||
size_needed);
|
|
||||||
return wstr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CustomApi(const char* event, const char* param,
|
|
||||||
FinclipApiCallback callback) {
|
|
||||||
std::string data = param;
|
|
||||||
std::string e = event;
|
|
||||||
std::string res = R"({"data":"ok"})";
|
|
||||||
callback(res.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace NodeFinClip {
|
namespace NodeFinClip {
|
||||||
using namespace Napi;
|
using namespace Napi;
|
||||||
// std::string current_appid;
|
|
||||||
std::string domain;
|
std::string domain;
|
||||||
std::string appkey;
|
std::string appkey;
|
||||||
std::string appid;
|
std::string appid;
|
||||||
std::string secret;
|
std::string secret;
|
||||||
|
char app_store[] = "1";
|
||||||
|
|
||||||
Napi::String start(const Napi::CallbackInfo& info) {
|
Napi::String start(const Napi::CallbackInfo& info) {
|
||||||
Napi::Env env = info.Env();
|
Napi::Env env = info.Env();
|
||||||
Napi::Object args = info[0].ToObject();
|
Napi::Object args = info[0].ToObject();
|
||||||
int handle = args.Get("handle").ToNumber().Int32Value();
|
int handle = args.Get("handle").ToNumber().Int32Value();
|
||||||
int appstore = 1;
|
|
||||||
// string domain("https://finchat-mop-b.finogeeks.club");
|
|
||||||
// string appkey("22LyZEib0gLTQdU3MUauAQVLIkNNhTSGIN42gXzlAsk=");
|
|
||||||
// string appid("60e3c059949a5300014d0c07");
|
|
||||||
// string secret("ae55433be2f62915");
|
|
||||||
string type("1");
|
|
||||||
std::string path = args.Get("finclipPath").ToString();
|
|
||||||
auto* factory = finclip_get_packer_factory();
|
|
||||||
auto* packer = finclip_packer_factory_get_config_packer(factory);
|
|
||||||
auto* config = finclip_config_packer_new_config(packer);
|
|
||||||
finclip_config_packer_add_config(packer, config);
|
|
||||||
finclip_config_set_app_store(config, appstore);
|
|
||||||
finclip_config_set_app_key(config, appkey.c_str());
|
|
||||||
finclip_config_set_secret(config, secret.c_str());
|
|
||||||
finclip_config_set_domain(config, domain.c_str());
|
|
||||||
finclip_config_set_start_flag(config, kAppletSync);
|
|
||||||
finclip_config_set_show_loading(config, false);
|
|
||||||
finclip_config_set_exe_path(config, path.c_str());
|
|
||||||
finclip_register_callback(packer, kApplet, "api", CustomApi);
|
|
||||||
finclip_register_callback(packer, kWebView, "webapi", CustomApi);
|
|
||||||
finclip_initialize(packer);
|
|
||||||
finclip_start_applet(appstore, appid.c_str());
|
|
||||||
|
|
||||||
// hWnd_container = GetForegroundWindow();
|
std::string path = args.Get("finclipPath").ToString();
|
||||||
// SetWindowPos(hWnd_container, HWND_TOP, 0, 0, 1024, 768,
|
|
||||||
// SWP_ASYNCWINDOWPOS);
|
auto *factory = finclip_get_packer_factory();
|
||||||
// // hWnd_container = (HWND) handle;
|
auto *packer = finclip_packer_factory_get_config_packer(factory);
|
||||||
// // hWnd_container = GetFocus();
|
finclip_initialize(packer);
|
||||||
// HRESULT hr = StartApplet(
|
FinclipParams *config;
|
||||||
// hWnd_container, appstore, Utf8Encode(wappid).c_str(), "", packer,
|
config = finclip_config_packer_get_config(packer, app_store);
|
||||||
// args.Get("finclipPath").ToString().Utf8Value().c_str(),
|
if (config == nullptr) config = finclip_create_params();
|
||||||
// FinclipAppletCallback);
|
|
||||||
// current_appid = appid;
|
finclip_params_set(config, FINCLIP_CONFIG_EXE_PATH, path.c_str());
|
||||||
finclip_set_position(appid.c_str(), 1000, 300, 540, 960);
|
finclip_params_set(config, FINCLIP_CONFIG_APPSTORE, "1");
|
||||||
// SetAppletPos(Utf8Encode(wappid).c_str(), 0, 30, 540, 960, true);
|
finclip_params_set(config, FINCLIP_CONFIG_APPKEY, appkey.c_str());
|
||||||
// packer->Release();
|
finclip_params_set(config, FINCLIP_CONFIG_SECRET, secret.c_str());
|
||||||
return Napi::String::New(env, path);
|
finclip_params_set(config, FINCLIP_CONFIG_DOMAIN, domain.c_str());
|
||||||
|
// 可选参数
|
||||||
|
finclip_params_set(config, FINCLIP_CONFIG_SHOW_LOADING, "0");
|
||||||
|
finclip_config_packer_add_config(packer, config);
|
||||||
|
|
||||||
|
if (handle) {
|
||||||
|
finclip_start_applet_embed(app_store, appid.c_str(), (HWND)handle);
|
||||||
|
} else {
|
||||||
|
finclip_start_applet(app_store, appid.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
return Napi::String::New(env, "success");
|
||||||
|
}
|
||||||
|
|
||||||
|
Napi::String embed(const Napi::CallbackInfo& info) {
|
||||||
|
Napi::Env env = info.Env();
|
||||||
|
Napi::Object args = info[0].ToObject();
|
||||||
|
int handle = args.Get("handle").ToNumber().Int32Value();
|
||||||
|
finclip_embed_applet(app_store, appid.c_str(), (HWND)handle);
|
||||||
|
return Napi::String::New(env, "success");
|
||||||
}
|
}
|
||||||
|
|
||||||
Napi::String close(const Napi::CallbackInfo& info) {
|
Napi::String close(const Napi::CallbackInfo& info) {
|
||||||
|
@ -172,6 +128,8 @@ Napi::Object Init(Napi::Env env, Napi::Object exports) {
|
||||||
Napi::Function::New(env, setAppletPos));
|
Napi::Function::New(env, setAppletPos));
|
||||||
exports.Set(Napi::String::New(env, "createWindow"),
|
exports.Set(Napi::String::New(env, "createWindow"),
|
||||||
Napi::Function::New(env, createWindow));
|
Napi::Function::New(env, createWindow));
|
||||||
|
exports.Set(Napi::String::New(env, "embed"),
|
||||||
|
Napi::Function::New(env, embed));
|
||||||
return exports;
|
return exports;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,38 @@
|
||||||
#pragma once
|
#ifndef FINCLIP_H
|
||||||
|
#define FINCLIP_H
|
||||||
|
|
||||||
#include "resource.h"
|
#include "../finclip_api.h"
|
||||||
|
|
||||||
|
typedef IPackerFactory *(FINSTDMETHODCALLTYPE *findll_get_packer_factory)();
|
||||||
|
typedef IFinConfigPacker *(
|
||||||
|
FINSTDMETHODCALLTYPE *findll_packer_factory_get_config_packer)(
|
||||||
|
IPackerFactory *factory);
|
||||||
|
typedef int(FINSTDMETHODCALLTYPE *findll_config_packer_add_config)(
|
||||||
|
IFinConfigPacker *packer, FinclipParams *config);
|
||||||
|
|
||||||
|
typedef void(FINSTDMETHODCALLTYPE *findll_register_api)(
|
||||||
|
IFinConfigPacker *packer, FinClipApiType type, const char *apis,
|
||||||
|
FinclipApiHandle handle, void *input);
|
||||||
|
typedef int(FINSTDMETHODCALLTYPE *findll_initialize)(
|
||||||
|
IFinConfigPacker *configpacker);
|
||||||
|
typedef int(FINSTDMETHODCALLTYPE *findll_start_applet)(char *appstore,
|
||||||
|
const char *appid);
|
||||||
|
typedef int(FINSTDMETHODCALLTYPE *findll_invoke_api)(
|
||||||
|
FinClipApiType type, const char *app_id, const char *api_name,
|
||||||
|
const char *params, FinclipApiCallback callback, void *input);
|
||||||
|
|
||||||
|
typedef int(FINSTDMETHODCALLTYPE *findll_embed_applet)(const char *appstore,
|
||||||
|
const char *appid,
|
||||||
|
HWND container);
|
||||||
|
|
||||||
|
typedef int(FINSTDMETHODCALLTYPE *findll_params_set)(FinclipParams *params,
|
||||||
|
const char *key,
|
||||||
|
const char *value);
|
||||||
|
typedef int(FINSTDMETHODCALLTYPE *findll_params_del)(FinclipParams *params,
|
||||||
|
const char *key);
|
||||||
|
typedef FinclipParams *(FINSTDMETHODCALLTYPE *findll_create_params)();
|
||||||
|
typedef void(FINSTDMETHODCALLTYPE *findll_destory_params)(
|
||||||
|
FinclipParams *params);
|
||||||
|
typedef int(FINSTDMETHODCALLTYPE *findll_close_all_applet)();
|
||||||
|
|
||||||
|
#endif // MAINWINDOW_H
|
|
@ -1,32 +1,14 @@
|
||||||
|
const path = require('path');
|
||||||
// setTimeout(() => {
|
const finclip = require('./build/Release/_finclip.node');
|
||||||
const hw = require('./build/Release/_finclip.node');
|
finclip.setDomain('https://finclip-testing.finogeeks.club');
|
||||||
hw.createWindow({});
|
finclip.setAppkey('22LyZEib0gLTQdU3MUauAfJ/xujwNfM6OvvEqQyH4igA');
|
||||||
console.log('gg')
|
finclip.setAppid('6152b5dbfcfb4e0001448e6e');
|
||||||
// console.log(hw.start({
|
finclip.setSecret('703b9026be3d6bc5');
|
||||||
// handle: 41419442,
|
const finclipPath = path.resolve(__dirname, '../../vendor/win/x64/finclip.exe');
|
||||||
// finclipPath: `C:\\Users\\gyt\\Code\\FinChat\\local-module\\fincliplib\\finclip.exe`
|
console.log('finclipPath', finclipPath);
|
||||||
// }))
|
const result = finclip.start({
|
||||||
// }, 1000 * 6);
|
handle: 0,
|
||||||
|
finclipPath,
|
||||||
|
});
|
||||||
// const { Worker } = require('worker_threads');
|
|
||||||
|
|
||||||
// const worker = new Worker(`
|
|
||||||
// const hw = require('./build/Release/_finclip.node');
|
|
||||||
// setTimeout(() => {
|
|
||||||
// console.log(hw.start({
|
|
||||||
// handle: 41419442,
|
|
||||||
// finclipPath: 'C:\\\\Users\\\\gyt\\\\Code\\\\FinChat\\\\local-module\\\\fincliplib\\\\finclip.exe'
|
|
||||||
// }))
|
|
||||||
// }, 1000 * 6);
|
|
||||||
// setTimeout(() => {
|
|
||||||
|
|
||||||
// }, 1000 * 60 * 60);
|
|
||||||
// `, { eval: true });
|
|
||||||
// worker.on('message', message => console.log(message));
|
|
||||||
// worker.postMessage('ping');
|
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
||||||
}, 1000 * 60 * 60);
|
}, 1000 * 60 * 60);
|
26753
src/npm/json.hpp
26753
src/npm/json.hpp
File diff suppressed because it is too large
Load Diff
|
@ -756,9 +756,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/got": {
|
"node_modules/got": {
|
||||||
"version": "11.8.3",
|
"version": "11.8.5",
|
||||||
"resolved": "https://registry.npmjs.org/got/-/got-11.8.3.tgz",
|
"resolved": "https://registry.npmjs.org/got/-/got-11.8.5.tgz",
|
||||||
"integrity": "sha512-7gtQ5KiPh1RtGS9/Jbv1ofDpBFuq42gyfEib+ejaRBJuj/3tQFeR5+gw57e4ipaU8c/rCjvX6fkQz2lyDlGAOg==",
|
"integrity": "sha512-o0Je4NvQObAuZPHLFoRSkdG2lTgtcynqymzg2Vupdx6PorhaT5MCbIyXG6d4D94kk8ZG57QeosgdiqfJWhEhlQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sindresorhus/is": "^4.0.0",
|
"@sindresorhus/is": "^4.0.0",
|
||||||
|
@ -2429,9 +2429,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"got": {
|
"got": {
|
||||||
"version": "11.8.3",
|
"version": "11.8.5",
|
||||||
"resolved": "https://registry.npmjs.org/got/-/got-11.8.3.tgz",
|
"resolved": "https://registry.npmjs.org/got/-/got-11.8.5.tgz",
|
||||||
"integrity": "sha512-7gtQ5KiPh1RtGS9/Jbv1ofDpBFuq42gyfEib+ejaRBJuj/3tQFeR5+gw57e4ipaU8c/rCjvX6fkQz2lyDlGAOg==",
|
"integrity": "sha512-o0Je4NvQObAuZPHLFoRSkdG2lTgtcynqymzg2Vupdx6PorhaT5MCbIyXG6d4D94kk8ZG57QeosgdiqfJWhEhlQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@sindresorhus/is": "^4.0.0",
|
"@sindresorhus/is": "^4.0.0",
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
//{{NO_DEPENDENCIES}}
|
|
||||||
// Microsoft Visual C++ generated include file.
|
|
||||||
// Used by finclip-win32-demo.rc
|
|
||||||
//
|
|
||||||
#define IDC_MYICON 2
|
|
||||||
#define IDD_FINCLIPWIN32DEMO_DIALOG 102
|
|
||||||
#define IDS_APP_TITLE 103
|
|
||||||
#define IDD_ABOUTBOX 103
|
|
||||||
#define IDM_ABOUT 104
|
|
||||||
#define IDM_EXIT 105
|
|
||||||
#define IDI_FINCLIPWIN32DEMO 107
|
|
||||||
#define IDI_SMALL 108
|
|
||||||
#define IDC_FINCLIPWIN32DEMO 109
|
|
||||||
#define IDR_MAINFRAME 128
|
|
||||||
#define ID_FILE_IDM 32771
|
|
||||||
#define IDM_SENDMESSAGE 32772
|
|
||||||
#define ID_FILE_IDM32773 32773
|
|
||||||
#define IDM_START_APPLET 32774
|
|
||||||
#define IDM_APPLET_APPKEY 32775
|
|
||||||
#define IDM_APPLET_SECRET 32776
|
|
||||||
#define IDM_APPLET_APPID 32777
|
|
||||||
#define IDM_APPLET_DOMAIN 32778
|
|
||||||
#define IDC_STATIC -1
|
|
||||||
|
|
||||||
// Next default values for new objects
|
|
||||||
//
|
|
||||||
#ifdef APSTUDIO_INVOKED
|
|
||||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
|
||||||
#define _APS_NO_MFC 1
|
|
||||||
#define _APS_NEXT_RESOURCE_VALUE 129
|
|
||||||
#define _APS_NEXT_COMMAND_VALUE 32779
|
|
||||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
|
||||||
#define _APS_NEXT_SYMED_VALUE 110
|
|
||||||
#endif
|
|
||||||
#endif
|
|
Loading…
Reference in New Issue