@@ -3,6 +3,8 @@ import { cn } from "@/utils/cn";
33import { open } from "@tauri-apps/plugin-shell" ;
44import { Calendar , ExternalLink , Heart , Server , User } from "lucide-react" ;
55import "./assets/font.css" ;
6+ import { isDevAtom } from "@/state" ;
7+ import { useAtom } from "jotai" ;
68
79interface DonationData {
810 user : string ;
@@ -180,8 +182,9 @@ const donations: DonationData[] = [
180182 */
181183export default function CreditsTab ( ) {
182184 const totalAmount = donations . reduce ( ( sum , donation ) => sum + donation . amount , 0 ) ;
185+ const [ isDev ] = useAtom ( isDevAtom ) ;
183186
184- // 计算从2024年9月1日到现在的月数
187+ // 计算从2024年9月1日到现在的天数
185188 const startDate = new Date ( 2024 , 8 , 1 ) ;
186189 const currentDate = new Date ( ) ;
187190 const monthsDiff =
@@ -190,40 +193,58 @@ export default function CreditsTab() {
190193 ( currentDate . getDate ( ) >= startDate . getDate ( ) ? 0 : - 1 ) ;
191194 const actualMonths = Math . max ( monthsDiff + 1 , 1 ) ; // 至少为1个月
192195 const averageMonthlyAmount = totalAmount / actualMonths ;
196+ const diffTime = currentDate . getTime ( ) - startDate . getTime ( ) ;
197+ const daysDiff = Math . floor ( diffTime / ( 1000 * 60 * 60 * 24 ) ) ;
198+ const actualDays = Math . max ( daysDiff + 1 , 1 ) ; // 至少为1天
193199
194200 return (
195201 < div className = "mx-auto flex w-2/3 flex-col overflow-auto py-4" >
196202 < div className = "mb-4 flex gap-4" >
197- < div className = "bg-muted/50 flex flex-1 flex-col gap-2 rounded-lg border p-4" >
198- < div className = "flex items-center justify-center gap-2" >
199- < Heart className = "h-5 w-5" />
200- < span className = "text-lg" > 合计</ span >
201- </ div >
202- < div
203- className = { cn (
204- "flex items-end justify-center gap-2 text-center *:font-[DINPro]" ,
205- totalAmount < 0 ? "text-red-500" : "text-green-500" ,
206- ) }
207- >
208- < span className = "text-3xl" > { totalAmount . toFixed ( 2 ) } </ span >
209- < span className = "text-xl" > CNY</ span >
210- </ div >
211- </ div >
212- < div className = "bg-muted/50 flex flex-1 flex-col gap-2 rounded-lg border p-4" >
213- < div className = "flex items-center justify-center gap-2" >
214- < Calendar className = "h-5 w-5" />
215- < span className = "text-lg" > 平均每月</ span >
216- </ div >
217- < div
218- className = { cn (
219- "flex items-end justify-center gap-2 text-center *:font-[DINPro]" ,
220- averageMonthlyAmount < 0 ? "text-red-500" : "text-green-500" ,
221- ) }
222- >
223- < span className = "text-3xl" > { averageMonthlyAmount . toFixed ( 2 ) } </ span >
224- < span className = "text-xl" > CNY</ span >
225- </ div >
226- </ div >
203+ { ! isDev ? (
204+ < >
205+ < div className = "bg-muted/50 flex flex-1 flex-col gap-2 rounded-lg border p-4" >
206+ < div className = "flex items-center justify-center gap-2" >
207+ < Heart className = "h-5 w-5" />
208+ < span className = "text-lg" > 合计</ span >
209+ </ div >
210+ < div
211+ className = { cn (
212+ "flex items-end justify-center gap-2 text-center *:font-[DINPro]" ,
213+ totalAmount < 0 ? "text-red-500" : "text-green-500" ,
214+ ) }
215+ >
216+ < span className = "text-3xl" > { totalAmount . toFixed ( 2 ) } </ span >
217+ < span className = "text-xl" > CNY</ span >
218+ </ div >
219+ </ div >
220+ < div className = "bg-muted/50 flex flex-1 flex-col gap-2 rounded-lg border p-4" >
221+ < div className = "flex items-center justify-center gap-2" >
222+ < Calendar className = "h-5 w-5" />
223+ < span className = "text-lg" > 平均每月</ span >
224+ </ div >
225+ < div
226+ className = { cn (
227+ "flex items-end justify-center gap-2 text-center *:font-[DINPro]" ,
228+ averageMonthlyAmount < 0 ? "text-red-500" : "text-green-500" ,
229+ ) }
230+ >
231+ < span className = "text-3xl" > { averageMonthlyAmount . toFixed ( 2 ) } </ span >
232+ < span className = "text-xl" > CNY</ span >
233+ </ div >
234+ </ div >
235+ </ >
236+ ) : (
237+ < >
238+ < div className = "bg-muted/50 flex flex-1 flex-col items-center gap-2 rounded-lg border p-4 text-sm" >
239+ < p className = "text-center" > 在过去的{ actualDays } 个日夜中,是屏幕前您的认可与支持,给了我们最温暖的鼓励</ p >
240+ < div className = "flex flex-nowrap items-center justify-center gap-1" >
241+ < Heart className = "size-4" />
242+ < span className = "text-sm" > 谨以此墙,致敬所有同行者</ span >
243+ </ div >
244+ </ div >
245+ </ >
246+ ) }
247+
227248 < Popover . Confirm
228249 title = "提示"
229250 description = "此列表并不是实时更新的,开发者将在您捐赠后的下一个版本中手动更新此列表,当您选择要捐赠时,请在开头添加备注“pg”,以便开发者能区分您的捐赠的项目是project-graph。"
0 commit comments