web/src/App.vue

181 lines
7.3 KiB
Vue
Raw Normal View History

2019-07-03 14:50:04 +00:00
<template>
2020-02-06 08:01:35 +00:00
<el-container id="app">
<el-main>
2021-05-24 14:19:37 +00:00
<file-selector @error="showFail" @success="showSuccess"/>
2020-02-06 08:01:35 +00:00
<div id="app-control">
<el-row class="mb-3">
<span>歌曲命名格式</span>
2020-02-23 05:45:30 +00:00
<el-radio label="1" name="format" v-model="download_format">歌手-歌曲名</el-radio>
<el-radio label="2" name="format" v-model="download_format">歌曲名</el-radio>
<el-radio label="3" name="format" v-model="download_format">歌曲名-歌手</el-radio>
<el-radio label="4" name="format" v-model="download_format">同原文件名</el-radio>
</el-row>
2020-02-23 05:41:39 +00:00
<el-row>
<el-button @click="handleDownloadAll" icon="el-icon-download" plain>下载全部</el-button>
<el-button @click="handleDeleteAll" icon="el-icon-delete" plain type="danger">清除全部</el-button>
<el-tooltip class="item" effect="dark" placement="top-start">
<div slot="content">
当您使用此工具进行大量文件解锁的时候建议开启此选项<br/>
开启后解锁结果将不会存留于浏览器中防止内存不足
</div>
<el-checkbox border class="ml-2" v-model="instant_download">立即保存</el-checkbox>
</el-tooltip>
2020-02-23 05:41:39 +00:00
</el-row>
</div>
2020-02-06 08:01:35 +00:00
<audio :autoplay="playing_auto" :src="playing_url" controls/>
2021-05-24 14:19:37 +00:00
<PreviewTable :filename_format="download_format" :table-data="tableData"
@music_changed="changePlaying"></PreviewTable>
2020-02-06 08:01:35 +00:00
</el-main>
<el-footer id="app-footer">
<el-row>
2021-05-24 14:19:37 +00:00
<a href="https://github.com/ix64/unlock-music" target="_blank">音乐解锁</a>
(v{{ version }})移除已购音乐的加密保护
2020-02-06 08:01:35 +00:00
<a href="https://github.com/ix64/unlock-music/wiki/使用提示" target="_blank">使用提示</a>
</el-row>
<el-row>
2020-07-16 14:29:06 +00:00
目前支持网易云音乐(ncm), QQ音乐(qmc, mflac, mgg), 酷狗音乐(kgm), 虾米音乐(xm), 酷我音乐(.kwm)
<a href="https://github.com/ix64/unlock-music/blob/master/README.md" target="_blank">更多</a>
2020-02-23 05:41:39 +00:00
</el-row>
<el-row>
2020-07-16 14:29:06 +00:00
<!--如果进行二次开发此行版权信息不得移除且应明显地标注于页面上-->
2021-05-24 14:19:37 +00:00
<span>Copyright &copy; 2019 - {{ (new Date()).getFullYear() }} MengYX</span>
2020-02-06 08:01:35 +00:00
音乐解锁使用
<a href="https://github.com/ix64/unlock-music/blob/master/LICENSE" target="_blank">MIT许可协议</a>
2020-02-23 05:41:39 +00:00
开放源代码
2020-02-06 08:01:35 +00:00
</el-row>
</el-footer>
</el-container>
2019-07-03 14:50:04 +00:00
</template>
<script>
2020-02-06 08:01:35 +00:00
2021-05-24 14:19:37 +00:00
import FileSelector from "./component/FileSelector"
import PreviewTable from "./component/PreviewTable"
import {DownloadBlobMusic, RemoveBlobMusic} from "./component/utils"
import config from "../package"
import {IXAREA_API_ENDPOINT} from "@/decrypt/utils";
2021-05-24 14:19:37 +00:00
export default {
name: 'app',
components: {
FileSelector,
PreviewTable
},
data() {
return {
version: config.version,
activeIndex: '1',
tableData: [],
playing_url: "",
playing_auto: false,
download_format: '1',
instant_download: false,
}
},
created() {
this.$nextTick(function () {
this.finishLoad();
});
},
methods: {
async finishLoad() {
const mask = document.getElementById("loader-mask");
if (!!mask) mask.remove();
let updateInfo;
try {
const resp = await fetch(IXAREA_API_ENDPOINT + "/music/app-version", {
method: "POST", headers: {"Content-Type": "application/json"},
body: JSON.stringify({"Version": this.version})
});
updateInfo = await resp.json();
} catch (e) {
}
2021-05-24 14:19:37 +00:00
if ((!!updateInfo && process.env.NODE_ENV === 'production') && (!!updateInfo.HttpsFound ||
(!!updateInfo.Found && window.location.protocol !== "https:"))) {
this.$notify.warning({
title: '发现更新',
message: '发现新版本 v' + updateInfo.Version +
'<br/>更新详情:' + updateInfo.Detail +
'<br/><a target="_blank" href="' + updateInfo.URL + '">获取更新</a>',
dangerouslyUseHTMLString: true,
duration: 15000,
position: 'top-left'
2021-05-24 14:19:37 +00:00
});
} else {
this.$notify.info({
title: '离线使用',
message: '我们使用PWA技术无网络也能使用' +
'<br/>最近更新:' + config.updateInfo +
'<br/><a target="_blank" href="https://github.com/ix64/unlock-music/wiki/使用提示">使用提示</a>',
2020-02-06 08:01:35 +00:00
dangerouslyUseHTMLString: true,
2021-05-24 14:19:37 +00:00
duration: 10000,
position: 'top-left'
2020-02-06 08:01:35 +00:00
});
2021-05-24 14:19:37 +00:00
}
},
showSuccess(data) {
if (this.instant_download) {
DownloadBlobMusic(data, this.download_format);
RemoveBlobMusic(data);
} else {
this.tableData.push(data);
this.$notify.success({
title: '解锁成功',
message: '成功解锁 ' + data.title,
duration: 3000
});
}
2021-05-24 14:19:37 +00:00
if (process.env.NODE_ENV === 'production') {
let _rp_data = [data.title, data.artist, data.album];
window._paq.push(["trackEvent", "Unlock", data.rawExt + "," + data.mime, JSON.stringify(_rp_data)]);
}
},
showFail(errInfo, filename) {
this.$notify.error({
title: '出现问题',
message: errInfo + "" + filename +
',参考<a target="_blank" href="https://github.com/ix64/unlock-music/wiki/使用提示">使用提示</a>',
dangerouslyUseHTMLString: true,
duration: 6000
});
if (process.env.NODE_ENV === 'production') {
window._paq.push(["trackEvent", "Error", errInfo, filename]);
}
console.error(errInfo, filename);
},
changePlaying(url) {
this.playing_url = url;
this.playing_auto = true;
},
handleDeleteAll() {
this.tableData.forEach(value => {
RemoveBlobMusic(value);
});
this.tableData = [];
2020-02-06 08:01:35 +00:00
},
2021-05-24 14:19:37 +00:00
handleDownloadAll() {
let index = 0;
let c = setInterval(() => {
if (index < this.tableData.length) {
DownloadBlobMusic(this.tableData[index], this.download_format);
index++;
} else {
clearInterval(c);
}
}, 300);
}
},
}
2019-07-03 14:50:04 +00:00
</script>
<style lang="scss">
2021-05-24 14:19:37 +00:00
@import "scss/unlock-music";
2019-07-03 14:50:04 +00:00
</style>