| 123456789101112131415161718192021222324252627 |
- /**
- * 获取当前运行平台信息
- * @returns {{isPC: boolean, isMobile: boolean, platform: string}}
- */
- export function getPlatformInfo() {
- try {
- const info = uni.getSystemInfoSync();
- const platform = info.platform.toLowerCase();
-
- const isPC = platform === 'windows' || platform === 'mac';
- const isMobile = platform === 'ios' || platform === 'android';
-
- return {
- isPC,
- isMobile,
- platform
- };
- } catch (e) {
- // 发生错误时,默认返回移动端信息或错误状态
- console.error('getPlatformInfo error:', e);
- return {
- isPC: false,
- isMobile: true, // 默认或降级处理
- platform: 'unknown'
- };
- }
- }
|