Compare commits

..

2 Commits

Author SHA1 Message Date
手瓜一十雪
b0eae307c2 release: 3.0.5 2024-10-20 22:18:57 +08:00
手瓜一十雪
f5d2b54cca fix: 兼容晚启动 2024-10-20 22:18:34 +08:00
7 changed files with 37 additions and 31 deletions

View File

@@ -4,7 +4,7 @@
"name": "NapCatQQ", "name": "NapCatQQ",
"slug": "NapCat.Framework", "slug": "NapCat.Framework",
"description": "高性能的 OneBot 11 协议实现", "description": "高性能的 OneBot 11 协议实现",
"version": "3.0.4", "version": "3.0.5",
"icon": "./logo.png", "icon": "./logo.png",
"authors": [ "authors": [
{ {

View File

@@ -2,7 +2,7 @@
"name": "napcat", "name": "napcat",
"private": true, "private": true,
"type": "module", "type": "module",
"version": "3.0.4", "version": "3.0.5",
"scripts": { "scripts": {
"build:framework": "vite build --mode framework", "build:framework": "vite build --mode framework",
"build:shell": "vite build --mode shell", "build:shell": "vite build --mode shell",

View File

@@ -1 +1 @@
export const napCatVersion = '3.0.4'; export const napCatVersion = '3.0.5';

View File

@@ -13,6 +13,7 @@ import {SendLongMsgResp} from "@/core/packet/proto/message/action";
import { PacketMsg } from "@/core/packet/msg/message"; import { PacketMsg } from "@/core/packet/msg/message";
import { OidbSvcTrpcTcp0x6D6Response } from "@/core/packet/proto/oidb/Oidb.0x6D6"; import { OidbSvcTrpcTcp0x6D6Response } from "@/core/packet/proto/oidb/Oidb.0x6D6";
import { PacketMsgPicElement } from "@/core/packet/msg/element"; import { PacketMsgPicElement } from "@/core/packet/msg/element";
import { c } from 'vite/dist/node/types.d-aGj9QkWt';
interface OffsetType { interface OffsetType {
[key: string]: { [key: string]: {
@@ -59,8 +60,12 @@ export class NTQQPacketApi {
if (!table) return false; if (!table) return false;
const url = 'ws://' + this.serverUrl + '/ws'; const url = 'ws://' + this.serverUrl + '/ws';
this.packetSession = new PacketSession(this.core.context.logger, new PacketClient(url, this.core)); this.packetSession = new PacketSession(this.core.context.logger, new PacketClient(url, this.core));
await this.packetSession.client.connect(); const cb = () => {
await this.packetSession.client.init(process.pid, table.recv, table.send); if (this.packetSession && this.packetSession.client) {
this.packetSession.client.init(process.pid, table.recv, table.send).then().catch(this.logger.logError.bind(this.logger));
}
}
await this.packetSession.client.connect(cb);
return true; return true;
} }

View File

@@ -22,7 +22,7 @@ export class PacketClient {
private websocket: WebSocket | undefined; private websocket: WebSocket | undefined;
private isConnected: boolean = false; private isConnected: boolean = false;
private reconnectAttempts: number = 0; private reconnectAttempts: number = 0;
private readonly maxReconnectAttempts: number = 5;//现在暂时不可配置 private readonly maxReconnectAttempts: number = 60;//现在暂时不可配置
private readonly cb = new LRUCache<string, (json: RecvPacketData) => Promise<void>>(500); // trace_id-type callback private readonly cb = new LRUCache<string, (json: RecvPacketData) => Promise<void>>(500); // trace_id-type callback
private readonly clientUrl: string = ''; private readonly clientUrl: string = '';
readonly napCatCore: NapCatCore; readonly napCatCore: NapCatCore;
@@ -47,7 +47,7 @@ export class PacketClient {
return text; return text;
} }
connect(): Promise<void> { connect(cb: any): Promise<void> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
//this.logger.log.bind(this.logger)(`[Core] [Packet Server] Attempting to connect to ${this.clientUrl}`); //this.logger.log.bind(this.logger)(`[Core] [Packet Server] Attempting to connect to ${this.clientUrl}`);
this.websocket = new WebSocket(this.clientUrl); this.websocket = new WebSocket(this.clientUrl);
@@ -57,6 +57,7 @@ export class PacketClient {
this.isConnected = true; this.isConnected = true;
this.reconnectAttempts = 0; this.reconnectAttempts = 0;
this.logger.log.bind(this.logger)(`[Core] [Packet Server] Connected to ${this.clientUrl}`); this.logger.log.bind(this.logger)(`[Core] [Packet Server] Connected to ${this.clientUrl}`);
cb();
resolve(); resolve();
}; };
@@ -74,17 +75,17 @@ export class PacketClient {
this.websocket.onclose = () => { this.websocket.onclose = () => {
this.isConnected = false; this.isConnected = false;
//this.logger.logWarn.bind(this.logger)(`[Core] [Packet Server] Disconnected from ${this.clientUrl}`); //this.logger.logWarn.bind(this.logger)(`[Core] [Packet Server] Disconnected from ${this.clientUrl}`);
this.attemptReconnect(); this.attemptReconnect(cb);
}; };
}); });
} }
private attemptReconnect(): void { private attemptReconnect(cb: any): void {
try { try {
if (this.reconnectAttempts < this.maxReconnectAttempts) { if (this.reconnectAttempts < this.maxReconnectAttempts) {
this.reconnectAttempts++; this.reconnectAttempts++;
setTimeout(() => { setTimeout(() => {
this.connect().catch((error) => { this.connect(cb).catch((error) => {
this.logger.logError.bind(this.logger)(`[Core] [Packet Server] Reconnecting attempt failed,${error.message}`); this.logger.logError.bind(this.logger)(`[Core] [Packet Server] Reconnecting attempt failed,${error.message}`);
}); });
}, 5000 * this.reconnectAttempts); }, 5000 * this.reconnectAttempts);

View File

@@ -30,7 +30,7 @@ async function onSettingWindowCreated(view: Element) {
SettingItem( SettingItem(
'<span id="napcat-update-title">Napcat</span>', '<span id="napcat-update-title">Napcat</span>',
undefined, undefined,
SettingButton('V3.0.4', 'napcat-update-button', 'secondary'), SettingButton('V3.0.5', 'napcat-update-button', 'secondary'),
), ),
]), ]),
SettingList([ SettingList([

View File

@@ -164,7 +164,7 @@ async function onSettingWindowCreated(view) {
SettingItem( SettingItem(
'<span id="napcat-update-title">Napcat</span>', '<span id="napcat-update-title">Napcat</span>',
void 0, void 0,
SettingButton("V3.0.4", "napcat-update-button", "secondary") SettingButton("V3.0.5", "napcat-update-button", "secondary")
) )
]), ]),
SettingList([ SettingList([