diff --git a/app/page.jsx b/app/page.jsx index d0bfde8..acc3c47 100644 --- a/app/page.jsx +++ b/app/page.jsx @@ -135,7 +135,7 @@ function CalendarIcon(props) { function DatePicker({ value, onChange }) { const [isOpen, setIsOpen] = useState(false); const [currentMonth, setCurrentMonth] = useState(() => value ? new Date(value) : new Date()); - + // 点击外部关闭 useEffect(() => { const close = () => setIsOpen(false); @@ -159,12 +159,12 @@ function DatePicker({ value, onChange }) { const handleSelect = (e, day) => { e.stopPropagation(); const dateStr = `${year}-${String(month + 1).padStart(2, '0')}-${String(day).padStart(2, '0')}`; - + // 检查是否是未来日期 const today = new Date(); today.setHours(0, 0, 0, 0); const selectedDate = new Date(dateStr); - + if (selectedDate > today) return; // 禁止选择未来日期 onChange(dateStr); @@ -174,19 +174,19 @@ function DatePicker({ value, onChange }) { // 生成日历数据 const daysInMonth = new Date(year, month + 1, 0).getDate(); const firstDayOfWeek = new Date(year, month, 1).getDay(); // 0(Sun)-6(Sat) - + const days = []; for (let i = 0; i < firstDayOfWeek; i++) days.push(null); for (let i = 1; i <= daysInMonth; i++) days.push(i); return (
e.stopPropagation()}> -
setIsOpen(!isOpen)} - style={{ - display: 'flex', - alignItems: 'center', + style={{ + display: 'flex', + alignItems: 'center', justifyContent: 'space-between', padding: '0 12px', height: '40px', @@ -224,16 +224,16 @@ function DatePicker({ value, onChange }) {
{year}年 {month + 1}月 -
- +
{['日', '一', '二', '三', '四', '五', '六'].map(d => (
{d}
@@ -247,9 +247,9 @@ function DatePicker({ value, onChange }) { const current = new Date(dateStr); const isToday = current.getTime() === today.getTime(); const isFuture = current > today; - + return ( -
!isFuture && handleSelect(e, d)} style={{ @@ -326,12 +326,12 @@ function DonateTabs() {
-
{method === 'alipay' ? ( - 支付宝收款码 ) : ( - 微信收款码 )}
@@ -427,7 +427,7 @@ function FeedbackModal({ onClose }) { if (!nickname) { formData.set("nickname", "匿名"); } - + // Web3Forms Access Key formData.append("access_key", "c390fbb1-77e0-4aab-a939-caa75edc7319"); formData.append("subject", "基估宝 - 用户反馈"); @@ -529,16 +529,16 @@ function FeedbackModal({ onClose }) {

- 如果您有 Github 账号,也可以在本项目 - Issues - + 区留言互动

@@ -578,7 +578,7 @@ function HoldingActionModal({ fund, onClose, onAction }) {
- +
{fund?.name}
#{fund?.code}
@@ -594,13 +594,13 @@ function HoldingActionModal({ fund, onClose, onAction }) { -
- +
{fund?.name}
#{fund?.code}
@@ -801,9 +801,9 @@ function TradeModal({ type, fund, onClose, onConfirm }) {
-
- +
{fund?.name}
@@ -980,7 +980,7 @@ function HoldingEditModal({ fund, holding, onClose, onSave }) { value={amount} onChange={(e) => setAmount(e.target.value)} placeholder="请输入持有总金额" - style={{ + style={{ width: '100%', border: !amount ? '1px solid var(--danger)' : undefined }} @@ -1014,7 +1014,7 @@ function HoldingEditModal({ fund, holding, onClose, onSave }) { value={share} onChange={(e) => setShare(e.target.value)} placeholder="请输入持有份额" - style={{ + style={{ width: '100%', border: !share ? '1px solid var(--danger)' : undefined }} @@ -1031,7 +1031,7 @@ function HoldingEditModal({ fund, holding, onClose, onSave }) { value={cost} onChange={(e) => setCost(e.target.value)} placeholder="请输入持仓成本价" - style={{ + style={{ width: '100%', border: !cost ? '1px solid var(--danger)' : undefined }} @@ -1042,9 +1042,9 @@ function HoldingEditModal({ fund, holding, onClose, onSave }) {
-
)} - - )} - )}
- @@ -3330,7 +3334,7 @@ export default function HomePage() { const isAfter9 = now.getHours() >= 9; const hasTodayData = f.jzrq === todayStr; const shouldHideChange = isTradingDay && isAfter9 && !hasTodayData; - + if (!shouldHideChange) { // 如果涨跌幅列显示(即非交易时段或今日净值已更新),则显示单位净值和真实涨跌幅 return ( @@ -3370,7 +3374,7 @@ export default function HomePage() { const amount = profit ? profit.amount : null; if (amount === null) { return ( -
{ e.stopPropagation(); setHoldingModal({ open: true, fund: f }); }} @@ -3382,7 +3386,7 @@ export default function HomePage() { ); } return ( -
{ e.stopPropagation(); setActionModal({ open: true, fund: f }); }} @@ -3404,14 +3408,14 @@ export default function HomePage() { const profit = getHoldingProfit(f, holding); const profitValue = profit ? profit.profitToday : null; const hasProfit = profitValue !== null; - + return (
- 0 ? 'up' : profitValue < 0 ? 'down' : '') : 'muted'} + 0 ? 'up' : profitValue < 0 ? 'down' : '') : 'muted'} style={{ fontWeight: 700 }} > - {hasProfit + {hasProfit ? `${profitValue > 0 ? '+' : profitValue < 0 ? '-' : ''}¥${Math.abs(profitValue).toFixed(2)}` : ''} @@ -3425,15 +3429,15 @@ export default function HomePage() { const principal = holding && holding.cost && holding.share ? holding.cost * holding.share : 0; const asPercent = percentModes[f.code]; const hasTotal = total !== null; - const formatted = hasTotal - ? (asPercent && principal > 0 + const formatted = hasTotal + ? (asPercent && principal > 0 ? `${total > 0 ? '+' : total < 0 ? '-' : ''}${Math.abs((total / principal) * 100).toFixed(2)}%` : `${total > 0 ? '+' : total < 0 ? '-' : ''}¥${Math.abs(total).toFixed(2)}`) : ''; const cls = hasTotal ? (total > 0 ? 'up' : total < 0 ? 'down' : '') : 'muted'; return ( -
{ e.stopPropagation(); @@ -3487,7 +3491,7 @@ export default function HomePage() { )}
- @@ -3523,14 +3527,14 @@ export default function HomePage() { const isAfter9 = now.getHours() >= 9; const hasTodayData = f.jzrq === todayStr; const shouldHideChange = isTradingDay && isAfter9 && !hasTodayData; - + if (shouldHideChange) return null; - + return ( - 0 ? '+' : ''}${Number(f.zzl).toFixed(2)}%` : ''} - delta={f.zzl} + delta={f.zzl} /> ); })()} @@ -3541,18 +3545,18 @@ export default function HomePage() { delta={f.estPricedCoverage > 0.05 ? f.estGszzl : (Number(f.gszzl) || 0)} />
- +
{(() => { const holding = holdings[f.code]; const profit = getHoldingProfit(f, holding); - + if (!profit) { return (
持仓金额 -
setHoldingModal({ open: true, fund: f })} > @@ -3564,8 +3568,8 @@ export default function HomePage() { return ( <> -
setActionModal({ open: true, fund: f })} > @@ -3581,7 +3585,7 @@ export default function HomePage() {
{profit.profitTotal !== null && ( -
{ e.stopPropagation(); @@ -3593,7 +3597,7 @@ export default function HomePage() { 持有收益{percentModes[f.code] ? '(%)' : ''} 0 ? 'up' : profit.profitTotal < 0 ? 'down' : ''}`}> {profit.profitTotal > 0 ? '+' : profit.profitTotal < 0 ? '-' : ''} - {percentModes[f.code] + {percentModes[f.code] ? `${Math.abs((holding.cost * holding.share) ? (profit.profitTotal / (holding.cost * holding.share)) * 100 : 0).toFixed(2)}%` : `¥${Math.abs(profit.profitTotal).toFixed(2)}` } @@ -3708,7 +3712,7 @@ export default function HomePage() { 点此提交反馈

-
@@ -3829,7 +3833,7 @@ export default function HomePage() {
- +