From e9d7ba397f5cf8c1ff34f7706cf1629f388818af Mon Sep 17 00:00:00 2001 From: readme-bot Date: Sat, 11 Nov 2023 05:02:50 +0800 Subject: [PATCH] add page to show system info --- src/components/comparison/index.tsx | 16 ++-- src/components/configuration.tsx | 1 - src/components/historical-data/index.tsx | 6 +- src/components/index/index.tsx | 41 +++++---- src/components/settings/index.tsx | 17 +--- src/components/system-info.tsx | 108 +++++++++++++++++++++++ 6 files changed, 147 insertions(+), 42 deletions(-) create mode 100644 src/components/system-info.tsx diff --git a/src/components/comparison/index.tsx b/src/components/comparison/index.tsx index 4e8b003..9c7546a 100644 --- a/src/components/comparison/index.tsx +++ b/src/components/comparison/index.tsx @@ -1,19 +1,19 @@ import { useEffect, useMemo, useState } from "react"; import "./index.css"; -import { CoinData, CurrencyRateDetail } from "../../middlelayers/types"; +import { CoinData, CurrencyRateDetail } from "@/middlelayers/types"; import { queryAllDataDates, queryCoinDataById, -} from "../../middlelayers/charts"; +} from "@/middlelayers/charts"; import _ from "lodash"; -import viewIcon from "../../assets/icons/view-icon.png"; -import hideIcon from "../../assets/icons/hide-icon.png"; +import ViewIcon from "@/assets/icons/view-icon.png"; +import HideIcon from "@/assets/icons/hide-icon.png"; import { currencyWrapper, prettyNumberToLocaleString, -} from "../../utils/currency"; -import { useWindowSize } from "../../utils/hook"; -import { parseDateToTS } from "../../utils/date"; +} from "@/utils/currency"; +import { useWindowSize } from "@/utils/hook"; +import { parseDateToTS } from "@/utils/date"; import { ButtonGroup, ButtonGroupItem } from "../ui/button-group"; import { Select, @@ -336,7 +336,7 @@ const App = ({ currency }: { currency: CurrencyRateDetail }) => { view-or-hide onHistoricalDataDeleteClick(d.id)}> delete onHistoricalDataDetailDeleteClick(d.assetId)}> delete { }, [lo.pathname]); return ( -
+
@@ -255,7 +255,7 @@ const App = () => {
-
+
@@ -327,6 +327,13 @@ const App = () => { /> } /> + + } + /> not found
} /> diff --git a/src/components/settings/index.tsx b/src/components/settings/index.tsx index 4b10137..adc1407 100644 --- a/src/components/settings/index.tsx +++ b/src/components/settings/index.tsx @@ -1,7 +1,4 @@ -import React from 'react' import _ from "lodash"; -import { getVersion } from "@tauri-apps/api/app"; -import { useEffect, useState } from "react"; import { SidebarNav } from "./sidebar-nav"; import { Outlet, Navigate, useLocation } from "react-router-dom"; @@ -14,20 +11,14 @@ const sidebarNavItems = [ title: "Data", href: "/settings/data", }, + { + title: "System", + href: "/settings/systemInfo", + }, ]; const App = () => { - const [version, setVersion] = useState("0.1.0"); const lo = useLocation(); - useEffect(() => { - loadVersion(); - }, []); - - function loadVersion() { - getVersion().then((ver) => { - setVersion(ver); - }); - } return (
diff --git a/src/components/system-info.tsx b/src/components/system-info.tsx new file mode 100644 index 0000000..bdff88c --- /dev/null +++ b/src/components/system-info.tsx @@ -0,0 +1,108 @@ +import _ from "lodash"; +import { Separator } from "./ui/separator"; +import { useEffect, useState } from "react"; +import { getVersion } from "@/utils/app"; +import { getLicenseIfIsPro, saveLicense } from "@/middlelayers/configuration"; +import ViewIcon from "@/assets/icons/view-icon.png"; +import HideIcon from "@/assets/icons/hide-icon.png"; +import { Input } from "./ui/input"; +import { Button } from "./ui/button"; +import { ReloadIcon } from "@radix-ui/react-icons"; + +const App = () => { + const [version, setVersion] = useState("0.1.0"); + + const [license, setLicense] = useState(); + const [showLicense, setShowLicense] = useState(false); + const [licenseChanged, setLicenseChanged] = useState(false); + const [saveLicenseLoading, setSaveLicenseLoading] = useState(false); + + useEffect(() => { + loadVersion(); + loadLicense(); + }, []); + + function loadVersion() { + getVersion().then((ver) => { + setVersion(ver); + }); + } + + function loadLicense() { + getLicenseIfIsPro().then((license) => { + setLicense(license); + }); + } + + function onSaveLicenseClick() { + if (!license) { + return; + } + setSaveLicenseLoading(true); + + saveLicense(license).then(() => {}); + } + + function onLicenseInputChange(val: string) { + setLicenseChanged(true); + setLicense(val); + } + + function onViewOrHideClick() { + setShowLicense(!showLicense); + } + + return ( +
+
+

System Info

+

+ Show basic system information +

+
+ + +
+
Version
+
{version}
+
+ +
+
Pro Version
+
+ Enter License Key To Active Pro Version ( Coming Soon ) +
+
+
+
+ ); +}; + +export default App;