Skip to content

Commit 6e3dd01

Browse files
neko-paraMistEO
authored andcommitted
fix(js): update
1 parent 34d0bca commit 6e3dd01

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

source/binding/NodeJS/src/apis/callback.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,8 @@ MaaBool CustomConnect(void* trans_arg)
156156
MaaBool CustomConnected(void* trans_arg)
157157
{
158158
auto customCtx = reinterpret_cast<CustomControllerContext*>(trans_arg);
159-
auto it = customCtx->callbacks.find("connected");
160-
if (it == customCtx->callbacks.end() || !it->second) {
161-
// 回调未提供时默认返回 true(已连接)
162-
return true;
163-
}
164-
return it->second->Call<bool>([&](maajs::FunctionType func) { return func.Call({}); });
159+
auto ctx = customCtx->callbacks["connected"];
160+
return ctx->Call<bool>([&](maajs::FunctionType func) { return func.Call({}); });
165161
}
166162

167163
MaaBool CustomRequestUuid(void* trans_arg, MaaStringBuffer* buffer)

source/binding/NodeJS/src/apis/controller.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,12 +580,15 @@ CustomControllerImpl* CustomControllerImpl::ctor(const maajs::CallbackInfo& info
580580
auto ret_false = [](maajs::EnvType env2) {
581581
return maajs::BooleanType::New(env2, false);
582582
};
583+
auto ret_true = [](maajs::EnvType env2) {
584+
return maajs::BooleanType::New(env2, true);
585+
};
583586
auto ret_null = [](maajs::EnvType env2) {
584587
return env2.Null();
585588
};
586589

587590
context->add_bind(info.Env(), "connect", "CustomConnect", 0, actor, ret_false);
588-
context->add_bind(info.Env(), "connected", "CustomConnected", 0, actor, ret_false);
591+
context->add_bind(info.Env(), "connected", "CustomConnected", 0, actor, ret_true);
589592
context->add_bind(info.Env(), "request_uuid", "CustomRequestUuid", 0, actor, ret_null);
590593
context->add_bind(info.Env(), "get_features", "CustomGetFeatures", 0, actor, ret_null);
591594
context->add_bind(info.Env(), "start_app", "CustomStartApp", 1, actor, ret_false);

source/binding/NodeJS/src/apis/controller.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ declare global {
180180
get connected(): boolean
181181
get cached_image(): ImageData | null
182182
get uuid(): string | null
183+
get resolution(): [width: number, height: number] | null
183184
}
184185

185186
type AdbDevice = [

0 commit comments

Comments
 (0)