diff --git a/src/views/gameManage/copyUnit/index.vue b/src/views/gameManage/copyUnit/index.vue
index fe5abb5..c3735f5 100644
--- a/src/views/gameManage/copyUnit/index.vue
+++ b/src/views/gameManage/copyUnit/index.vue
@@ -37,29 +37,11 @@
复制
-
- 正在复制账号
+
+ 正在复制账号
下载账号json数据
-
-
- 正在复制仓库
- 下载仓库json数据
-
-
-
-
- 正在复制村民
- 下载村民json数据
-
-
-
-
- 正在复制装饰
- 下载装饰json数据
-
-
@@ -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');
}
};
// 打开修改字典弹窗