feat(share): 通用脚本模板与分享接入新版配置中心 - #630
Open
qiyinxi wants to merge 2 commits into
Open
Conversation
模板列表、搜索、分页与下载改用配置中心的 /api/v1/configs 与结构化下载接口, 渲染进程不再提交任意下载 URL;下载有体积上限与格式校验,导入失败会删掉刚建出来 的空脚本。 分享改为设备授权:桌面端申请人读短码,用系统浏览器打开配置中心授权页,用户确认后 换取一枚只能上传配置的短期令牌,令牌只留在内存里。分享表单去掉作者,身份由登录 账号决定,上传后进入配置中心已有的待审核流程。 分享前的隐私清理扩展到全部字段,并新增一次扫描:疑似账号、密码、令牌、本机用户名 或本机绝对路径的配置项会列给用户,确认后才允许上传。 Closes AUTO-MAS-Project#624 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
审查者指南本 PR 将通用脚本模板和分享流程整体迁移至新版配置中心:模板使用服务端筛选分页及结构化下载,分享通过浏览器设备授权获得仅内存令牌,并在上传前执行隐私脱敏与风险确认,同时移除旧站配置契约。 分享前浏览器授权时序图sequenceDiagram
participant User as User
participant Desktop as AUTO_MAS
participant Center as ConfigCenter
participant Browser as SystemBrowser
User->>Desktop: startShareAuth()
Desktop->>Center: POST /auth/device/code
Center-->>Desktop: userCode and verificationUri
Desktop->>Browser: open verificationUri
User->>Browser: approve authorization
loop until terminal status
Desktop->>Center: POST /auth/device/token
Center-->>Desktop: pending or authorized
end
Center-->>Desktop: 30-minute upload token
Desktop->>Desktop: store token in memory
User->>Desktop: cancel or close dialog
Desktop->>Center: cancel_authorization()
Desktop->>Desktop: stop polling and clear device session
隐私检查配置分享时序图sequenceDiagram
participant User as User
participant Desktop as AUTO_MAS
participant Backend as DesktopBackend
participant Center as ConfigCenter
User->>Desktop: open share form
Desktop->>Backend: POST /api/scripts/share/inspect
Backend->>Backend: build_share_config()
Backend->>Backend: remove_privacy_info()
Backend->>Backend: scan_privacy_risks()
Backend-->>Desktop: sanitized risks
User->>Desktop: acknowledge risks
Desktop->>Backend: POST /api/scripts/Upload/web
Backend->>Backend: build_share_config()
Backend->>Center: POST /user/configs
Center-->>Backend: pending review result
Backend-->>Desktop: upload success
从已发布模板创建脚本流程图flowchart TD
A["Open general script template picker"] --> B["Search or change page"]
B --> C["Fetch published templates from config center"]
C --> D["Select template by configKey"]
D --> E["Create empty script"]
E --> F["Import using configKey and versionNo"]
F --> G{"Download and validation succeeds"}
G -->|yes| H["Open imported script"]
G -->|no| I["Delete newly created empty script"]
文件级变更
可能相关的问题
提示与命令与 Sourcery 交互
自定义使用体验访问你的控制面板:
获取帮助Original review guide in EnglishReviewer's Guide本 PR 将通用脚本模板和分享流程整体迁移至新版配置中心:模板使用服务端筛选分页及结构化下载,分享通过浏览器设备授权获得仅内存令牌,并在上传前执行隐私脱敏与风险确认,同时移除旧站配置契约。 Sequence diagram for browser authorization before sharingsequenceDiagram
participant User as User
participant Desktop as AUTO_MAS
participant Center as ConfigCenter
participant Browser as SystemBrowser
User->>Desktop: startShareAuth()
Desktop->>Center: POST /auth/device/code
Center-->>Desktop: userCode and verificationUri
Desktop->>Browser: open verificationUri
User->>Browser: approve authorization
loop until terminal status
Desktop->>Center: POST /auth/device/token
Center-->>Desktop: pending or authorized
end
Center-->>Desktop: 30-minute upload token
Desktop->>Desktop: store token in memory
User->>Desktop: cancel or close dialog
Desktop->>Center: cancel_authorization()
Desktop->>Desktop: stop polling and clear device session
Sequence diagram for privacy-checked configuration sharingsequenceDiagram
participant User as User
participant Desktop as AUTO_MAS
participant Backend as DesktopBackend
participant Center as ConfigCenter
User->>Desktop: open share form
Desktop->>Backend: POST /api/scripts/share/inspect
Backend->>Backend: build_share_config()
Backend->>Backend: remove_privacy_info()
Backend->>Backend: scan_privacy_risks()
Backend-->>Desktop: sanitized risks
User->>Desktop: acknowledge risks
Desktop->>Backend: POST /api/scripts/Upload/web
Backend->>Backend: build_share_config()
Backend->>Center: POST /user/configs
Center-->>Backend: pending review result
Backend-->>Desktop: upload success
Flow diagram for creating a script from a published templateflowchart TD
A["Open general script template picker"] --> B["Search or change page"]
B --> C["Fetch published templates from config center"]
C --> D["Select template by configKey"]
D --> E["Create empty script"]
E --> F["Import using configKey and versionNo"]
F --> G{"Download and validation succeeds"}
G -->|yes| H["Open imported script"]
G -->|no| I["Delete newly created empty script"]
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
…0260908 冲突只在 app/api/__init__.py(两边各加了一个 router)与两个 OpenAPI 生成文件上。 生成文件按规范起开发后端后用 yarn openapi 重新生成,没有手改。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
通用脚本的「从模板创建」与「分享配置」全部改走新配置中心;分享前要先在浏览器完成一次登录授权。
GET /api/v1/configs与结构化下载接口,只展示已审核发布、属于 AUTO-MAS 通用脚本分类的配置。渲染进程不再提交任意下载 URL,改为传configKey+versionNo;下载有 2 MiB 上限并校验确实是通用脚本配置,导入失败会把刚建出来的空脚本删掉,不留空壳。%USERPROFILE%);新增一次分享前扫描,把疑似账号/密码/令牌、链接里带账号密码、含本机用户名或本机绝对路径的配置项列给用户,勾选确认后才允许上传。用户数据(SubConfigsInfo)一如既往整体不上传。Important
部署方需要确认的三个值,都收敛在
app/services/config_center.py顶部,也可用环境变量覆盖:AUTO_MAS_CONFIG_CENTER_APIhttps://share.auto-mas.top/api/v1AUTO_MAS_CONFIG_CENTER_PROJECTauto-masproject_key,需要管理员在配置中心后台建好并置为 active。AUTO_MAS_CONFIG_CENTER_CATEGORYgeneralcategory_key,需要是 active 且 public。授权页地址由配置中心后端下发(
FRONTEND_BASE_URL),桌面端不写死。Note
契约变更:
POST /api/scripts/import/web的请求体由{scriptId, url}改为{scriptId, configKey, versionNo};POST /api/scripts/Upload/web去掉author、加acknowledged;删除POST /api/info/webconfig(返回的是旧站专有结构,新站接上后没有消费方);新增POST /api/scripts/share/inspect与/api/share/*。全局配置里Data.WebConfig、Data.LastWebConfigUpdated两项随旧接口一并移除。frontend/src/api是按规范起开发后端后yarn openapi重新生成的。分支已合入当时的
dev(97335f0a):冲突只在app/api/__init__.py(两边各加了一个 router)与两个 OpenAPI 生成文件上,生成文件是重新起开发后端后yarn openapi重新生成的,没有手改;git diff upstream/dev确认除本 PR 自己的文件外没有动到 dev 的任何改动。CHANGELOG.md里另有两行不属于本次改动:res/version.json上「森空岛获取凭据改为扫码登录…」和「BetterGI专项、ZZZ-OD专项 修复任务出错时提示…」两条带着by [@qiyinxi]署名,但CHANGELOG.md上没有,直接跑changelog.py sync会把这两个署名抹掉。这里把署名补回单一来源,res/version.json的 diff 就只剩本 PR 新增的一条。需要配置中心两个仓库同时合并:
/device授权页本地验证(
.venv\Scripts\python.exe3.12 / Corepack Yarn 4.9.1):frontend:yarn lint --max-warnings 1、yarn typecheck通过;yarn testTest Files 1 failed | 44 passed (45)、Tests 1 failed | 419 passed (420),失败的electron/services/backendService.test.tsmanaged 模式那条在完全无关的工作树上复现,是既存红灯。python -m pytest tests -q:720 passed, 3 skipped(含合并 dev 之后的全量);--collect-only -q退出码 0。Game.Path、Script.Arguments两项 → 未勾确认时上传被拒 → 勾选后上传成功 → 普通用户进待审核、管理员通过后出现在模板列表 → 关键字搜索命中/落空 → 结构化标识下载导入并落到编辑页。校验了上传内容里不再含本机用户名,重名上传会提示「该配置名称已被占用」。Closes #624
🤖 Generated with Claude Code