mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-04-03 14:20:50 +08:00
✨ feat: 修改更新检查功能
This commit is contained in:
@@ -200,5 +200,10 @@ ipcMain.on('get-store-value', (_, key) => {
|
|||||||
_.returnValue = value || '';
|
_.returnValue = value || '';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 添加 IPC 处理程序
|
||||||
|
ipcMain.on('get-arch', (event) => {
|
||||||
|
event.returnValue = process.arch;
|
||||||
|
});
|
||||||
|
|
||||||
// In this file you can include the rest of your app"s specific main process
|
// In this file you can include the rest of your app"s specific main process
|
||||||
// code. You can also put them in separate files and require them here.
|
// code. You can also put them in separate files and require them here.
|
||||||
|
|||||||
@@ -97,10 +97,41 @@ const checkForUpdates = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleUpdate = async () => {
|
const handleUpdate = async () => {
|
||||||
const downloadUrl = updateInfo.value.releaseInfo?.assets[0]?.browser_download_url;
|
const assets = updateInfo.value.releaseInfo?.assets || [];
|
||||||
|
const platform = window.electron.process.platform;
|
||||||
|
const arch = window.electron.ipcRenderer.sendSync('get-arch');
|
||||||
|
console.log(arch);
|
||||||
|
console.log(platform);
|
||||||
|
|
||||||
|
let downloadUrl = '';
|
||||||
|
|
||||||
|
// 根据平台和架构选择对应的安装包
|
||||||
|
if (platform === 'darwin') {
|
||||||
|
// macOS
|
||||||
|
const macAsset = assets.find(asset =>
|
||||||
|
asset.name.includes('mac')
|
||||||
|
);
|
||||||
|
downloadUrl = macAsset?.browser_download_url || '';
|
||||||
|
} else if (platform === 'win32') {
|
||||||
|
// Windows
|
||||||
|
const winAsset = assets.find(asset =>
|
||||||
|
asset.name.includes('win') &&
|
||||||
|
(arch === 'x64' ? asset.name.includes('x64') : asset.name.includes('ia32'))
|
||||||
|
);
|
||||||
|
downloadUrl = winAsset?.browser_download_url || '';
|
||||||
|
} else if (platform === 'linux') {
|
||||||
|
// 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) {
|
if (downloadUrl) {
|
||||||
window.open(downloadUrl, '_blank');
|
window.open(downloadUrl, '_blank');
|
||||||
} else {
|
} else {
|
||||||
|
// 如果没有找到对应的安装包,跳转到 release 页面
|
||||||
window.open('https://github.com/algerkong/AlgerMusicPlayer/releases/latest', '_blank');
|
window.open('https://github.com/algerkong/AlgerMusicPlayer/releases/latest', '_blank');
|
||||||
}
|
}
|
||||||
closeModal();
|
closeModal();
|
||||||
|
|||||||
Reference in New Issue
Block a user