mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 23:16:52 +08:00
@ -18,7 +18,7 @@ export const PLATFORMS_MAP = {
|
||||
export type Platforms = keyof typeof PLATFORMS_MAP;
|
||||
|
||||
export function getPlatforms(win: any) {
|
||||
return win.Ionic.platforms;
|
||||
return setupPlatforms(win);
|
||||
}
|
||||
|
||||
export function isPlatform(win: Window, platform: Platforms) {
|
||||
@ -26,12 +26,15 @@ export function isPlatform(win: Window, platform: Platforms) {
|
||||
}
|
||||
|
||||
export function setupPlatforms(win: any) {
|
||||
win.Ionic = win.Ionic || {};
|
||||
|
||||
let platforms: string[] = win.Ionic.platforms;
|
||||
if (platforms == null) {
|
||||
platforms = win.Ionic.platforms = detectPlatforms(win);
|
||||
const classList = win.document.documentElement.classList;
|
||||
platforms.forEach(p => classList.add(`plt-${p}`));
|
||||
}
|
||||
return platforms;
|
||||
}
|
||||
|
||||
function detectPlatforms(win: Window): string[] {
|
||||
|
||||
Reference in New Issue
Block a user