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) { ...@@ -168,13 +168,16 @@ function download(url, fileName, cb) {
response.on("data", function(chunk) { response.on("data", function(chunk) {
partiallength += chunk.length //adds each time partiallength += chunk.length //adds each time
if (partiallength / totallength != 1) { let decimallength = partiallength / totallength
win.setProgressBar(partiallength / totallength) //sets progress bar to decimal if (decimallength != 1) {
win.setProgressBar(decimallength) //sets progress bar to decimal
win.webContents.send("downloadProgress", decimallength)
} }
else { else {
win.setProgressBar(0) //sets progress bar to blank when done 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); response.pipe(file);
......
...@@ -18,14 +18,14 @@ ...@@ -18,14 +18,14 @@
<div class="artist">{{ item.artist }}</div> <div class="artist">{{ item.artist }}</div>
</div> </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> </div>
</div> </div>
</template> </template>
<script> <script>
import { remote, ipcMain } from 'electron'; import { remote, ipcRenderer } from 'electron';
const { shell } = remote; const { shell } = remote;
export default { export default {
...@@ -34,9 +34,8 @@ ...@@ -34,9 +34,8 @@
'downloadQueue' 'downloadQueue'
], ],
mounted: function(){ mounted: function(){
this.$electron.ipcMain.on('downloadProgress', (decimal) => { ipcRenderer.on('downloadProgress', (event, data) => {
this.$data.downloadProgress = decimal; this.$data.downloadProgress = data
console.log(this.$data.downloadProgress)
}); });
}, },
data: function() { 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