2024-05-15 11:57:30 +08:00
|
|
|
import { repoID, historyRepoID } from './constants';
|
2018-09-18 10:11:37 +08:00
|
|
|
import { seafileAPI } from './seafile-api';
|
2018-09-04 17:16:50 +08:00
|
|
|
|
|
|
|
class EditorUtilities {
|
2020-11-02 13:56:35 +08:00
|
|
|
|
2018-09-12 10:32:31 +08:00
|
|
|
listRepoDir() {
|
2018-09-12 17:01:48 +08:00
|
|
|
return seafileAPI.listDir(repoID, '/',{recursive: true}).then(items => {
|
2019-01-22 18:27:51 +08:00
|
|
|
const files = items.data.dirent_list.map(item => {
|
2018-09-12 17:01:48 +08:00
|
|
|
return {
|
|
|
|
name: item.name,
|
|
|
|
type: item.type === 'dir' ? 'dir' : 'file',
|
|
|
|
isExpanded: item.type === 'dir' ? true : false,
|
|
|
|
parent_path: item.parent_dir,
|
|
|
|
last_update_time: item.mtime,
|
2018-09-29 15:47:53 +08:00
|
|
|
permission: item.permission,
|
2018-09-12 17:01:48 +08:00
|
|
|
size: item.size
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
return files;
|
|
|
|
});
|
2018-09-12 10:32:31 +08:00
|
|
|
}
|
|
|
|
|
2018-09-04 17:16:50 +08:00
|
|
|
deleteFile(filePath) {
|
2018-09-12 17:01:48 +08:00
|
|
|
return seafileAPI.deleteFile(repoID, filePath);
|
2018-09-04 17:16:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
renameFile(filePath, newFileName) {
|
2018-09-12 17:01:48 +08:00
|
|
|
return seafileAPI.renameFile(repoID, filePath, newFileName);
|
2018-09-04 17:16:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
createDir(dirPath) {
|
2018-09-12 17:01:48 +08:00
|
|
|
return seafileAPI.createDir(repoID, dirPath);
|
2018-09-04 17:16:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
deleteDir(dirPath) {
|
2018-09-12 17:01:48 +08:00
|
|
|
return seafileAPI.deleteDir(repoID, dirPath);
|
2018-09-04 17:16:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
renameDir(dirPath, newDirName) {
|
2018-09-12 17:01:48 +08:00
|
|
|
return seafileAPI.renameDir(repoID, dirPath, newDirName);
|
2018-09-04 17:16:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
getWikiFileContent(slug, filePath) {
|
|
|
|
return seafileAPI.getWikiFileContent(slug, filePath);
|
|
|
|
}
|
|
|
|
|
|
|
|
getSource() {
|
|
|
|
return seafileAPI.getSource();
|
|
|
|
}
|
|
|
|
|
|
|
|
searchFiles(queryData,cancelToken) {
|
|
|
|
return seafileAPI.searchFiles(queryData,cancelToken);
|
|
|
|
}
|
|
|
|
|
|
|
|
getAccountInfo() {
|
|
|
|
return seafileAPI.getAccountInfo();
|
|
|
|
}
|
|
|
|
|
2018-09-12 17:01:48 +08:00
|
|
|
// file history
|
|
|
|
getFileDownloadLink(filePath) {
|
|
|
|
return seafileAPI.getFileDownloadLink(historyRepoID, filePath);
|
|
|
|
}
|
|
|
|
|
|
|
|
getFileContent(filePath) {
|
|
|
|
return seafileAPI.getFileContent(filePath);
|
|
|
|
}
|
|
|
|
|
2018-09-25 15:10:23 +08:00
|
|
|
listFileHistoryRecords(filePath, page, per_page) {
|
|
|
|
return seafileAPI.listFileHistoryRecords(historyRepoID, filePath, page, per_page);
|
2018-09-12 17:01:48 +08:00
|
|
|
}
|
2020-11-02 13:56:35 +08:00
|
|
|
|
2018-09-12 17:01:48 +08:00
|
|
|
revertFile(filePath, commitID) {
|
|
|
|
return seafileAPI.revertFile(historyRepoID, filePath, commitID);
|
|
|
|
}
|
2018-09-15 16:14:17 +08:00
|
|
|
|
2018-09-29 15:47:53 +08:00
|
|
|
zipDownload(parent_dir, dirents) {
|
|
|
|
return seafileAPI.zipDownload(repoID, parent_dir, dirents);
|
|
|
|
}
|
|
|
|
|
|
|
|
queryZipProgress(zip_token) {
|
|
|
|
return seafileAPI.queryZipProgress(zip_token);
|
|
|
|
}
|
|
|
|
|
|
|
|
cancelZipTask(zip_token) {
|
2018-09-29 18:32:53 +08:00
|
|
|
return seafileAPI.cancelZipTask(zip_token);
|
2018-09-29 15:47:53 +08:00
|
|
|
}
|
2018-09-04 17:16:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const editorUtilities = new EditorUtilities();
|
|
|
|
|
|
|
|
export default editorUtilities;
|