3d tooltip
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import React, { useState, useEffect, useCallback } from 'react';
|
||||
import Image from 'next/image';
|
||||
import useNavigationStore from '@/app/store/navigationStore';
|
||||
|
||||
interface MonitoringProps {
|
||||
objectId?: string;
|
||||
onClose?: () => void;
|
||||
onSelectModel?: (modelPath: string) => void;
|
||||
}
|
||||
@@ -10,15 +10,13 @@ interface MonitoringProps {
|
||||
const Monitoring: React.FC<MonitoringProps> = ({ onClose, onSelectModel }) => {
|
||||
const [models, setModels] = useState<{ title: string; path: string }[]>([]);
|
||||
const [loadError, setLoadError] = useState<string | null>(null);
|
||||
const PREFERRED_MODEL = useNavigationStore((state) => state.PREFERRED_MODEL);
|
||||
|
||||
const handleSelectModel = useCallback((modelPath: string) => {
|
||||
console.log(`[NavigationPage] Model selected: ${modelPath}`);
|
||||
onSelectModel?.(modelPath);
|
||||
}, [onSelectModel]);
|
||||
|
||||
console.log('[Monitoring] Models:', models, 'Error:', loadError);
|
||||
|
||||
// Загружаем список доступных моделей из assets/big-models через API
|
||||
useEffect(() => {
|
||||
const fetchModels = async () => {
|
||||
try {
|
||||
@@ -31,14 +29,15 @@ const Monitoring: React.FC<MonitoringProps> = ({ onClose, onSelectModel }) => {
|
||||
const data = await res.json();
|
||||
const items: { name: string; path: string }[] = Array.isArray(data?.models) ? data.models : [];
|
||||
|
||||
// Приоритизируем указанную модель, чтобы она была первой карточкой
|
||||
const preferred = 'AerBIM-Monitor_ASM-HT-Viewer_Expo2017Astana_20250910';
|
||||
const preferredModelName = PREFERRED_MODEL.split('/').pop()?.split('.').slice(0, -1).join('.') || '';
|
||||
|
||||
const formatted = items
|
||||
.map((it) => ({ title: it.name, path: it.path }))
|
||||
.sort((a, b) => {
|
||||
const ap = a.path.includes(preferred) ? -1 : 0;
|
||||
const bp = b.path.includes(preferred) ? -1 : 0;
|
||||
if (ap !== bp) return ap - bp;
|
||||
const aName = a.path.split('/').pop()?.split('.').slice(0, -1).join('.') || '';
|
||||
const bName = b.path.split('/').pop()?.split('.').slice(0, -1).join('.') || '';
|
||||
if (aName === preferredModelName) return -1;
|
||||
if (bName === preferredModelName) return 1;
|
||||
return a.title.localeCompare(b.title);
|
||||
});
|
||||
|
||||
@@ -51,7 +50,7 @@ const Monitoring: React.FC<MonitoringProps> = ({ onClose, onSelectModel }) => {
|
||||
};
|
||||
|
||||
fetchModels();
|
||||
}, []);
|
||||
}, [PREFERRED_MODEL]);
|
||||
|
||||
return (
|
||||
<div className="w-full">
|
||||
@@ -144,7 +143,7 @@ const Monitoring: React.FC<MonitoringProps> = ({ onClose, onSelectModel }) => {
|
||||
</>
|
||||
)}
|
||||
|
||||
{models.length === 0 && (
|
||||
{models.length === 0 && !loadError && (
|
||||
<div className="col-span-2">
|
||||
<div className="rounded-lg bg-gray-200 text-gray-700 text-xs px-3 py-2 border border-gray-300">
|
||||
Список моделей пуст. Добавьте файлы в assets/big-models или проверьте API /api/big-models/list.
|
||||
|
||||
Reference in New Issue
Block a user