修正几个前端错误
parent
9b0614e7a1
commit
9c79196bf3
|
|
@ -36,7 +36,7 @@ export function Header({
|
||||||
<h1 className="text-2xl font-bold text-white tracking-tight drop-shadow-md">Cosmo</h1>
|
<h1 className="text-2xl font-bold text-white tracking-tight drop-shadow-md">Cosmo</h1>
|
||||||
{formattedCutoffDate && (
|
{formattedCutoffDate && (
|
||||||
<span className="text-xs text-gray-400 font-mono">
|
<span className="text-xs text-gray-400 font-mono">
|
||||||
(截止日期 {formattedCutoffDate})
|
({formattedCutoffDate})
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { useState } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import { ChevronLeft, ChevronRight, ChevronDown, ChevronUp, Search, Globe, Rocket, Moon, Asterisk, Sparkles } from 'lucide-react';
|
import { ChevronLeft, ChevronRight, ChevronDown, ChevronUp, Search, Globe, Rocket, Moon, Asterisk, Sparkles } from 'lucide-react';
|
||||||
import type { CelestialBody } from '../types';
|
import type { CelestialBody } from '../types';
|
||||||
|
|
||||||
|
|
@ -15,6 +15,13 @@ export function ProbeList({ probes, planets, onBodySelect, selectedBody, onReset
|
||||||
const [searchTerm, setSearchTerm] = useState('');
|
const [searchTerm, setSearchTerm] = useState('');
|
||||||
const [expandedGroup, setExpandedGroup] = useState<string | null>(null); // 只允许一个分组展开
|
const [expandedGroup, setExpandedGroup] = useState<string | null>(null); // 只允许一个分组展开
|
||||||
|
|
||||||
|
// Auto-collapse when a body is selected (focus mode)
|
||||||
|
useEffect(() => {
|
||||||
|
if (selectedBody) {
|
||||||
|
setIsCollapsed(true);
|
||||||
|
}
|
||||||
|
}, [selectedBody]);
|
||||||
|
|
||||||
// Calculate distance for sorting
|
// Calculate distance for sorting
|
||||||
const calculateDistance = (body: CelestialBody) => {
|
const calculateDistance = (body: CelestialBody) => {
|
||||||
const pos = body.positions[0];
|
const pos = body.positions[0];
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ import dayjs from 'dayjs';
|
||||||
import isBetween from 'dayjs/plugin/isBetween';
|
import isBetween from 'dayjs/plugin/isBetween';
|
||||||
import { request } from '../../utils/request';
|
import { request } from '../../utils/request';
|
||||||
import { useToast } from '../../contexts/ToastContext';
|
import { useToast } from '../../contexts/ToastContext';
|
||||||
|
import { useDataCutoffDate } from '../../hooks/useDataCutoffDate';
|
||||||
|
|
||||||
// Extend dayjs with isBetween plugin
|
// Extend dayjs with isBetween plugin
|
||||||
dayjs.extend(isBetween);
|
dayjs.extend(isBetween);
|
||||||
|
|
@ -65,6 +66,9 @@ export function NASADownload() {
|
||||||
const [downloadProgress, setDownloadProgress] = useState({ current: 0, total: 0 });
|
const [downloadProgress, setDownloadProgress] = useState({ current: 0, total: 0 });
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
|
|
||||||
|
// Get data cutoff date
|
||||||
|
const { cutoffDate } = useDataCutoffDate();
|
||||||
|
|
||||||
// Type name mapping
|
// Type name mapping
|
||||||
const typeNames: Record<string, string> = {
|
const typeNames: Record<string, string> = {
|
||||||
star: '恒星',
|
star: '恒星',
|
||||||
|
|
@ -260,13 +264,16 @@ export function NASADownload() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Alert
|
{/* Data Cutoff Date Display */}
|
||||||
title="数据下载说明"
|
{cutoffDate && (
|
||||||
description="选择左侧天体,右侧日历将显示数据可用性。点击未下载的日期可下载该天的位置数据(00:00 UTC)。"
|
<Alert
|
||||||
type="info"
|
message={`数据截止日期: ${cutoffDate.getFullYear()}/${String(cutoffDate.getMonth() + 1).padStart(2, '0')}/${String(cutoffDate.getDate()).padStart(2, '0')}`}
|
||||||
showIcon
|
description="选择左侧天体,右侧日历将显示数据可用性。点击未下载的日期可下载该天的位置数据(00:00 UTC)。"
|
||||||
style={{ marginBottom: 16 }}
|
type="success"
|
||||||
/>
|
showIcon
|
||||||
|
style={{ marginBottom: 16 }}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
<Row gutter={16}>
|
<Row gutter={16}>
|
||||||
{/* Left: Body Selection */}
|
{/* Left: Body Selection */}
|
||||||
|
|
@ -281,7 +288,7 @@ export function NASADownload() {
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Collapse
|
<Collapse
|
||||||
defaultActiveKey={['planet', 'dwarf_planet']}
|
defaultActiveKey={[]}
|
||||||
items={Object.entries(bodies).map(([type, typeBodies]) => ({
|
items={Object.entries(bodies).map(([type, typeBodies]) => ({
|
||||||
key: type,
|
key: type,
|
||||||
label: (
|
label: (
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ export function Tasks() {
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
const res = await request.get('/celestial/tasks?limit=50');
|
const res = await request.get('/tasks?limit=50');
|
||||||
setData(res.data);
|
setData(res.data);
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
|
@ -42,10 +42,10 @@ export function Tasks() {
|
||||||
// Polling for active tasks
|
// Polling for active tasks
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
loadData();
|
loadData();
|
||||||
|
|
||||||
timerRef.current = setInterval(() => {
|
timerRef.current = setInterval(() => {
|
||||||
// Silent refresh to avoid table flickering
|
// Silent refresh to avoid table flickering
|
||||||
request.get('/celestial/tasks?limit=50').then(res => {
|
request.get('/tasks?limit=50').then(res => {
|
||||||
setData(res.data);
|
setData(res.data);
|
||||||
});
|
});
|
||||||
}, 3000);
|
}, 3000);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue