Skip to content

Commit

Permalink
mobile增加识别鸿蒙系统 (#2571)
Browse files Browse the repository at this point in the history
由于鸿蒙系统的User-Agent如下
Mozilla/5.0 (Phone; OpenHarmony5.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 ArkWeb/4.1.6.1 Mobile
导致目前登录显示desktop
  • Loading branch information
xiaobingtech authored Nov 18, 2024
1 parent fff5728 commit 02c6ad8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion back/config/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,14 @@ export function getPlatform(userAgent: string): 'mobile' | 'desktop' {
system = 'android'; // android系统
} else if (testUa(/ios|iphone|ipad|ipod|iwatch/g)) {
system = 'ios'; // ios系统
} else if (testUa(/openharmony/g)) {
system = 'openharmony'; // openharmony系统
}

let platform = 'desktop';
if (system === 'windows' || system === 'macos' || system === 'linux') {
platform = 'desktop';
} else if (system === 'android' || system === 'ios' || testUa(/mobile/g)) {
} else if (system === 'android' || system === 'ios' || system === 'openharmony' || testUa(/mobile/g)) {
platform = 'mobile';
}

Expand Down

0 comments on commit 02c6ad8

Please sign in to comment.