ArkMowers / arknights-mower

《明日方舟》长草助手
https://arkmowers.github.io/arknights-mower/
MIT License
505 stars 53 forks source link

[✨Feature] 添加 Pushplus 推送方法 #647

Closed MuelNova closed 1 month ago

MuelNova commented 1 month ago

Why email 推送会干烂我的邮件箱让我不那么容易注意到有用的邮件 Server Chan 现在每天就 5 条免费推送 Pushplus 有 200 条额度,够用

How 基本就是照着 ServerChan 抄的

ZhaoZuohong commented 1 month ago

基本就是照着 ServerChan 抄的

由于当时的水平限制,ServerChan 部分有很多不合理的地方没有发现,又因为开发力量有限、Server 酱几乎没人使用,所以一直没有修改。新加 pushplus,没有必要把 ServerChan 的问题也照搬过来。以下是个人的几点建议:

  1. Pushplus 相关的配置放到 pushplus 下,不要每项设置单列一项:
-pushplus_enable: false
-pushplus_token: ''
+pushplus:
+  enable: false
+  token: ''

这样读取配置时也更简单,比如后端 __main__.py

-"pushplus_config": {
-    "pushplus_push_enable": conf["pushplus_enable"],
-    "pushplus_token": conf["pushplus_token"],
-},
+"pushplus_config": conf["pushplus"],

前端 store/config.js

-const pushplus_enable = ref(false) // PushPlus通知开关
-const pushplus_token = ref('') // PushPlus Token
+const pushplus = ref({})

-pushplus_enable.value = response.data.pushplus_enable != 0
-pushplus_token.value = response.data.pushplus_token
+pushplus.value = response.data.pushplus

-pushplus_enable: pushplus_enable.value ? 1 : 0,
-pushplus_token: pushplus_token.value,
+pushplus: pushplus.value,

Vue 模板中把 pushplus_enablepushplus_token 相应地改为 pushplus.enablepushplus.token 即可。

另外,配置文件中直接使用布尔类型,不要在前端把布尔类型转化成数字。早期开发 PySimpleGUI 界面时采取了错误的设计,store/config.js 中各种转换是为了兼容以前的配置文件。新的设置项没有必要沿续以前的错误。

  1. 关于 pushplus:

我看到 pushplus 可以使用 html 格式的消息模板。如果可以发送 html,请不要使用 markdown。Server 酱只支持 markdown,而且其 markdown 中不能嵌入 html,而且由于 markdown 的表格不能换行,生成 markdown 的 jinja 模板很不好写,所以才生成 html 后转换成 markdown。Pushplus 既然可以直接发送 html 格式的消息,那就没有必要经过一层转换了。

另外,pushplus 似乎不能很方便地发送图片(或许可以将图片以 base64 格式嵌入 html 中?),体验应该是不如有附件的邮件。

email 推送会干烂我的邮件箱让我不那么容易注意到有用的邮件

改进邮件的实现,比如将 mower 的邮件放到一个子目录下,或许是更好的方案。


如果你坚持要加 pushplus 的支持,请按照上述的第一部分的内容,简化一下相关的设置。

MuelNova commented 1 month ago

另外,pushplus 似乎不能很方便地发送图片(或许可以将图片以 base64 格式嵌入 html 中?),体验应该是不如有附件的邮件。

是的,我看了一下隔壁的实现方案是 CDN,如果用 base64 会超长,暂时先不考虑 Image(等后面咱有钱买 OSS 了再说)