Skip to content

feat(user-edit): 用户编辑页新增打开配置文件夹的快捷入口 - #755

Open
TianHengZhuang wants to merge 1 commit into
AUTO-MAS-Project:devfrom
TianHengZhuang:user-config-dir-shortcut
Open

TianHengZhuang wants to merge 1 commit into
AUTO-MAS-Project:devfrom
TianHengZhuang:user-config-dir-shortcut

Conversation

@TianHengZhuang

@TianHengZhuang TianHengZhuang commented Sep 14, 2026

Copy link
Copy Markdown

关联 Issue

Closes #185

改动内容

用户编辑页标题栏新增「配置文件夹」快捷入口:编辑已有用户时,可一键在文件管理器中打开该用户的配置目录,不必再手动逐层查找。

  • 后端:新增 POST /api/scripts/user/config-dir,按脚本与用户定位配置目录,目录不存在时创建,返回绝对路径。
  • 前端:UserEditHeader 增加按钮(仅编辑已有用户时显示),绝区零 / 崩坏:星穹铁道 / 鸣潮三个用户编辑页均通过 extra-actions 插槽接入,并补齐 zh-CN / en-US / ja-JP 文案。
  • 前端 API 客户端由 yarn openapi 依后端 OpenAPI 重新生成,仅包含本功能相关文件。
  • 按仓库约定新增 changelog.d/user-config-dir-shortcut.feat.md(一个 PR 一个碎片)。

本地验证

  • python -m pytest tests --collect-only -q:1083 tests collected,退出码 0
  • python -m pytest tests/api -q:18 passed
  • frontendyarn typecheck(vue-tsc --noEmit)通过;yarn lint(oxlint)0 warnings / 0 errors
  • 前端单测:本地 vitest 进程无输出、无法启动,未取得结果(未进一步定位,与本改动无关的证据暂无)。
  • 未做端到端 UI 验证(本机未以 Electron 方式启动应用)。

Sourcery 总结

为用户编辑页面添加快捷方式,用于打开现有用户的配置文件夹。

新功能:

  • 在现有用户的编辑页面上添加快捷方式,以便在文件管理器中打开用户的配置文件夹。
  • 提供用于定位和创建用户配置目录的 API,并返回其绝对路径。

增强:

  • 在支持的游戏用户编辑器中集成配置文件夹操作,并提供本地化的中文、英文和日文标签。

杂项:

  • 为新的配置文件夹快捷方式添加变更日志条目。
Original summary in English

Summary by Sourcery

Add a user edit-page shortcut for opening an existing user’s configuration folder.

New Features:

  • Add a shortcut on existing user edit pages to open the user’s configuration folder in the file manager.
  • Expose an API for locating and creating user configuration directories and return their absolute paths.

Enhancements:

  • Integrate the configuration-folder action across the supported game user editors with localized Chinese, English, and Japanese labels.

Chores:

  • Add a changelog entry for the new configuration-folder shortcut.

编辑已有用户时可直接打开该用户的配置目录,省去手动在文件管理器中逐层查找。
@sourcery-ai

sourcery-ai Bot commented Sep 14, 2026

Copy link
Copy Markdown

审查者指南

本 PR 为用户编辑页增加配置文件夹快捷入口:后端校验用户并按需创建配置目录、返回绝对路径,前端通过生成的 API 客户端调用接口并使用 Electron 打开目录,同时覆盖三个游戏编辑页、多语言文案和 changelog。

打开用户配置文件夹的时序图

sequenceDiagram
    participant User
    participant UserEditHeader
    participant useUserApi
    participant Backend as BackendAPI
    participant Config
    participant Electron

    User->>UserEditHeader: click openConfigFolder
    UserEditHeader->>useUserApi: openUserConfigFolder(scriptId, userId)
    useUserApi->>Backend: POST /api/scripts/user/config-dir
    Backend->>Config: get_user_config_dir(scriptId, userId)
    Config->>Config: validate user and mkdir config directory
    Config-->>Backend: absolute config path
    Backend-->>useUserApi: UserConfigDirOut
    useUserApi->>Electron: openFile(path)
    Electron-->>User: open config directory
Loading

