(title, subtitle = "", content = "", options = {})
| 456 | |
| 457 | // notification |
| 458 | notify(title, subtitle = "", content = "", options = {}) { |
| 459 | const openURL = options["open-url"]; |
| 460 | const mediaURL = options["media-url"]; |
| 461 | |
| 462 | if (isQX) $notify(title, subtitle, content, options); |
| 463 | if (isSurge) { |
| 464 | $notification.post( |
| 465 | title, |
| 466 | subtitle, |
| 467 | content + `${mediaURL ? "\n多媒体:" + mediaURL : ""}`, |
| 468 | { |
| 469 | url: openURL, |
| 470 | } |
| 471 | ); |
| 472 | } |
| 473 | if (isLoon) { |
| 474 | let opts = {}; |
| 475 | if (openURL) opts["openUrl"] = openURL; |
| 476 | if (mediaURL) opts["mediaUrl"] = mediaURL; |
| 477 | if (JSON.stringify(opts) === "{}") { |
| 478 | $notification.post(title, subtitle, content); |
| 479 | } else { |
| 480 | $notification.post(title, subtitle, content, opts); |
| 481 | } |
| 482 | } |
| 483 | if (isNode || isScriptable) { |
| 484 | const content_ = |
| 485 | content + |
| 486 | (openURL ? `\n点击跳转: ${openURL}` : "") + |
| 487 | (mediaURL ? `\n多媒体: ${mediaURL}` : ""); |
| 488 | if (isJSBox) { |
| 489 | const push = require("push"); |
| 490 | push.schedule({ |
| 491 | title: title, |
| 492 | body: (subtitle ? subtitle + "\n" : "") + content_, |
| 493 | }); |
| 494 | } else { |
| 495 | console.log(`${title}\n${subtitle}\n${content_}\n\n`); |
| 496 | } |
| 497 | } |
| 498 | } |
| 499 | |
| 500 | // other helper functions |
| 501 | log(msg) { |
no test coverage detected