From 3115d8a3248e8cab1de15eb3eab8095279b7b547 Mon Sep 17 00:00:00 2001 From: Ilya Date: Sun, 12 Mar 2023 15:36:09 +0200 Subject: [PATCH] new --- .gitignore | 4 ++-- package.json | 3 ++- public/config.js | 12 +++++++----- public/index.html | 2 +- src/common/helper.js | 6 +++--- src/components/app.js | 2 +- src/components/header.js | 2 +- src/components/link.js | 4 ++-- src/components/uptimerobot.js | 14 +++++++------- src/index.js | 5 ----- test.js | 5 +++++ 11 files changed, 31 insertions(+), 28 deletions(-) create mode 100644 test.js diff --git a/.gitignore b/.gitignore index 23afb8c..8c7c09d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ node_modules build -Status v1.0.rar -Status v1.1.rar \ No newline at end of file +releases +.vs \ No newline at end of file diff --git a/package.json b/package.json index 46ff21b..4163551 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "license": "MIT", "scripts": { "start": "react-scripts start", - "build": "react-scripts build" + "build": "react-scripts build", + "test": "node test.js" }, "dependencies": { "axios": "^0.27.2", diff --git a/public/config.js b/public/config.js index aeb3508..9fc46e7 100644 --- a/public/config.js +++ b/public/config.js @@ -1,9 +1,8 @@ window.Config = { // Menu-bar Name - SiteName: 'HLP Status', + SiteName: 'Hosting Status', // UptimeRobot Api Keys - // Monitor-Specific Read-Only ApiKeys: [ 'm793883641-2edcb5af15f7045abf2c2d24', 'm793883641-2edcb5af15f7045abf2c2d24', @@ -25,15 +24,18 @@ window.Config = { Navi: [ { text: 'Homepage', - url: 'https://status.org.cn/' + url: 'https://status.org.cn/', + target: '_self' }, { text: 'GitHub', - url: 'https://github.com/yb/uptime-status' + url: 'https://github.com/yb/uptime-status', + target: '_blank' }, { text: 'Blog', - url: 'https://abo.xyz/' + url: 'https://abo.xyz/', + target: '_self' }, ], }; diff --git a/public/index.html b/public/index.html index ce68133..2a4e900 100644 --- a/public/index.html +++ b/public/index.html @@ -7,7 +7,7 @@ content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> - HLP Status + Hosting Status diff --git a/src/common/helper.js b/src/common/helper.js index b989af6..e6fc6de 100644 --- a/src/common/helper.js +++ b/src/common/helper.js @@ -14,8 +14,8 @@ export function formatDuration(seconds) { m = parseInt(m % 60); } } - let text = `${s} s`; - if (m > 0) text = `${m} m ${text}`; - if (h > 0) text = `${h} h ${text}`; + let text = `${s}s`; + if (m > 0) text = `${m}m ${text}`; + if (h > 0) text = `${h}h ${text}`; return text; } diff --git a/src/components/app.js b/src/components/app.js index 3831b4f..b5d8a42 100644 --- a/src/components/app.js +++ b/src/components/app.js @@ -23,7 +23,7 @@ function App() { ))} diff --git a/src/components/header.js b/src/components/header.js index 5fe3d91..128bda5 100644 --- a/src/components/header.js +++ b/src/components/header.js @@ -13,7 +13,7 @@ function Header() {

{window.Config.SiteName}

{window.Config.Navi.map((item, index) => ( - + ))}
diff --git a/src/components/link.js b/src/components/link.js index fc85067..49316fa 100644 --- a/src/components/link.js +++ b/src/components/link.js @@ -1,6 +1,6 @@ -function Link(props = { text, to }) { +function Link(props = { text, to, tar }) { return ( - + {props.text} ); diff --git a/src/components/uptimerobot.js b/src/components/uptimerobot.js index 5160739..1355128 100644 --- a/src/components/uptimerobot.js +++ b/src/components/uptimerobot.js @@ -1,4 +1,4 @@ -import ReactTooltip from 'react-tooltip'; +import ReactTooltip from 'react-tooltip'; import { useEffect, useState } from 'react'; import { GetMonitors } from '../common/uptimerobot'; import { formatDuration, formatNumber } from '../common/helper'; @@ -7,8 +7,8 @@ import Link from './link'; function UptimeRobot({ apikey }) { const status = { - ok: 'Ok', - down: 'Down', + ok: 'Online', + down: 'Offline', unknow: 'Unknown' }; @@ -33,7 +33,7 @@ function UptimeRobot({ apikey }) { let text = data.date.format('YYYY-MM-DD '); if (data.uptime >= 100) { status = 'ok'; - text += `Uptime ${formatNumber(data.uptime)}%`; + text += `| Uptime: ${formatNumber(data.uptime)}%`; } else if (data.uptime <= 0 && data.down.times === 0) { status = 'none'; @@ -41,7 +41,7 @@ function UptimeRobot({ apikey }) { } else { status = 'down'; - text += `Times Down ${data.down.times} Duration ${formatDuration(data.down.duration)},Uptime ${formatNumber(data.uptime)}%`; + text += `| Times Down: ${data.down.times},Duration: ${formatDuration(data.down.duration)},Uptime: ${formatNumber(data.uptime)}%`; } return () })} @@ -50,8 +50,8 @@ function UptimeRobot({ apikey }) { Today {site.total.times - ? `Days ${CountDays} Times ${site.total.times} Duration ${formatDuration(site.total.duration)},Uptime ${site.average}%` - : `Days ${CountDays} Uptime ${site.average}%`} + ? `Times down: ${site.total.times},Duration: ${formatDuration(site.total.duration)},Uptime: ${site.average}%` + : `Uptime: ${site.average}%`} {site.daily[site.daily.length - 1].date.format('YYYY-MM-DD')} diff --git a/src/index.js b/src/index.js index 6c5a050..41dcb96 100644 --- a/src/index.js +++ b/src/index.js @@ -5,8 +5,3 @@ import './app.scss'; const root = ReactDOM.createRoot(document.getElementById('app')); root.render(); -// root.render( -// -// -// -// ); diff --git a/test.js b/test.js new file mode 100644 index 0000000..d281fef --- /dev/null +++ b/test.js @@ -0,0 +1,5 @@ +function main() { + return 'Hello, World!'; +} + +main(); \ No newline at end of file