mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
chore: use electron-vite build
This commit is contained in:
parent
e9e8288f34
commit
f7b9d599c3
58
electron.vite.config.ts
Normal file
58
electron.vite.config.ts
Normal file
@ -0,0 +1,58 @@
|
||||
import cp from 'vite-plugin-cp';
|
||||
import "./scripts/gen-version"
|
||||
export default {
|
||||
main: {
|
||||
build: {
|
||||
outDir: "dist/main",
|
||||
emptyOutDir: true,
|
||||
lib: {
|
||||
formats: ["cjs"],
|
||||
entry: { "main": "src/main/main.ts" },
|
||||
},
|
||||
rollupOptions: {
|
||||
external: ["silk-wasm"],
|
||||
input: "src/main/main.ts",
|
||||
}
|
||||
},
|
||||
resolve:{
|
||||
alias: {
|
||||
'./lib-cov/fluent-ffmpeg': './lib/fluent-ffmpeg'
|
||||
},
|
||||
},
|
||||
plugins: [cp({ targets: [{src: './node_modules/silk-wasm', dest: 'dist/node_modules/silk-wasm', flatten: false}, { src: './manifest.json', dest: 'dist' }] })]
|
||||
},
|
||||
preload: {
|
||||
// vite config options
|
||||
build: {
|
||||
outDir: "dist/preload",
|
||||
emptyOutDir: true,
|
||||
lib: {
|
||||
formats: ["cjs"],
|
||||
entry: { "preload": "src/preload.ts" },
|
||||
},
|
||||
rollupOptions: {
|
||||
// external: externalAll,
|
||||
input: "src/preload.ts",
|
||||
}
|
||||
},
|
||||
resolve:{
|
||||
}
|
||||
},
|
||||
renderer: {
|
||||
// vite config options
|
||||
build: {
|
||||
outDir: "dist/renderer",
|
||||
emptyOutDir: true,
|
||||
lib: {
|
||||
formats: ["es"],
|
||||
entry: { "renderer": "src/renderer.ts" },
|
||||
},
|
||||
rollupOptions: {
|
||||
// external: externalAll,
|
||||
input: "src/renderer.ts",
|
||||
}
|
||||
},
|
||||
resolve:{
|
||||
}
|
||||
}
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
{
|
||||
"manifest_version": 4,
|
||||
"type": "extension",
|
||||
"name": "LLOneBot v3.11.0",
|
||||
"name": "LLOneBot v3.12.0",
|
||||
"slug": "LLOneBot",
|
||||
"description": "LiteLoaderQQNT的OneBotApi",
|
||||
"version": "3.11.0",
|
||||
"version": "3.12.0",
|
||||
"thumbnail": "./icon.png",
|
||||
"authors": [
|
||||
{
|
||||
@ -26,8 +26,8 @@
|
||||
"darwin"
|
||||
],
|
||||
"injects": {
|
||||
"renderer": "./renderer.js",
|
||||
"main": "./main.cjs",
|
||||
"preload": "./preload.cjs"
|
||||
"renderer": "./renderer/renderer.js",
|
||||
"main": "./main/main.cjs",
|
||||
"preload": "./preload/preload.cjs"
|
||||
}
|
||||
}
|
3013
package-lock.json
generated
3013
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
17
package.json
17
package.json
@ -5,16 +5,18 @@
|
||||
"description": "NTQQLiteLoaderOneBotApi",
|
||||
"main": "dist/main.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"build": "vite build",
|
||||
"depend": "cd ./dist & npm install --omit=dev"
|
||||
"build": "electron-vite build",
|
||||
"build-mac": "npm run build && npm run deploy-mac",
|
||||
"deploy-mac": "cp -r dist/* ~/Library/Containers/com.tencent.qq/Data/LiteLoaderQQNT/plugins/LLOneBot/",
|
||||
"build-win": "npm run build && npm run deploy-win",
|
||||
"deploy-win": "cmd /c \"xcopy /S /Y dist\\* %USERPROFILE%\\documents\\LiteLoaderQQNT\\plugins\\LLOneBot\\\""
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"electron-vite": "^2.0.0",
|
||||
"express": "^4.18.2",
|
||||
"fluent-ffmpeg": "^2.1.2",
|
||||
"json-bigint": "^1.0.0",
|
||||
"music-metadata": "^8.1.4",
|
||||
"silk-wasm": "^3.2.3",
|
||||
"utf-8-validate": "^6.0.3",
|
||||
@ -22,14 +24,15 @@
|
||||
"ws": "^8.16.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"vite": "^4.4.9",
|
||||
"vite-plugin-cp": "^4.0.8",
|
||||
"@types/express": "^4.17.20",
|
||||
"@types/fluent-ffmpeg": "^2.1.24",
|
||||
"@types/node": "^20.11.24",
|
||||
"@types/uuid": "^9.0.8",
|
||||
"@types/ws": "^8.5.10",
|
||||
"electron": "^29.0.1",
|
||||
"typescript": "^5.2.2"
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.2.2",
|
||||
"vite": "^5.1.4",
|
||||
"vite-plugin-cp": "^4.0.8"
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import fs = require("fs");
|
||||
import path = require("path");
|
||||
import fs from "fs";
|
||||
import path from"path";
|
||||
import {version} from "../src/version";
|
||||
const manifestPath = path.join(__dirname, "../manifest.json");
|
||||
function readManifest(): any{
|
||||
|
@ -1,9 +1,7 @@
|
||||
import express, {Express, Request, Response} from "express";
|
||||
import express, {Express, Request, Response, json} from "express";
|
||||
import {getConfigUtil, log} from "../utils";
|
||||
import http from "http";
|
||||
|
||||
const JSONbig = require('json-bigint')({storeAsString: true});
|
||||
|
||||
type RegisterHandler = (res: Response, payload: any) => Promise<any>
|
||||
|
||||
export abstract class HttpServerBase {
|
||||
@ -14,23 +12,7 @@ export abstract class HttpServerBase {
|
||||
constructor() {
|
||||
this.expressAPP = express();
|
||||
this.expressAPP.use(express.urlencoded({extended: true, limit: "500mb"}));
|
||||
this.expressAPP.use((req, res, next) => {
|
||||
let data = '';
|
||||
req.on('data', chunk => {
|
||||
data += chunk.toString();
|
||||
});
|
||||
req.on('end', () => {
|
||||
if (data) {
|
||||
try {
|
||||
// log("receive raw", data)
|
||||
req.body = JSONbig.parse(data);
|
||||
} catch (e) {
|
||||
return next(e);
|
||||
}
|
||||
}
|
||||
next();
|
||||
});
|
||||
});
|
||||
this.expressAPP.use(json({limit: "500mb"}));
|
||||
}
|
||||
|
||||
authorize(req: Request, res: Response, next: () => void) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {Server, WebSocket} from "ws";
|
||||
import {WebSocket, WebSocketServer} from "ws";
|
||||
import {getConfigUtil, log} from "../utils";
|
||||
import urlParse from "url";
|
||||
import {IncomingMessage} from "node:http";
|
||||
@ -21,14 +21,14 @@ class WebsocketClientBase {
|
||||
}
|
||||
|
||||
export class WebsocketServerBase {
|
||||
private ws: Server = null;
|
||||
private ws: WebSocketServer = null;
|
||||
|
||||
constructor() {
|
||||
console.log(`llonebot websocket service started`)
|
||||
}
|
||||
|
||||
start(port: number) {
|
||||
this.ws = new Server({port});
|
||||
this.ws = new WebSocketServer({port});
|
||||
this.ws.on("connection", (wsClient, req)=>{
|
||||
const url = req.url.split("?").shift()
|
||||
this.authorize(wsClient, req);
|
||||
|
@ -1 +1 @@
|
||||
export const version = "3.11.0"
|
||||
export const version = "3.12.0"
|
@ -11,7 +11,8 @@
|
||||
// "sourceMap": true
|
||||
},
|
||||
"include": [
|
||||
"src/*"
|
||||
"src/*",
|
||||
"scripts/*"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
|
@ -1,41 +0,0 @@
|
||||
import { InlineConfig, defineConfig } from 'vite'
|
||||
import { build } from "vite";
|
||||
import cp from 'vite-plugin-cp';
|
||||
import pkg from './package.json' assert { type: 'json' };
|
||||
const externalAll = ["electron", "fs/promises", "fs", "url", "util", "path", /node:/, ...Object.keys(pkg.dependencies)];
|
||||
console.log(externalAll);
|
||||
function createConfig(library: string, path: string, emptyOutDir: boolean): InlineConfig {
|
||||
return {
|
||||
configFile: false,
|
||||
build: {
|
||||
emptyOutDir: emptyOutDir,
|
||||
lib: {
|
||||
formats: ["cjs"],
|
||||
entry: { [library]: path }
|
||||
},
|
||||
rollupOptions: {
|
||||
external: externalAll,
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
export function BuildPlugin() {
|
||||
build(createConfig("main", "src/main/main.ts", false));
|
||||
build(createConfig("preload", "src/preload.ts", false));
|
||||
}
|
||||
|
||||
BuildPlugin();
|
||||
|
||||
export default defineConfig({
|
||||
build: {
|
||||
emptyOutDir: false,
|
||||
lib: {
|
||||
formats: ['es'],
|
||||
entry: { ["renderer"]: `src/renderer.ts` },
|
||||
},
|
||||
rollupOptions: {
|
||||
external: externalAll
|
||||
}
|
||||
},
|
||||
plugins: [cp({ targets: [{ src: './package.json', dest: 'dist' }, { src: './manifest.json', dest: 'dist' }] })]
|
||||
})
|
Loading…
x
Reference in New Issue
Block a user