update: download page

main
Mack 2 weeks ago
parent 52c589ef0b
commit c5d305d4e3

@ -1 +1,2 @@
NEXT_PUBLIC_HOST = 'https://api.indie.cn' NEXT_PUBLIC_HOST = 'https://api.indie.cn'
NEXT_PUBLIC_APP_PACKAGE_NAME = 'cn.luoo.indiemusic'

@ -21,6 +21,7 @@ export default function Download() {
useEffect(() => { useEffect(() => {
document.title = '雀乐-下载'; document.title = '雀乐-下载';
if (!inWX) handleDownload();
}, []); }, []);
return ( return (

@ -1,7 +1,5 @@
// 安卓包名 // 获取内置浏览器类型
// const APK_NAME = 'cn.luoo.indiemusic'; export const getBuiltInBrowserType = () => {
export const isBuiltIn = () => {
const ua = window?.navigator?.userAgent?.toLowerCase(); const ua = window?.navigator?.userAgent?.toLowerCase();
if (ua.match(/MicroMessenger/i)?.[0] === 'micromessenger') { if (ua.match(/MicroMessenger/i)?.[0] === 'micromessenger') {
return 'weixin'; return 'weixin';
@ -15,25 +13,25 @@ export const isBuiltIn = () => {
export const verifyBrand = () => { export const verifyBrand = () => {
const userAgent = window?.navigator?.userAgent?.toLowerCase(); const userAgent = window?.navigator?.userAgent?.toLowerCase();
const isIphone = userAgent.match(/(iphone|ipad|ipod)/i); const isApple = userAgent.match(/(iphone|ipad|ipod)/i);
const isHuawei = userAgent.match(/huawei/i); // const isHuawei = userAgent.match(/huawei/i);
const isHonor = userAgent.match(/honor/i); // const isHonor = userAgent.match(/honor/i);
const isOppo = userAgent.match(/oppo/i); // const isOppo = userAgent.match(/oppo/i);
const isOppoR15 = userAgent.match(/PACM00/i); // const isOppoR15 = userAgent.match(/PACM00/i);
const isVivo = userAgent.match(/vivo/i); // const isVivo = userAgent.match(/vivo/i);
const isXiaomi = userAgent.match(/mi\s/i); const isXiaomi = userAgent.match(/mi\s/i);
const isXIAOMI = userAgent.match(/xiaomi/i); const isXIAOMI = userAgent.match(/xiaomi/i);
const isXiaomi2s = userAgent.match(/mix\s/i); const isXiaomi2s = userAgent.match(/mix\s/i);
const isRedmi = userAgent.match(/redmi/i); const isRedmi = userAgent.match(/redmi/i);
if (isIphone) { if (isApple) {
return 'iphone'; return 'apple';
} else if (isHuawei || isHonor) { // } else if (isHuawei || isHonor) {
return 'huawei'; // return 'huawei';
} else if (isOppo || isOppoR15) { // } else if (isOppo || isOppoR15) {
return 'oppo'; // return 'oppo';
} else if (isVivo) { // } else if (isVivo) {
return 'vivo'; // return 'vivo';
} else if (isXiaomi || isRedmi || isXiaomi2s || isXIAOMI) { } else if (isXiaomi || isRedmi || isXiaomi2s || isXIAOMI) {
return 'xiaomi'; return 'xiaomi';
} else { } else {
@ -41,50 +39,37 @@ export const verifyBrand = () => {
} }
}; };
export const download = () => { const appMarketUrlList: Record<string, string> = {
window.open('https://a.app.qq.com/o/simple.jsp?pkgname=cn.luoo.indiemusic', '_blank'); xiaomi: `mimarket://details?id=${process.env.NEXT_PUBLIC_APP_PACKAGE_NAME}`,
return; huawei: `appmarket://details?id=${process.env.NEXT_PUBLIC_APP_PACKAGE_NAME}`,
// if (isBuiltIn()) { vivo: `vivomarket://details?id=${process.env.NEXT_PUBLIC_APP_PACKAGE_NAME}`,
// // 内置浏览器 可加提示使其打开手机自带浏览器 oppo: `oppomarket://details?packagename=${process.env.NEXT_PUBLIC_APP_PACKAGE_NAME}`,
// return; apple: `https://apps.apple.com/app/%E9%9B%80%E4%B9%90/id6478897923`,
// } other: `https://a.app.qq.com/o/simple.jsp?pkgname=${process.env.NEXT_PUBLIC_APP_PACKAGE_NAME}`,
const iosLinkUrl = 'https://apps.apple.com/app/%E9%9B%80%E4%B9%90/id6478897923'; };
// const iosLinkUrl = 'itms-apps://itunes.apple.com/app/id6478897923';
const androidLinkurl = 'https://cdn2.indie.cn/indie/queyue.apk'; // 唤起雀乐 APP
// const huaweiUrl = `appmarket://details?id=${APK_NAME}`; // export const openApp = (url: string, callback: () => void) => {
// const oppoUrl = `oppomarket://details?packagename=${APK_NAME}`; // let timer: NodeJS.Timeout | null = null;
// const vivoUrl = `vivomarket://details?id=${APK_NAME}`; // window.location.href = url;
// const xiaomiUrl = `mimarket://details?id=${APK_NAME}`;
// switch (verifyBrand()) { // if (timer) clearTimeout(timer);
// case 'iphone': // timer = setTimeout(function () {
// window.location.href = iosLinkUrl; // callback && callback();
// break; // }, 3000);
// case 'xiaomi':
// window.location.href = xiaomiUrl; // document.addEventListener('visibilitychange', () => {
// break; // clearTimeout(timer);
// case 'huawei': // });
// window.location.href = huaweiUrl; // };
// break;
// case 'vivo': export const openAppMarket = () => {
// window.location.href = vivoUrl; window.location.href = appMarketUrlList[verifyBrand() as keyof typeof appMarketUrlList];
// break; };
// case 'oppo':
// window.location.href = oppoUrl; export const download = async () => {
// break; // 唤起雀乐 APP
// default: // openApp('queyue://', () => openAppMarket());
// window.location.href = androidLinkurl;
// break; openAppMarket();
// }
switch (verifyBrand()) {
case 'iphone':
// window.location.href = iosLinkUrl;
window.open(iosLinkUrl, '_blank');
break;
default:
if (!isBuiltIn()) {
// window.location.href = androidLinkurl;
window.open(androidLinkurl, '_blank');
}
break;
}
}; };

Loading…
Cancel
Save