|
11 | 11 | el-button(:disabled="file.state !== 'progressing'", :plain="true", type="danger", size="mini", icon="circle-close", @click="cancelDownload(file.startTime)")
|
12 | 12 | el-button(:disabled="file.state === 'cancelled'", :plain="true", type="info", size="mini", icon="document", @click="showItemInFolder(file.savePath)")
|
13 | 13 | li(class="download-list__item", slot="reference")
|
14 |
| - a(class="download-list__item-name", :href="`${file.url}`") |
15 |
| - i(class="el-icon-document") {{ file.name }} |
| 14 | + div(class="download-list__item-panel") |
| 15 | + a(class="download-list__item-name", href='#', @click.prevent="openItem(file.savePath)") |
| 16 | + i(class="el-icon-document") {{ file.name }} |
| 17 | + span(class="download-list__item-description") {{ file.state === 'progressing' ? `${prettyReceivedSize(file.getReceivedBytes)}/${file.totalSize}`: file.state }} |
16 | 18 | el-progress(:status="checkStateForProgress(file.state)", type="circle", :percentage="percentage(file)", :width="30", :stroke-width="3", class="download-list__item-progress")
|
17 | 19 | span#download-bar-close(class="el-icon-close", @click="closeDownloadBar")
|
18 | 20 | </template>
|
|
22 | 24 |
|
23 | 25 | import '../../css/el-progress';
|
24 | 26 | import '../../css/el-popover';
|
| 27 | + import prettySize from '../../js/lib/prettysize'; |
25 | 28 |
|
26 | 29 | export default {
|
27 | 30 | components: {
|
|
32 | 35 | },
|
33 | 36 | computed: {
|
34 | 37 | files() {
|
35 |
| - // eslint-disable-next-line arrow-body-style |
36 |
| - return this.$store.getters.downloads.filter((download) => { |
37 |
| - return download.style !== 'hidden'; |
38 |
| - }); |
| 38 | + let tmpFiles = []; |
| 39 | + if (this.$store.getters.downloads.length !== 0) { |
| 40 | + // eslint-disable-next-line arrow-body-style |
| 41 | + tmpFiles = this.$store.getters.downloads.filter((download) => { |
| 42 | + return download.style !== 'hidden'; |
| 43 | + }); |
| 44 | + tmpFiles.forEach((file) => { |
| 45 | + file.totalSize = prettySize.process(file.totalBytes); |
| 46 | + }); |
| 47 | + } |
| 48 | + return tmpFiles; |
39 | 49 | },
|
40 | 50 | },
|
41 | 51 | methods: {
|
| 52 | + prettyReceivedSize(size) { |
| 53 | + return prettySize.process(size); |
| 54 | + }, |
42 | 55 | percentage(file) {
|
43 | 56 | return parseInt((file.getReceivedBytes / file.totalBytes) * 100, 10) || 0;
|
44 | 57 | },
|
45 | 58 | showItemInFolder(savePath) {
|
46 | 59 | this.$electron.ipcRenderer.send('show-item-in-folder', savePath);
|
47 | 60 | },
|
| 61 | + openItem(savePath) { |
| 62 | + this.$electron.ipcRenderer.send('open-item', savePath); |
| 63 | + }, |
48 | 64 | checkStateForButtonGroup(state) {
|
49 | 65 | switch (state) {
|
50 | 66 | case 'cancelled':
|
|
143 | 159 | align-items: center;
|
144 | 160 | justify-content: space-around;
|
145 | 161 | }
|
| 162 | + .download-list__item-panel { |
| 163 | + display: flex; |
| 164 | + flex-direction: column; |
| 165 | + } |
146 | 166 | .download-list__item-name {
|
147 | 167 | color: #48576a;
|
148 | 168 | padding-left: 4px;
|
|
154 | 174 | text-overflow: ellipsis;
|
155 | 175 | width: 160px;
|
156 | 176 | }
|
| 177 | + .download-list__item-description { |
| 178 | + font-size: 13px; |
| 179 | + } |
157 | 180 | .download-list__item-progress {
|
158 | 181 | right: 0;
|
159 | 182 | }
|
|
0 commit comments