Conversation
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.
Summary / 概述
This PR refactors the detection module by splitting the monolithic
detectors.jsfile into separate platform-specific detection modules. Each special platform detector now has its own dedicated file, improving code organization and maintainability.Related Issue / 关联 Issue
N/A
Type of Change / 更改类型
Changes Made / 更改内容
packages/detection/src/detectors.js(644 lines) - monolithic file containing all special detectorspackages/detection/src/platforms/:alipay.js(94 lines) - Alipay Open platform detection with cache strategyaliyun.js(24 lines) - Aliyun Developer platform detectionelecfans.js(40 lines) - Elecfans platform detection with cookie-based authhuaweicloud.js(50 lines) - Huawei Cloud detection with CSRF token handlinghuaweidev.js(51 lines) - Huawei Developer platform detectionmedium.js(38 lines) - Medium platform detection with regex parsingqianfan.js(24 lines) - Baidu Qianfan platform detectionsohu.js(31 lines) - Sohu (搜狐号) platform detectionsspai.js(26 lines) - Sspai (少数派) platform with JWT tokentencentcloud.js(37 lines) - Tencent Cloud Developer platformtwitter.js(38 lines) - Twitter/X platform detectionwechat.js(104 lines) - WeChat Official Account with caching and multi-strategy detectionweibo.js(90 lines) - Weibo platform with complex cookie handlingxiaohongshu.js(64 lines) - Xiaohongshu (Little Red Book) with long-term cachingpackages/detection/src/detect.js(64 changes):detectors.jsPLATFORM_DETECTORSmap to use explicit imports instead of dynamic property accessImplementation Details / 实现细节
Key Changes / 主要更改:
File-per-Platform Architecture: Each special platform detector is now isolated in its own file:
Explicit Imports: Changed from
import * as specialDetectors from './detectors.js'to individual named imports:Consistent Module Structure: Each platform detector follows the same pattern:
detect{Platform}User(){ loggedIn, username?, avatar? }objectDetection Strategies Preserved:
Technical Notes / 技术说明:
Testing / 测试
Testing Checklist / 测试清单
Manual Testing Steps / 手动测试步骤
Reviewer Checklist / 审阅者清单
Additional Notes / 补充说明
This refactoring improves the codebase structure by: