/** * 应用商店渠道检测工具 */ // 应用商店渠道配置 const STORE_CONFIG = { vivo: { channel: 'vivo', name: 'VIVO', package: 'com.vivo.appstore' }, oppo: { channel: 'oppo', name: 'OPPO', package: 'com.oppo.market' }, huawei: { channel: 'huawei', name: '华为应用商店', package: 'com.huawei.appmarket' }, honor: { channel: 'honor', name: '荣耀', package: 'com.hihonor.appmarket' }, yyb: { channel: 'yyb', name: '应用宝', package: 'com.tencent.android.qqdownloader' }, xiaomi: { channel: 'xiaomi', name: '小米应用商店', package: 'com.xiaomi.market' }, appstore: { channel: 'appstore', name: 'App Store', package: 'com.apple.AppStore' }, none: { channel: 'none', name: '无', package: '' }, googleplay: { channel: 'googleplay', name: 'Google Play(AAB)', package: 'com.android.vending' }, wandoujia: { channel: 'wandoujia', name: '豌豆荚', package: 'com.wandoujia.phoenix2' }, shichangbu: { channel: 'shichangbu', name: '市场部', package: '' }, _360: { channel: '360', name: '360应用市场', package: 'com.qihoo.appstore' }, default: { channel: 'default', name: '默认渠道', package: '' } }; // 获取当前应用商店信息 export function getCurrentStore() { let store = STORE_CONFIG.default; // #ifdef APP-PLUS const systemInfo = uni.getSystemInfoSync(); if (systemInfo.platform === 'ios') { store = STORE_CONFIG.appstore; } else { const channel = plus.runtime.channel; if (channel && STORE_CONFIG[channel]) { store = STORE_CONFIG[channel]; } } // #endif return store; } // 获取当前应用商店名称 export function getCurrentStoreName() { return getCurrentStore().name; } // 判断是否为特定应用商店 export function isStore(targetStore) { return getCurrentStore().channel === targetStore; } // 判断是否为应用商店渠道 export function isAppStore() { const currentStore = getCurrentStore(); return currentStore.channel !== 'default'; } export default { getCurrentStore, getCurrentStoreName, isStore, isAppStore };