支持原生鸿蒙UA,否则纯血鸿蒙手机下_isMobile 返回非预期的 false#5569
Open
mayunhai wants to merge 1 commit intodcloudio:nextfrom
Open
Conversation
举例说明:
Mozilla/5.0 (Phone; OpenHarmony 5.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 ArkWeb/4.1.6.1 Mobile
```javascript
// iphone return true
/android|phone/i.test('mozilla/5.0 (iphone; cpu iphone os 16_6 like mac os x) applewebkit/605.1.15 (khtml, like gecko) version/16.6 mobile/15e148 safari/604.1')
// openharmony return true
/android|phone/i.test('mozilla/5.0 (phone; openharmony 5.0) applewebkit/537.36 (khtml, like gecko) chrome/114.0.0.0 safari/537.36 arkweb/4.1.6.1 mobile')
```
Member
|
这个是广告服务内的逻辑,鸿蒙侧你们在使用了吗? |
|
|
||
| _isMobile () { | ||
| return /android|iphone/i.test(navigator.userAgent.toLowerCase()) | ||
| return /android|phone/i.test(navigator.userAgent.toLowerCase()) |
There was a problem hiding this comment.
The call to toLowerCase() is redundant because the regex already uses the case-insensitive flag 'i'. Consider removing .toLowerCase() to simplify the code.
Suggested change
| return /android|phone/i.test(navigator.userAgent.toLowerCase()) | |
| return /android|phone/i.test(navigator.userAgent) |
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.
举例说明:
Mozilla/5.0 (Phone; OpenHarmony 5.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 ArkWeb/4.1.6.1 Mobile