AutoJs6 icon indicating copy to clipboard operation
AutoJs6 copied to clipboard

notice(title, content, options)不能用

Open wengzhenquan opened this issue 1 month ago • 1 comments

这个函数是不是用法错了?

notice('message', 'hello', { isSilent: true });

执行以上代码,报下面错误:

05:07:16.251/V: 开始运行 [$cwd/小社/test-2.js [cache]]. 05:07:16.266/E: 方法 "notice" 调用失败: [ Argument options [object Object] (Object) must be a JavaScript Object for notice with title and content ] (/data/user/0/org.autojs.autojs6/cache/tmp-scripts/tmp-1762463236149.js#1) 方法 "notice" 调用失败: [ Argument options [object Object] (Object) must be a JavaScript Object for notice with title and content ] at /data/user/0/org.autojs.autojs6/cache/tmp-scripts/tmp-1762463236149.js:1:0

05:07:16.269/V: [$cwd/小社/test-2.js [cache]] 运行结束 (用时 0.016 秒)

wengzhenquan avatar Nov 06 '25 21:11 wengzhenquan

感谢反馈.

下面的判断条件有误 (app/src/main/java/org/autojs/autojs/runtime/api/augment/notice/Notice.kt):

// @Signature notice(title: string, content: string, options?: Notice.Options): void;

require(argList.size <= 3) {
    "Arguments length ${argList.size} shouldn't be greater than 3 for notice with title and content"
}
require(argList.size <= 2 && (arg2.isJsNullish() || arg2 is NativeObject)) {
    "Argument options ${arg2.jsBrief()} must be a JavaScript Object for notice with title and content"
}

目前可暂时使用其他可替代重载方法使用 notice.

SuperMonster003 avatar Nov 10 '25 06:11 SuperMonster003