mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-31 14:08:06 +08:00
fix: 解决备份文件过大导致下载超时问题 (#1199)
Refs https://github.com/1Panel-dev/1Panel/issues/1191
This commit is contained in:
parent
824051e89e
commit
8dfba82a70
@ -49,7 +49,7 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { reactive, ref } from 'vue';
|
||||
import { dateFormat } from '@/utils/util';
|
||||
import { dateFormat, downloadFile } from '@/utils/util';
|
||||
import { useDeleteData } from '@/hooks/use-delete-data';
|
||||
import { handleBackup, handleRecover } from '@/api/modules/setting';
|
||||
import i18n from '@/lang';
|
||||
@ -57,7 +57,7 @@ import DrawerHeader from '@/components/drawer-header/index.vue';
|
||||
import { deleteBackupRecord, downloadBackupRecord, searchBackupRecords } from '@/api/modules/setting';
|
||||
import { Backup } from '@/api/interface/backup';
|
||||
import { MsgSuccess } from '@/utils/message';
|
||||
import { DownloadByPath } from '@/api/modules/files';
|
||||
// import { DownloadByPath } from '@/api/modules/files';
|
||||
|
||||
const selects = ref<any>([]);
|
||||
const loading = ref();
|
||||
@ -147,14 +147,7 @@ const onDownload = async (row: Backup.RecordInfo) => {
|
||||
fileName: row.fileName,
|
||||
};
|
||||
await downloadBackupRecord(params).then(async (res) => {
|
||||
const file = await DownloadByPath(res.data);
|
||||
const downloadUrl = window.URL.createObjectURL(new Blob([file]));
|
||||
const a = document.createElement('a');
|
||||
a.style.display = 'none';
|
||||
a.href = downloadUrl;
|
||||
a.download = row.fileName;
|
||||
const event = new MouseEvent('click');
|
||||
a.dispatchEvent(event);
|
||||
downloadFile(res.data);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -236,3 +236,8 @@ export function isJson(str: string) {
|
||||
export function toLowerCase(str: string) {
|
||||
return str.toLowerCase();
|
||||
}
|
||||
|
||||
export function downloadFile(filePath: string) {
|
||||
let url = `${import.meta.env.VITE_API_URL as string}/files/download?`;
|
||||
window.open(url + 'path=' + filePath, '_blank');
|
||||
}
|
||||
|
@ -183,7 +183,7 @@
|
||||
<script setup lang="ts">
|
||||
import { nextTick, onMounted, reactive, ref } from '@vue/runtime-core';
|
||||
import { GetFilesList, DeleteFile, GetFileContent, ComputeDirSize } from '@/api/modules/files';
|
||||
import { computeSize, dateFormat, getIcon, getRandomStr } from '@/utils/util';
|
||||
import { computeSize, dateFormat, downloadFile, getIcon, getRandomStr } from '@/utils/util';
|
||||
import { File } from '@/api/interface/file';
|
||||
import { useDeleteData } from '@/hooks/use-delete-data';
|
||||
import i18n from '@/lang';
|
||||
@ -207,8 +207,6 @@ import { MsgSuccess, MsgWarning } from '@/utils/message';
|
||||
import { ElMessageBox } from 'element-plus';
|
||||
import { useSearchable } from './hooks/searchable';
|
||||
import { ResultData } from '@/api/interface';
|
||||
// import streamSaver from 'streamsaver';
|
||||
// import axios from 'axios';
|
||||
|
||||
interface FilePaths {
|
||||
url: string;
|
||||
@ -245,7 +243,6 @@ const fileRename = reactive({ path: '', oldName: '' });
|
||||
const fileWget = reactive({ path: '' });
|
||||
const fileMove = reactive({ oldPaths: [''], type: '', path: '' });
|
||||
const processPage = reactive({ open: false });
|
||||
// const fileDownload = reactive({ path: '', name: '' });
|
||||
|
||||
const createRef = ref();
|
||||
const roleRef = ref();
|
||||
@ -573,8 +570,7 @@ const openPaste = () => {
|
||||
};
|
||||
|
||||
const openDownload = (file: File.File) => {
|
||||
let url = `${import.meta.env.VITE_API_URL as string}/files/download?`;
|
||||
window.open(url + 'path=' + file.path, '_blank');
|
||||
downloadFile(file.path);
|
||||
};
|
||||
|
||||
const openDetail = (row: File.File) => {
|
||||
|
@ -323,6 +323,7 @@ const submitDate = (row: any) => {
|
||||
remark: row.remark,
|
||||
webSiteGroupId: row.webSiteGroupId,
|
||||
expireDate: reqDate,
|
||||
IPV6: row.IPV6,
|
||||
};
|
||||
|
||||
UpdateWebsite(req).then(() => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user