added download progress bar to taskbar
This commit is contained in:
parent
761ad12dba
commit
898742b9f0
@ -49,7 +49,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
<button v-for="result in adnSearchResults" @click="selectShow(result)" class="flex flex-row gap-3 px-3 py-3 hover:bg-[#747474] rounded-xl h-20">
|
<button v-for="result in adnSearchResults" @click="selectShow(result)" class="flex flex-row gap-3 px-3 py-3 hover:bg-[#747474] rounded-xl h-20">
|
||||||
{{ result.languages }}
|
|
||||||
<div class="min-w-10 w-10 h-14 bg-gray-700">
|
<div class="min-w-10 w-10 h-14 bg-gray-700">
|
||||||
<img :src="result.image2x" alt="Image Banner" class="h-full w-full object-cover" />
|
<img :src="result.image2x" alt="Image Banner" class="h-full w-full object-cover" />
|
||||||
</div>
|
</div>
|
||||||
|
@ -12,6 +12,7 @@ import { finished } from 'stream/promises'
|
|||||||
import Ffmpeg from 'fluent-ffmpeg'
|
import Ffmpeg from 'fluent-ffmpeg'
|
||||||
import { adnGetM3U8Playlist, adnGetPlaylist } from '../adn/adn.service'
|
import { adnGetM3U8Playlist, adnGetPlaylist } from '../adn/adn.service'
|
||||||
import { ADNEpisode } from '../../types/adn'
|
import { ADNEpisode } from '../../types/adn'
|
||||||
|
import { setProgressBar } from '../../../electron/background'
|
||||||
const ffmpegPath = require('ffmpeg-static').replace('app.asar', 'app.asar.unpacked')
|
const ffmpegPath = require('ffmpeg-static').replace('app.asar', 'app.asar.unpacked')
|
||||||
const ffprobePath = require('ffprobe-static').path.replace('app.asar', 'app.asar.unpacked')
|
const ffprobePath = require('ffprobe-static').path.replace('app.asar', 'app.asar.unpacked')
|
||||||
|
|
||||||
@ -103,6 +104,30 @@ export async function getDownloading(id: number) {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateProgress(): void {
|
||||||
|
const totalParts = downloading.reduce((total, item) => total + item.partsToDownload, 0);
|
||||||
|
let downloadedParts = 0;
|
||||||
|
|
||||||
|
downloading.forEach((item) => {
|
||||||
|
downloadedParts += item.downloadedParts;
|
||||||
|
});
|
||||||
|
|
||||||
|
const progress = totalParts > 0 ? downloadedParts / totalParts : 0;
|
||||||
|
|
||||||
|
setProgressBar(progress);
|
||||||
|
|
||||||
|
const allDownloaded = downloading.every((item) => item.downloadedParts === item.partsToDownload);
|
||||||
|
|
||||||
|
if (allDownloaded) {
|
||||||
|
setProgressBar(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cron.schedule('*/2 * * * * *', () => {
|
||||||
|
updateProgress()
|
||||||
|
})
|
||||||
|
|
||||||
// Define IsDownloading Count
|
// Define IsDownloading Count
|
||||||
var isDownloading: number = 0
|
var isDownloading: number = 0
|
||||||
|
|
||||||
|
@ -15,10 +15,11 @@ const platform: 'darwin' | 'win32' | 'linux' = process.platform as any
|
|||||||
const architucture: '64' | '32' = os.arch() === 'x64' ? '64' : '32'
|
const architucture: '64' | '32' = os.arch() === 'x64' ? '64' : '32'
|
||||||
const headerSize = 32
|
const headerSize = 32
|
||||||
const modules = [titleBarActionsModule, macMenuModule, updaterModule]
|
const modules = [titleBarActionsModule, macMenuModule, updaterModule]
|
||||||
|
var mainWindow: BrowserWindow;
|
||||||
|
|
||||||
function createWindow() {
|
function createWindow() {
|
||||||
console.log('System info', { isProduction, platform, architucture })
|
console.log('System info', { isProduction, platform, architucture })
|
||||||
const mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
title: 'Crunchyroll Downloader',
|
title: 'Crunchyroll Downloader',
|
||||||
icon: __dirname + '/icon/favicon.ico',
|
icon: __dirname + '/icon/favicon.ico',
|
||||||
width: 950,
|
width: 950,
|
||||||
@ -134,6 +135,12 @@ export async function messageBox(
|
|||||||
console.log(response)
|
console.log(response)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function setProgressBar(
|
||||||
|
c: number
|
||||||
|
) {
|
||||||
|
mainWindow.setProgressBar(c)
|
||||||
|
}
|
||||||
|
|
||||||
ipcMain.handle('dialog:openDirectory', async () => {
|
ipcMain.handle('dialog:openDirectory', async () => {
|
||||||
const window = BrowserWindow.getFocusedWindow()
|
const window = BrowserWindow.getFocusedWindow()
|
||||||
|
|
||||||
@ -157,14 +164,13 @@ ipcMain.handle('dialog:defaultDirectory', async () => {
|
|||||||
|
|
||||||
if (!savedPath) {
|
if (!savedPath) {
|
||||||
const path = app.getPath('documents')
|
const path = app.getPath('documents')
|
||||||
|
|
||||||
await settings.set('downloadPath', path)
|
await settings.set('downloadPath', path)
|
||||||
|
|
||||||
return path
|
return path
|
||||||
}
|
}
|
||||||
|
|
||||||
return savedPath
|
return savedPath
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// Quit when all windows are closed, except on macOS. There, it's common
|
// Quit when all windows are closed, except on macOS. There, it's common
|
||||||
|
Reference in New Issue
Block a user