napcat native

This commit is contained in:
手瓜一十雪 2024-09-28 13:27:13 +08:00
parent cfd7808169
commit 1ce8cd2100
4 changed files with 22 additions and 0 deletions

BIN
src/native/external/MoeHoo.win32.node vendored Normal file

Binary file not shown.

15
src/native/index.ts Normal file
View File

@ -0,0 +1,15 @@
import { constants } from "node:os";
import path from "path";
import { dlopen } from "process";
export class Native {
platform: string;
supportedPlatforms = ['win32'];
MoeHooExport: any = { exports: {} };
constructor(nodePath: string, platform: string = process.platform) {
this.platform = platform;
if (!this.supportedPlatforms.includes(this.platform)) {
throw new Error(`Platform ${this.platform} is not supported`);
}
dlopen(this.MoeHooExport, path.join(nodePath, './native/MoeHoo.win32.node'), constants.dlopen.RTLD_LAZY);
}
}

View File

@ -29,6 +29,7 @@ import { InitWebUi } from '@/webui';
import { WebUiDataRuntime } from '@/webui/src/helper/Data';
import { napCatVersion } from '@/common/version';
import { NodeIO3MiscListener } from '@/core/listeners/NodeIO3MiscListener';
import { Native } from '@/native';
program.option('-q, --qq [number]', 'QQ号').parse(process.argv);
const cmdOptions = program.opts();
@ -55,6 +56,11 @@ export async function NCoreInitShell() {
const session = wrapper.NodeIQQNTWrapperSession.create();
let appNative = new Native(pathWrapper.binaryPath);
appNative.MoeHooExport.exports.registMsgPush((...args: any[]) => {
console.log(args);
});
console.log(appNative);
// from get dataPath
const [dataPath, dataPathGlobal] = (() => {
if (os.platform() === 'darwin') {

View File

@ -41,6 +41,7 @@ const FrameworkBaseConfigPlugin: PluginOption[] = [
const ShellBaseConfigPlugin: PluginOption[] = [
cp({
targets: [
{ src: './src/native/external', dest: 'dist/native', flatten: false },
{ src: './static/', dest: 'dist/static/', flatten: false },
{ src: './src/core/external/napcat.json', dest: 'dist/config/' },
{ src: './src/onebot/config/onebot11.json', dest: 'dist/config/' },