The only downloader you need. 下载器的集大成者。
TypeScript asyncasynciobittorentbtcross-platformdownload-managerdownloaderfluent-designftphttp3magnetpyqtpyside6pythonqtquicreactsoftwarestreaming
refactor(app): 更改接收到浏览器任务弹窗的音效
XiaoYouChRf50ea07f4b7e
diff --git a/app/common/download_task.py b/app/common/download_task.pyindex 0746d952..4933162f 100644--- a/app/common/download_task.py+++ b/app/common/download_task.py@@ -248,14 +248,14 @@ class DownloadTask(QThread):WorkingRangeHeaders = self.headers.copy()async with worker.client.stream(url=self.url, headers=WorkingRangeHeaders, timeout=30,method="GET") as res:- async for chunk in res.aiter_bytes(): # aiter_content 的单位是字节, 即每64K写一次文件+ async for chunk in res.aiter_bytes():if chunk:await self.file.seek(worker.progress)await self.file.write(chunk)_ = len(chunk)worker.progress += _- cfg.globalSpeed += _ # B 转 KB+ cfg.globalSpeed += _if cfg.speedLimitation.value:if cfg.globalSpeed >= cfg.speedLimitation.value:await asyncio.sleep(1) # 在锁里面睡,只阻塞 worker, 不阻塞 supervisordiff --git a/app/view/pop_up_window.py b/app/view/pop_up_window.pyindex 6a93577a..3c7a1d00 100644--- a/app/view/pop_up_window.py+++ b/app/view/pop_up_window.py@@ -113,7 +113,7 @@ class PopUpWindowBase(QWidget, Ui_PopUpWindow):super().showEvent(event)- def __playSound(self):+ def _playSound(self):# 设置音效self.soundEffect = QSoundEffect(self)self.soundEffect.setSource(QUrl.fromLocalFile(r":/res/completed_task.wav"))@@ -122,7 +122,7 @@ class PopUpWindowBase(QWidget, Ui_PopUpWindow):def __moveIn(self):- self.__playSound()+ self._playSound()if not hasattr(self, "geometryAnimation"):self.geometryAnimation = QPropertyAnimation(self, b"geometry")@@ -244,6 +244,13 @@ class ReceivedPopUpWindow(PopUpWindowBase):self.show()+ def _playSound(self):+ # 设置音效+ self.soundEffect = QSoundEffect(self)+ self.soundEffect.setSource(QUrl.fromLocalFile(r":/res/received_info.wav"))+ self.soundEffect.setVolume(100)+ self.soundEffect.play()+@classmethoddef showPopUpWindow(cls, receiveContent:str, mainWindow=None):return cls(receiveContent, mainWindow)