You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
unblock-music-web/src/App.vue

185 lines
8.0 KiB
Vue

5 years ago
<template>
5 years ago
<el-container id="app">
<el-main>
5 years ago
<x-upload v-on:handle_error="showFail" v-on:handle_finish="showSuccess"></x-upload>
5 years ago
<div id="app-control">
<el-row class="mb-3">
<span>歌曲命名格式</span>
<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>
5 years ago
<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>
5 years ago
</el-row>
</div>
5 years ago
<audio :autoplay="playing_auto" :src="playing_url" controls/>
5 years ago
<x-preview :download_format="download_format" :table-data="tableData"
5 years ago
v-on:music_changed="changePlaying"></x-preview>
</el-main>
<el-footer id="app-footer">
<el-row>
5 years ago
<a href="https://github.com/ix64/unlock-music" target="_blank">音乐解锁</a>(v<span
v-text="version"></span>)移除已购音乐的加密保护
5 years ago
<a href="https://github.com/ix64/unlock-music/wiki/使用提示" target="_blank">使用提示</a>
</el-row>
<el-row>
4 years ago
目前支持网易云音乐(ncm), QQ音乐(qmc, mflac, mgg), 酷狗音乐(kgm), 虾米音乐(xm), 酷我音乐(.kwm)
<a href="https://github.com/ix64/unlock-music/blob/master/README.md" target="_blank">更多</a>
5 years ago
</el-row>
<el-row>
4 years ago
<!--如果进行二次开发此行版权信息不得移除且应明显地标注于页面上-->
5 years ago
<span>Copyright &copy; 2019-</span><span v-text="(new Date()).getFullYear()"></span> MengYX
5 years ago
音乐解锁使用
<a href="https://github.com/ix64/unlock-music/blob/master/LICENSE" target="_blank">MIT许可协议</a>
5 years ago
开放源代码
5 years ago
</el-row>
</el-footer>
</el-container>
5 years ago
</template>
<script>
5 years ago
import upload from "./component/upload"
import preview from "./component/preview"
import {DownloadBlobMusic, RemoveBlobMusic} from "./component/util"
5 years ago
import config from "../package"
import {IXAREA_API_ENDPOINT} from "./decrypt/util";
export default {
name: 'app',
5 years ago
components: {
xUpload: upload,
xPreview: preview
},
data() {
return {
5 years ago
version: config.version,
activeIndex: '1',
tableData: [],
playing_url: "",
playing_auto: false,
download_format: '1',
5 years ago
instant_download: false,
}
},
5 years ago
created() {
this.$nextTick(function () {
this.finishLoad();
});
},
methods: {
5 years ago
async finishLoad() {
5 years ago
const mask = document.getElementById("loader-mask");
if (!!mask) mask.remove();
5 years ago
let updateInfo;
try {
const resp = await fetch(IXAREA_API_ENDPOINT + "/music/app-version", {
5 years ago
method: "POST", headers: {"Content-Type": "application/json"},
body: JSON.stringify({"Version": this.version})
5 years ago
});
updateInfo = await resp.json();
} catch (e) {
}
if ((!!updateInfo && process.env.NODE_ENV === 'production') && (!!updateInfo.HttpsFound ||
4 years ago
(!!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'
});
5 years ago
} else {
this.$notify.info({
title: '离线使用',
message: '我们使用PWA技术无网络也能使用' +
5 years ago
'<br/>最近更新:' + config.updateInfo +
5 years ago
'<br/><a target="_blank" href="https://github.com/ix64/unlock-music/wiki/使用提示">使用提示</a>',
dangerouslyUseHTMLString: true,
duration: 10000,
position: 'top-left'
});
}
},
5 years ago
showSuccess(data) {
if (data.status) {
if (this.instant_download) {
DownloadBlobMusic(data, this.download_format);
RemoveBlobMusic(data);
} else {
5 years ago
this.tableData.push(data);
this.$notify.success({
title: '解锁成功',
message: '成功解锁 ' + data.title,
duration: 3000
});
}
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)]);
}
5 years ago
} else {
this.showFail(data.message, data.rawFilename + "." + data.rawExt)
}
},
5 years ago
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);
5 years ago
},
changePlaying(url) {
this.playing_url = url;
this.playing_auto = true;
},
handleDeleteAll() {
this.tableData.forEach(value => {
5 years ago
RemoveBlobMusic(value);
});
this.tableData = [];
},
handleDownloadAll() {
let index = 0;
let c = setInterval(() => {
if (index < this.tableData.length) {
5 years ago
DownloadBlobMusic(this.tableData[index], this.download_format);
index++;
} else {
clearInterval(c);
}
5 years ago
}, 300);
}
5 years ago
},
}
5 years ago
</script>
<style lang="scss">
@import "scss/unlock-music";
5 years ago
</style>