diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d8c4146 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 ourongxing + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/package.json b/package.json index 2925222..6fd4072 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,12 @@ "version": "0.0.1", "private": true, "packageManager": "pnpm@9.11.0+sha512.0a203ffaed5a3f63242cd064c8fb5892366c103e328079318f78062f24ea8c9d50bc6a47aa3567cabefd824d170e78fa2745ed1f16b132e16436146b7688f19b", + "author": { + "url": "https://github.com/ourongxing/", + "email": "orongxing@gmail.com", + "name": "Ou Rongxing" + }, + "homepage": "https://github.com/ourongxing/newsnow", "scripts": { "dev": "vite dev", "build": "vite build", diff --git a/shared/consts.ts b/shared/consts.ts index ff3cf06..9c7de3f 100644 --- a/shared/consts.ts +++ b/shared/consts.ts @@ -1,8 +1,15 @@ /** * 缓存过期时间 */ +import packageJSON from "../package.json" + export const TTL = 30 * 60 * 1000 /** * 默认刷新间隔, 10 min */ export const Interval = 10 * 60 * 1000 + +export const Homepage = packageJSON.homepage + +export const Version = packageJSON.version +export const Author = packageJSON.author diff --git a/src/components/header.tsx b/src/components/header.tsx index a0c30d5..a020541 100644 --- a/src/components/header.tsx +++ b/src/components/header.tsx @@ -4,6 +4,7 @@ import { useAtomValue, useSetAtom } from "jotai" import { useIsFetching } from "@tanstack/react-query" import clsx from "clsx" import type { SourceID } from "@shared/types" +import { Homepage, Version } from "@shared/consts" import logo from "~/assets/react.svg" import { useDark } from "~/hooks/useDark" import { currentSectionAtom, refetchSourcesAtom } from "~/atoms" @@ -20,6 +21,10 @@ function ThemeToggle() { ) } +export function GithubIcon() { + return +} + function RefreshButton() { const currentSection = useAtomValue(currentSectionAtom) const setRefetchSource = useSetAtom(refetchSourcesAtom) @@ -44,15 +49,19 @@ function RefreshButton() { export function Header() { return ( -
+ <> logo NewsNow + + {`v${Version}`} + -
+
+
-
+ ) } diff --git a/src/components/section/card.tsx b/src/components/section/card.tsx index 3d5b2d2..c6191d4 100644 --- a/src/components/section/card.tsx +++ b/src/components/section/card.tsx @@ -102,7 +102,12 @@ export function NewsCard({ id, inView, isOverlay, handleListeners }: NewsCardPro className={clsx("flex justify-between p-2 items-center")} >
- {id} e.currentTarget.hidden = true} /> + {id} e.currentTarget.hidden = true} + /> {sources[id].name} @@ -118,14 +123,18 @@ export function NewsCard({ id, inView, isOverlay, handleListeners }: NewsCardPro
- +
@@ -134,14 +143,14 @@ export function NewsCard({ id, inView, isOverlay, handleListeners }: NewsCardPro function UpdateTime({ query }: Query) { const updatedTime = useRelativeTime(query.data?.updatedTime ?? "") - if (updatedTime) return {`${updatedTime}更新`} - if (query.isError) return 获取失败 + if (updatedTime) return `${updatedTime}更新` + if (query.isError) return "获取失败" + return "加载中..." } function Num({ num }: { num: number }) { - const color = ["bg-red-900", "bg-red-500", "bg-red-400"] return ( - + {num} ) diff --git a/src/components/section/dnd.tsx b/src/components/section/dnd.tsx index 4e77377..7f18950 100644 --- a/src/components/section/dnd.tsx +++ b/src/components/section/dnd.tsx @@ -24,7 +24,7 @@ export function Dnd() { return (
-
+
{sectionIds.map(section => ( - -
- + +
+
+
+
+ +
+ - { import.meta.env.DEV && ( + {import.meta.env.DEV && ( <> diff --git a/vite.config.ts b/vite.config.ts index f8b3af1..1b30b5e 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -11,9 +11,6 @@ import { projectDir } from "./shared/dir" const isCF = process.env.CF_PAGES export default defineConfig({ - resolve: { - mainFields: ["module"], - }, plugins: [ TanStackRouterVite({ autoCodeSplitting: true,