fix msg
Some checks failed
build / Build (push) Failing after 9s
test / Run tests (push) Failing after 9s

This commit is contained in:
2025-01-26 15:57:42 +08:00
parent 9f8f7c8347
commit 23b8efcdf5
4 changed files with 26 additions and 12 deletions

View File

@ -1,7 +1,13 @@
import { Message, MessageConnect } from "./server";
export function sendMessage(msg: Message, action: string, data?: any): Promise<any> {
return msg.sendMessage({ action, data });
export async function sendMessage(msg: Message, action: string, data?: any): Promise<any> {
const res = await msg.sendMessage({ action, data });
if (res.code) {
console.error(res);
return Promise.reject(res.message);
} else {
return Promise.resolve(res.data);
}
}
export function connect(msg: Message, action: string, data?: any): Promise<MessageConnect> {