Skip to content

feat: 添加地理位置检查工具以优化资源下载源选择#60

Open
WingChunWong wants to merge 9 commits intoCFPAOrg:mainfrom
WingChunWong:feature/geo-detect
Open

feat: 添加地理位置检查工具以优化资源下载源选择#60
WingChunWong wants to merge 9 commits intoCFPAOrg:mainfrom
WingChunWong:feature/geo-detect

Conversation

@WingChunWong
Copy link
Copy Markdown

@WingChunWong WingChunWong commented Mar 4, 2026

What's Changed:

  1. 添加地理位置检测
  2. 将 Github 移出镜像列表
  3. 根据检测到的地理位置选择下载源

具体思路:

graph TD
    A[检测地理位置] --> B[中国大陆]
    A --> C[非中国大陆]
    B --> D[葫芦]
    B --> E[镜像源]
    D --> F[测速]
    E --> F[测速]
    F --> G[选择最快的]
    C --> H[直接使用 Github]
    G --> I[下载]
    H --> I[下载]

Loading

由 AI 修改,并在本地测试
resolve #59

Copilot's Summary This pull request introduces geographic-based source selection for asset downloads by detecting if the user is in mainland China and adjusting the asset mirror list accordingly. It adds a new utility class for location detection, updates the mirror selection logic, and improves logging and fallback behavior.

Geographic source selection and location detection:

  • Added a new LocationDetectUtil class to determine if the user is in mainland China using external geo-IP APIs, with result caching and fallback logic. (src/main/java/i18nupdatemod/util/LocationDetectUtil.java)
  • Updated AssetUtil.getFastestUrl() to use LocationDetectUtil.isMainlandChina() to select different asset sources: domestic mirrors and the legacy root for users in China, or GitHub for users elsewhere. (src/main/java/i18nupdatemod/util/AssetUtil.java)

Mirror management and logging:

  • Removed GitHub from the default MIRRORS list and instead added it as a separate constant, only used for overseas users. (src/main/java/i18nupdatemod/util/AssetUtil.java)
  • Enhanced logging in getFastestUrl() to indicate which source list is being used and to clarify fallback behavior when all sources fail. (src/main/java/i18nupdatemod/util/AssetUtil.java) [1] [2]

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.

关于自动选择下载源

1 participant