6.3.1 - 新增发布通知权限 / WS 实例创建; 修复 floaty 模块异常 / 安卓 7.x 异常; UI 模式增强; 迁移至 View Binding

This commit is contained in:
SuperMonster003
2023-05-26 20:58:38 +08:00
parent 31ebd5b854
commit 1755ae3271
511 changed files with 12567 additions and 11063 deletions

View File

@@ -1532,6 +1532,10 @@
<li><span class="stability_undefined"><a href="#console_setgloballogconfig_config">setGlobalLogConfig(config)</a></span></li>
</ul>
</li>
<li><span class="stability_undefined"><a href="#console_m_resetgloballogconfig">[m] resetGlobalLogConfig</a></span><ul>
<li><span class="stability_undefined"><a href="#console_resetgloballogconfig">resetGlobalLogConfig()</a></span></li>
</ul>
</li>
<li><span class="stability_undefined"><a href="#console_m_input">[m] input</a></span><ul>
<li><span class="stability_undefined"><a href="#console_input_data_args">input(data, ...args)</a></span></li>
</ul>
@@ -2017,6 +2021,10 @@
<li><span class="stability_undefined"><a href="#web_newinjectablewebclient">newInjectableWebClient()</a></span></li>
</ul>
</li>
<li><span class="stability_undefined"><a href="#web_m_newwebsocket">[m] newWebSocket</a></span><ul>
<li><span class="stability_undefined"><a href="#web_newwebsocket_url">newWebSocket(url)</a></span></li>
</ul>
</li>
</ul>
</li>
<li><span class="stability_undefined"><a href="#http_http">HTTP</a></span><ul>
@@ -2541,7 +2549,7 @@ console.log(UiObject.bounds()); /* 访问的是类 UiObject 的静态方法 boun
<h3>OCR 特性<span><a class="mark" href="#qa_ocr" id="qa_ocr">#</a></span></h3>
<p>AutoJs6 的 OCR 特性是基于 <a href="https://developers.google.com/ml-kit?hl=zh-cn">Google ML Kit</a><a href="https://developers.google.com/ml-kit/vision/text-recognition/android?hl=zh-cn">文字识别 API</a> 实现的.</p>
<blockquote>
<p>注: AutoJs6 的 <a href="http://project.autojs6.com/blob/master/app/src/main/java/org/autojs/autojs/runtime/api/MlKitOCR.kt">OCR 实现源码</a> 参考自 <a href="https://github.com/TonyJiangWJ">TonyJiangWJ</a>开源项目.</p>
<p>注: AutoJs6 的 <a href="http://project.autojs6.com/blob/master/app/src/main/java/org/autojs/autojs/runtime/api/MlKitOCR.kt">OCR 实现源码</a> 参考自 <a href="https://github.com/TonyJiangWJ">TonyJiangWJ</a> <a href="https://github.com/TonyJiangWJ/Auto.js">开源项目</a>.</p>
</blockquote>
<blockquote>
<p>参阅: <a href="ocr.html">光学字符识别 (OCR)</a> 模块</p>
@@ -7615,7 +7623,7 @@ ocr.recognizeText(img, [ 0, 0, 100, 150 ]).filter(text =&gt; text.includes(&#39;
<pre><code class="lang-js">ocr.recognizeText(&#39;./picture.jpg&#39;); /* 获取本地图像文件中的所有文本. */
</code></pre>
<h3>recognizeText(imgPath, region)<span><a class="mark" href="#ocr_recognizetext_imgpath_region" id="ocr_recognizetext_imgpath_region">#</a></span></h3>
<p><strong><code>6.3.0</code></strong> <strong><code>Overload [4-5]/6</code></strong></p>
<p><strong><code>6.3.0</code></strong> <strong><code>Overload 6/6</code></strong></p>
<ul>
<li><strong>imgPath</strong> { <span class="type"><a href="dataTypes.html#datatypes_string">string</a></span> } - 图像路径</li>
<li><strong>region</strong> { <span class="type"><a href="omniTypes.html#omnitypes_omniregion">OmniRegion</a></span> } - OCR 识别区域</li>
@@ -10278,6 +10286,14 @@ console.timeEnd(&#39;fruit&#39;);
maxFileSize: 384 &lt;&lt; 10, /* 384 KB. */
});
</code></pre>
<h2>[m] resetGlobalLogConfig<span><a class="mark" href="#console_m_resetgloballogconfig" id="console_m_resetgloballogconfig">#</a></span></h2>
<h3>resetGlobalLogConfig()<span><a class="mark" href="#console_resetgloballogconfig" id="console_resetgloballogconfig">#</a></span></h3>
<p><strong><code>6.3.1</code></strong></p>
<ul>
<li><ins><strong>returns</strong></ins> { <span class="type"><a href="dataTypes.html#datatypes_void">void</a></span> }</li>
</ul>
<p>重置全局日志写入配置.</p>
<p>此方法可重置 <a href="#all_m_setgloballogconfig">setGlobalLogConfig</a> 的全部选项配置.</p>
<h2>[m] input<span><a class="mark" href="#console_m_input" id="console_m_input">#</a></span></h2>
<h3>input(data, ...args)<span><a class="mark" href="#console_input_data_args" id="console_input_data_args">#</a></span></h3>
<p><strong><code>ABANDONED</code></strong></p>
@@ -10286,7 +10302,7 @@ console.timeEnd(&#39;fruit&#39;);
<li><strong>args</strong> { <span class="type"><a href="documentation.html#documentation_可变参数">...</a><a href="dataTypes.html#datatypes_any">any</a><a href="documentation.html#documentation_可变参数">[]</a></span> } - <a href="glossaries.html#glossaries_占位符替换参数">占位符替换参数</a></li>
<li><ins><strong>returns</strong></ins> { <span class="type"><a href="dataTypes.html#datatypes_void">void</a></span> }</li>
</ul>
<p>此方法已于 <code>6.3.0</code> 版本被废弃, 使用后将无任何效果.</p>
<p>此方法已于 <code>6.3.1</code> 版本被废弃, 使用后将无任何效果.</p>
<h2>[m] rawInput<span><a class="mark" href="#console_m_rawinput" id="console_m_rawinput">#</a></span></h2>
<h3>rawInput(data, ...args)<span><a class="mark" href="#console_rawinput_data_args" id="console_rawinput_data_args">#</a></span></h3>
<p><strong><code>ABANDONED</code></strong></p>
@@ -10295,7 +10311,7 @@ console.timeEnd(&#39;fruit&#39;);
<li><strong>args</strong> { <span class="type"><a href="documentation.html#documentation_可变参数">...</a><a href="dataTypes.html#datatypes_any">any</a><a href="documentation.html#documentation_可变参数">[]</a></span> } - <a href="glossaries.html#glossaries_占位符替换参数">占位符替换参数</a></li>
<li><ins><strong>returns</strong></ins> { <span class="type"><a href="dataTypes.html#datatypes_void">void</a></span> }</li>
</ul>
<p>此方法已于 <code>6.3.0</code> 版本被废弃, 使用后将无任何效果.
<p>此方法已于 <code>6.3.1</code> 版本被废弃, 使用后将无任何效果.
<!-- [end-include:console.md] --></p>
<!-- [start-include:shell.md] -->
<h1>Shell<span><a class="mark" href="#shell_shell" id="shell_shell">#</a></span></h1>
@@ -13433,6 +13449,73 @@ settings.setDisplayZoomControls(false);
<pre><code class="lang-js">/* 为 webView 对象重新设置一个新的客户端. */
webView.setWebViewClient(newInjectableWebClient());
</code></pre>
<h2>[m] newWebSocket<span><a class="mark" href="#web_m_newwebsocket" id="web_m_newwebsocket">#</a></span></h2>
<h3>newWebSocket(url)<span><a class="mark" href="#web_newwebsocket_url" id="web_newwebsocket_url">#</a></span></h3>
<p><strong><code>6.3.1</code></strong> <strong><code>Global</code></strong></p>
<ul>
<li><strong>url</strong> { <span class="type"><a href="dataTypes.html#datatypes_string">string</a></span> }</li>
<li><ins><strong>returns</strong></ins> { <span class="type"><a href="webSocketType.html">WebSocket</a></span> }</li>
</ul>
<p>新建并返回一个 <a href="webSocketType.html">WebSocket</a> 实例.</p>
<pre><code class="lang-js">console.setExitOnClose(7e3).show();
let ws = web.newWebSocket(&#39;wss://echo.websocket.events&#39;);
ws
.on(&#39;open&#39;, (res, ws) =&gt; {
console.log(&#39;WebSocket 已连接&#39;);
})
.on(&#39;message&#39;, (message, ws) =&gt; {
console.log(&#39;接收到消息&#39;);
// if (message instanceof okio.ByteString) {
// console.log(`消息类型: ByteString`);
// } else if (typeof message === &#39;string&#39;) {
// console.log(`消息类型: String`);
// } else {
// throw TypeError(&#39;Should never happen&#39;);
// }
})
.on(&#39;text&#39;, (text, ws) =&gt; {
console.info(&#39;接收到文本消息:&#39;);
console.info(`text: ${text}`);
})
.on(&#39;bytes&#39;, (bytes, ws) =&gt; {
console.info(&#39;接收到字节数组消息:&#39;);
console.info(`utf8: ${bytes.utf8()}`);
console.info(`base64: ${bytes.base64()}`);
console.info(`md5: ${bytes.md5()}`);
console.info(`hex: ${bytes.hex()}`);
})
.on(&#39;closing&#39;, (code, reason, ws) =&gt; {
console.log(&#39;WebSocket 关闭中&#39;);
})
.on(&#39;closed&#39;, (code, reason, ws) =&gt; {
console.log(&#39;WebSocket 已关闭&#39;);
console.log(`code: ${code}`);
if (reason) console.log(`reason: ${reason}`);
})
.on(&#39;failure&#39;, (err, res, ws) =&gt; {
console.error(&#39;WebSocket 连接失败&#39;);
console.error(err);
});
/* 发送文本消息. */
ws.send(&#39;Hello WebSocket&#39;);
/* 发送字节数组消息. */
ws.send(new okio.ByteString(new java.lang.String(&#39;Hello WebSocket&#39;).getBytes()));
setTimeout(() =&gt; {
console.log(&#39;断开 WebSocket&#39;);
/* code 支持的范围 [1000,5000). */
/* 1000 表示成功操作或常规的 Socket 关闭操作. */
/* 参阅 https://github.com/Luka967/websocket-close-codes */
ws.close(1000, &#39;Closed by user&#39;);
}, 8e3);
setTimeout(() =&gt; console.log(&#39;Exit&#39;), 9e3);
</code></pre>
<!-- [end-include:web.md] -->
<!-- [start-include:http.md] -->
<h1>HTTP<span><a class="mark" href="#http_http" id="http_http">#</a></span></h1>
@@ -13441,7 +13524,7 @@ webView.setWebViewClient(newInjectableWebClient());
<p style="font: italic 1em sans-serif; color: #78909C">Marked by SuperMonster003 on Mar 21, 2023.</p>
<hr>
<p>http模块提供一些进行http请求的函数.</p>
<p>http 模块主要用于发送 HTTP 请求, 获取并解析 HTTP 响应.</p>
<blockquote>
<p>注: 与 <a href="web.html">web</a> 模块不同, web 模块主要用于 WebView 网页的注入及客户端构建.</p>
</blockquote>
@@ -13578,11 +13661,11 @@ log(res.body.string());
<p>选项options可以包含以下属性</p>
<ul>
<li><code>headers</code> { <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type">Object</a> } 键值对形式的HTTP头部信息. 有关HTTP头部信息, 参见<a href="http://www.runoob.com/http/http-header-fields.html">菜鸟教程HTTP响应头信息</a>.</li>
<li><code>method</code> { <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">string</a> } HTTP请求方法. 包括&quot;GET&quot;, &quot;POST&quot;, &quot;PUT&quot;, &quot;DELET&quot;, &quot;PATCH&quot;.</li>
<li><code>method</code> { <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">string</a> } HTTP请求方法. 包括&quot;GET&quot;, &quot;POST&quot;, &quot;PUT&quot;, &quot;DELETE&quot;, &quot;PATCH&quot;.</li>
<li><code>contentType</code> { <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">string</a> } HTTP头部信息中的&quot;Content-Type&quot;, 表示HTTP请求的内容类型. 例如&quot;text/plain&quot;, &quot;application/json&quot;. 更多信息参见<a href="http://www.runoob.com/http/http-content-type.html">菜鸟教程HTTP contentType</a>.</li>
<li><code>body</code> { <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">string</a> } | { <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array" class="type">Array</a> } | { <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function" class="type">Function</a> } HTTP请求的内容. 可以是一个字符串, 也可以是一个字节数组;或者是一个以<a href="https://github.com/square/okio/blob/master/okio/src/main/java/okio/BufferedSink.java/">BufferedSink</a>为参数的函数.</li>
</ul>
<p>该函数是get, post, postJson等函数的基础函数. 因此除非是PUT, DELET等请求, 或者需要更高定制的HTTP请求, 否则直接使用get, post, postJson等函数会更加方便.</p>
<p>该函数是get, post, postJson等函数的基础函数. 因此除非是PUT, DELETE等请求, 或者需要更高定制的HTTP请求, 否则直接使用get, post, postJson等函数会更加方便.</p>
<h2>[m] buildRequest<span><a class="mark" href="#http_m_buildrequest" id="http_m_buildrequest">#</a></span></h2>
<h3>buildRequest(url, options)<span><a class="mark" href="#http_buildrequest_url_options" id="http_buildrequest_url_options">#</a></span></h3>
<p>... ...

View File

@@ -189,12 +189,20 @@
</thead>
<tbody>
<tr>
<td style="text-align:left">35 (?)</td>
<td style="text-align:left">Android 15</td>
<td style="text-align:left">VANILLA_ICE_CREAM</td>
<td style="text-align:left">15</td>
<td style="text-align:left">Vanilla Ice Cream</td>
<td style="text-align:left">Q3, 2024 (?)</td>
</tr>
<tr>
<td style="text-align:left">34</td>
<td style="text-align:left">Android 14</td>
<td style="text-align:left">?</td>
<td style="text-align:left">UPSIDE_DOWN_CAKE</td>
<td style="text-align:left">14</td>
<td style="text-align:left">Upside Down Cake</td>
<td style="text-align:left">Feb 8, 2023</td>
<td style="text-align:left">Q3, 2023 (?)</td>
</tr>
<tr>
<td style="text-align:left">33</td>
@@ -475,6 +483,7 @@
<p>要求设备 API 级别不低于指定值:</p>
<pre><code class="lang-js">/* 在 API 级别低于 30 的设备上将抛出异常. */
runtime.requiresApi(30);
runtime.requiresApi(util.versionCodes.R); /* 效果同上. */
</code></pre>
<blockquote>
<p>注: AutoJs6 安装及使用需满足的最低 API 级别为 24 (7.0) [N].</p>

View File

@@ -166,6 +166,7 @@
<h2>目录</h2>
<ul>
<li><span class="stability_undefined"><a href="#changelog_changelog">文档更新日志 (Changelog)</a></span><ul>
<li><span class="stability_undefined"><a href="#changelog_v1_1_4">v1.1.4</a></span></li>
<li><span class="stability_undefined"><a href="#changelog_v1_1_3">v1.1.3</a></span></li>
<li><span class="stability_undefined"><a href="#changelog_v1_1_2">v1.1.2</a></span></li>
<li><span class="stability_undefined"><a href="#changelog_v1_1_1">v1.1.1</a></span></li>
@@ -183,6 +184,15 @@
<div id="apicontent">
<h1>文档更新日志 (Changelog)<span><a class="mark" href="#changelog_changelog" id="changelog_changelog">#</a></span></h1>
<h2>v1.1.4<span><a class="mark" href="#changelog_v1_1_4" id="changelog_v1_1_4">#</a></span></h2>
<p style="font: bold 0.8em sans-serif; color: #888888">2023/05/26</p>
<ul>
<li><code>新增</code> <a href="https://docs.autojs6.com/#/console?id=m-resetgloballogconfig">console.resetGlobalLogConfig</a> 文档</li>
<li><code>新增</code> <a href="https://docs.autojs6.com/#/web?id=m-newwebsocket">web.newWebSocket</a> 文档</li>
<li><code>优化</code> 完善 <a href="https://docs.autojs6.com/#/omniTypes">全能类型 (Omnipotent Types)</a> 章节</li>
<li><code>优化</code> 完善 <a href="https://docs.autojs6.com/#/apiLevel">安卓 API 级别 (Android API Level)</a> 章节</li>
</ul>
<h2>v1.1.3<span><a class="mark" href="#changelog_v1_1_3" id="changelog_v1_1_3">#</a></span></h2>
<p style="font: bold 0.8em sans-serif; color: #888888">2023/04/29</p>
@@ -211,7 +221,7 @@
<li><code>新增</code> <a href="https://docs.autojs6.com/#/notice">消息通知 (Notice)</a> 文档</li>
<li><code>新增</code> <a href="https://docs.autojs6.com/#/httpRequestHeadersType">HttpRequestHeaders</a> / <a href="https://docs.autojs6.com/#/httpResponseHeadersType">HttpResponseHeaders</a> / <a href="https://docs.autojs6.com/#/opencvRectType">OpencvRect</a> 等类型</li>
<li><code>新增</code> <a href="https://docs.autojs6.com/#/glossaries?id=通知渠道">通知渠道</a> / <a href="https://docs.autojs6.com/#/glossaries?id=HTTP-标头">HTTP 标头</a> / <a href="https://docs.autojs6.com/#/glossaries?id=MIME-类型">MIME 类型</a> / <a href="https://docs.autojs6.com/#/glossaries?id=HTTP-请求方法">HTTP 请求方法</a> 等术语</li>
<li><code>新增</code> <a href="https://docs.autojs6.com/#/color">颜色 (Color)</a> 章节增加 <a href="https://docs.autojs6.com/#/color?id=m-toColorStateList">toColorStateList</a><a href="https://docs.autojs6.com/#/color?id=m-setPaintColor">setPaintColor</a> 条目</li>
<li><code>新增</code> <a href="https://docs.autojs6.com/#/color">颜色 (Color)</a> 章节增加 <a href="https://docs.autojs6.com/#/color?id=m-tocolorstatelist">toColorStateList</a><a href="https://docs.autojs6.com/#/color?id=m-setpaintcolor">setPaintColor</a> 条目</li>
<li><code>修复</code> 文档更新日志条目中的链接无效的问题</li>
<li><code>优化</code> 完善 <a href="https://docs.autojs6.com/#/qa">疑难解答 (Q &amp; A)</a> 章节</li>
</ul>

View File

@@ -404,7 +404,7 @@ c.getRed(); // 255
c.getRedDouble(); // 1
</code></pre>
<p>Color 类是对 <a href="color.html">colors</a> 模块的一种变式封装, 用于解决 colors 模块冗余嵌套的难题.</p>
<p>如需对颜色 <code>hsv(174,100,59)</code> 设置 <code>80%</code> 透明度然后返回其 Hex 代码:</p>
<p>如需对颜色 <code>hsv(174,100,59)</code> 设置 <code>80%</code> 透明度然后返回其 Hex 代码:</p>
<pre><code class="lang-js">colors.toHex(colors.setAlpha(colors.hsv(174, 100, 59), 0.8));
</code></pre>
<p>或使用变量拆写形式以增加可读性:</p>
@@ -422,7 +422,7 @@ colors.toHex(colorWithAlpha);
.toHex();
</code></pre>
<blockquote>
<p>注: 上述示例仅用于演示, 否则可使用 colors.hsva 或 Color#setHsva 同时设置 HSV 分量与 A 分量.</p>
<p>注: 上述示例仅用于演示, 实际可使用 colors.hsva 或 Color#setHsva 同时设置 HSV 分量与 A 分量.</p>
</blockquote>
<p>Color 实例方法的使用方式与 colors 模块对应方法多数情况是类似的, 因此某些情况下可用于替代 colors 模块.</p>
<p><code>set</code><code>remove</code> 为前缀的方法, 通常都会返回 Color 自身类型, 从而支持链式调用, 如 <a href="#colortype_m_setalpha">setAlpha</a>, <a href="#colortype_m_removealpha">removeAlpha</a>, <a href="#colortype_m_setred">setRed</a>, <a href="#colortype_m_removered">removeRed</a>, <a href="#colortype_m_sethsv">setHsv</a>, <a href="#colortype_m_setrgba">setRgba</a> 等.</p>

View File

@@ -324,6 +324,10 @@
<li><span class="stability_undefined"><a href="#console_setgloballogconfig_config">setGlobalLogConfig(config)</a></span></li>
</ul>
</li>
<li><span class="stability_undefined"><a href="#console_m_resetgloballogconfig">[m] resetGlobalLogConfig</a></span><ul>
<li><span class="stability_undefined"><a href="#console_resetgloballogconfig">resetGlobalLogConfig()</a></span></li>
</ul>
</li>
<li><span class="stability_undefined"><a href="#console_m_input">[m] input</a></span><ul>
<li><span class="stability_undefined"><a href="#console_input_data_args">input(data, ...args)</a></span></li>
</ul>
@@ -1174,6 +1178,14 @@ console.timeEnd(&#39;fruit&#39;);
maxFileSize: 384 &lt;&lt; 10, /* 384 KB. */
});
</code></pre>
<h2>[m] resetGlobalLogConfig<span><a class="mark" href="#console_m_resetgloballogconfig" id="console_m_resetgloballogconfig">#</a></span></h2>
<h3>resetGlobalLogConfig()<span><a class="mark" href="#console_resetgloballogconfig" id="console_resetgloballogconfig">#</a></span></h3>
<p><strong><code>6.3.1</code></strong></p>
<ul>
<li><ins><strong>returns</strong></ins> { <span class="type"><a href="dataTypes.html#datatypes_void">void</a></span> }</li>
</ul>
<p>重置全局日志写入配置.</p>
<p>此方法可重置 <a href="#console_m_setgloballogconfig">setGlobalLogConfig</a> 的全部选项配置.</p>
<h2>[m] input<span><a class="mark" href="#console_m_input" id="console_m_input">#</a></span></h2>
<h3>input(data, ...args)<span><a class="mark" href="#console_input_data_args" id="console_input_data_args">#</a></span></h3>
<p><strong><code>ABANDONED</code></strong></p>
@@ -1182,7 +1194,7 @@ console.timeEnd(&#39;fruit&#39;);
<li><strong>args</strong> { <span class="type"><a href="documentation.html#documentation_可变参数">...</a><a href="dataTypes.html#datatypes_any">any</a><a href="documentation.html#documentation_可变参数">[]</a></span> } - <a href="glossaries.html#glossaries_占位符替换参数">占位符替换参数</a></li>
<li><ins><strong>returns</strong></ins> { <span class="type"><a href="dataTypes.html#datatypes_void">void</a></span> }</li>
</ul>
<p>此方法已于 <code>6.3.0</code> 版本被废弃, 使用后将无任何效果.</p>
<p>此方法已于 <code>6.3.1</code> 版本被废弃, 使用后将无任何效果.</p>
<h2>[m] rawInput<span><a class="mark" href="#console_m_rawinput" id="console_m_rawinput">#</a></span></h2>
<h3>rawInput(data, ...args)<span><a class="mark" href="#console_rawinput_data_args" id="console_rawinput_data_args">#</a></span></h3>
<p><strong><code>ABANDONED</code></strong></p>
@@ -1191,7 +1203,7 @@ console.timeEnd(&#39;fruit&#39;);
<li><strong>args</strong> { <span class="type"><a href="documentation.html#documentation_可变参数">...</a><a href="dataTypes.html#datatypes_any">any</a><a href="documentation.html#documentation_可变参数">[]</a></span> } - <a href="glossaries.html#glossaries_占位符替换参数">占位符替换参数</a></li>
<li><ins><strong>returns</strong></ins> { <span class="type"><a href="dataTypes.html#datatypes_void">void</a></span> }</li>
</ul>
<p>此方法已于 <code>6.3.0</code> 版本被废弃, 使用后将无任何效果.</p>
<p>此方法已于 <code>6.3.1</code> 版本被废弃, 使用后将无任何效果.</p>
</div>
</div>

View File

@@ -309,7 +309,8 @@ console.build({ titleIconsTint: &#39;green&#39; }).show();
console.build({ contentTextSize: 18 }).show();
</code></pre>
<h2>[p?] contentTextColor<span><a class="mark" href="#consolebuildoptionstype_p_contenttextcolor" id="consolebuildoptionstype_p_contenttextcolor">#</a></span></h2>
<div class="signature"><ul>
<p><strong><code>Overload 1/2</code></strong></p>
<ul>
<li>{{<ul>
<li>verbose?: <a href="omniTypes.html#omnitypes_omnicolor">OmniColor</a>;</li>
<li>log?: <a href="omniTypes.html#omnitypes_omnicolor">OmniColor</a>;</li>
@@ -319,9 +320,9 @@ console.build({ contentTextSize: 18 }).show();
<li>assert?: <a href="omniTypes.html#omnitypes_omnicolor">OmniColor</a>;</li>
</ul>
</li>
<li>} | <a href="omniTypes.html#omnitypes_omnicolor">OmniColor</a> } - 浮动窗口日志文本字体颜色</li>
<li>}} - 浮动窗口日志文本字体颜色</li>
</ul>
</div><p>设置控制台浮动窗口的日志文本字体颜色, 按日志等级设置一个或多个不同的字体颜色.</p>
<p>设置控制台浮动窗口的日志文本字体颜色, 按日志等级设置一个或多个不同的字体颜色.</p>
<pre><code class="lang-js">/* 设置 LOG 等级日志字体颜色为深橙色. */
console.build({ contentTextColor: { log: &#39;dark-orange&#39; } }).show();
console.log(&#39;content text color test for console.log&#39;);
@@ -344,7 +345,11 @@ console.build({
console[fName].call(console, `content text color test for console.${fName}`);
});
</code></pre>
<p>如果希望不区分日志等级, 统一设置所有日志的文本颜色, 可参考下述示例:</p>
<p><strong><code>Overload 2/2</code></strong></p>
<ul>
<li>{ <span class="type"><a href="omniTypes.html#omnitypes_omnicolor">OmniColor</a></span> } - 浮动窗口日志文本统一字体颜色</li>
</ul>
<p>使用 <code>{ contentTextColor: OmniColor }</code> 时, 不区分日志等级, 统一设置所有日志的文本颜色:</p>
<pre><code class="lang-js">/* 所有日志本文的颜色统一设置为深绿色. */
console.build({
contentTextColor: &#39;dark-green&#39;,

View File

@@ -203,7 +203,7 @@
<p style="font: italic 1em sans-serif; color: #78909C">Marked by SuperMonster003 on Mar 21, 2023.</p>
<hr>
<p>http模块提供一些进行http请求的函数.</p>
<p>http 模块主要用于发送 HTTP 请求, 获取并解析 HTTP 响应.</p>
<blockquote>
<p>注: 与 <a href="web.html">web</a> 模块不同, web 模块主要用于 WebView 网页的注入及客户端构建.</p>
</blockquote>
@@ -340,11 +340,11 @@ log(res.body.string());
<p>选项options可以包含以下属性</p>
<ul>
<li><code>headers</code> { <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type">Object</a> } 键值对形式的HTTP头部信息. 有关HTTP头部信息, 参见<a href="http://www.runoob.com/http/http-header-fields.html">菜鸟教程HTTP响应头信息</a>.</li>
<li><code>method</code> { <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">string</a> } HTTP请求方法. 包括&quot;GET&quot;, &quot;POST&quot;, &quot;PUT&quot;, &quot;DELET&quot;, &quot;PATCH&quot;.</li>
<li><code>method</code> { <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">string</a> } HTTP请求方法. 包括&quot;GET&quot;, &quot;POST&quot;, &quot;PUT&quot;, &quot;DELETE&quot;, &quot;PATCH&quot;.</li>
<li><code>contentType</code> { <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">string</a> } HTTP头部信息中的&quot;Content-Type&quot;, 表示HTTP请求的内容类型. 例如&quot;text/plain&quot;, &quot;application/json&quot;. 更多信息参见<a href="http://www.runoob.com/http/http-content-type.html">菜鸟教程HTTP contentType</a>.</li>
<li><code>body</code> { <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">string</a> } | { <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array" class="type">Array</a> } | { <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function" class="type">Function</a> } HTTP请求的内容. 可以是一个字符串, 也可以是一个字节数组;或者是一个以<a href="https://github.com/square/okio/blob/master/okio/src/main/java/okio/BufferedSink.java/">BufferedSink</a>为参数的函数.</li>
</ul>
<p>该函数是get, post, postJson等函数的基础函数. 因此除非是PUT, DELET等请求, 或者需要更高定制的HTTP请求, 否则直接使用get, post, postJson等函数会更加方便.</p>
<p>该函数是get, post, postJson等函数的基础函数. 因此除非是PUT, DELETE等请求, 或者需要更高定制的HTTP请求, 否则直接使用get, post, postJson等函数会更加方便.</p>
<h2>[m] buildRequest<span><a class="mark" href="#http_m_buildrequest" id="http_m_buildrequest">#</a></span></h2>
<h3>buildRequest(url, options)<span><a class="mark" href="#http_buildrequest_url_options" id="http_buildrequest_url_options">#</a></span></h3>
<p>... ...</p>

View File

@@ -316,7 +316,7 @@ ocr.recognizeText(img, [ 0, 0, 100, 150 ]).filter(text =&gt; text.includes(&#39;
<pre><code class="lang-js">ocr.recognizeText(&#39;./picture.jpg&#39;); /* 获取本地图像文件中的所有文本. */
</code></pre>
<h3>recognizeText(imgPath, region)<span><a class="mark" href="#ocr_recognizetext_imgpath_region" id="ocr_recognizetext_imgpath_region">#</a></span></h3>
<p><strong><code>6.3.0</code></strong> <strong><code>Overload [4-5]/6</code></strong></p>
<p><strong><code>6.3.0</code></strong> <strong><code>Overload 6/6</code></strong></p>
<ul>
<li><strong>imgPath</strong> { <span class="type"><a href="dataTypes.html#datatypes_string">string</a></span> } - 图像路径</li>
<li><strong>region</strong> { <span class="type"><a href="omniTypes.html#omnitypes_omniregion">OmniRegion</a></span> } - OCR 识别区域</li>

View File

@@ -240,6 +240,35 @@ console.show(); /* 显示控制台悬浮窗. */
</tr>
</tbody>
</table>
<p><code>OmniColor</code> 不仅可用于参数传入方法中, 还可以作为 XML 元素的属性值:</p>
<pre><code class="lang-js">&#39;ui&#39;;
ui.layout(&lt;vertical&gt;
&lt;button text=&quot;click to start&quot; color=&quot;#006400&quot;/&gt;
&lt;/vertical&gt;);
</code></pre>
<p>上述示例设置按钮布局的文字颜色为深绿色, 使用了 <a href="dataTypes.html#datatypes_colorhex">ColorHex</a> 作为颜色值.</p>
<p>使用 <a href="dataTypes.html#datatypes_colorname">ColorName</a> 作为颜色值也可达到相同的效果:</p>
<pre><code class="lang-js">&#39;ui&#39;;
ui.layout(&lt;vertical&gt;
&lt;button text=&quot;click to start&quot; color=&quot;dark-green&quot;/&gt;
&lt;/vertical&gt;);
</code></pre>
<p>使用 <a href="dataTypes.html#datatypes_colorint">ColorInt</a> 作为颜色值同样可以达到相同的效果:</p>
<pre><code class="lang-js">&#39;ui&#39;;
ui.layout(&lt;vertical&gt;
&lt;button text=&quot;click to start&quot; color=&quot;-16751616&quot;/&gt;
&lt;/vertical&gt;);
</code></pre>
<p>如需使用主题色作为颜色值, 需要使用一对花括号以及绑定全局作用域的表达式:</p>
<pre><code class="lang-js">&#39;ui&#39;;
ui.layout(&lt;vertical&gt;
&lt;button text=&quot;click to start&quot; color=&quot;{{autojs.themeColor}}&quot;/&gt;
&lt;/vertical&gt;);
</code></pre>
<h2>OmniIntent<span><a class="mark" href="#omnitypes_omniintent" id="omnitypes_omniintent">#</a></span></h2>
<p>Intent 聚合类型.</p>
<table>

View File

@@ -275,7 +275,7 @@
<h3>OCR 特性<span><a class="mark" href="#qa_ocr" id="qa_ocr">#</a></span></h3>
<p>AutoJs6 的 OCR 特性是基于 <a href="https://developers.google.com/ml-kit?hl=zh-cn">Google ML Kit</a><a href="https://developers.google.com/ml-kit/vision/text-recognition/android?hl=zh-cn">文字识别 API</a> 实现的.</p>
<blockquote>
<p>注: AutoJs6 的 <a href="http://project.autojs6.com/blob/master/app/src/main/java/org/autojs/autojs/runtime/api/MlKitOCR.kt">OCR 实现源码</a> 参考自 <a href="https://github.com/TonyJiangWJ">TonyJiangWJ</a>开源项目.</p>
<p>注: AutoJs6 的 <a href="http://project.autojs6.com/blob/master/app/src/main/java/org/autojs/autojs/runtime/api/MlKitOCR.kt">OCR 实现源码</a> 参考自 <a href="https://github.com/TonyJiangWJ">TonyJiangWJ</a> <a href="https://github.com/TonyJiangWJ/Auto.js">开源项目</a>.</p>
</blockquote>
<blockquote>
<p>参阅: <a href="ocr.html">光学字符识别 (OCR)</a> 模块</p>

View File

@@ -175,6 +175,10 @@
<li><span class="stability_undefined"><a href="#web_newinjectablewebclient">newInjectableWebClient()</a></span></li>
</ul>
</li>
<li><span class="stability_undefined"><a href="#web_m_newwebsocket">[m] newWebSocket</a></span><ul>
<li><span class="stability_undefined"><a href="#web_newwebsocket_url">newWebSocket(url)</a></span></li>
</ul>
</li>
</ul>
</li>
</ul>
@@ -287,6 +291,73 @@ settings.setDisplayZoomControls(false);
<p>新建并返回一个 <a href="injectableWebClientType.html">InjectableWebClient</a> (可 <a href="glossaries.html#glossaries_注入">注入</a><a href="https://developer.android.com/reference/android/webkit/WebViewClient">WebViewClient</a>) 实例.</p>
<pre><code class="lang-js">/* 为 webView 对象重新设置一个新的客户端. */
webView.setWebViewClient(newInjectableWebClient());
</code></pre>
<h2>[m] newWebSocket<span><a class="mark" href="#web_m_newwebsocket" id="web_m_newwebsocket">#</a></span></h2>
<h3>newWebSocket(url)<span><a class="mark" href="#web_newwebsocket_url" id="web_newwebsocket_url">#</a></span></h3>
<p><strong><code>6.3.1</code></strong> <strong><code>Global</code></strong></p>
<ul>
<li><strong>url</strong> { <span class="type"><a href="dataTypes.html#datatypes_string">string</a></span> }</li>
<li><ins><strong>returns</strong></ins> { <span class="type"><a href="webSocketType.html">WebSocket</a></span> }</li>
</ul>
<p>新建并返回一个 <a href="webSocketType.html">WebSocket</a> 实例.</p>
<pre><code class="lang-js">console.setExitOnClose(7e3).show();
let ws = web.newWebSocket(&#39;wss://echo.websocket.events&#39;);
ws
.on(&#39;open&#39;, (res, ws) =&gt; {
console.log(&#39;WebSocket 已连接&#39;);
})
.on(&#39;message&#39;, (message, ws) =&gt; {
console.log(&#39;接收到消息&#39;);
// if (message instanceof okio.ByteString) {
// console.log(`消息类型: ByteString`);
// } else if (typeof message === &#39;string&#39;) {
// console.log(`消息类型: String`);
// } else {
// throw TypeError(&#39;Should never happen&#39;);
// }
})
.on(&#39;text&#39;, (text, ws) =&gt; {
console.info(&#39;接收到文本消息:&#39;);
console.info(`text: ${text}`);
})
.on(&#39;bytes&#39;, (bytes, ws) =&gt; {
console.info(&#39;接收到字节数组消息:&#39;);
console.info(`utf8: ${bytes.utf8()}`);
console.info(`base64: ${bytes.base64()}`);
console.info(`md5: ${bytes.md5()}`);
console.info(`hex: ${bytes.hex()}`);
})
.on(&#39;closing&#39;, (code, reason, ws) =&gt; {
console.log(&#39;WebSocket 关闭中&#39;);
})
.on(&#39;closed&#39;, (code, reason, ws) =&gt; {
console.log(&#39;WebSocket 已关闭&#39;);
console.log(`code: ${code}`);
if (reason) console.log(`reason: ${reason}`);
})
.on(&#39;failure&#39;, (err, res, ws) =&gt; {
console.error(&#39;WebSocket 连接失败&#39;);
console.error(err);
});
/* 发送文本消息. */
ws.send(&#39;Hello WebSocket&#39;);
/* 发送字节数组消息. */
ws.send(new okio.ByteString(new java.lang.String(&#39;Hello WebSocket&#39;).getBytes()));
setTimeout(() =&gt; {
console.log(&#39;断开 WebSocket&#39;);
/* code 支持的范围 [1000,5000). */
/* 1000 表示成功操作或常规的 Socket 关闭操作. */
/* 参阅 https://github.com/Luka967/websocket-close-codes */
ws.close(1000, &#39;Closed by user&#39;);
}, 8e3);
setTimeout(() =&gt; console.log(&#39;Exit&#39;), 9e3);
</code></pre>
</div>