1
0
forked from um/web

#19 Add Download Type: Origin Filename

This commit is contained in:
MengYX 2020-02-23 13:45:30 +08:00
parent 9fd7177ebb
commit 984b549448
No known key found for this signature in database
GPG Key ID: E63F9C7303E8F604
2 changed files with 12 additions and 9 deletions

View File

@ -7,10 +7,10 @@
<el-row id="app-control"> <el-row id="app-control">
<el-row style="padding-bottom: 1em; font-size: 14px"> <el-row style="padding-bottom: 1em; font-size: 14px">
歌曲命名格式 歌曲命名格式
<el-radio name="format" v-model="download_format" label="1">歌曲名</el-radio> <el-radio label="1" name="format" v-model="download_format">歌手-歌曲名</el-radio>
<el-radio name="format" v-model="download_format" label="2">歌手-歌曲名</el-radio> <el-radio label="2" name="format" v-model="download_format">歌曲名</el-radio>
<el-radio name="format" v-model="download_format" label="3">歌曲名-歌手</el-radio> <el-radio label="3" name="format" v-model="download_format">歌曲名-歌手</el-radio>
<el-checkbox v-model="instant_download" border>立即保存</el-checkbox> <el-radio label="4" name="format" v-model="download_format">同原文件名</el-radio>
</el-row> </el-row>
<el-row> <el-row>
<el-button @click="handleDownloadAll" icon="el-icon-download" plain>下载全部</el-button> <el-button @click="handleDownloadAll" icon="el-icon-download" plain>下载全部</el-button>
@ -65,7 +65,7 @@
tableData: [], tableData: [],
playing_url: "", playing_url: "",
playing_auto: false, playing_auto: false,
download_format: '2', download_format: '1',
instant_download: false, instant_download: false,
} }
}, },

View File

@ -2,16 +2,19 @@ export function DownloadBlobMusic(data, format) {
const a = document.createElement('a'); const a = document.createElement('a');
a.href = data.file; a.href = data.file;
switch (format) { switch (format) {
case "1":
a.download = data.title + "." + data.ext;
break;
default: default:
case "2": case "1":
a.download = data.artist + " - " + data.title + "." + data.ext; a.download = data.artist + " - " + data.title + "." + data.ext;
break; break;
case "2":
a.download = data.title + "." + data.ext;
break;
case "3": case "3":
a.download = data.title + " - " + data.artist + "." + data.ext; a.download = data.title + " - " + data.artist + "." + data.ext;
break; break;
case "4":
a.download = data.rawFilename + "." + data.ext;
break;
} }
document.body.append(a); document.body.append(a);
a.click(); a.click();