条件显示配置文件夹快捷入口的流程图

flowchart LR
    EditUser["Edit existing user"] --> Header["UserEditHeader"]
    NewUser["Create new user"] --> Header
    Header --> Existing{userId provided?}
    Existing -->|Yes| Button["Show openConfigFolder button"]
    Existing -->|No| Hidden["Hide shortcut"]
    Button --> Open["openUserConfigFolder"]
    Open --> FileManager["Electron opens config directory"]
Loading

文件级变更

变更 详情 文件
新增按脚本和用户获取并创建配置目录的后端接口。
  • 校验脚本及用户 UUID 和用户存在性
  • 按 data/{scriptId}/{userId} 创建目录并返回绝对路径
  • 通过统一响应模型返回成功或错误信息
app/api/scripts.py
app/core/config.py
app/models/schema.py
在用户编辑页标题栏集成打开配置文件夹快捷入口。
  • 仅已有用户显示按钮并提供加载状态
  • 调用用户 API 获取目录后通过 Electron 文件管理器打开
  • 为绝区零、崩坏:星穹铁道和鸣潮编辑页传入用户 ID
frontend/src/components/UserEditHeader.vue
frontend/src/composables/useUserApi.ts
frontend/src/views/EditView/User/HSRUserEdit.vue
frontend/src/views/EditView/User/OkNteUserEdit.vue
frontend/src/views/EditView/User/OkwwUserEdit.vue
同步生成前端 API 类型和服务,并补充多语言及变更记录。
  • 根据 OpenAPI 增加请求/响应类型和 POST 服务方法
  • 补充 zh-CN、en-US、ja-JP 按钮文案
  • 新增功能 changelog 碎片
frontend/src/api/index.ts
frontend/src/api/models/UserConfigDirIn.ts
frontend/src/api/models/UserConfigDirOut.ts
frontend/src/api/services/GetService.ts
frontend/src/api/services/Service.ts
frontend/src/i18n/locales/zh-CN.ts
frontend/src/i18n/locales/en-US.ts
frontend/src/i18n/locales/ja-JP.ts
changelog.d/user-config-dir-shortcut.feat.md

可能关联的问题


提示和命令

与 Sourcery 交互

  • 触发新的审查: 在拉取请求中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 根据审查评论生成 GitHub Issue: 回复审查评论,请 Sourcery 根据评论创建 Issue。也可以回复审查评论并输入 @sourcery-ai issue,以根据该评论创建 Issue。
  • 生成拉取请求标题: 在拉取请求标题的任意位置输入 @sourcery-ai,即可随时生成标题。也可以在拉取请求中评论 @sourcery-ai title,以随时生成或重新生成标题。
  • 生成拉取请求摘要: 在拉取请求正文的任意位置输入 @sourcery-ai summary,即可在指定位置生成 PR 摘要。也可以在拉取请求中评论 @sourcery-ai summary,以随时生成或重新生成摘要。
  • 生成审查者指南: 在拉取请求中评论 @sourcery-ai guide,即可随时生成或重新生成审查者指南。
  • 解决所有 Sourcery 评论: 在拉取请求中评论 @sourcery-ai resolve,即可解决所有 Sourcery 评论。如果你已经处理完所有评论且不想再看到它们,这会很有用。
  • 忽略所有 Sourcery 审查: 在拉取请求中评论 @sourcery-ai dismiss,即可忽略所有现有的 Sourcery 审查。如果你想重新开始一次新的审查,这尤其有用——别忘了评论 @sourcery-ai review 以触发新的审查!

自定义使用体验

访问你的控制面板以:

  • 启用或禁用审查功能,例如 Sourcery 生成的拉取请求摘要、审查者指南等。
  • 更改审查语言。
  • 添加、删除或编辑自定义审查说明。
  • 调整其他审查设置。

获取帮助

Original review guide in English

Reviewer's Guide

本 PR 为用户编辑页增加配置文件夹快捷入口:后端校验用户并按需创建配置目录、返回绝对路径,前端通过生成的 API 客户端调用接口并使用 Electron 打开目录,同时覆盖三个游戏编辑页、多语言文案和 changelog。

Sequence diagram for opening a user config folder

