feat(mirror-redirect): 收敛主站与 x 站的镜像通道判定为 createMirrorRedirect - #2
Open
cc-hearts wants to merge 2 commits into
Open
feat(mirror-redirect): 收敛主站与 x 站的镜像通道判定为 createMirrorRedirect#2cc-hearts wants to merge 2 commits into
cc-hearts wants to merge 2 commits into
Conversation
…rorRedirect antdv-next site and x site each maintained their own geo-redirect logic and diverged after only one side was hardened. Add a configurable single implementation: local signal scoring, GeoIP fallback chain, cn-site reachability probe, preference memory with TTL, debug/opt-out switches, plus isMirrorHost for mirror-host matching (ICP footer).
cc-hearts
force-pushed
the
feat/mirror-redirect
branch
from
September 7, 2026 07:35
4726e2a to
11e0c6b
Compare
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.
🤔 本次变更属于 ...
🔗 相关 Issue
无(由 docs-plugins 仓库内讨论直接提出)。
💡 背景与方案
antdv-next 主站(
docs/src/utils/geo-redirect.ts,约 324 行)与 x 站(packages/docs/src/utils/geo-redirect.ts,约 149 行)各自维护一份"国内访问 →.cn镜像站"的判定逻辑,后续加固只发生在主站一侧(本地信号打分、GeoIP 回退、可达性探测、偏好记忆、调试 / 豁免开关等),两份实现逐渐分叉。本 PR 将判定逻辑收敛为按站点配置实例化的单一实现,两站差异只由配置表达:
createMirrorRedirect及MirrorRedirectOptions/MirrorRedirect/MirrorRedirectDecision/MirrorRedirectPreference/HostnameMatcher/GeoIpApi-cn路径,港/澳/台否决)、rejected30 天 TTL、GeoIP 回退链、提示 / 跳转前probeUrl可达性探测(可选)、?cn-redirect=off单次豁免、localStorage.DEBUG调试开关、兼容旧版纯字符串偏好'cn-suffix'(/→/index-cn,同主站toCnPathname语义)、'same'(同 x 站)与自定义函数mirror.isMirrorHost(hostname):判断主机是否属于镜像站部署(如仅在.cn镜像站展示 ICP 备案),默认由mirrorOrigin推导匹配规则站点侧接入时删除各自
utils/geo-redirect.ts,改为配置实例化并保留各自弹窗 / 文案(两个站点弹窗方式不同:Modal.useModal与useAppContext),行为差异收敛为配置差异。📝 变更日志
createMirrorRedirect: a single configurable implementation for detecting mainland-China visitors and switching them to the.cnmirror site — local signal scoring, GeoIP fallback chain, cn-site reachability probe, preference memory with TTL, debug and opt-out switches — plusisMirrorHostfor mirror-host matching.createMirrorRedirect:将"国内访问 →.cn镜像站"的判定与跳转收敛为按站点配置实例化的单一实现(语言 / 时区 / 路径本地信号打分、GeoIP 回退链、镜像站可达性探测、偏好记忆与 TTL、调试与豁免开关),并新增isMirrorHost用于镜像站部署判断(如 ICP 备案展示)。