From c969f503f904269026208dbfdb2b09c750fefa18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=8D=A1=E6=8B=89=E5=B8=95=E9=B2=81=E7=81=B0?= <939671113@qq.com> Date: Thu, 26 Nov 2026 03:10:09 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat(theme):=20=E7=82=B9=E6=A1=8C=E5=AE=A0?= =?UTF-8?q?=E6=92=AD=E4=B8=80=E4=B8=AA=E9=9A=8F=E6=9C=BA=E5=8A=A8=E4=BD=9C?= =?UTF-8?q?=20(#143)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 卫戍协议主题包里本来就有 pet/actions(talk / happy / think),前端只在 pet.every 秒随机播一次。现在点桌宠也会立刻播一个,更像在戳它。 - 把「随机挑一个 → 播完回待机」抽成 playPetAction(),定时器和点击共用; 两处各写一份的话,「播完回待机」「播不起来也回待机」迟早有一边漏掉 - play() reject 时回待机(素材损坏 / 编码不支持),不会停在动作最后一帧 - 容器 #theme-pet 仍然 pointer-events:none,只给 .on video 放开点击, 否则右下角那块会把右栏按钮挡住 - 关桌宠 / 换主题时摘掉 el.onclick - 冒烟新增 B76,共 79 项 Co-authored-by: HuiParu <171644868+HuiParu@users.noreply.github.com> --- docs/frontend.md | 5 +++++ frontend/app.js | 38 +++++++++++++++++++++++------------ frontend/themes.css | 3 +++ tools/smoketest/smoke_test.py | 37 ++++++++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 13 deletions(-) diff --git a/docs/frontend.md b/docs/frontend.md index 14db00c..6b566f7 100644 --- a/docs/frontend.md +++ b/docs/frontend.md @@ -439,6 +439,11 @@ webm、fixed 右下、`pointer-events: none`、`object-position: bottom right` `pet.every` 秒换一个动作播一遍,`onended` 回到待机。窄屏和 `prefers-reduced-motion` 下直接不显示。 +**点一下也播(2026-11-26)**:点击和定时共用 `playPetAction()`,连点就重播 +(每次重新随机);`play()` 起不来(素材坏 / 编码不支持)也回待机,不会停在 +动作最后一帧。容器 `#theme-pet` 仍然 `pointer-events: none`,只给 +`#theme-pet.on video` 放开点击——整块放开会把右下角那一片右栏按钮拦住。 + ## 助手页两栏与 markdown(2026-11-17) `#mod-chat` 分两栏:`.chat-main`(左,聊天占大头)+ `.chat-side`(右 300px,执行日志)。 diff --git a/frontend/app.js b/frontend/app.js index aa28ae9..adfb986 100644 --- a/frontend/app.js +++ b/frontend/app.js @@ -2700,12 +2700,31 @@ function petEnabled() { try { return localStorage.getItem('maaprts.pet') !== '0'; } catch (e) { return true; } } +/* 播一次随机动作,播完回待机。定时触发和点击触发共用这一份——两处各写 + 一遍的话,「播完回待机」「播不起来也要回待机」这些分支迟早走岔。 + 连点就重播:每次重新随机,比"动作没播完就不理你"更像在戳它。 */ +function playPetAction(acts, base, idle) { + const v = document.getElementById('theme-pet-v'); + if (!v || !acts.length) return; + const back = () => { + v.onended = null; + v.loop = true; + v.src = base + idle; + v.play().catch(() => { }); + }; + v.onended = back; + v.loop = false; + v.src = base + acts[Math.floor(Math.random() * acts.length)]; + // 素材坏了 / 解码不支持时 play() 会 reject,别停在动作的最后一帧 + v.play().catch(back); +} + function syncThemePet(id) { let el = document.getElementById('theme-pet'); const info = id && !THEME_FIXED[id] ? themeInstalled[id] : null; const pet = info && info.pet; if (!pet || !pet.video || !petEnabled()) { - if (el) { el.classList.remove('on'); el.innerHTML = ''; } + if (el) { el.classList.remove('on'); el.innerHTML = ''; el.onclick = null; } stopPetLoop(); return; } @@ -2721,20 +2740,13 @@ function syncThemePet(id) { el.classList.toggle('float', pet.float !== false); stopPetLoop(); const acts = Object.values(pet.actions || {}).filter(Boolean); + // 点桌宠立刻播一个随机动作。容器仍然不拦界面点击,只有视频这一块接 + // 事件,见 themes.css 的 #theme-pet.on video。 + el.onclick = acts.length ? () => playPetAction(acts, base, pet.video) : null; if (!acts.length || !(pet.every > 0)) return; _petTimer = setInterval(() => { - const v = document.getElementById('theme-pet-v'); - if (!v || document.hidden) return; - const pick = acts[Math.floor(Math.random() * acts.length)]; - v.onended = () => { - v.onended = null; - v.loop = true; - v.src = base + pet.video; - v.play().catch(() => { }); - }; - v.loop = false; - v.src = base + pick; - v.play().catch(() => { }); + if (document.hidden) return; + playPetAction(acts, base, pet.video); }, Math.max(8000, Number(pet.every) * 1000)); } diff --git a/frontend/themes.css b/frontend/themes.css index 9da8208..3264f45 100644 --- a/frontend/themes.css +++ b/frontend/themes.css @@ -109,6 +109,9 @@ html[data-theme="light"] .badge-on { object-position: bottom right; display: block; } +/* 点桌宠播一个随机动作(素材来自主题包的 pet.actions)。容器保持 + pointer-events:none,只让视频本体接点击——右栏的按钮照常可按。 */ +#theme-pet.on video { pointer-events: auto; cursor: pointer; } /* 小人待机动作:轻微上下浮动 + 呼吸;视频本身在播 idle.webm, 这一层是「视频解码前的空窗期」和不支持视频时的兜底 */ #theme-pet.float { diff --git a/tools/smoketest/smoke_test.py b/tools/smoketest/smoke_test.py index 8eb21e4..d15b021 100644 --- a/tools/smoketest/smoke_test.py +++ b/tools/smoketest/smoke_test.py @@ -8912,6 +8912,8 @@ def main(): lambda: check_theme_switch(tmp)) r.check('B75 国内源 Mirror 酱(默认值/错误码/按源校验/时效链接不落盘)', lambda: check_mirror_source(tmp)) + r.check('B76 桌宠点一下播随机动作(点击与定时共用 / 播不起来也回待机)', + lambda: check_theme_pet(tmp)) finally: shutil.rmtree(tmp, ignore_errors=True) @@ -8925,5 +8927,40 @@ def main(): return 0 +def check_theme_pet(tmp): + """B76 桌宠点一下播随机动作(点击与定时共用一份 / 播不起来也回待机) + + 素材(pet/idle.webm 加 pet.actions 里的动作)由主题包自己提供,前端只 + 负责随机挑一个、播完回待机。这里一个视频都不加载,验的是接线: + + - 定时触发和点击触发共用 playPetAction,不许各写一份——「播完回待机」 + 和「播不起来也回待机」这两条分支写两遍,早晚会有一边漏掉; + - play() reject 时必须回待机,否则停在动作最后一帧不动; + - 容器 #theme-pet 保持 pointer-events:none,只让视频本体接点击,不然 + 右下角那块会把右栏按钮挡住。 + """ + js = open(os.path.join(REPO, 'frontend', 'app.js'), encoding='utf-8').read() + css = open(os.path.join(REPO, 'frontend', 'themes.css'), + encoding='utf-8').read() + + assert 'function playPetAction(acts, base, idle) {' in js, '没有抽 playPetAction' + assert js.count('playPetAction(') >= 3, '定时器 / 点击没有共用 playPetAction' + body = js.split('function playPetAction(acts, base, idle) {', 1)[1].split( + 'function syncThemePet', 1)[0] + assert 'v.onended = back' in body, '动作播完没回待机' + assert 'v.play().catch(back)' in body, '动作播不起来时没回待机' + assert 'Math.floor(Math.random()' in body, '没随机挑动作' + + assert 'el.onclick = acts.length' in js, '桌宠没接点击' + assert 'el.onclick = null' in js, '关桌宠 / 换主题后没摘掉点击' + tail = js.split('_petTimer = setInterval', 1)[1][:240] + assert 'document.hidden' in tail, '后台标签页还在播动作' + + # 容器不许放开(右栏照常可点),只放视频本体 + container = css.split('#theme-pet {', 1)[1].split('}', 1)[0] + assert 'pointer-events: none' in container, '桌宠容器放开了点击,会拦住右栏' + assert '#theme-pet.on video { pointer-events: auto' in css, '桌宠视频没接点击' + + if __name__ == '__main__': sys.exit(main()) From 5ac32dd21c14bae0587e7af75bcbab6db67dd9cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=93=E4=B8=B6=E6=A2=A6=E4=B8=B6=E4=BB=81?= <74444214+Daydreamer114@users.noreply.github.com> Date: Wed, 25 Nov 2026 20:47:08 +0000 Subject: [PATCH 2/3] =?UTF-8?q?ci:=20=E5=8F=91=E7=89=88=E5=90=8E=E6=8A=8A?= =?UTF-8?q?=20release=20=E5=90=88=E5=B9=B6=E6=8F=90=E4=BA=A4=E5=90=88?= =?UTF-8?q?=E5=9B=9E=20main=20(#144)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ci: 发版后把 release 合并提交合回 main 参考 MAA pr-auto-tag.yml:Release PR 合入 release 并发布后,sync-main job 用写权限 deploy key(secret MAIN_SYNC_DEPLOY_KEY)签出 main,git merge 本次合并提交并推回 main。main 未动则快进,两边同指一个合并提交;动过则 生成 merge 节点。tag 从 main 可达,main 不再显示落后 release。 配套 ruleset 已改:main 去掉 required_linear_history,main / main Squash bypass 加 Deploy keys。 Co-Authored-By: Claude Opus 5.5 * ci: sync-main 改为合入即同步,不等构建发布 只依赖 meta、与 release 并行:合并提交在 PR 合入时就已落在 release 上, 同步不该被构建/发布/Mirror 酱的失败卡住。job 挪到 release 之前,顶部流程 说明补一行。 Co-Authored-By: Claude Opus 5.5 --------- Co-authored-by: Claude Opus 5.5 --- .github/workflows/release.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 070984e..b02eec4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,6 +6,7 @@ # - PR 标题「Release vX.Y.Z」即版本号;用 merge commit 合入 release, # 合并关闭 PR 时触发: # meta 从标题提取版本号;严格 X.Y.Z 为正式版,带 -后缀 视为预发布 +# sync-main 与 release 并行:把合并提交合回 main(能快进就快进) # release 在合并提交上:冒烟 → 打包 → 把版号写进包内 version.json → # zip 命名 MAA-PRTS-vX.Y.Z-win-<架构>.zip → # changelog 取上一个 tag 以来的全部 commits → 发布 Release, @@ -62,6 +63,38 @@ jobs: echo "prerelease=true" | tee -a $GITHUB_OUTPUT fi + # Release PR 合入即把 release 的合并提交合回 main(抄 MAA pr-auto-tag.yml), + # 只依赖 meta、与构建发布并行:合并提交在 PR 合入时就已落在 release 上, + # 同步不该被构建/发布/Mirror 酱的失败卡住。main 没动过则快进,两边指向 + # 同一个合并提交;动过则在 main 上生成一个 merge 节点。这样 tag 从 main + # 也可达,main 也不再显示「落后 release」。 + # main 的 ruleset 禁止直接推送,这里用写权限 deploy key(secret + # MAIN_SYNC_DEPLOY_KEY)推送,两个 main ruleset 的 bypass 里都放了 Deploy keys + sync-main: + name: 合回 main + needs: meta + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - name: Checkout main + uses: actions/checkout@v7 + with: + ref: main + fetch-depth: 0 + ssh-key: ${{ secrets.MAIN_SYNC_DEPLOY_KEY }} + show-progress: false + + - name: Merge release into main and push + env: + TAG: ${{ needs.meta.outputs.tag }} + MERGE_SHA: ${{ github.event.pull_request.merge_commit_sha }} + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git fetch origin "$MERGE_SHA" + git merge --no-edit -m "Merge release $TAG into main" "$MERGE_SHA" + git push origin HEAD:main + release: name: 构建并发布(Windows) needs: meta From 1bf94cae693ce07b43e9d764f37e7d5457d75ec3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=93=E4=B8=B6=E6=A2=A6=E4=B8=B6=E4=BB=81?= <74444214+Daydreamer114@users.noreply.github.com> Date: Wed, 25 Nov 2026 21:45:44 +0000 Subject: [PATCH 3/3] =?UTF-8?q?feat(garrison):=20=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E6=A0=B8=E5=BF=83=201.1.11=EF=BC=88=E6=A0=87=E5=87=86=E6=A8=A1?= =?UTF-8?q?=E6=8B=9F/=E8=A7=84=E7=A8=8B=E7=AD=89=E7=BA=A7=E3=80=81?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E9=97=B4=E9=9A=94=E3=80=81unknown=20?= =?UTF-8?q?=E8=AF=8A=E6=96=AD=EF=BC=89=20(#145)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(garrison): 同步核心 1.1.11(标准模拟/规程等级、操作间隔、unknown 诊断) - 核心:adaptedVersions 加 1.1.11,FALLBACKS 首位补 1.1.11 直链(sha256/bytes 取自本机 records) - 补丁 v1111:拉丁名 2 字容差、免费领取信详情、策略页 un 容差 - 补丁 v1111:非调试模式也应用操作间隔(0.5–5×,按 0.5 取整;verify*/fullBoard 仍关闭) - 补丁 v1111:unknown 时记 OCR 文字、持续 15 秒存一张 unknown-.png;主页 Banner 点完校验 lobby/mode/info,未进则按返回回主页重试(累计 9 次封顶) - UI/后端:模拟模式改 mode+level 模型(策略徽章 极速/标准·规程等级 1;叠层任务 1/5/12,阿戈尔组强制 standard/5),host 同时发 mode 与 medalMode/level - UI:恢复「操作间隔」控件;目标胜场仅策略徽章显示;连接与策略/写入配置的行标签改 div,只有控件本身可点 - 冒烟 B47:level 归一化、1.1.11 适配表与选版、speed 取整与默认 1.0 * revert(garrison): 移除操作间隔选项,回滚已打过的 speed 补丁 - UI/后端/host 不再暴露或传递 speed,账号 json 里残留的旧 speed 值不再生效 - patches 删掉 speed-nondebug-v1111,新增 speed-nondebug-revert-v1111:把已经打过旧补丁的核心恢复成 speed:1(未打过的核心自动跳过) - B47 同步:默认值/清洗/持久化断言去掉 speed;持久化改用 goal+level 验证 --- README.md | 2 +- backend/core/garrison.py | 33 +++++++++++++---- backend/core/garrisondl.py | 15 +++++++- frontend/app.js | 65 ++++++++++++++++++++++++++++++--- frontend/index.html | 65 ++++++++++++++------------------- resources/garrison/host.mjs | 9 ++++- resources/garrison/patches.json | 53 ++++++++++++++++++++++++++- tools/smoketest/smoke_test.py | 56 ++++++++++++++++++---------- 8 files changed, 222 insertions(+), 76 deletions(-) diff --git a/README.md b/README.md index ec1b605..a5b763a 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ MAA-PRTS\ | 抽卡统计 | 「抽卡统计」模块:总抽数、六星数/出率、平均出六星、距上次六星,按卡池分开列(每池挂出自己的六星与第几抽)、星级分布、最近记录;终末地分「角色寻访 / 武器申领」两个 tab(两套保底不能混算)。记录只增不减地存在本地,没网也能看 | | 终末地抽卡 | 角色寻访(5 类池子全翻页)+ 武器申领分开统计:角色看抽数/六星/出率/保底,武器单独两张卡;记录接口只给最近一段窗口,本地只增不减,滑走的旧记录不会丢 | | 森空岛签到 | 「森空岛签到」模块:左「全局签到」一键签列表里所有账号(明日方舟 + 终末地),右「单号签到」只签当前账号;两边各一块日志,跑完给「成功 / 已签到 / 失败 / 跳过」汇总。先查状态再签,今天签过的直接说已签到,不会重复打接口 | -| 卫戍协议 | 「卫戍协议」模块:策略刻章速刷(极速模拟自动打满 31 个策略目标)。连接参数从当前账号绑定的 MAA 配置里抄(MuMu 自动用快速截图 Extras、雷电→ldplayer、PC 官方客户端→pc;默认极速 / 1.5× / 3 胜),每个账号一个独立速刷后端、自己的检查点,可多账号同时跑。核心包(约 61MB)不随本程序分发:首次打开该页自动从小黑盒官方 CDN 下载并逐文件校验(装过小黑盒的用本机记录拿最新版),断点续传;另需 Node.js 20+ | +| 卫戍协议 | 「卫戍协议」模块:策略刻章速刷(极速模拟自动打满 31 个策略目标;也可选标准模拟·规程等级 1 刷极速未开放的策略,叠层任务可选规程等级 1/5/12)。连接参数从当前账号绑定的 MAA 配置里抄(MuMu 自动用快速截图 Extras、雷电→ldplayer、PC 官方客户端→pc;默认极速 / 3 胜),每个账号一个独立速刷后端、自己的检查点,可多账号同时跑。核心包(约 61MB)不随本程序分发:首次打开该页自动从小黑盒官方 CDN 下载并逐文件校验(装过小黑盒的用本机记录拿最新版),断点续传;另需 Node.js 20+ | | 练度统计 | 干员数 / 精二 / 满级 / 六星 / 专三 / 模组 / 潜能 / 信赖 | | 缺卡清单 | 点顶部「缺卡」,按星级列出还没有的干员名字 | | 作业匹配 | 输入关卡代号(`TL-10`)、章节号(`2` 返回整章:主线 + S 支线 + TR 教学)、活动(`act55side`)、系列(`TR-`)或中文名,逐份比对干员与练度 | diff --git a/backend/core/garrison.py b/backend/core/garrison.py index 996c5f0..09a17c5 100644 --- a/backend/core/garrison.py +++ b/backend/core/garrison.py @@ -199,7 +199,8 @@ def _maa_dir_for(file: str) -> str: def _maa_defaults(file: str): """从账号绑定 MAA 的连接配置里抄出来的裸默认值(不含用户偏好 overlay)""" opts = { - 'device': 'mumu', 'mode': 'quick', 'goal': 'medal', 'speed': 1.5, 'medalWins': 3, + 'device': 'mumu', 'mode': 'quick', 'goal': 'medal', 'level': 1, + 'medalWins': 3, 'adbAddress': '127.0.0.1:16384', 'adbPath': '', 'screenshotMethod': 'auto', 'pcUiScale': 90, } @@ -228,7 +229,7 @@ def _maa_defaults(file: str): # 可持久化的速刷选项键(账号 json 里的 garrisonOpts 只认这些) -OPT_KEYS = ('device', 'mode', 'goal', 'adbAddress', 'adbPath', 'medalWins', 'speed', +OPT_KEYS = ('device', 'mode', 'goal', 'level', 'adbAddress', 'adbPath', 'medalWins', 'screenshotMethod', 'pcUiScale') @@ -280,20 +281,36 @@ def save_opts(file: str, options: dict) -> dict: def sanitize(body: dict) -> dict: - """前端提交的选项清洗:只放行核心认识的枚举与范围,其余回默认""" + """前端提交的选项清洗:只放行核心认识的枚举与范围,其余回默认 + + 模拟模式自 v1.1.10 起分两套口径:策略徽章看 medalMode(极速,或标准模拟· + 规程等级 1),叠层任务看 mode+level(极速,或标准模拟·规程等级 1/5/12)。 + 阿戈尔/卡西米尔/突袭(task-2)没有极速与等级 1 入口,统一落到标准·等级 5。 + 前端只提交 mode + level,归一化后由 host.mjs 分别透传为 medalMode/level。 + """ body = body or {} dft, _src = defaults('') # 兜底基底(读不到 MAA 配置时的那套) device = body.get('device') if body.get('device') in DEVICES else dft['device'] + goal = body.get('goal') if body.get('goal') in GOALS else 'medal' + mode = body.get('mode') if body.get('mode') in ('quick', 'standard') else 'quick' try: - speed = min(5.0, max(0.5, float(body.get('speed') or 1.5))) + level = int(body.get('level')) except (TypeError, ValueError): - speed = 1.5 + level = 1 + if goal == 'medal': + level = 1 # 策略徽章的标准模拟固定规程等级 1 + elif goal == 'task-2': + if level not in (5, 12): + level = 5 + mode = 'standard' # 这组盟约只有等级 5/12,没有极速/等级 1 + elif level not in (1, 5, 12): + level = 1 return { 'device': device, - 'mode': body.get('mode') if body.get('mode') in ('quick', 'standard') else 'quick', - 'goal': body.get('goal') if body.get('goal') in GOALS else 'medal', + 'mode': mode, + 'goal': goal, + 'level': level, 'medalWins': 6 if str(body.get('medalWins')) == '6' else 3, - 'speed': speed, 'adbAddress': str(body.get('adbAddress') or dft['adbAddress']).strip() or dft['adbAddress'], 'adbPath': str(body.get('adbPath') or '').strip(), 'screenshotMethod': (body.get('screenshotMethod') diff --git a/backend/core/garrisondl.py b/backend/core/garrisondl.py index 0dfe7ef..bdef3ba 100644 --- a/backend/core/garrisondl.py +++ b/backend/core/garrisondl.py @@ -8,8 +8,8 @@ %APPDATA%\\HeyboxDesktop\\desktop\\extension-artifacts\\v1\\records\\*.catalog.json 里 package_id == ai-desktop.arknights-medal-farm 的记录(多条取版本最大), 带 target.cdn_url(官方 CDN 直链,匿名可下)与 integrity.files 逐文件清单。 - 2. 回退:硬编码的 v1.1.4 已验证直链(整包 sha256 已锚定;无逐文件清单时 - 退化为 zip 可解压 + core/service.mjs 存在 + 体量下限)。 + 2. 回退:硬编码的已验证直链(1.1.11 / 1.1.7 / 1.1.5 / 1.1.4,整包 sha256 + 已锚定;无逐文件清单时退化为 zip 可解压 + core/service.mjs 存在 + 体量下限)。 落盘到 ``<运行根>/garrison/medal-farm-v<版本>/``(garrison.core_dir 的约定 位置之一,装好即被发现)。下载在后台线程跑,进度/阶段记在模块级 _DL, @@ -39,6 +39,17 @@ # 已验证直链(匿名可下载,整包 sha256 锚定):按版本降序作回退链—— # 记录里的新版不在适配表时,装「表内最新」的直链版本而不是一味落到最老。 FALLBACKS = [ + { + 'version': '1.1.11', + 'url': ('https://static.max-c.com/heybox/desktop/extension/' + 'ai-desktop.arknights-medal-farm/version/1.1.11/' + 'f87f56c2110138158f44fce014dff979b36d26e206baf99b004e3e0953988fe1-' + '20261124T111647922Z/ai-desktop.arknights-medal-farm-1.1.11.hbext'), + 'sha256': 'f87f56c2110138158f44fce014dff979b36d26e206baf99b004e3e0953988fe1', + 'bytes': 61131567, + 'files': None, + 'source': '官方直链(回退)', + }, { 'version': '1.1.7', 'url': ('https://static.max-c.com/heybox/desktop/extension/' diff --git a/frontend/app.js b/frontend/app.js index adfb986..1559861 100644 --- a/frontend/app.js +++ b/frontend/app.js @@ -5273,26 +5273,73 @@ function garCurrentOpts() { return S.garOpts[S.current] || (d ? { ...d } : null); } +/* 模拟模式下拉:选项随速刷目标变。上游 v1.1.10 起策略徽章 = 极速 / 标准·规程 + 等级 1(只刷极速未开放的策略);叠层任务 = 极速 / 标准·规程 1/5/12(杰西卡), + 阿戈尔/卡西米尔/突袭(task-2)只有等级 5/12。值编码成 quick / standard-N, + 提交时再拆成 mode + level。 */ +const GAR_LEVELS = [1, 5, 12]; + +function garModeChoices(goal) { + const task = !!goal && goal !== 'medal'; + const list = [ + { value: 'quick', label: '极速模拟 · 9 回合' }, + { value: 'standard-1', label: '标准模拟 · 规程等级 1' + (task ? ' · 杰西卡' : '') }, + ]; + if (task) { + for (const n of [5, 12]) { + list.push({ value: `standard-${n}`, label: `标准模拟 · 规程等级 ${n} · 杰西卡` }); + } + } + if (goal === 'task-2') { // 这组盟约没有极速 / 等级 1 入口(上游同款) + list[0].disabled = true; + list[1].disabled = true; + } + return list; +} + +/* 目标切换后把当前选择落到新目标可用的值上(无效时回退,与核心归一化一致) */ +function garModeWant(goal, mode, level) { + const want = mode === 'standard' + ? `standard-${GAR_LEVELS.includes(Number(level)) ? Number(level) : 1}` + : 'quick'; + const list = garModeChoices(goal); + if (list.some(c => c.value === want && !c.disabled)) return want; + if (goal === 'task-2') return 'standard-5'; + return mode === 'standard' ? 'standard-1' : 'quick'; +} + +function paintGarMode(goal, mode, level) { + const sel = $('#gar-mode'); + if (!sel) return; + sel.innerHTML = garModeChoices(goal).map(c => + ``).join(''); + sel.value = garModeWant(goal, mode, level); + const wins = $('#gar-wins-row'); // 目标胜场只对策略徽章有意义 + if (wins) wins.style.display = goal === 'medal' ? '' : 'none'; +} + /* 把选项描进表单:用户改过用改过的,否则用后端从 MAA 抄的默认值 */ function paintGarInputs() { const o = garCurrentOpts(); if (!o) return; const set = (id, v) => { const el = $(id); if (el && v !== undefined && v !== null) el.value = String(v); }; set('#gar-device', o.device); - set('#gar-mode', 'quick'); // 上游 v1.1.7 起仅支持极速 set('#gar-goal', o.goal); + paintGarMode(o.goal, o.mode, o.level); set('#gar-adb', o.adbAddress); set('#gar-wins', o.medalWins); - set('#gar-speed', o.speed); set('#gar-scale', o.pcUiScale); set('#gar-shot', o.screenshotMethod); } function collectGarOpts() { const v = id => $(id) ? $(id).value : ''; + const m = /^standard-(\d+)$/.exec(v('#gar-mode')); const o = { - device: v('#gar-device'), mode: v('#gar-mode'), goal: v('#gar-goal'), adbAddress: v('#gar-adb').trim(), - medalWins: Number(v('#gar-wins')) || 3, speed: Number(v('#gar-speed')) || 1.5, + device: v('#gar-device'), goal: v('#gar-goal'), + mode: m ? 'standard' : 'quick', level: m ? Number(m[1]) : 1, + adbAddress: v('#gar-adb').trim(), + medalWins: Number(v('#gar-wins')) || 3, pcUiScale: Number(v('#gar-scale')) || 90, screenshotMethod: v('#gar-shot'), }; S.garOpts[S.current] = o; // 会话内缓存:切号再回来还在 @@ -5362,7 +5409,7 @@ function paintGarState(d) { if (bs) bs.disabled = busy; if (br) br.disabled = busy || !d.hasCheckpoint; if (bp) bp.disabled = !busy; - ['#gar-device', '#gar-mode', '#gar-adb', '#gar-wins', '#gar-speed', '#gar-scale', '#gar-shot'] + ['#gar-device', '#gar-mode', '#gar-goal', '#gar-adb', '#gar-wins', '#gar-scale', '#gar-shot'] .forEach(id => { const el = $(id); if (el) el.disabled = busy; }); // 来源标注:让用户知道这份默认值是从哪个 MAA 配置抄的 const src = $('#gar-src'); @@ -5868,6 +5915,14 @@ function bindGlobal() { $('#gar-start').addEventListener('click', () => garAction('start')); $('#gar-resume').addEventListener('click', () => garAction('resume')); $('#gar-stop').addEventListener('click', () => garAction('stop')); + // 速刷目标变了先重铺模拟模式选项(旧选择在新目标下不可用时回退), + // 再由 .gar-form 的 change 冒泡统一收集保存 + const garGoal = $('#gar-goal'); + if (garGoal) garGoal.addEventListener('change', () => { + const cur = $('#gar-mode') ? $('#gar-mode').value : 'quick'; + const m = /^standard-(\d+)$/.exec(cur); + paintGarMode(garGoal.value, m ? 'standard' : 'quick', m ? Number(m[1]) : 1); + }); const garForm = $('.gar-form'); if (garForm) garForm.addEventListener('change', collectGarOpts); $('#btn-add-account').addEventListener('click', openAddAccount); diff --git a/frontend/index.html b/frontend/index.html index 1daeaaf..30655bc 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -301,18 +301,14 @@

搜一个关卡开始

默认值来自该账号绑定的 MAA
- - -
+
速刷目标 + - -
+
模拟模式 +
+
目标胜场 + - -
+
ADB 地址 +
+
PC UI 缩放 + -
+
截图方式 + +
@@ -390,17 +381,17 @@

搜一个关卡开始

在搜索结果里点「加入」
拖动作业可以调整写入 MAA 的顺序
-