Commit 76cf1416 authored by Amy Yan's avatar Amy Yan

download bar now works

parent b596b408
......@@ -168,13 +168,16 @@ function download(url, fileName, cb) {
response.on("data", function(chunk) {
partiallength += chunk.length //adds each time
if (partiallength / totallength != 1) {
win.setProgressBar(partiallength / totallength) //sets progress bar to decimal
let decimallength = partiallength / totallength
if (decimallength != 1) {
win.setProgressBar(decimallength) //sets progress bar to decimal
win.webContents.send("downloadProgress", decimallength)
}
else {
win.setProgressBar(0) //sets progress bar to blank when done
win.webContents.send("downloadProgress", 0)
}
ipcMain.emit("downloadProgress", partiallength / totallength) //emits decimal for download
});
response.pipe(file);
......
......@@ -18,14 +18,14 @@
<div class="artist">{{ item.artist }}</div>
</div>
</div>
<div class="progress-bar" v-if="index == 0" :style="{ width: downloadProgress * 100 + 'px' }"></div>
<div class="progress-bar" v-if="index == 0" :style="{ width: downloadProgress * 100 + '%' }"></div>
</div>
</div>
</div>
</template>
<script>
import { remote, ipcMain } from 'electron';
import { remote, ipcRenderer } from 'electron';
const { shell } = remote;
export default {
......@@ -34,9 +34,8 @@
'downloadQueue'
],
mounted: function(){
this.$electron.ipcMain.on('downloadProgress', (decimal) => {
this.$data.downloadProgress = decimal;
console.log(this.$data.downloadProgress)
ipcRenderer.on('downloadProgress', (event, data) => {
this.$data.downloadProgress = data
});
},
data: function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment