I18nUpdateMod3 icon indicating copy to clipboard operation
I18nUpdateMod3 copied to clipboard

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

Open ChouChiu opened this issue 8 months ago • 0 comments

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[下载]


由 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]

ChouChiu avatar Mar 04 '26 13:03 ChouChiu