From 465f0afd64581c676e9c457452166cd554fb4f59 Mon Sep 17 00:00:00 2001 From: meetqy Date: Tue, 24 Oct 2023 11:06:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20Row?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/renderer/src/components/Row.tsx | 35 +++++ .../src/renderer/src/pages/basic/index.tsx | 136 +++++++++--------- .../src/renderer/src/pages/unsync/index.tsx | 40 ++---- 3 files changed, 115 insertions(+), 96 deletions(-) create mode 100644 apps/electron/src/renderer/src/components/Row.tsx diff --git a/apps/electron/src/renderer/src/components/Row.tsx b/apps/electron/src/renderer/src/components/Row.tsx new file mode 100644 index 00000000..b1a44afc --- /dev/null +++ b/apps/electron/src/renderer/src/components/Row.tsx @@ -0,0 +1,35 @@ +import { ChevronRightIcon } from "@heroicons/react/24/outline"; + +interface Props { + left?: React.ReactNode; + right?: React.ReactNode; + onLeftClick?: () => void; + onRightClick?: () => void; + compact?: boolean; +} + +export const Row = (props: Props) => { + return ( +
+ + + +
+ ); +}; + +export default Row; diff --git a/apps/electron/src/renderer/src/pages/basic/index.tsx b/apps/electron/src/renderer/src/pages/basic/index.tsx index 38b1520a..0441b0d0 100644 --- a/apps/electron/src/renderer/src/pages/basic/index.tsx +++ b/apps/electron/src/renderer/src/pages/basic/index.tsx @@ -1,12 +1,12 @@ import { useState } from "react"; import { - ChevronRightIcon, ClockIcon, EyeIcon, FolderIcon, PhotoIcon, } from "@heroicons/react/24/outline"; import Content from "@renderer/components/Content"; +import Row from "@renderer/components/Row"; import Title from "@renderer/components/Title"; import { useLanguage } from "@renderer/hooks"; import { trpc } from "@renderer/utils/trpc"; @@ -115,80 +115,74 @@ const BasicPage = () => { {lang.title}}>
-
- - - - {lang.file_path} - - - -
- -
- - - - {lang.last_time} - - - - {library?.lastSyncTime?.toLocaleString("zh", { hour12: false }) ?? - lang.un_sync} - -
- -
- - - - {lang.sync_count} - - - - {library?.syncCount ?? 0} - - {library?.unSyncCount ?? 0} - -
+ + + {lang.file_path} + + } + right={library?.path + "/123123/123/123"} + onRightClick={() => { + if (library) { + window.shell.showItemInFolder(library.path); + } + }} + /> + + + + {lang.last_time} + + } + right={ + library?.lastSyncTime?.toLocaleString("zh", { hour12: false }) ?? + lang.un_sync + } + /> + + + + {lang.sync_count} + + } + right={ + <> + {library?.syncCount ?? 0} + + + {library?.unSyncCount ?? 0} + + + } + />
-
- -
- -
- - {lang.preview} -
- - -
+ ) + } + onRightClick={() => { + void window.shell.openExternal( + `http://${config?.ip}:${config?.clientPort}`, + ); + }} + />
diff --git a/apps/electron/src/renderer/src/pages/unsync/index.tsx b/apps/electron/src/renderer/src/pages/unsync/index.tsx index e843d425..469bb673 100644 --- a/apps/electron/src/renderer/src/pages/unsync/index.tsx +++ b/apps/electron/src/renderer/src/pages/unsync/index.tsx @@ -1,6 +1,6 @@ import { useState } from "react"; -import { ChevronRightIcon } from "@heroicons/react/24/outline"; import Content from "@renderer/components/Content"; +import Row from "@renderer/components/Row"; import Title from "@renderer/components/Title"; import { useDebounce, useLanguage } from "@renderer/hooks"; import { trpc } from "@renderer/utils/trpc"; @@ -61,31 +61,21 @@ const UnsyncPage = () => { {data.length > 0 ? (
{data?.map((item, index) => ( -
-
- {item.type === "unknown" ? "unkonwn error" : item.type} -
-
- { - void window.dialog.showErrorBox( - item.path, - item.message, - ); - }} - aria-hidden="true" - > - - {item.path - .replace(libPath, "") - .replace("/metadata.json", "")} - - + + {item.type === "unknown" ? "unkonwn error" : item.type} -
-
+ } + right={item.path + .replace(libPath, "") + .replace("/metadata.json", "")} + onRightClick={() => { + void window.dialog.showErrorBox(item.path, item.message); + }} + /> ))}
) : (