1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-31 22:18:07 +08:00

fix: 解决上传报错的BUG

This commit is contained in:
zhengkunwang223 2023-03-12 11:40:21 +08:00 committed by zhengkunwang223
parent 83ca72e153
commit 90c7f9cc2c
3 changed files with 8 additions and 3 deletions

View File

@ -26,7 +26,8 @@ func (f *FileRouter) InitFileRouter(Router *gin.RouterGroup) {
fileRouter.POST("/content", baseApi.GetContent) fileRouter.POST("/content", baseApi.GetContent)
fileRouter.POST("/save", baseApi.SaveContent) fileRouter.POST("/save", baseApi.SaveContent)
fileRouter.POST("/check", baseApi.CheckFile) fileRouter.POST("/check", baseApi.CheckFile)
fileRouter.POST("/upload", baseApi.UploadChunkFiles) fileRouter.POST("/upload", baseApi.UploadFiles)
fileRouter.POST("/chunkupload", baseApi.UploadChunkFiles)
fileRouter.POST("/rename", baseApi.ChangeFileName) fileRouter.POST("/rename", baseApi.ChangeFileName)
fileRouter.POST("/wget", baseApi.WgetFile) fileRouter.POST("/wget", baseApi.WgetFile)
fileRouter.POST("/move", baseApi.MoveFile) fileRouter.POST("/move", baseApi.MoveFile)

View File

@ -59,6 +59,10 @@ export const UploadFileData = (params: FormData, config: AxiosRequestConfig) =>
return http.upload<File.File>('files/upload', params, config); return http.upload<File.File>('files/upload', params, config);
}; };
export const ChunkUploadFileData = (params: FormData, config: AxiosRequestConfig) => {
return http.upload<File.File>('files/chunkupload', params, config);
};
export const RenameRile = (params: File.FileRename) => { export const RenameRile = (params: File.FileRename) => {
return http.post<File.File>('files/rename', params); return http.post<File.File>('files/rename', params);
}; };

View File

@ -39,7 +39,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue'; import { ref } from 'vue';
import { UploadFile, UploadFiles, UploadInstance } from 'element-plus'; import { UploadFile, UploadFiles, UploadInstance } from 'element-plus';
import { UploadFileData } from '@/api/modules/files'; import { ChunkUploadFileData } from '@/api/modules/files';
import i18n from '@/lang'; import i18n from '@/lang';
import DrawerHeader from '@/components/drawer-header/index.vue'; import DrawerHeader from '@/components/drawer-header/index.vue';
import { MsgSuccess } from '@/utils/message'; import { MsgSuccess } from '@/utils/message';
@ -95,7 +95,7 @@ const submit = async () => {
formData.append('chunkCount', chunkCount.toString()); formData.append('chunkCount', chunkCount.toString());
try { try {
await UploadFileData(formData, { await ChunkUploadFileData(formData, {
onUploadProgress: (progressEvent) => { onUploadProgress: (progressEvent) => {
const progress = Math.round( const progress = Math.round(
((uploadedChunkCount + progressEvent.loaded / progressEvent.total) * 100) / chunkCount, ((uploadedChunkCount + progressEvent.loaded / progressEvent.total) * 100) / chunkCount,