@nsnanocat/util 2.6.8 → 2.6.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/notification.mjs +3 -2
- package/package.json +1 -1
- package/polyfill/Console.d.ts +5 -0
- package/polyfill/Console.mjs +6 -0
package/lib/notification.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { $app } from "./app.mjs";
|
|
2
1
|
import { Console } from "../polyfill/Console.mjs";
|
|
2
|
+
import { $app } from "./app.mjs";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* 通知内容扩展参数。
|
|
@@ -42,6 +42,7 @@ import { Console } from "../polyfill/Console.mjs";
|
|
|
42
42
|
*/
|
|
43
43
|
export function notification(title = `ℹ️ ${$app} 通知`, subtitle = "", body = "", content = {}) {
|
|
44
44
|
const mutableContent = MutableContent(content);
|
|
45
|
+
const bodyLines = body.split(/\r?\n/u);
|
|
45
46
|
switch ($app) {
|
|
46
47
|
case "Surge":
|
|
47
48
|
case "Loon":
|
|
@@ -59,7 +60,7 @@ export function notification(title = `ℹ️ ${$app} 通知`, subtitle = "", bod
|
|
|
59
60
|
break;
|
|
60
61
|
}
|
|
61
62
|
Console.group("📣 系统通知");
|
|
62
|
-
Console.log(title, subtitle,
|
|
63
|
+
Console.log(title, subtitle, bodyLines, JSON.stringify(mutableContent, null, 2));
|
|
63
64
|
Console.groupEnd();
|
|
64
65
|
}
|
|
65
66
|
|
package/package.json
CHANGED
package/polyfill/Console.d.ts
CHANGED
|
@@ -92,6 +92,11 @@ export class Console {
|
|
|
92
92
|
* 输出普通日志。
|
|
93
93
|
* Print standard log messages.
|
|
94
94
|
*
|
|
95
|
+
* 说明:
|
|
96
|
+
* Notes:
|
|
97
|
+
* - 顶层数组参数会按多个独立日志项展开。
|
|
98
|
+
* - Top-level array arguments are expanded into multiple log entries.
|
|
99
|
+
*
|
|
95
100
|
* @param msg 日志内容 / Log payloads.
|
|
96
101
|
*/
|
|
97
102
|
static log(...msg: unknown[]): void;
|
package/polyfill/Console.mjs
CHANGED
|
@@ -224,11 +224,17 @@ export class Console {
|
|
|
224
224
|
* 输出通用日志。
|
|
225
225
|
* Print generic logs.
|
|
226
226
|
*
|
|
227
|
+
* 说明:
|
|
228
|
+
* Notes:
|
|
229
|
+
* - 顶层数组参数会按多个独立日志项展开。
|
|
230
|
+
* - Top-level array arguments are expanded into multiple log entries.
|
|
231
|
+
*
|
|
227
232
|
* @param {...any} msg 日志内容 / Log messages.
|
|
228
233
|
* @returns {void}
|
|
229
234
|
*/
|
|
230
235
|
static log = (...msg) => {
|
|
231
236
|
if (Console.#level === 0) return;
|
|
237
|
+
msg = msg.flatMap(log => (Array.isArray(log) ? log : [log]));
|
|
232
238
|
msg = msg.map(log => {
|
|
233
239
|
switch (typeof log) {
|
|
234
240
|
case "object":
|