Browse Source

fix: 解决上传报错的BUG

pull/203/head
zhengkunwang223 2 years ago committed by zhengkunwang223
parent
commit
90c7f9cc2c
  1. 3
      backend/router/ro_file.go
  2. 4
      frontend/src/api/modules/files.ts
  3. 4
      frontend/src/views/host/file-management/upload/index.vue

3
backend/router/ro_file.go

@ -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)

4
frontend/src/api/modules/files.ts

@ -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);
}; };

4
frontend/src/views/host/file-management/upload/index.vue

@ -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,

Loading…
Cancel
Save