|
1 | | -import { Globe, Github } from "lucide-react"; |
| 1 | +import { |
| 2 | + Globe, |
| 3 | + Github, |
| 4 | + Rocket, |
| 5 | + BookOpen, |
| 6 | + MessageCircleReply, |
| 7 | + ScrollText, |
| 8 | + SquareArrowOutUpRight, |
| 9 | +} from "lucide-react"; |
2 | 10 | import { useTranslation } from "react-i18next"; |
3 | 11 |
|
4 | 12 | import { OpenURLWithBrowser } from "@/utils"; |
5 | | -import logoLight from "@/assets/images/logo-text-light.svg"; |
6 | | -import logoDark from "@/assets/images/logo-text-dark.svg"; |
| 13 | +import lightLogo from "@/assets/images/logo-text-light.svg"; |
| 14 | +import darkLogo from "@/assets/images/logo-text-dark.svg"; |
7 | 15 | import { useThemeStore } from "@/stores/themeStore"; |
| 16 | +import { cloneElement, ReactElement, useMemo } from "react"; |
| 17 | +import platformAdapter from "@/utils/platformAdapter"; |
| 18 | + |
| 19 | +interface Link { |
| 20 | + icon: ReactElement; |
| 21 | + label: string; |
| 22 | + url?: string; |
| 23 | + onPress?: () => void; |
| 24 | +} |
8 | 25 |
|
9 | 26 | export default function AboutView() { |
10 | 27 | const { t } = useTranslation(); |
11 | | - const isDark = useThemeStore((state) => state.isDark); |
| 28 | + const { isDark } = useThemeStore(); |
| 29 | + |
| 30 | + const links = useMemo<Link[]>(() => { |
| 31 | + return [ |
| 32 | + { |
| 33 | + icon: <Rocket />, |
| 34 | + label: t("settings.about.labels.changelog"), |
| 35 | + url: "https://coco.rs/en/roadmap", |
| 36 | + }, |
| 37 | + { |
| 38 | + icon: <BookOpen />, |
| 39 | + label: t("settings.about.labels.docs"), |
| 40 | + url: "https://docs.infinilabs.com/coco-app/main", |
| 41 | + }, |
| 42 | + { |
| 43 | + icon: <Github />, |
| 44 | + label: "GitHub", |
| 45 | + url: "https://github.com/infinilabs/coco-app", |
| 46 | + }, |
| 47 | + { |
| 48 | + icon: <Globe />, |
| 49 | + label: t("settings.about.labels.officialWebsite"), |
| 50 | + url: "https://coco.rs", |
| 51 | + }, |
| 52 | + { |
| 53 | + icon: <MessageCircleReply />, |
| 54 | + label: t("settings.about.labels.submitFeedback"), |
| 55 | + url: "https://github.com/infinilabs/coco-app/issues", |
| 56 | + }, |
| 57 | + { |
| 58 | + icon: <ScrollText />, |
| 59 | + label: t("settings.about.labels.runningLog"), |
| 60 | + onPress: platformAdapter.openLogDir, |
| 61 | + }, |
| 62 | + ]; |
| 63 | + }, [t]); |
| 64 | + |
| 65 | + const handleClick = (link: Link) => { |
| 66 | + const { url, onPress } = link; |
12 | 67 |
|
13 | | - const logo = isDark ? logoDark : logoLight; |
| 68 | + if (url) { |
| 69 | + return OpenURLWithBrowser(url); |
| 70 | + } |
| 71 | + |
| 72 | + onPress?.(); |
| 73 | + }; |
14 | 74 |
|
15 | 75 | return ( |
16 | | - <div className="flex justify-center items-center flex-col h-[calc(100vh-170px)]"> |
17 | | - <div> |
| 76 | + <div className="flex h-[calc(100vh-170px)]"> |
| 77 | + <div className="flex flex-col items-center justify-center w-[70%] pr-10 text-[#999] text-sm"> |
18 | 78 | <img |
19 | | - src={logo} |
20 | | - className="w-48 dark:text-white" |
| 79 | + src={isDark ? darkLogo : lightLogo} |
| 80 | + className="h-14" |
21 | 81 | alt={t("settings.about.logo")} |
22 | 82 | /> |
| 83 | + |
| 84 | + <div className="mt-4 text-base font-medium text-[#333] dark:text-white/80"> |
| 85 | + {t("settings.about.slogan")} |
| 86 | + </div> |
| 87 | + |
| 88 | + <div className="mt-10"> |
| 89 | + {t("settings.about.version", { |
| 90 | + version: process.env.VERSION || "N/A", |
| 91 | + })} |
| 92 | + </div> |
| 93 | + |
| 94 | + <div className="mt-3"> |
| 95 | + {t("settings.about.copyright", { year: new Date().getFullYear() })} |
| 96 | + </div> |
23 | 97 | </div> |
24 | | - <div className="mt-8 font-medium text-gray-900 dark:text-gray-100"> |
25 | | - {t("settings.about.slogan")} |
26 | | - </div> |
27 | | - <div className="flex justify-center items-center mt-10"> |
28 | | - <button |
29 | | - onClick={() => OpenURLWithBrowser("https://coco.rs")} |
30 | | - className="w-6 h-6 mr-2.5 flex justify-center rounded-[6px] border-[1px] gray-200 dark:border-gray-700" |
31 | | - aria-label={t("settings.about.website")} |
32 | | - > |
33 | | - <Globe className="w-3 text-blue-500" /> |
34 | | - </button> |
35 | | - <button |
36 | | - onClick={() => |
37 | | - OpenURLWithBrowser("https://github.com/infinilabs/coco-app") |
38 | | - } |
39 | | - className="w-6 h-6 flex justify-center rounded-[6px] border-[1px] gray-200 dark:border-gray-700" |
40 | | - aria-label={t("settings.about.github")} |
41 | | - > |
42 | | - <Github className="w-3 text-blue-500" /> |
43 | | - </button> |
44 | | - </div> |
45 | | - <div className="mt-8 text-sm text-gray-500 dark:text-gray-400"> |
46 | | - {t("settings.about.version", { |
47 | | - version: process.env.VERSION || "N/A", |
| 98 | + |
| 99 | + <div className="flex-1 flex flex-col items-center justify-center gap-4 pl-10 border-l border-[#e5e5e5] dark:border-[#4e4e56]"> |
| 100 | + {links.map((item) => { |
| 101 | + const { icon, label } = item; |
| 102 | + |
| 103 | + return ( |
| 104 | + <div |
| 105 | + key={label} |
| 106 | + className="flex items-center justify-between w-full" |
| 107 | + > |
| 108 | + <div className="flex items-center gap-2"> |
| 109 | + {cloneElement(icon, { |
| 110 | + className: "size-4 text-[#999]", |
| 111 | + })} |
| 112 | + |
| 113 | + <span |
| 114 | + className="text-[#333] dark:text-white/80 cursor-pointer hover:text-[#027FFE] transition" |
| 115 | + onClick={() => { |
| 116 | + handleClick(item); |
| 117 | + }} |
| 118 | + > |
| 119 | + {label} |
| 120 | + </span> |
| 121 | + </div> |
| 122 | + |
| 123 | + <SquareArrowOutUpRight |
| 124 | + className="text-[#027FFE] size-4 cursor-pointer" |
| 125 | + onClick={() => { |
| 126 | + handleClick(item); |
| 127 | + }} |
| 128 | + /> |
| 129 | + </div> |
| 130 | + ); |
48 | 131 | })} |
49 | 132 | </div> |
50 | | - <div className="mt-4 text-sm text-gray-500 dark:text-gray-400"> |
51 | | - {t("settings.about.copyright", { year: new Date().getFullYear() })} |
52 | | - </div> |
53 | 133 | </div> |
54 | 134 | ); |
55 | 135 | } |
0 commit comments