diff --git a/api/constants.ts b/api/constants.ts index 53e1866..95cd888 100644 --- a/api/constants.ts +++ b/api/constants.ts @@ -1,2 +1,3 @@ export const BASE_URL = process.env.NEXT_PUBLIC_SMART_API +// export const BASE_URL ='http://192.168.120.36:8000' // diff --git a/components/SmartChatBox/DateDivider.tsx b/components/SmartChatBox/DateDivider.tsx new file mode 100644 index 0000000..d6d7897 --- /dev/null +++ b/components/SmartChatBox/DateDivider.tsx @@ -0,0 +1,39 @@ +import React from 'react'; + +interface DateDividerProps { + timestamp: number; +} + +export function DateDivider({ timestamp }: DateDividerProps) { + const formatDate = (ts: number) => { + const date = new Date(ts); + const today = new Date(); + const yesterday = new Date(today); + yesterday.setDate(yesterday.getDate() - 1); + + // 判断是否是今天 + if (date.toDateString() === today.toDateString()) { + return '今天'; + } + // 判断是否是昨天 + if (date.toDateString() === yesterday.toDateString()) { + return '昨天'; + } + // 其他日期显示完整日期 + return date.toLocaleDateString('zh-CN', { + year: 'numeric', + month: 'long', + day: 'numeric' + }); + }; + + return ( +
+ {b.text} +
+ ); + case "image": + return ( +