Browse Source

copyUnit

master
linquan 1 month ago
parent
commit
2df62a4eb1
  1. 58
      src/views/gameManage/copyUnit/index.vue

58
src/views/gameManage/copyUnit/index.vue

@ -37,29 +37,11 @@
<el-button size="large" type="primary" class="ml10" @click="copyUnit"> 复制</el-button>
</el-form-item>
<el-form-item>
<el-button size="default" type="primary" @click="onDownload(filename)" v-if="!disabled" :loading="loading">
<div v-if="loading">正在复制账号</div>
<el-button size="default" type="primary" @click="onDownload()" v-if="!disabled" :loading="loading && loading1 && loading2 && loading3">
<div v-if="loading && loading1 && loading2 && loading3">正在复制账号</div>
<div v-else>下载账号json数据</div>
</el-button>
</el-form-item>
<el-form-item inlist="true">
<el-button size="default" type="primary" @click="onDownload(storeFilename)" v-if="!disabled" :loading="loading1">
<div v-if="loading1">正在复制仓库</div>
<div v-else>下载仓库json数据</div>
</el-button>
</el-form-item>
<el-form-item inlist="true">
<el-button size="default" type="primary" @click="onDownload(deadFilename)" v-if="!disabled" :loading="loading2">
<div v-if="loading2">正在复制村民</div>
<div v-else>下载村民json数据</div>
</el-button>
</el-form-item>
<el-form-item inlist="true">
<el-button size="default" type="primary" @click="onDownload(decorationFilename)" v-if="!disabled" :loading="loading3">
<div v-if="loading3">正在复制装饰</div>
<div v-else>下载装饰json数据</div>
</el-button>
</el-form-item>
</el-form>
</div>
</div>
@ -475,9 +457,41 @@ export default defineComponent({
}
});
};
const onDownload = (file: string) => {
const onDownload = () => {
setTimeout(function () {
download(state.filename);
}, 1000);
setTimeout(function () {
download(state.storeFilename);
}, 2000);
setTimeout(function () {
download(state.deadFilename);
}, 3000);
setTimeout(function () {
download(state.decorationFilename);
}, 4000);
};
function downloadFile(url, fileName) {
fetch(url)
.then((response) => response.blob())
.then((blob) => {
const blobUrl = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = blobUrl;
link.download = fileName;
link.click();
URL.revokeObjectURL(blobUrl);
})
.catch((error) => console.error(error));
}
const download = (file: string) => {
if (file) {
window.open(baseURL + 'download_file?filename=' + file);
console.log('download', file);
downloadFile(baseURL + 'download_file?filename=' + file, file);
// window.open(baseURL + 'download_file?filename=' + file, '_blank');
}
};
//

Loading…
Cancel
Save