This commit is contained in:
fanbook-wangdage
2025-11-20 20:28:27 +08:00
commit 1f268acc29
2530 changed files with 221582 additions and 0 deletions

13
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1,13 @@
# These are supported funding model platforms
github: [DGP-Studio]
patreon: # Replace with a single Patreon username
open_collective: snaphutao
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
custom: https://afdian.com/a/DismissedLight

View File

@@ -0,0 +1,93 @@
name: 问题反馈
description: 通过这个议题向开发团队反馈你发现的程序中的问题
title: "[Bug]: 在这里填写一个合适的标题"
type: "Bug"
labels: ["priority:none"]
body:
- type: markdown
attributes:
value: |
> **请在上方以一句话简短地概括你的问题作为标题**
> 请按下方的要求填写完整的问题表单,以便我们更快的定位问题。
- type: input
id: winver
attributes:
label: Windows 版本
description: |
`Win+R` 输入 `winver` 回车后在打开的窗口第二行可以找到
placeholder: 22000.556
validations:
required: true
- type: input
id: shver
attributes:
label: Snap Hutao 版本
description: 在应用标题,应用程序的反馈中心界面中可以找到
placeholder: 1.9.9.0
validations:
required: true
- type: input
id: deviceid
attributes:
label: 设备 ID
description: |
> 在胡桃工具箱的反馈中心界面,你可以找到并复制你的设备 ID
> 如果你的问题涉及程序崩溃,请填写该项,这将有助于我们定位问题
> 如果你的程序已经无法启动,请下载并运行[诊断工具](https://github.com/DGP-Automation/ISSUE_TEMPLATES/releases/download/diagnosis_tools/Snap.Hutao.Diagnostic.Tooling.exe),它将显示你的设备 ID
validations:
required: true
- type: dropdown
id: user-set-category
attributes:
label: 问题分类
description: 请设置一个你认为合适的分类,这将帮助我们快速定位问题
options:
- 安装和环境
- 游戏启动器
- 祈愿记录
- 成就管理
- 我的角色
- 实时便笺
- 养成计算
- 深境螺旋/胡桃数据库
- Wiki
- 米游社账号面板
- 每日签到奖励
- 胡桃通行证/胡桃云
- 用户界面
- 文件缓存
- 公告
- 其它
validations:
required: true
- type: textarea
id: what-happened
attributes:
label: 发生了什么?
description: |
详细的描述问题发生前后的行为,以便我们解决问题。**如果你的问题涉及程序崩溃,你应当检查 Windows 事件查看器,并将相关的 `.Net 错误`详情附上**
如果你无法找到该日志,请下载并运行[诊断工具](https://github.com/DGP-Automation/ISSUE_TEMPLATES/releases/download/diagnosis_tools/Snap.Hutao.Diagnostic.Tooling.exe),它将转储问题日志至工具运行目录中的 `Snap.Hutao Error Log.txt`
validations:
required: true
- type: textarea
id: what-expected
attributes:
label: 你期望发生的行为?
description: 详细的描述你期望发生的行为,突出与目前(可能不正确的)行为的不同
validations:
required: false
- type: checkboxes
id: checklist-final
attributes:
label: 最后一步
description: 回顾你的回答
options:
- label: 我认为上述的描述已经足以详细,以允许开发人员能复现该问题
required: true

View File

@@ -0,0 +1,26 @@
name: 功能请求
description: 通过这个议题来向开发团队分享你的想法
title: "[Feat]: 在这里填写一个合适的标题"
type: "Feature"
labels: ["needs-triage", "priority:none"]
body:
- type: markdown
attributes:
value: |
请按下方的要求填写完整的问题表单。
- type: textarea
id: back
attributes:
label: 背景与动机
description: 添加此功能的理由,如果你想要实现多个功能,请分别发起多个单独的议题
validations:
required: true
- type: textarea
id: req
attributes:
label: 想要实现或优化的功能
description: 详细的描述一下你想要的功能,描述的越具体,采纳的可能性越高
validations:
required: true

View File

@@ -0,0 +1,84 @@
name: 网络问题
description: 通过这个议题来反馈网络问题
title: "[Network]: 在这里填写一个合适的标题"
type: "Bug"
labels: ["area-Network"]
assignees:
- Lightczx
- Masterain98
body:
- type: markdown
attributes:
value: |
**请先在上方为工单设置一个合适的标题**
**请按下方的要求填写完整的问题表单,以便我们更快的定位问题。**
- type: textarea
id: network-diagnosis-report
attributes:
label: 提交你的网络诊断报告
description: |
停下!
**在填写下面的问题之前请先使用我们的网络诊断工具**
**这个工具将会生成一份报告并加密压缩,请将这份报告拖入下面的框中,让其与你的工单一起被上传提交**
- 你可以点击下面的链接以下载网络诊断工具:
- [GitHub](https://github.com/Masterain98/network-diagnosis-tool/releases/latest/download/SH-Network-Diagnosis.exe)
validations:
required: true
- type: input
id: user-geo-location
attributes:
label: 你的地理位置
description: |
中国用户请精确到省级行政区
海外用户请精确到国家
placeholder: 北京
validations:
required: true
- type: dropdown
id: user-isp
attributes:
label: 你的运营商
description: 海外用户请选其它
options:
- 中国电信
- 中国联通
- 中国移动
- 中国广电
- 其它
validations:
required: true
- type: dropdown
id: user-issue-category
attributes:
label: 你的问题
description: 选择一个问题类别
options:
- 完全无法连接服务器
- 连接速度慢
- 获取到了不正确的页面或数据
- 客户端图片下载错误
- 客户端图片预下载错误
- 其它
validations:
required: true
- type: textarea
id: what-happened
attributes:
label: 你的问题(补充)
description: 如果你在上一项中选择了`其它`或者你有更多信息需要提供,请在这里写下来
validations:
required: false
- type: checkboxes
id: checklist-final
attributes:
label: 最后一步
description: 检查你提交的议题
options:
- label: 我已经在该议题中上传了包含网络诊断报告的加密压缩包
required: true

View File

@@ -0,0 +1,93 @@
name: BUG Report [English Form]
description: Tell us what issue you get
title: "[ENG][Bug]: Place your Issue Title Here"
type: "Bug"
labels: ["priority:none"]
body:
- type: markdown
attributes:
value: |
> **Please use one sentence to briefly describe your issue as title above**
> Please follow the instruction below to fill the form, so we can locate the issue quickly
- type: input
id: winver
attributes:
label: Windows Version
description: |
Use `Win+R` and input `winver`, Windows build version is usually at the second line
placeholder: e.g. 22000.556
validations:
required: true
- type: input
id: shver
attributes:
label: Snap Hutao Version
description: You can find the version in application's title bar
placeholder: e.g. 1.9.9.0
validations:
required: true
- type: input
id: deviceid
attributes:
label: Device ID
description: |
> In Snap Hutao's Feedback Center, you can find and copy your device ID
> If your issue is about program crash, please fill this so we can dump the log and locate the source easier
> If your program cannot startup, please download and run [Diagnostic Tooling](https://github.com/DGP-Automation/ISSUE_TEMPLATES/releases/download/diagnosis_tools/Snap.Hutao.Diagnostic.Tooling.exe), it will shows your device ID.
validations:
required: true
- type: dropdown
id: user-set-category
attributes:
label: Issue Category
description: Please select the most associated category of your issue
options:
- Installation and Environment
- Game Launcher
- Wish Export
- Achievement
- My Character
- Realtime Note
- Develop Plan
- Spiral Abyss
- Wiki
- MiHoYo Account Panel
- Daily Checkin Reward
- Hutao Passport/Hutao Cloud
- User Interface
- File Cache
- Announcement
- Other
validations:
required: true
- type: textarea
id: what-happened
attributes:
label: What Happened?
description: |
Describe your issue in detail to help us identify the issue. **If your issue is about program crash, you should check Windows Event Viewer, and attach associated `.Net Error` details here**If your program cannot startup, please download and run [this PowerShell script](https://github.com/DGP-Studio/ISSUE_TEMPLATES/releases/download/get_device_id/GetHutaoDeviceId.ps1), it will shows your device ID.
If you cannot find it, please download and run [Diagnosis Tool](https://github.com/DGP-Automation/ISSUE_TEMPLATES/releases/download/diagnosis_tools/Snap.Hutao.Diagnostic.Tooling.exe), it will dump the error log to `Snap.Hutao Error Log.txt` in the working directory of the tool.
validations:
required: true
- type: textarea
id: what-expected
attributes:
label: What is expected?
description: Describe expected outcome, highlight the difference with current outcome
validations:
required: false
- type: checkboxes
id: checklist-final
attributes:
label: Last Step
description: Review your Form
options:
- label: I believe the description above is detail enough to allow developers to reproduce the issue
required: true

View File

@@ -0,0 +1,26 @@
name: Feature Request [English Form]
description: Tell us about your thought
title: "[Feat]: Place your title here"
type: "Feature"
labels: ["needs-triage", "priority:none"]
body:
- type: markdown
attributes:
value: |
Please fill the form below
- type: textarea
id: back
attributes:
label: Background & Motivation
description: Reason why this feature is needed. If multiple features is requested, please open multiple issues for each of them.
validations:
required: true
- type: textarea
id: req
attributes:
label: Detail of the Feature
description: Descripbe the feaure in detail. The more detailed and convincing the desciprtion the more likyly feature will be accepted.
validations:
required: true

View File

@@ -0,0 +1,79 @@
name: Network Issue [English Form]
description: Submit this issue form when network issue affect your client experience
title: "[Network]: Place your title here"
type: "Bug"
labels: ["area-Network"]
assignees:
- Lightczx
- Masterain98
body:
- type: markdown
attributes:
value: |
**Please use one sentence to briefly describe your issue as title above**
**Please follow the instruction below to fill the form, so we can locate the issue quickly**
- type: textarea
id: network-diagnosis-report
attributes:
label: Submit Your Network Diagnosis Report
description: |
STOP HERE!
**Please run our network diagnosis tool before filling this form**
**The diagnosis tool will generate a report and add it into a password-protected archive. Drag the `.zip` archive to the box below so it can be uploaded.**
- Use the following link to download the Network Diagnosis Tool:
- [GitHub](https://github.com/Masterain98/network-diagnosis-tool/releases/latest/download/SH-Network-Diagnosis.exe)
validations:
required: true
- type: input
id: user-geo-location
attributes:
label: Your Geographical Location
description: |
Description accurate to country
placeholder: USA
validations:
required: true
- type: input
id: user-isp
attributes:
label: Your ISP Name
description: |
Name of your Internet service provider
placeholder: AT&T
validations:
required: true
- type: dropdown
id: user-issue-category
attributes:
label: Issue Category
description: Select an issue category
options:
- Cannot connect to server completely
- Slow spped
- Fetched wrong page or data
- Image download error in the client
- Image set pre-download error (client welcome wizard process)
- Other
validations:
required: true
- type: textarea
id: what-happened
attributes:
label: Your Issue (cont.)
description: If you selected `Other` in previous dropdown, please explain your issue in detail here.
validations:
required: false
- type: checkboxes
id: checklist-final
attributes:
label: One Last Step
description: Check your issue form
options:
- label: I confirm I have attached the network diagnosis report archive in the issue
required: true

31
.github/ISSUE_TEMPLATE/MGMT-publish.yml vendored Normal file
View File

@@ -0,0 +1,31 @@
name: Publish Process
description: FOR ADMIN USE ONLY. WILL CAUSE A BAN IF NO PERMISSION.
title: "[Publish]: Version 1.9.98"
labels: ["Publish"]
assignees:
- Lightczx
body:
- type: textarea
id: main-body
attributes:
label: Publish Process
value: |
## 创建版本
- [ ] 同步一次 [Crowdin](https://crowdin.com/project/snap-hutao) 翻译
- [ ] 发布 RC 版本Optional
- [ ] 合并入主分支
- [ ] 整理更新内容,等待翻译
- [ ] 在 [Snap.Hutao.Docs@next-patch](https://github.com/DGP-Studio/Snap.Hutao.Docs/tree/next-patch) 分支更新文档并直接开 PR
- [ ] 更新日志
- [ ] 功能文档更新
- type: checkboxes
id: checklist-final
attributes:
label: Final Check
description: Understand what you are doing
options:
- label: I understand that I will get banned from repository if I don't have permission to use this template
required: true

14
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@@ -0,0 +1,14 @@
blank_issues_enabled: false
contact_links:
- name: Snap Hutao 官方文档 / Snap Hutao Document
url: https://hut.ao
about: 请在提出问题前阅读文档 / Read the document before submit the issue
- name: 常见问题 / FAQ
url: https://hut.ao/advanced/FAQ.html
about: 常见的用户提出的问题 / Common questions asked by users
- name: 常见程序异常 / Common Program Exceptions
url: https://hut.ao/advanced/exceptions.html
about: 用户通常能自行解决这些问题 / Users may solve these problems by themselves

13
.github/ISSUE_TEMPLATE/task.yml vendored Normal file
View File

@@ -0,0 +1,13 @@
name: 内部任务
description: 此Issue模板仅用于创建内部任务非 DGP Studio 成员请勿使用
title: "[Task]: 在这里填写一个合适的标题"
type: "Task"
labels: ["priority:none"]
body:
- type: textarea
id: content
attributes:
label: 背景与动机
description: 添加相关的说明
validations:
required: true

156
.github/copilot-instructions.md vendored Normal file
View File

@@ -0,0 +1,156 @@
Your task is to “onboard” this repository to the Copilot coding agent by adding this .github/copilot-instructions.md file. It gives the agent the minimum, durable context it needs to understand the project, validate changes, and open mergeable PRs.
These instructions are repository-wide and task-agnostic. If something here contradicts ad-hoc guidance in an issue or PR, prefer the ad-hoc guidance for that task.
<Goals>
- Keep generated PRs mergeable by aligning with repository conventions; build and packaging validation will be performed by GitHub Actions.
- Minimize broken shell or PowerShell steps by pinning prerequisites and the order of operations.
- Reduce unnecessary codebase exploration by pointing to the right files and patterns first.
</Goals>
<Limitations>
- Do not include issue-specific plans or debugging transcripts.
- Keep guidance concise (≈2 pages). Link to existing scripts or configs in-repo rather than inlining them.
- Localization policy: Base language is Chinese (Simplified). English is also maintained by the core team; all other languages are community-contributed via Crowdin. If a PR introduces new UI strings, only add the new strings to the Chinese resource file at src/Snap.Hutao/Snap.Hutao/Resource/Localization/SH.resx. Do not edit any other locale files (including English) in that PR; leave them untranslated.
</Limitations>
---
## High-level overview
- What this is. Snap Hutao (胡桃工具箱) is a C# WinUI 3 desktop application packaged as MSIX. It is an open-source toolkit that enhances the Genshin Impact experience on Windows without modifying the game client.
- Target OS. Runs on Windows 11 (22H2+) and Windows 10 22H2 with the January 2025 update. Agent work should assume a modern, fully updated Windows dev box.
- Key tech. The lastest .NET and Windows App SDK / WinUI 3 (XAML), GitHub Actions CI, analyzers such as StyleCop, and validation utilities such as Microsoft.VisualStudio.Validation (see usage policy below).
- License and scope. MIT. The app integrates official game data and community features; it must not introduce destructive client modifications.
Rule of thumb: Prefer Visual Studio 2022 for packaging or signing workflows. Use the .NET SDK CLI for restore, build, and test where practical.
---
## Repository layout (what to look for first)
- Top level
- .github — issue templates and workflows; this file lives here.
- res — assets and miscellaneous resources.
- src/Snap.Hutao — the solution root for the desktop app (primary code lives here).
- Build and CI configuration in the root (for example build.cake, NuGet.Config, CI YAML).
- Inside src/Snap.Hutao
- Solution: Snap.Hutao.sln (primary).
- Main app project: Snap.Hutao (WinUI 3 XAML and C#).
- Common folders you will work in:
- UI (XAML views, controls) and ViewModel (MVVM presentation).
- Service (application and business services; network, storage, background work).
- Model (domain and data models).
- Core and Extension (infrastructure, helpers, extensions).
- Web (HTTP or API integrations) and Win32 (interop).
- Important config:
- App.xaml and App.xaml.cs (app startup and resources), Package.appxmanifest (MSIX).
- .editorconfig, stylecop.json, GlobalUsing.cs, BannedSymbols.txt (coding standards and guardrails).
Search shortcuts: Package.appxmanifest for capabilities or identity, stylecop.json for style rules, GlobalUsing.cs for shared namespaces, *.xaml plus ViewModel for MVVM entry points.
---
## Branching and PR policy (follow strictly)
- Work on develop for feature and bug-fix branches; target PRs to develop.
- CI builds main, develop, and feat/* branches. Alpha artifacts may be produced by CI for testing.
- Link issues with closing keywords in PR descriptions when appropriate, for example `Fixes #123`.
---
## Prerequisites (Windows only)
1) Windows: Windows 11 22H2+ or Windows 10 22H2 with the latest updates. Enable Developer Mode.
2) Visual Studio 2022 with workloads:
- .NET desktop development
- Desktop development with C++
- Windows application development
3) MSIX tooling: Single-project MSIX Packaging Tools for Visual Studio 2022 if your VS installation does not include it.
4) SDK policy: Always target the latest .NET SDK. Do not downgrade SDK versions or LangVersion.
5) Optional runtime UX: WebView2 Runtime, Segoe Fluent Icons font, MSVC Runtime if required by features.
If the agent runs headless, prefer CLI restore, build, and test for validation and rely on CI to produce MSIX artifacts.
---
## Build, run, and validate (minimal, reliable sequence)
Use this order on a clean clone. Local build is recommended for rapid feedback but not required; GitHub Actions will perform the authoritative validation.
1) Restore
dotnet restore src/Snap.Hutao/Snap.Hutao.sln
2) Build (Debug)
dotnet build src/Snap.Hutao/Snap.Hutao.sln -c Debug
Expect WinUI 3 XAML compilation and analyzer checks. Fix analyzer violations before proposing changes.
3) Run for development
- Open src/Snap.Hutao/Snap.Hutao.sln in Visual Studio 2022.
- Set the main project as startup, select x64, press F5. Packaged debugging will register the app locally.
4) Package when needed
- Use Visual Studio Publish or Package for MSIX.
- CI may also produce Alpha packages for main, develop, or feat/* branches. Local install of CI-signed packages can require installing the provided certificate.
5) Tests (if present)
dotnet test src/Snap.Hutao/Snap.Hutao.sln
Add or update tests for non-UI logic when you change behavior.
Common validation before opening a PR:
- Solution builds cleanly and analyzer warnings are resolved per repository policy.
- App starts in Debug; smoke-test the feature you touched.
- Do not change Package.appxmanifest capabilities unless required by the task and documented in the PR.
---
## Coding style and contribution patterns
- MVVM: Put UI behavior in ViewModels. Use async APIs for I/O and keep the UI thread responsive.
- Consistency first: Mirror existing folder structure, naming, and patterns. Prefer existing services/helpers over new global/singleton patterns.
- Analyzers: Fix StyleCop and other analyzer diagnostics. Follow rules set in .editorconfig / stylecop.json (naming, docs, layout).
- Validation & errors: Use established guard/validation utilities; fail fast on bad inputs; handle network/storage exceptions gracefully.
- XAML: Reuse existing styles/resources; keep bindings simple and observable; avoid UI thread blocking.
- Security & privacy: Dont log secrets or game tokens; follow existing storage conventions.
---
## Localization and strings (enforced)
- Base language is Chinese (Simplified). English is maintained by the core team; other languages are translated by the community via Crowdin.
- When adding new UI strings in a PR, only add them to the Chinese resource file:
src/Snap.Hutao/Snap.Hutao/Resource/Localization/SH.resx
- Do not create or modify any other locale resource files (including English) in that PR; leave them untranslated. The core team and Crowdin will handle downstream updates.
- Prefer resource bindings over hard-coded strings. Reuse existing keys where possible; introduce new keys only when needed and name them consistently.
---
## Where to implement changes (quick map)
- New UI feature → UI (XAML) plus ViewModel (presentation) plus Service (logic or data) plus Model (types).
- Network or API work → Web (HTTP clients, DTOs) plus relevant Service.
- Interop → Win32 (P/Invoke or wrappers). Follow precedent conservatively to avoid regressions.
- Cross-cutting → Core and Extension for helpers, dependency injection, and reusable infrastructure.
---
## CI interaction (what the agent should expect)
- Pushes to feature branches trigger build checks; some branches produce Alpha artifacts.
- Build and packaging validation is performed by GitHub Actions and is the source of truth.
- If CI fails on analyzers or formatting, align code with the repositorys rules rather than suppressing diagnostics.
- Keep local steps minimal and deterministic; rely on CI for signing and distribution.
---
## Agent operating guidelines
- Trust this file first. Explore or run extra commands only if information is missing or build errors indicate a mismatch.
- Do not downgrade SDKs or language level. Avoid changing packaging or signing settings unless the task explicitly requires it.
- Keep edits scoped. Touch the smallest set of files; update tests or docs alongside code when behavior changes.
- PR hygiene. Use clear commit messages, link issues with keywords, and summarize the validation steps you performed such as build, tests, and manual smoke checks.
---

20
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,20 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "nuget"
directory: "/src/Snap.Hutao" # Snap.Hutao.csproj
target-branch: "develop"
schedule:
interval: "weekly"
groups:
packages:
patterns:
- "*"
- package-ecosystem: "github-actions"
directory: "/.github/workflows" # GitHub Workflows
schedule:
interval: "weekly"

15
.github/pull_request_template.md vendored Normal file
View File

@@ -0,0 +1,15 @@
<!--- Hi, thanks for considering make a PR contribution to Snap Hutao, we appreciate your work. -->
<!--- Before you create this PR, please check our contribution guide (https://hut.ao/en/development/contribute.html) and fill out the following form and checklist -->
## Description
<!--- Describe your changes -->
## Related Issue
<!--- If there's an associated issue, please use [GitHub Keyword](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests) to link it -->
<!-- e.g. fix #999, resolve #999, close #999 -->
## Checklist
- [ ] The target PR branch is `develop` branch

View File

@@ -0,0 +1,73 @@
name: PublishDistribution
on:
release:
types: [released]
workflow_dispatch:
jobs:
Publish:
runs-on: ubuntu-latest
steps:
# Purge Patch System Cache
- name: Purge Patch
env:
PURGE_URL: ${{ secrets.PURGE_URL }}
run: |
curl -X PATCH $PURGE_URL
- name: Overwrite CN patch mirrors
shell: pwsh
run: |
$latestRelease = Invoke-RestMethod -Uri "https://api.github.com/repos/DGP-Studio/Snap.Hutao/releases/latest"
$asset = $latestRelease.assets[0]
$assetUrl = "https://ghproxy.qhy04.cc/" + $asset.browser_download_url
$tagName = $latestRelease.tag_name
Write-Output "Waiting Patch API to update"
while ($true) {
$patchData = Invoke-RestMethod -Uri "https://api.snapgenshin.com/patch/hutao"
$cachedVersion = $patchData.data.version.Substring(0, $patchData.data.version.Length - 2)
if ($cachedVersion -eq $tagName) {
break
}
Start-Sleep -Seconds 3
}
Write-Output "Add GitHub Proxy to Patch API"
$mirrorData = @{
key = "snap-hutao"
url = $assetUrl
mirror_name = "GitHub Proxy"
mirror_type = "direct"
} | ConvertTo-Json
$response1 = Invoke-WebRequest -Uri "https://api.snapgenshin.com/patch/mirror" `
-Method POST `
-Headers @{"API-Token" = "${{ secrets.OVERWRITE_TOKEN }}"} `
-Body $mirrorData `
-ContentType "application/json"
Write-Output $response1.Content
Write-Output "Add R2 to Patch API"
$r2Url = "https://hutao-dist.qhy04.cc/$($asset.name)"
$r2Data = @{
key = "snap-hutao"
url = $r2Url
mirror_name = "Cloudflare R2"
mirror_type = "direct"
} | ConvertTo-Json
$response2 = Invoke-WebRequest -Uri "https://api.snapgenshin.com/patch/mirror" `
-Method POST `
-Headers @{"API-Token" = "${{ secrets.OVERWRITE_TOKEN }}"} `
-Body $r2Data `
-ContentType "application/json"
Write-Output $response2.Content
- uses: benc-uk/workflow-dispatch@v1.2.4
with:
workflow: Build
repo: DGP-Studio/hutao-installer
ref: main
token: "${{ secrets.RUNNER_CHECK_TOKEN }}"
inputs: '{ "only-offline": true }'

139
.github/workflows/alpha.yml vendored Normal file
View File

@@ -0,0 +1,139 @@
name: Snap Hutao Alpha
on:
workflow_dispatch:
push:
branches: [ develop ]
paths-ignore:
- '.gitattributes'
- '.github/**'
- '.gitignore'
- '.gitmodules'
- '**.md'
- 'LICENSE'
- '**.yml'
pull_request:
branches: [ develop ]
paths-ignore:
- '.gitattributes'
- '.github/**'
- '.gitignore'
- '.gitmodules'
- '**.md'
- 'LICENSE'
- '**.yml'
- '**.resx'
jobs:
select-runner:
runs-on: ubuntu-latest
outputs:
runner: ${{ steps.select_runner.outputs.runner }}
steps:
- name: Select runner
id: select_runner
shell: bash
env:
ORG: ${{ github.repository_owner }}
REPO: ${{ github.repository }}
TOKEN: ${{ secrets.RUNNER_CHECK_TOKEN }}
LABEL: ${{ vars.RUNNER_LABEL || 'sjc1' }}
run: |
set -o pipefail
FALLBACK="windows-latest"
get_status_by_label () {
local url="$1"
local json
json=$(curl -fsSL \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $TOKEN" \
"$url" 2>/dev/null || true)
jq -r --arg label "$LABEL" '
(.runners // [])
| map(select(any(.labels[]?; .name==$label)))
| .[0].status // ""' <<<"$json" 2>/dev/null || echo ""
}
# Check org's runner first and then repo's
STATUS="$(get_status_by_label "https://api.github.com/orgs/${ORG}/actions/runners?per_page=100")"
if [ -z "$STATUS" ]; then
STATUS="$(get_status_by_label "https://api.github.com/repos/${REPO}/actions/runners?per_page=100")"
fi
if [ "$STATUS" = "online" ]; then
PICK="$LABEL"
else
PICK="$FALLBACK"
fi
echo "Selected runner: $PICK (label=$LABEL, status=${STATUS:-unknown})"
echo "runner=$PICK" >> "$GITHUB_OUTPUT"
build:
needs: select-runner
runs-on: ${{ needs.select-runner.outputs.runner }}
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup .NET (self-hosted)
if: ${{ needs.select-runner.outputs.runner == 'sjc1' }}
shell: pwsh
run: |
Write-Host "Running environment setup script…"
Invoke-WebRequest `
-Uri 'https://raw.githubusercontent.com/DGP-Studio/Snap.Hutao.DevelopEnvironment.Setup/refs/heads/main/setup.ps1' `
-OutFile 'setup.ps1' `
-UseBasicParsing
Write-Host "Executing setup.ps1"
.\setup.ps1
- name: Setup .NET
if: ${{ needs.select-runner.outputs.runner == 'windows-latest' }}
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0
- name: Cache NuGet packages
if: ${{ needs.select-runner.outputs.runner == 'windows-latest' }}
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/Snap.Hutao.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Cake
id: cake
shell: pwsh
run: dotnet tool restore && dotnet cake
env:
VERSION_API_TOKEN: ${{ secrets.VERSION_API_TOKEN }}
CERTIFICATE: ${{ secrets.CERTIFICATE }}
PW: ${{ secrets.PW }}
- name: Upload signed msix
if: success() && github.event_name != 'pull_request'
uses: actions/upload-artifact@v5
with:
name: Snap.Hutao.Alpha-${{ steps.cake.outputs.version }}
path: ${{ github.workspace }}/src/output/Snap.Hutao.Alpha-${{ steps.cake.outputs.version }}.msix
- name: Add summary
if: success() && github.event_name != 'pull_request'
shell: pwsh
run: |
$summary = "
> [!WARNING]
> 该版本是由 CI 程序自动打包生成的 `Alpha` 测试版本,包含已经基本完工的新功能及问题修复
> [!IMPORTANT]
> 请先安装 **[DGP_Studio_CA.crt](https://github.com/DGP-Automation/Hutao-Auto-Release/releases/download/certificate-ca/DGP_Studio_CA.crt)** 到 **受信任的根证书颁发机构** 以安装测试版安装包
"
echo $summary >> $Env:GITHUB_STEP_SUMMARY
- name: Clean up
shell: pwsh
run: |
Write-Host "Cleaning up NuGet cache..."
Remove-Item -Recurse -Force "$env:USERPROFILE\.nuget\packages"
Write-Host "NuGet cache cleaned."

97
.github/workflows/canary.yml vendored Normal file
View File

@@ -0,0 +1,97 @@
name: Snap Hutao Canary
on:
workflow_dispatch:
push:
branches-ignore:
- l10n_develop
- main
- release
- dependabot/**
paths-ignore:
- '.gitattributes'
- '.github/**'
- '.gitignore'
- '.gitmodules'
- '**.md'
- 'LICENSE'
- '**.yml'
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v5
with:
ref: develop
fetch-depth: 0
- name: Merge all branches into develop locally
id: merge
run: |
$continue = $true
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git fetch origin '+refs/heads/*:refs/remotes/origin/*'
git checkout origin/develop
$response = curl -s https://api.github.com/repos/DGP-Studio/Snap.Hutao/pulls?state=open
$refs = $response | ConvertFrom-Json | Where-Object { $_.draft -eq $false } | ForEach-Object { $_.head.ref }
if ($refs.Count -eq 0 -or ($refs.Count -eq 1 -and $refs -eq "l10n_develop")) {
echo "No PRs to merge"
$continue = $false
echo "continue=$continue" >> $Env:GITHUB_OUTPUT
exit
}
foreach ($ref in $refs) {
echo "Merging $ref into develop"
git merge "origin/$ref" --strategy=ort --allow-unrelated-histories -m "Merge $ref into develop"
}
echo "continue=$continue" >> $Env:GITHUB_OUTPUT
- name: Setup .NET
if: ${{ steps.merge.outputs.continue == 'true' }}
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0
- name: Cache NuGet packages
if: ${{ steps.merge.outputs.continue == 'true' }}
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/Snap.Hutao.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Cake
if: ${{ steps.merge.outputs.continue == 'true' }}
id: cake
shell: pwsh
run: dotnet tool restore && dotnet cake
env:
CERTIFICATE: ${{ secrets.CERTIFICATE }}
PW: ${{ secrets.PW }}
- name: Upload signed msix
if: ${{ success() && steps.merge.outputs.continue == 'true' }}
uses: actions/upload-artifact@v5
with:
name: Snap.Hutao.Canary-${{ steps.cake.outputs.version }}
path: ${{ github.workspace }}/src/output/Snap.Hutao.Canary-${{ steps.cake.outputs.version }}.msix
- name: Add summary
if: ${{ success() && steps.merge.outputs.continue == 'true' }}
shell: pwsh
run: |
$summary = "
> [!WARNING]
> 该版本是由 CI 程序自动打包生成的 `Canary` 测试版本,包含新功能原型及问题修复
> [!IMPORTANT]
> 请先安装 **[DGP_Studio_CA.crt](https://github.com/DGP-Automation/Hutao-Auto-Release/releases/download/certificate-ca/DGP_Studio_CA.crt)** 到 **受信任的根证书颁发机构** 以安装测试版安装包
"
echo $summary >> $Env:GITHUB_STEP_SUMMARY

16
.github/workflows/close_stale.yml vendored Normal file
View File

@@ -0,0 +1,16 @@
name: 'Close stale issues and PRs'
on:
schedule:
- cron: '30 1 * * *'
jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v10
with:
any-of-labels: 'needs-more-info,需要更多信息'
stale-issue-message: 'This issue is stale because it has been open 7 days with no activity. Remove stale label or comment or this will be closed in 3 days.'
days-before-stale: 7
days-before-close: 3
close-issue-reason: not_planned

20
.github/workflows/issue_similarity.yml vendored Normal file
View File

@@ -0,0 +1,20 @@
name: Issues Similarity Analysis
on:
issues:
types: [opened, edited]
jobs:
similarity-analysis:
runs-on: ubuntu-latest
steps:
- name: analysis
uses: actions-cool/issues-similarity-analysis@v1
with:
filter-threshold: 0.5
comment-title: '### Probable Similar Topics'
title-excludes: '[Publish]:,[Bug]:,[Feat]:,[Network]:,[ENG]'
comment-body: '${index}. ${similarity} #${number}'
show-footer: false
show-mentioned: true
since-days: 365

View File

@@ -0,0 +1,26 @@
name: 'Lock Threads'
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
permissions:
issues: write
pull-requests: write
discussions: write
concurrency:
group: lock-threads
jobs:
action:
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v5
with:
issue-inactive-days: '30'
issue-comment: 'This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related topic.'
issue-lock-reason: 'resolved'
process-only: 'issues'
log-output: false