From ff2cee1a9edc51e620e27b5bb792d9e28c34b076 Mon Sep 17 00:00:00 2001 From: liuwei Date: Fri, 29 Jul 2022 18:51:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=A5=E5=8F=A3=E5=86=85?= =?UTF-8?q?=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuwei --- .../napi/ohos_multimodalInput_pointer.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_pointer.js b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_pointer.js index 1bf87446..757ec522 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_pointer.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_pointer.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -45,12 +45,20 @@ export function mockPointer() { console.warn("multimodalInput.pointer.isPointerVisible interface mocked in the Previewer." + "How this interface works on the" + " Previewer may be different from that on a real device."); const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramBooleanMock); - } else { + if (len > 1) { + console.warn("parameter number error"); + return; + } + if (len == 0) { return new Promise((resolve, reject) => { resolve(paramMock.paramArrayMock); }) + } else { + if (typeof args[0] !== 'function') { + console.warn("the first parameter type must be function"); + return; + } + args[0].call(this, paramMock.businessErrorMoc, paramMock.paramBooleanMock); } }, };