parent
cd4487c102
commit
b264af3265
@ -1,9 +1,75 @@
|
||||
import { Hosting } from '@/utils/ua';
|
||||
// 安卓包名
|
||||
const APK_NAME = 'cn.luoo.indiemusic';
|
||||
|
||||
// 下载
|
||||
export const download = () => {
|
||||
export const isBuiltIn = () => {
|
||||
const ua = window?.navigator?.userAgent?.toLowerCase();
|
||||
if (!Hosting.isWX(ua)) {
|
||||
window.open('//cdn.indie.cn/release/queyue.apk', '__blank');
|
||||
if (ua.match(/MicroMessenger/i)?.[0] === 'micromessenger') {
|
||||
return 'weixin';
|
||||
} else if (ua.match(/QQ/i)?.[0] === 'qq') {
|
||||
return 'QQ';
|
||||
} else if (ua.match(/Alipay/i)?.[0] === 'alipay') {
|
||||
return 'alipay';
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
export const verifyBrand = () => {
|
||||
const userAgent = window?.navigator?.userAgent?.toLowerCase();
|
||||
const isIphone = userAgent.match(/(iphone|ipad|ipod)/i);
|
||||
const isHuawei = userAgent.match(/huawei/i);
|
||||
const isHonor = userAgent.match(/honor/i);
|
||||
const isOppo = userAgent.match(/oppo/i);
|
||||
const isOppoR15 = userAgent.match(/PACM00/i);
|
||||
const isVivo = userAgent.match(/vivo/i);
|
||||
const isXiaomi = userAgent.match(/mi\s/i);
|
||||
const isXIAOMI = userAgent.match(/xiaomi/i);
|
||||
const isXiaomi2s = userAgent.match(/mix\s/i);
|
||||
const isRedmi = userAgent.match(/redmi/i);
|
||||
|
||||
if (isIphone) {
|
||||
return 'iphone';
|
||||
} else if (isHuawei || isHonor) {
|
||||
return 'huawei';
|
||||
} else if (isOppo || isOppoR15) {
|
||||
return 'oppo';
|
||||
} else if (isVivo) {
|
||||
return 'vivo';
|
||||
} else if (isXiaomi || isRedmi || isXiaomi2s || isXIAOMI) {
|
||||
return 'xiaomi';
|
||||
} else {
|
||||
return 'other';
|
||||
}
|
||||
};
|
||||
|
||||
export const download = () => {
|
||||
if (isBuiltIn()) {
|
||||
// 内置浏览器 可加提示使其打开手机自带浏览器
|
||||
return;
|
||||
}
|
||||
const iosLinkUrl = ''; // TODO:
|
||||
const androidLinkurl = '//cdn.indie.cn/release/queyue.apk';
|
||||
const huaweiUrl = `appmarket://details?id=${APK_NAME}`;
|
||||
const oppoUrl = `oppomarket://details?packagename=${APK_NAME}`;
|
||||
const vivoUrl = `vivomarket://details?id=${APK_NAME}`;
|
||||
const xiaomiUrl = `mimarket://details?id=${APK_NAME}`;
|
||||
switch (verifyBrand()) {
|
||||
case 'iphone':
|
||||
window.location.href = iosLinkUrl;
|
||||
break;
|
||||
case 'xiaomi':
|
||||
window.location.href = xiaomiUrl;
|
||||
break;
|
||||
case 'huawei':
|
||||
window.location.href = huaweiUrl;
|
||||
break;
|
||||
case 'vivo':
|
||||
window.location.href = vivoUrl;
|
||||
break;
|
||||
case 'oppo':
|
||||
window.location.href = oppoUrl;
|
||||
break;
|
||||
default:
|
||||
window.location.href = androidLinkurl;
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in new issue