Skip to content

Commit

Permalink
检查版本更新邮件美化、添加选项
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhaoZuohong committed Jul 30, 2024
1 parent 6d4f62f commit d9afc8f
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 12 deletions.
24 changes: 18 additions & 6 deletions arknights_mower/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import os
import re
from datetime import datetime, timedelta

from evalidate import Expr
Expand All @@ -14,7 +15,7 @@
from arknights_mower.utils.depot import 创建csv, 创建json
from arknights_mower.utils.device.adb_client.session import Session
from arknights_mower.utils.device.scrcpy import Scrcpy
from arknights_mower.utils.email import send_message, task_template
from arknights_mower.utils.email import send_message, task_template, version_template
from arknights_mower.utils.hot_update import get_listing
from arknights_mower.utils.log import logger
from arknights_mower.utils.logic_expression import LogicExpression
Expand Down Expand Up @@ -211,9 +212,20 @@ def simulate():
listing = get_listing()
version = __version__.replace("+", "-")
if not any(i.name.startswith(version) for i in listing):
msg = "Mower版本过旧,请更新至受支持的版本"
logger.error(msg)
send_message(msg)
stable = []
testing = []
for i in listing:
name = i.name
if re.fullmatch(r"[0-9]{4}\.[0-9]{2}\.[0-9]+/", name):
stable.append(name[:-1])
elif re.fullmatch(r"[0-9]{4}\.[0-9]{2}-[0-9a-z]{7}/", name):
testing.append(name[:-1])
title = "Mower版本过旧,请及时更新"
logger.error(title)
body = version_template.render(
stable=stable, testing=testing, current=version
)
send_message(body, title)

# 刷新时间以鹰历为准
if (
Expand Down Expand Up @@ -428,8 +440,8 @@ def _is_depotscan():
continue
else:
raise e
except RuntimeError as re:
logger.exception(f"程序出错-尝试重启模拟器->{re}")
except RuntimeError as e:
logger.exception(f"程序出错-尝试重启模拟器->{e}")
restart_simulator()
base_scheduler.device.client.check_server_alive()
Session().connect(config.conf.adb)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>arknights-mower任务列表</title>
<title>任务</title>
<style>
table {
border-collapse: collapse;
width: 320px;
}
th,
td {
Expand Down
24 changes: 24 additions & 0 deletions arknights_mower/templates/version.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>版本</title>
</head>
<body>
<p>当前版本{{ current }}过旧,请及时更新。</p>
<p>以下为推荐的mower版本:</p>
<p>稳定版:</p>
<ul>
{% for i in stable %}
<li>{{ i }}</li>
{% endfor %}
</ul>
<p>测试版:</p>
<ul>
{% for i in testing %}
<li>{{ i }}</li>
{% endfor %}
</ul>
</body>
</html>
2 changes: 2 additions & 0 deletions arknights_mower/utils/config/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ class WebViewConf(ConfModel):
"界面主题"
screenshot: int = 200
"截图数量"
check_for_updates: bool = True
"检查更新"


class LongTaskPart(ConfModel):
Expand Down
3 changes: 1 addition & 2 deletions arknights_mower/utils/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@
"arknights_mower",
"__init__",
"templates",
"email",
)
else:
template_dir = os.path.join(
os.getcwd(),
"arknights_mower",
"templates",
"email",
)

env = Environment(loader=FileSystemLoader(template_dir), autoescape=select_autoescape())
Expand All @@ -37,6 +35,7 @@
recruit_template = env.get_template("recruit_template.html")
recruit_rarity = env.get_template("recruit_rarity.html")
report_template = env.get_template("report_template.html")
version_template = env.get_template("version.html")


class Email:
Expand Down
6 changes: 5 additions & 1 deletion ui/src/pages/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ const {
droidcast,
maa_adb_path,
maa_gap,
custom_screenshot
custom_screenshot,
check_for_updates
} = storeToRefs(config_store)
const { operators } = storeToRefs(plan_store)
Expand Down Expand Up @@ -270,6 +271,9 @@ async function test_screenshot() {
<n-form-item :show-label="false">
<n-checkbox v-model:checked="start_automatically">启动后自动开始任务</n-checkbox>
</n-form-item>
<n-form-item :show-label="false">
<n-checkbox v-model:checked="check_for_updates">检查版本更新</n-checkbox>
</n-form-item>
<n-form-item label="截图方案">
<n-radio-group v-model:value="screenshot_method">
<n-flex>
Expand Down
8 changes: 6 additions & 2 deletions ui/src/stores/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export const useConfigStore = defineStore('config', () => {
const visit_friend = ref(true)
const credit_fight = ref({})
const custom_screenshot = ref({})
const check_for_updates = ref(true)

async function load_shop() {
const response = await axios.get(`${import.meta.env.VITE_HTTP_URL}/shop`)
Expand Down Expand Up @@ -165,6 +166,7 @@ export const useConfigStore = defineStore('config', () => {
visit_friend.value = response.data.visit_friend
credit_fight.value = response.data.credit_fight
custom_screenshot.value = response.data.custom_screenshot
check_for_updates.value = response.data.check_for_updates
}

function build_config() {
Expand Down Expand Up @@ -247,7 +249,8 @@ export const useConfigStore = defineStore('config', () => {
droidcast: droidcast.value,
visit_friend: visit_friend.value,
credit_fight: credit_fight.value,
custom_screenshot: custom_screenshot.value
custom_screenshot: custom_screenshot.value,
check_for_updates: check_for_updates.value
}
}

Expand Down Expand Up @@ -333,6 +336,7 @@ export const useConfigStore = defineStore('config', () => {
droidcast,
visit_friend,
credit_fight,
custom_screenshot
custom_screenshot,
check_for_updates
}
})

0 comments on commit d9afc8f

Please sign in to comment.