sequenceDiagram
    participant User
    participant UserEditHeader
    participant useUserApi
    participant Backend as BackendAPI
    participant Config
    participant Electron

    User->>UserEditHeader: click openConfigFolder
    UserEditHeader->>useUserApi: openUserConfigFolder(scriptId, userId)
    useUserApi->>Backend: POST /api/scripts/user/config-dir
    Backend->>Config: get_user_config_dir(scriptId, userId)
    Config->>Config: validate user and mkdir config directory
    Config-->>Backend: absolute config path
    Backend-->>useUserApi: UserConfigDirOut
    useUserApi->>Electron: openFile(path)
    Electron-->>User: open config directory
Loading

Flow diagram for conditional config-folder shortcut

flowchart LR
    EditUser["Edit existing user"] --> Header["UserEditHeader"]
    NewUser["Create new user"] --> Header
    Header --> Existing{userId provided?}
    Existing -->|Yes| Button["Show openConfigFolder button"]
    Existing -->|No| Hidden["Hide shortcut"]
    Button --> Open["openUserConfigFolder"]
    Open --> FileManager["Electron opens config directory"]
Loading

File-Level Changes

Change Details Files
新增按脚本和用户获取并创建配置目录的后端接口。
  • 校验脚本及用户 UUID 和用户存在性
  • 按 data/{scriptId}/{userId} 创建目录并返回绝对路径
  • 通过统一响应模型返回成功或错误信息
app/api/scripts.py
app/core/config.py
app/models/schema.py
在用户编辑页标题栏集成打开配置文件夹快捷入口。
  • 仅已有用户显示按钮并提供加载状态
  • 调用用户 API 获取目录后通过 Electron 文件管理器打开
  • 为绝区零、崩坏:星穹铁道和鸣潮编辑页传入用户 ID
frontend/src/components/UserEditHeader.vue
frontend/src/composables/useUserApi.ts
frontend/src/views/EditView/User/HSRUserEdit.vue
frontend/src/views/EditView/User/OkNteUserEdit.vue
frontend/src/views/EditView/User/OkwwUserEdit.vue
同步生成前端 API 类型和服务,并补充多语言及变更记录。
  • 根据 OpenAPI 增加请求/响应类型和 POST 服务方法
  • 补充 zh-CN、en-US、ja-JP 按钮文案
  • 新增功能 changelog 碎片
frontend/src/api/index.ts
frontend/src/api/models/UserConfigDirIn.ts
frontend/src/api/models/UserConfigDirOut.ts
frontend/src/api/services/GetService.ts
frontend/src/api/services/Service.ts
frontend/src/i18n/locales/zh-CN.ts
frontend/src/i18n/locales/en-US.ts
frontend/src/i18n/locales/ja-JP.ts
changelog.d/user-config-dir-shortcut.feat.md

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嘿——我已经审阅了你的更改,看起来很棒!

Sourcery 评估

需要人工审阅。 该端点会创建用户配置目录,并返回其绝对文件系统路径,供 Electron 打开。如果查找或路径处理有误,可能会打开或暴露错误的本地配置目录;此外,回滚不会删除已经创建的目录,不过最终状态是有限的,也可以手动修复。


Sourcery 对开源项目免费——如果你喜欢我们的审阅,请考虑分享 ✨
Original comment in English

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Needs a human reviewer. The endpoint creates a user configuration directory and returns its absolute filesystem path for Electron to open. If the lookup or path handling is wrong, it could open or expose the wrong local configuration directory, and reverting will not remove directories already created, though the resulting state is bounded and manually repairable.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@HarcoChen HarcoChen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

新代码现在是 await window.electronAPI.openFile(response.path) 后直接 return true。 但 MAS 现有 open-file IPC 的设计是:shell.openPath() 打不开时不会 reject,而是正常 resolve { success: false, error };

当前实现遇到目录无法打开、权限/系统文件管理器异常等情况时,会静默认为成功,用户点击按钮可能什么都没发生。仓库现有历史记录页的正确范例:拿到 result 后检查 result.success,失败则展示 result.error。

@HarcoChen

Copy link
Copy Markdown
Contributor

另外能否为所有的用户编辑页面都加入这个?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants