mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-21 11:27:18 +00:00
[Wiki] Support show folder (#2334)
This commit is contained in:
committed by
Daniel Pan
parent
b8662376a1
commit
681a4235a4
71
frontend/src/utils/editor-utilties.js
Normal file
71
frontend/src/utils/editor-utilties.js
Normal file
@@ -0,0 +1,71 @@
|
||||
import { slug, repoID, siteRoot } from '../components/constance';
|
||||
import { SeafileAPI } from 'seafile-js';
|
||||
import cookie from 'react-cookies';
|
||||
|
||||
let seafileAPI = new SeafileAPI();
|
||||
let xcsrfHeaders = cookie.load('sfcsrftoken');
|
||||
seafileAPI.initForSeahubUsage({ siteRoot, xcsrfHeaders });
|
||||
|
||||
class EditorUtilities {
|
||||
|
||||
getFiles() {
|
||||
return seafileAPI.listWikiDir(slug, "/").then(items => {
|
||||
const files = items.data.dir_file_list.map(item => {
|
||||
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.last_update_time,
|
||||
size: item.size
|
||||
}
|
||||
})
|
||||
return files;
|
||||
})
|
||||
}
|
||||
|
||||
createFile(filePath) {
|
||||
return seafileAPI.createFile(repoID, filePath)
|
||||
}
|
||||
|
||||
deleteFile(filePath) {
|
||||
return seafileAPI.deleteFile(repoID, filePath)
|
||||
}
|
||||
|
||||
renameFile(filePath, newFileName) {
|
||||
return seafileAPI.renameFile(repoID, filePath, newFileName)
|
||||
}
|
||||
|
||||
createDir(dirPath) {
|
||||
return seafileAPI.createDir(repoID, dirPath)
|
||||
}
|
||||
|
||||
deleteDir(dirPath) {
|
||||
return seafileAPI.deleteDir(repoID, dirPath)
|
||||
}
|
||||
|
||||
renameDir(dirPath, newDirName) {
|
||||
return seafileAPI.renameDir(repoID, dirPath, newDirName)
|
||||
}
|
||||
|
||||
getWikiFileContent(slug, filePath) {
|
||||
return seafileAPI.getWikiFileContent(slug, filePath);
|
||||
}
|
||||
|
||||
getSource() {
|
||||
return seafileAPI.getSource();
|
||||
}
|
||||
|
||||
searchFiles(queryData,cancelToken) {
|
||||
return seafileAPI.searchFiles(queryData,cancelToken);
|
||||
}
|
||||
|
||||
getAccountInfo() {
|
||||
return seafileAPI.getAccountInfo();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const editorUtilities = new EditorUtilities();
|
||||
|
||||
export default editorUtilities;
|
Reference in New Issue
Block a user