Browse Source

Fix bugs

HEAD
Yang Luo 3 years ago
parent
commit
1cb5aef777
3 changed files with 23 additions and 34 deletions
  1. +5
    -0
      controllers/store.go
  2. +18
    -27
      web/src/FileTree.js
  3. +0
    -7
      web/src/StoreListPage.js

+ 5
- 0
controllers/store.go View File

@@ -22,6 +22,11 @@ func (c *ApiController) GetStore() {
id := c.Input().Get("id")

store := object.GetStore(id)
if store == nil {
c.ResponseError("store is empty")
return
}

store.Populate()

c.Data["json"] = store


+ 18
- 27
web/src/FileTree.js View File

@@ -1,14 +1,6 @@
import React from "react";
import {Button, Col, Empty, Input, Popconfirm, Row, Spin, Tooltip, Tree, Upload} from 'antd';
import {
CloudUploadOutlined,
createFromIconfontCN,
DeleteOutlined,
DownloadOutlined,
EditOutlined,
FolderAddOutlined,
RadiusSettingOutlined
} from "@ant-design/icons";
import {CloudUploadOutlined, createFromIconfontCN, DeleteOutlined, DownloadOutlined, FolderAddOutlined} from "@ant-design/icons";
import * as Setting from "./Setting";
import * as FileBackend from "./backend/FileBackend";
import DocViewer, { DocViewerRenderers } from "react-doc-viewer";
@@ -17,7 +9,6 @@ import i18next from "i18next";

import {Controlled as CodeMirror} from "react-codemirror2";
import "codemirror/lib/codemirror.css";
import {downloadFile, openLink} from "./Setting";
// require("codemirror/theme/material-darker.css");
// require("codemirror/mode/javascript/javascript");

@@ -440,9 +431,23 @@ class FileTree extends React.Component {
}}
/>
);
}

if (["txt", "htm", "html", "js", "css", "md"].includes(ext)) {
} else if (["png", "jpeg", "gif", "bmp", "pdf", "csv", "xlsx", "docx", "mp4", "webm", "mp3"].includes(ext)) {
// https://github.com/plangrid/react-file-viewer
return (
<a target="_blank" rel="noreferrer" href={url}>
<FileViewer
key={path}
fileType={ext}
filePath={url}
errorComponent={<div>error</div>}
onError={(error) => {
Setting.showMessage("error", error);
}}
/>
</a>
);
} else {
// https://github.com/scniro/react-codemirror2
if (this.state.loading) {
return (
<div className="App">
@@ -461,20 +466,6 @@ class FileTree extends React.Component {
</div>
);
}

return (
<a target="_blank" rel="noreferrer" href={url}>
<FileViewer
key={path}
fileType={ext}
filePath={url}
errorComponent={<div>error</div>}
onError={(error) => {
Setting.showMessage("error", error);
}}
/>
</a>
);
}

render() {


+ 0
- 7
web/src/StoreListPage.js View File

@@ -36,13 +36,6 @@ class StoreListPage extends React.Component {
displayName: `Store ${this.state.stores.length}`,
bucket: "casbase",
domain: "https://github.com/casbin/casbase",
fileTree: {
key: "/",
title: "",
modifiedTime: moment().format(),
isLeaf: false,
children: [],
},
}
}


Loading…
Cancel
Save