mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-04-24 16:27:23 +08:00
🔧 chore: 优化网页端下载程序功能
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
export default {
|
export default {
|
||||||
installApp: {
|
installApp: {
|
||||||
description: 'Install the application on the desktop for a better experience',
|
description: 'Install the application for a better experience',
|
||||||
noPrompt: 'Do not prompt again',
|
noPrompt: 'Do not prompt again',
|
||||||
install: 'Install now',
|
install: 'Install now',
|
||||||
cancel: 'Cancel',
|
cancel: 'Cancel',
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
export default {
|
export default {
|
||||||
installApp: {
|
installApp: {
|
||||||
description: '在桌面安装应用,获得更好的体验',
|
description: '安装应用程序,获得更好的体验',
|
||||||
noPrompt: '不再提示',
|
noPrompt: '不再提示',
|
||||||
install: '立即安装',
|
install: '立即安装',
|
||||||
cancel: '暂不安装',
|
cancel: '暂不安装',
|
||||||
|
|||||||
@@ -45,8 +45,7 @@
|
|||||||
import { onMounted, ref } from 'vue';
|
import { onMounted, ref } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
import { isElectron, isMobile } from '@/utils';
|
import { isElectron } from '@/utils';
|
||||||
import { getLatestReleaseInfo, getProxyNodes } from '@/utils/update';
|
|
||||||
|
|
||||||
import config from '../../../../package.json';
|
import config from '../../../../package.json';
|
||||||
|
|
||||||
@@ -54,7 +53,6 @@ const { t } = useI18n();
|
|||||||
|
|
||||||
const showModal = ref(false);
|
const showModal = ref(false);
|
||||||
const noPrompt = ref(false);
|
const noPrompt = ref(false);
|
||||||
const releaseInfo = ref<any>(null);
|
|
||||||
|
|
||||||
const closeModal = () => {
|
const closeModal = () => {
|
||||||
showModal.value = false;
|
showModal.value = false;
|
||||||
@@ -63,11 +61,9 @@ const closeModal = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const proxyHosts = ref<string[]>([]);
|
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
// 如果是 electron 环境,不显示安装提示
|
// 如果是 electron 环境,不显示安装提示
|
||||||
if (isElectron || isMobile.value) {
|
if (isElectron) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,58 +72,11 @@ onMounted(async () => {
|
|||||||
if (isDismissed) {
|
if (isDismissed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取最新版本信息
|
|
||||||
releaseInfo.value = await getLatestReleaseInfo();
|
|
||||||
showModal.value = true;
|
showModal.value = true;
|
||||||
proxyHosts.value = await getProxyNodes();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleInstall = async (): Promise<void> => {
|
const handleInstall = async (): Promise<void> => {
|
||||||
const assets = releaseInfo.value?.assets || [];
|
window.open('http://donate.alger.fun/download', '_blank');
|
||||||
const { userAgent } = navigator;
|
|
||||||
const isMac = userAgent.toLowerCase().includes('mac');
|
|
||||||
const isWindows = userAgent.toLowerCase().includes('win');
|
|
||||||
const isLinux = userAgent.toLowerCase().includes('linux');
|
|
||||||
const isX64 =
|
|
||||||
userAgent.includes('x86_64') || userAgent.includes('Win64') || userAgent.includes('WOW64');
|
|
||||||
|
|
||||||
let downloadUrl = '';
|
|
||||||
|
|
||||||
// 根据平台和架构选择对应的安装包
|
|
||||||
if (isMac) {
|
|
||||||
// macOS
|
|
||||||
const macAsset = assets.find((asset) => asset.name.includes('mac'));
|
|
||||||
downloadUrl = macAsset?.browser_download_url || '';
|
|
||||||
} else if (isWindows) {
|
|
||||||
// Windows
|
|
||||||
let winAsset = assets.find(
|
|
||||||
(asset) =>
|
|
||||||
asset.name.includes('win') &&
|
|
||||||
(isX64 ? asset.name.includes('x64') : asset.name.includes('ia32'))
|
|
||||||
);
|
|
||||||
if (!winAsset) {
|
|
||||||
winAsset = assets.find((asset) => asset.name.includes('win.exe'));
|
|
||||||
}
|
|
||||||
downloadUrl = winAsset?.browser_download_url || '';
|
|
||||||
} else if (isLinux) {
|
|
||||||
// Linux
|
|
||||||
const linuxAsset = assets.find(
|
|
||||||
(asset) =>
|
|
||||||
(asset.name.endsWith('.AppImage') || asset.name.endsWith('.deb')) &&
|
|
||||||
asset.name.includes('x64')
|
|
||||||
);
|
|
||||||
downloadUrl = linuxAsset?.browser_download_url || '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (downloadUrl) {
|
|
||||||
const proxyDownloadUrl = `${proxyHosts.value[0]}/${downloadUrl}`;
|
|
||||||
window.open(proxyDownloadUrl, '_blank');
|
|
||||||
} else {
|
|
||||||
// 如果没有找到对应的安装包,跳转到 release 页面
|
|
||||||
window.open('https://github.com/algerkong/AlgerMusicPlayer/releases/latest', '_blank');
|
|
||||||
}
|
|
||||||
closeModal();
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user