update: download page

main
Mack 2 weeks ago
parent 52c589ef0b
commit c5d305d4e3

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

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

@ -1,7 +1,5 @@
// 安卓包名
// const APK_NAME = 'cn.luoo.indiemusic';
export const isBuiltIn = () => {
// 获取内置浏览器类型
export const getBuiltInBrowserType = () => {
const ua = window?.navigator?.userAgent?.toLowerCase();
if (ua.match(/MicroMessenger/i)?.[0] === 'micromessenger') {
return 'weixin';
@ -15,25 +13,25 @@ export const isBuiltIn = () => {
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 isApple = 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';
if (isApple) {
return 'apple';
// } 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 {
@ -41,50 +39,37 @@ export const verifyBrand = () => {
}
};
export const download = () => {
window.open('https://a.app.qq.com/o/simple.jsp?pkgname=cn.luoo.indiemusic', '_blank');
return;
// if (isBuiltIn()) {
// // 内置浏览器 可加提示使其打开手机自带浏览器
// return;
// }
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';
// 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;
// }
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;
}
const appMarketUrlList: Record<string, string> = {
xiaomi: `mimarket://details?id=${process.env.NEXT_PUBLIC_APP_PACKAGE_NAME}`,
huawei: `appmarket://details?id=${process.env.NEXT_PUBLIC_APP_PACKAGE_NAME}`,
vivo: `vivomarket://details?id=${process.env.NEXT_PUBLIC_APP_PACKAGE_NAME}`,
oppo: `oppomarket://details?packagename=${process.env.NEXT_PUBLIC_APP_PACKAGE_NAME}`,
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}`,
};
// 唤起雀乐 APP
// export const openApp = (url: string, callback: () => void) => {
// let timer: NodeJS.Timeout | null = null;
// window.location.href = url;
// if (timer) clearTimeout(timer);
// timer = setTimeout(function () {
// callback && callback();
// }, 3000);
// document.addEventListener('visibilitychange', () => {
// clearTimeout(timer);
// });
// };
export const openAppMarket = () => {
window.location.href = appMarketUrlList[verifyBrand() as keyof typeof appMarketUrlList];
};
export const download = async () => {
// 唤起雀乐 APP
// openApp('queyue://', () => openAppMarket());
openAppMarket();
};

Loading…
Cancel
Save