File size: 1,636 Bytes
0070fce
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { Dict } from '@/util'
import { axiosInst } from '.'

export interface FileNodeInfo {
  size: string
  type: 'file' | 'dir'
  created_time: string
  name: string
  date: string
  bytes: number
  fullpath: string
  is_under_scanned_path: boolean
  gen_info_raw?: string
  gen_info_obj?: object
  cover_url?: string
}

export interface GenDiffInfo {
  empty: boolean
  ownFile: string
  otherFile: string
  diff: any
}

export const getTargetFolderFiles = async (folder_path: string) => {
  const resp = await axiosInst.value.get('/files', { params: { folder_path } })
  return resp.data as { files: FileNodeInfo[] }
}


export const deleteFiles = async (file_paths: string[]) => {
  const resp = await axiosInst.value.post('/delete_files', { file_paths })
  return resp.data as { files: FileNodeInfo[] }
}

export const moveFiles = async (
  file_paths: string[],
  dest: string,
  create_dest_folder?: boolean
) => {
  const resp = await axiosInst.value.post('/move_files', { file_paths, dest, create_dest_folder })
  return resp.data as { files: FileNodeInfo[] }
}

export const copyFiles = async (
  file_paths: string[],
  dest: string,
  create_dest_folder?: boolean
) => {
  const resp = await axiosInst.value.post('/copy_files', { file_paths, dest, create_dest_folder })
  return resp.data as { files: FileNodeInfo[] }
}

export const mkdirs = async (dest_folder: string) => {
  await axiosInst.value.post('/mkdirs', { dest_folder })
}


export const  batchGetFilesInfo = async (paths: string[]) => {
  const resp = await axiosInst.value.post('/batch_get_files_info', { paths }) 
  return  resp.data as Dict<FileNodeInfo>
}