|
|
|
@ -1,57 +1,59 @@
|
|
|
|
import './App.css';
|
|
|
|
import "./App.css";
|
|
|
|
|
|
|
|
|
|
|
|
import intl from 'react-intl-universal';
|
|
|
|
import intl from "react-intl-universal";
|
|
|
|
import React, { useState, useEffect } from 'react';
|
|
|
|
import React, { useState, useEffect } from "react";
|
|
|
|
import { Layout, Row, Col, Spin } from 'antd';
|
|
|
|
import { Layout, Row, Col, Spin } from "antd";
|
|
|
|
import ServerRow from './ServerRow';
|
|
|
|
import ServerRow from "./ServerRow";
|
|
|
|
|
|
|
|
|
|
|
|
require('intl/locale-data/jsonp/en.js');
|
|
|
|
require("intl/locale-data/jsonp/en.js");
|
|
|
|
require('intl/locale-data/jsonp/zh.js');
|
|
|
|
require("intl/locale-data/jsonp/zh.js");
|
|
|
|
|
|
|
|
|
|
|
|
const { Header, Footer, Content } = Layout;
|
|
|
|
const { Header, Footer, Content } = Layout;
|
|
|
|
|
|
|
|
|
|
|
|
const App: React.FC = () => {
|
|
|
|
const App: React.FC = () => {
|
|
|
|
const [serverData, setServerData] = useState({servers: [], updated: "0"});
|
|
|
|
const [serverData, setServerData] = useState({ servers: [], updated: "0" });
|
|
|
|
const [isOnline, setIsOnline] = useState(false);
|
|
|
|
const [isOnline, setIsOnline] = useState(false);
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
useEffect(() => {
|
|
|
|
let fetchData = setInterval(() => {
|
|
|
|
const fetchData = () => {
|
|
|
|
fetch('json/stats.json')
|
|
|
|
fetch("json/stats.json")
|
|
|
|
.then(res => res.json())
|
|
|
|
.then((res) => res.json())
|
|
|
|
.then(data => {
|
|
|
|
.then((data) => {
|
|
|
|
setServerData(data);
|
|
|
|
setServerData(data);
|
|
|
|
setIsOnline(true);
|
|
|
|
setIsOnline(true);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.catch(e => console.log('错误:',e))
|
|
|
|
.catch((e) => console.log("错误:", e));
|
|
|
|
}, 5000);
|
|
|
|
};
|
|
|
|
|
|
|
|
fetchData();
|
|
|
|
|
|
|
|
let itv = setInterval(fetchData, 5000);
|
|
|
|
return () => {
|
|
|
|
return () => {
|
|
|
|
clearInterval(fetchData);
|
|
|
|
clearInterval(itv);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
|
|
const [initDone, setInitDone] = useState(false);
|
|
|
|
const [initDone, setInitDone] = useState(false);
|
|
|
|
let currentLocale = navigator.language || 'zh-CN';
|
|
|
|
let currentLocale = navigator.language || "zh-CN";
|
|
|
|
if (currentLocale === 'zh-TW' || currentLocale === 'zh-HK') {
|
|
|
|
if (currentLocale === "zh-TW" || currentLocale === "zh-HK") {
|
|
|
|
currentLocale = 'zh-TW';
|
|
|
|
currentLocale = "zh-TW";
|
|
|
|
} else if (currentLocale.startsWith('zh')) {
|
|
|
|
} else if (currentLocale.startsWith("zh")) {
|
|
|
|
currentLocale = 'zh-CN';
|
|
|
|
currentLocale = "zh-CN";
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
currentLocale = 'en-US';
|
|
|
|
currentLocale = "en-US";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
initDone || fetch(`locales/${currentLocale}.json`)
|
|
|
|
initDone ||
|
|
|
|
.then(res => res.json())
|
|
|
|
fetch(`locales/${currentLocale}.json`)
|
|
|
|
.then(data => {
|
|
|
|
.then((res) => res.json())
|
|
|
|
return intl.init({
|
|
|
|
.then((data) => {
|
|
|
|
currentLocale,
|
|
|
|
return intl.init({
|
|
|
|
locales: {
|
|
|
|
currentLocale,
|
|
|
|
[currentLocale]: data
|
|
|
|
locales: {
|
|
|
|
}
|
|
|
|
[currentLocale]: data,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.then(() => {
|
|
|
|
|
|
|
|
setInitDone(true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
})
|
|
|
|
|
|
|
|
.then(() => {
|
|
|
|
|
|
|
|
setInitDone(true);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div className="App">
|
|
|
|
<div className="App">
|
|
|
|
@ -59,21 +61,41 @@ const App: React.FC = () => {
|
|
|
|
<Header>
|
|
|
|
<Header>
|
|
|
|
<div className="logo">ServerStatus</div>
|
|
|
|
<div className="logo">ServerStatus</div>
|
|
|
|
</Header>
|
|
|
|
</Header>
|
|
|
|
<Content style={{background:'#fff'}}>
|
|
|
|
<Content style={{ background: "#fff" }}>
|
|
|
|
<Row type="flex" justify="center">
|
|
|
|
<Row type="flex" justify="center">
|
|
|
|
<Col xs={24} sm={23} md={23} lg={22} xl={20} xxl={16}>
|
|
|
|
<Col xs={24} sm={23} md={23} lg={22} xl={20} xxl={16}>
|
|
|
|
{initDone ? (<Spin size="large" spinning={!isOnline} tip="Loading...">
|
|
|
|
{initDone ? (
|
|
|
|
<ServerRow {...serverData} />
|
|
|
|
<Spin size="large" spinning={!isOnline} tip="Loading...">
|
|
|
|
</Spin>) : (<div />)}
|
|
|
|
<ServerRow {...serverData} />
|
|
|
|
|
|
|
|
</Spin>
|
|
|
|
|
|
|
|
) : (
|
|
|
|
|
|
|
|
<div />
|
|
|
|
|
|
|
|
)}
|
|
|
|
</Col>
|
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
</Row>
|
|
|
|
</Content>
|
|
|
|
</Content>
|
|
|
|
<Footer className="footer">
|
|
|
|
<Footer className="footer">
|
|
|
|
<a href="https://github.com/krwu/ServerStatus-web" rel="external noopener">WebUI</a> for <a href="https://github.com/BotoX/ServerStatus/" rel="external noopener">ServerStatus</a>, made by <a href="https://www.ofcss.com/" rel="external noopener">Kairee</a>
|
|
|
|
<a
|
|
|
|
|
|
|
|
href="https://github.com/krwu/ServerStatus-web"
|
|
|
|
|
|
|
|
rel="external noopener"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
WebUI
|
|
|
|
|
|
|
|
</a>{" "}
|
|
|
|
|
|
|
|
for{" "}
|
|
|
|
|
|
|
|
<a
|
|
|
|
|
|
|
|
href="https://github.com/BotoX/ServerStatus/"
|
|
|
|
|
|
|
|
rel="external noopener"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
ServerStatus
|
|
|
|
|
|
|
|
</a>
|
|
|
|
|
|
|
|
, made by{" "}
|
|
|
|
|
|
|
|
<a href="https://www.ofcss.com/" rel="external noopener">
|
|
|
|
|
|
|
|
Kairee
|
|
|
|
|
|
|
|
</a>
|
|
|
|
</Footer>
|
|
|
|
</Footer>
|
|
|
|
</Layout>
|
|
|
|
</Layout>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export default App;
|
|
|
|
export default App;
|
|
|
|
|