| 644 | */ |
| 645 | msg(title = name, subt = '', desc = '', opts = {}) { |
| 646 | const toEnvOpts = (rawopts) => { |
| 647 | const { $open, $copy, $media, $mediaMime } = rawopts |
| 648 | switch (typeof rawopts) { |
| 649 | case undefined: |
| 650 | return rawopts |
| 651 | case 'string': |
| 652 | switch (this.getEnv()) { |
| 653 | case 'Surge': |
| 654 | case 'Stash': |
| 655 | case 'Egern': |
| 656 | default: |
| 657 | return { url: rawopts } |
| 658 | case 'Loon': |
| 659 | case 'Shadowrocket': |
| 660 | return rawopts |
| 661 | case 'Quantumult X': |
| 662 | return { 'open-url': rawopts } |
| 663 | case 'Node.js': |
| 664 | return undefined |
| 665 | } |
| 666 | case 'object': |
| 667 | switch (this.getEnv()) { |
| 668 | case 'Surge': |
| 669 | case 'Stash': |
| 670 | case 'Shadowrocket': |
| 671 | case 'Egern': |
| 672 | default: { |
| 673 | const options = {} |
| 674 | |
| 675 | // 打开URL |
| 676 | let openUrl = |
| 677 | rawopts.openUrl || rawopts.url || rawopts['open-url'] || $open |
| 678 | if (openUrl) |
| 679 | Object.assign(options, { action: 'open-url', url: openUrl }) |
| 680 | |
| 681 | // 粘贴板 |
| 682 | let copy = |
| 683 | rawopts['update-pasteboard'] || |
| 684 | rawopts.updatePasteboard || |
| 685 | $copy |
| 686 | if (copy) { |
| 687 | Object.assign(options, { action: 'clipboard', text: copy }) |
| 688 | } |
| 689 | |
| 690 | // 图片通知 |
| 691 | let mediaUrl = |
| 692 | rawopts.mediaUrl || rawopts['media-url'] || $media |
| 693 | if (mediaUrl) { |
| 694 | let media = undefined |
| 695 | let mime = undefined |
| 696 | // http 开头的网络地址 |
| 697 | if (mediaUrl.startsWith('http')) { |
| 698 | //不做任何操作 |
| 699 | } |
| 700 | // 带标识的 Base64 字符串 |
| 701 | // data:image/png;base64,iVBORw0KGgo... |
| 702 | else if (mediaUrl.startsWith('data:')) { |
| 703 | const [data] = mediaUrl.split(';') |