123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- /**
- * 应用商店渠道检测工具
- */
-
- // 应用商店渠道配置
- 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
- };
|