diff --git a/package.json b/package.json
index d09d0b0..7ae9809 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "ferrum",
- "version": "0.1.0",
+ "version": "1.5.0",
"private": true,
"dependencies": {
"@babel/core": "7.12.3",
diff --git a/src/client/components/FerrumPlugin.tsx b/src/client/components/FerrumPlugin.tsx
index 4a93c2b..7e68d1e 100644
--- a/src/client/components/FerrumPlugin.tsx
+++ b/src/client/components/FerrumPlugin.tsx
@@ -9,9 +9,8 @@ import {
GetDataUrlResponse
} from "../types";
import * as config from "../../config.json";
+import { apiUrl } from "../global";
-export const hostname = "http://"+ window.location.hostname;
-const apiUrl = hostname +":3301";
const root = config.explorer.root;
export default abstract class FerrumPlugin extends Component {
diff --git a/src/client/components/ListItem.tsx b/src/client/components/ListItem.tsx
index 22926dc..2729023 100644
--- a/src/client/components/ListItem.tsx
+++ b/src/client/components/ListItem.tsx
@@ -5,9 +5,8 @@ import Axios from "axios";
import Utils from "../../Utils";
import { ListItemProps, ListItemState } from "../types";
-
-const hostname = "http://"+ window.location.hostname;
-const apiUrl = hostname +":3301";
+import { apiUrl } from "../global";
+import Emitter from "../emitter";
export default class ListItem extends Component {
private itemSize: string;
@@ -55,7 +54,7 @@ export default class ListItem extends Component {
error: "重命名失败"
}).then(() => {
this.renameBoxSwitch();
- document.dispatchEvent(new CustomEvent("fileListUpdate"));
+ Emitter.get().emit("fileListUpdate");
});
}
diff --git a/src/client/components/StarredItem.tsx b/src/client/components/StarredItem.tsx
index a29aece..00bc15e 100644
--- a/src/client/components/StarredItem.tsx
+++ b/src/client/components/StarredItem.tsx
@@ -1,7 +1,7 @@
import { Component, ReactElement } from "react";
import { ListGroup } from "react-bootstrap";
-import { hostname } from "../pages/Explorer";
+import { hostname } from "../global";
import { StarredItemProps } from "../types";
import * as config from "../../config.json";
diff --git a/src/client/containers/explorer/RightSidebar.tsx b/src/client/containers/explorer/RightSidebar.tsx
index e4c1ee1..ea918f0 100644
--- a/src/client/containers/explorer/RightSidebar.tsx
+++ b/src/client/containers/explorer/RightSidebar.tsx
@@ -1,13 +1,14 @@
import { Component, ReactElement } from "react";
import { FilePond } from "react-filepond";
+import Emitter from "../../emitter";
import {
ExplorerRightSidebarProps,
ExplorerRightSidebarState,
SysInfo
} from "../../types";
+import { version, apiUrl } from "../../global";
-const apiUrl = "http://"+ window.location.hostname +":3301";
const defaultSysInfo: SysInfo = {
system: "",
version: "",
@@ -40,7 +41,7 @@ export default class RightSidebar extends Component
许可
+ Ver: {version}
diff --git a/src/client/containers/explorer/ToolButtons.tsx b/src/client/containers/explorer/ToolButtons.tsx
index 0defe2f..12cc955 100644
--- a/src/client/containers/explorer/ToolButtons.tsx
+++ b/src/client/containers/explorer/ToolButtons.tsx
@@ -1,7 +1,7 @@
import { Component, ReactElement } from "react";
import { Button } from "react-bootstrap";
-import { hostname } from "../../pages/Explorer";
+import { hostname } from "../../global";
import { ExplorerToolButtonsProps } from "../../types";
export default class ToolButtons extends Component
{
diff --git a/src/client/global.tsx b/src/client/global.tsx
new file mode 100644
index 0000000..7a761da
--- /dev/null
+++ b/src/client/global.tsx
@@ -0,0 +1,3 @@
+export const version = "1.5.0";
+export const hostname = "http://"+ window.location.hostname;
+export const apiUrl = hostname +":3301";
diff --git a/src/client/pages/Editor.tsx b/src/client/pages/Editor.tsx
index 3c173b8..9ea7f2b 100644
--- a/src/client/pages/Editor.tsx
+++ b/src/client/pages/Editor.tsx
@@ -10,10 +10,9 @@ import Header from "../containers/editor/Header";
import { theme } from "../theme";
import { EditorProps, EditorState, GetFileContentResponse } from "../types";
+import { apiUrl } from "../global";
import * as config from "../../config.json";
-const hostname = "http://"+ window.location.hostname;
-const apiUrl = hostname +":3301";
const root = config.explorer.root;
export default class Editor extends Component {
diff --git a/src/client/pages/Explorer.tsx b/src/client/pages/Explorer.tsx
index 308f162..00e055e 100644
--- a/src/client/pages/Explorer.tsx
+++ b/src/client/pages/Explorer.tsx
@@ -1,6 +1,7 @@
import { Component, ReactElement } from "react";
import { toast, Toaster } from "react-hot-toast";
import Axios from "axios";
+import md5 from "md5-node";
// components
import ListItem from "../components/ListItem";
@@ -14,17 +15,16 @@ import LeftSidebar from "../containers/explorer/LeftSidebar";
import RightSidebar from "../containers/explorer/RightSidebar";
import Utils from "../../Utils";
+import Emitter from "../emitter";
import { FetchDirInfoResponse, ExplorerProps, ExplorerState } from "../types";
+import { hostname, apiUrl } from "../global";
import * as config from "../../config.json";
import { plugins } from "../../plugins";
// icons
import starOutline from "../../icons/star_outline.svg";
import starRate from "../../icons/star_rate.svg";
-import md5 from "md5-node";
-export const hostname = "http://"+ window.location.hostname;
-const apiUrl = hostname +":3301";
const root = config.explorer.root;
export default class Explorer extends Component {
@@ -308,7 +308,8 @@ export default class Explorer extends Component {
}
});
- document.addEventListener("fileListUpdate", () => this.refreshItemList());
+ // document.addEventListener("fileListUpdate", () => this.refreshItemList());
+ Emitter.get().on("fileListUpdate", () => this.refreshItemList());
this.refreshItemList();
this.refreshStarredList();
diff --git a/src/client/pages/PictureViewer.tsx b/src/client/pages/PictureViewer.tsx
index c7495a6..e020102 100644
--- a/src/client/pages/PictureViewer.tsx
+++ b/src/client/pages/PictureViewer.tsx
@@ -9,10 +9,9 @@ import Header from "../containers/pictureViewer/Header";
import transparentImage from "../../icons/transparent.png";
import { PictureViewerProps, PictureViewerState, GetDataUrlResponse } from "../types";
+import { apiUrl } from "../global";
import * as config from "../../config.json";
-const hostname = "http://"+ window.location.hostname;
-const apiUrl = hostname +":3301";
const root = config.explorer.root;
export default class PictureViewer extends Component {
diff --git a/src/client/pages/Terminal.tsx b/src/client/pages/Terminal.tsx
index 92b337a..b2983e2 100644
--- a/src/client/pages/Terminal.tsx
+++ b/src/client/pages/Terminal.tsx
@@ -2,7 +2,7 @@ import { Component, ReactElement } from "react";
import openSocket from "socket.io-client";
import { Terminal as XTermTerminal } from "xterm";
-import { hostname } from "../pages/Explorer";
+import { hostname } from "../global";
import Utils from "../../Utils";
import * as config from "../../config.json";
diff --git a/src/client/style/explorer.less b/src/client/style/explorer.less
index 568227f..9010512 100644
--- a/src/client/style/explorer.less
+++ b/src/client/style/explorer.less
@@ -188,6 +188,11 @@
vertical-align: bottom;
margin-right: 10px;
}
+ span {
+ float: right;
+ line-height: 30px;
+ font-size: 10pt;
+ }
}
.upload-container {
overflow-y: auto;
diff --git a/src/index.tsx b/src/index.tsx
index 9edaaa4..b662f54 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -16,15 +16,19 @@ import * as config from "./config.json";
import Main from "./Main";
import Login from "./client/pages/Login";
+import { version } from "./client/global";
+
if(window.location.pathname == "/" || window.location.pathname == "/dir") {
window.location.href = "/dir/"; // default page
}
console.log(
- "%cFerrum Explorer %cBy NriotHrreion\n"+
+ "%cFerrum Explorer%cv"+ version +" | By NriotHrreion\n"+
+ "%c Website: https://nin.red/#/projects/ferrum/\n"+
"%cGithub Repo: https://github.com/NriotHrreion/ferrum\n",
"font-size: 16pt;font-weight: bold; padding: 10px",
"font-size: 8pt;color: gray",
+ "font-size: 8pt;color: white",
"font-size: 8pt;color: white"
);