diff --git a/index.html b/index.html index f071723..666197f 100644 --- a/index.html +++ b/index.html @@ -3,6 +3,7 @@ + Кварц diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000..61f0e51 Binary files /dev/null and b/public/favicon.ico differ diff --git a/src/App.css b/src/App.css index e0d4572..2ebadf5 100644 --- a/src/App.css +++ b/src/App.css @@ -1,58 +1,43 @@ -body { - font-family: Arial, sans-serif; - display: flex; - justify-content: center; - align-items: center; - height: 100vh; +/* Глобальные стили */ +* { margin: 0; - background-color: #f5f5f5; -} - -.login-form { - background: white; - padding: 2rem; - border-radius: 8px; - box-shadow: 0 2px 4px rgba(0,0,0,0.1); - width: 300px; -} - -input { - display: block; - margin: 10px 0; - padding: 8px; - width: 100%; + padding: 0; box-sizing: border-box; } -button { - width: 100%; - padding: 10px; - background: #007bff; +body { + font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; + background: #1a1a1a; color: white; - border: none; + overflow-x: hidden; +} + +#root { + min-height: 100vh; +} + +/* Базовые стили для скроллбара */ +::-webkit-scrollbar { + width: 8px; +} + +::-webkit-scrollbar-track { + background: rgba(255, 255, 255, 0.1); +} + +::-webkit-scrollbar-thumb { + background: rgba(76, 175, 80, 0.6); border-radius: 4px; - cursor: pointer; - margin-top: 10px; } -button:disabled { - background: #cccccc; - cursor: not-allowed; +::-webkit-scrollbar-thumb:hover { + background: rgba(76, 175, 80, 0.8); } -.error-message { - color: #dc3545; - margin-top: 10px; - text-align: center; -} - -.loading { - text-align: center; - margin-top: 10px; -} - -.loading-viewer { - text-align: center; - font-size: 18px; - margin-top: 20px; +/* Отключение выделения текста для UI элементов */ +.no-select { + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; } \ No newline at end of file diff --git a/src/App.tsx b/src/App.tsx index 5616ce3..7e90070 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,6 +1,7 @@ import React from 'react'; import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom'; import Login from './pages/Login'; +import Register from './pages/Register'; import PotreeViewer from './pages/PotreeViewer'; import './App.css'; @@ -10,6 +11,7 @@ export default function App() { } /> } /> + } /> } /> {/* Все остальные маршруты ведут на логин */} } /> diff --git a/src/components/FormButton.css b/src/components/FormButton.css new file mode 100644 index 0000000..22e293e --- /dev/null +++ b/src/components/FormButton.css @@ -0,0 +1,138 @@ +/* Основная кнопка */ +.form-button { + position: relative; + width: 100%; + padding: 1rem 2rem; + border: none; + border-radius: 8px; + font-size: 1rem; + font-weight: 600; + cursor: pointer; + transition: all 0.3s ease; + overflow: hidden; + backdrop-filter: blur(10px); + animation: slideUpFade 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) both; +} + +/* Основная кнопка */ +.form-button.primary { + background: linear-gradient(135deg, #4CAF50, #45a049); + color: white; + box-shadow: + 0 4px 15px rgba(76, 175, 80, 0.3), + inset 0 1px 0 rgba(255, 255, 255, 0.2); +} + +.form-button.primary:hover:not(:disabled) { + background: linear-gradient(135deg, #45a049, #3d8b40); + box-shadow: + 0 6px 20px rgba(76, 175, 80, 0.4), + inset 0 1px 0 rgba(255, 255, 255, 0.3); + transform: translateY(-2px); +} + +.form-button.primary:active:not(:disabled) { + transform: translateY(0); + box-shadow: + 0 2px 10px rgba(76, 175, 80, 0.3), + inset 0 1px 0 rgba(255, 255, 255, 0.1); +} + +/* Вторичная кнопка */ +.form-button.secondary { + background: rgba(255, 255, 255, 0.1); + color: white; + border: 2px solid rgba(255, 255, 255, 0.3); +} + +.form-button.secondary:hover:not(:disabled) { + background: rgba(255, 255, 255, 0.2); + border-color: rgba(255, 255, 255, 0.5); + transform: translateY(-2px); + box-shadow: 0 4px 15px rgba(255, 255, 255, 0.1); +} + +.form-button.secondary:active:not(:disabled) { + transform: translateY(0); + background: rgba(255, 255, 255, 0.15); +} + +/* Отключенная кнопка */ +.form-button:disabled { + opacity: 0.6; + cursor: not-allowed; + transform: none !important; +} + +/* Состояние загрузки */ +.form-button.loading { + cursor: wait; +} + +/* Спиннер загрузки */ +.button-spinner { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); +} + +.spinner-ring { + width: 20px; + height: 20px; + border: 2px solid rgba(255, 255, 255, 0.3); + border-top: 2px solid white; + border-radius: 50%; + animation: spin 1s linear infinite; +} + +/* Текст кнопки */ +.button-text { + transition: opacity 0.3s ease; +} + +.button-text.hidden { + opacity: 0; +} + +/* Анимация вращения спиннера */ +@keyframes spin { + 0% { transform: rotate(0deg); } + 100% { transform: rotate(360deg); } +} + +/* Анимация появления снизу */ +@keyframes slideUpFade { + 0% { + opacity: 0; + transform: translateY(30px); + } + 100% { + opacity: 1; + transform: translateY(0); + } +} + +/* Эффект пульсации для основной кнопки */ +.form-button.primary::before { + content: ''; + position: absolute; + top: 0; + left: -100%; + width: 100%; + height: 100%; + background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent); + transition: left 0.5s ease; +} + +.form-button.primary:hover::before { + left: 100%; +} + +/* Адаптивность */ +@media (max-width: 768px) { + .form-button { + padding: 0.875rem 1.5rem; + font-size: 0.9rem; + } +} \ No newline at end of file diff --git a/src/components/FormButton.tsx b/src/components/FormButton.tsx new file mode 100644 index 0000000..a4f668f --- /dev/null +++ b/src/components/FormButton.tsx @@ -0,0 +1,43 @@ +import React from 'react'; +import './FormButton.css'; + +interface FormButtonProps { + type?: 'button' | 'submit'; + children: React.ReactNode; + onClick?: () => void; + disabled?: boolean; + loading?: boolean; + variant?: 'primary' | 'secondary'; + delay?: number; +} + +const FormButton: React.FC = ({ + type = 'button', + children, + onClick, + disabled = false, + loading = false, + variant = 'primary', + delay = 0 +}) => { + return ( + + ); +}; + +export default FormButton; \ No newline at end of file diff --git a/src/components/FormInput.css b/src/components/FormInput.css new file mode 100644 index 0000000..fcca931 --- /dev/null +++ b/src/components/FormInput.css @@ -0,0 +1,104 @@ +/* Контейнер поля ввода */ +.form-input-container { + position: relative; + margin-bottom: 1.5rem; + animation: slideUpFade 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) both; +} + +/* Само поле ввода */ +.form-input { + width: 100%; + padding: 1rem 0.75rem 0.5rem 0.75rem; + border: 2px solid rgba(255, 255, 255, 0.2); + border-radius: 8px; + background: rgba(0, 0, 0, 0.3); + color: white; + font-size: 1rem; + transition: all 0.3s ease; + outline: none; + backdrop-filter: blur(10px); +} + +.form-input:focus { + border-color: #4CAF50; + background: rgba(0, 0, 0, 0.4); + box-shadow: + 0 0 20px rgba(76, 175, 80, 0.3), + inset 0 0 10px rgba(76, 175, 80, 0.1); +} + +.form-input::placeholder { + color: transparent; +} + +/* Плавающий лейбл */ +.form-label { + position: absolute; + left: 0.75rem; + top: 50%; + transform: translateY(-50%); + color: rgba(255, 255, 255, 0.7); + font-size: 1rem; + pointer-events: none; + transition: all 0.3s ease; + background: transparent; + padding: 0 0.25rem; +} + +.form-label.focused { + top: 0; + transform: translateY(-50%); + font-size: 0.75rem; + color: #4CAF50; + background: rgba(0, 0, 0, 0.8); + border-radius: 4px; +} + +/* Анимированная граница */ +.form-input-border { + position: absolute; + bottom: 0; + left: 50%; + width: 0; + height: 2px; + background: linear-gradient(90deg, #4CAF50, #45a049); + transition: all 0.3s ease; + transform: translateX(-50%); +} + +.form-input:focus + .form-label + .form-input-border { + width: 100%; +} + +/* Анимация появления снизу */ +@keyframes slideUpFade { + 0% { + opacity: 0; + transform: translateY(30px); + } + 100% { + opacity: 1; + transform: translateY(0); + } +} + +/* Адаптивность */ +@media (max-width: 768px) { + .form-input-container { + margin-bottom: 1.25rem; + } + + .form-input { + padding: 0.875rem 0.625rem 0.5rem 0.625rem; + font-size: 0.9rem; + } + + .form-label { + left: 0.625rem; + font-size: 0.9rem; + } + + .form-label.focused { + font-size: 0.7rem; + } +} \ No newline at end of file diff --git a/src/components/FormInput.tsx b/src/components/FormInput.tsx new file mode 100644 index 0000000..ecee495 --- /dev/null +++ b/src/components/FormInput.tsx @@ -0,0 +1,45 @@ +import React, { useState } from 'react'; +import './FormInput.css'; + +interface FormInputProps { + type: string; + placeholder: string; + value: string; + onChange: (value: string) => void; + required?: boolean; + delay?: number; +} + +const FormInput: React.FC = ({ + type, + placeholder, + value, + onChange, + required = false, + delay = 0 +}) => { + const [isFocused, setIsFocused] = useState(false); + + return ( +
+ onChange(e.target.value)} + onFocus={() => setIsFocused(true)} + onBlur={() => setIsFocused(false)} + required={required} + className={`form-input ${isFocused || value ? 'focused' : ''}`} + /> + +
+
+ ); +}; + +export default FormInput; \ No newline at end of file diff --git a/src/pages/Login.css b/src/pages/Login.css new file mode 100644 index 0000000..3edfec5 --- /dev/null +++ b/src/pages/Login.css @@ -0,0 +1,238 @@ +/* Основная страница авторизации */ +.auth-page { + min-height: 100vh; + display: flex; + align-items: center; + justify-content: center; + padding: 1rem; + background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 50%, #1a1a1a 100%); + position: relative; + overflow: hidden; +} + +/* Анимированный фон */ +.auth-page::before { + content: ''; + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + background: + radial-gradient(circle at 20% 80%, rgba(76, 175, 80, 0.1) 0%, transparent 50%), + radial-gradient(circle at 80% 20%, rgba(76, 175, 80, 0.1) 0%, transparent 50%), + radial-gradient(circle at 40% 40%, rgba(76, 175, 80, 0.05) 0%, transparent 50%); + animation: backgroundPulse 8s ease-in-out infinite; +} + +@keyframes backgroundPulse { + 0%, 100% { opacity: 0.5; } + 50% { opacity: 1; } +} + +/* Фоновый контейнер */ +.auth-background { + position: relative; + z-index: 1; + backdrop-filter: blur(10px); + border-radius: 16px; + padding: 2rem; + background: rgba(0, 0, 0, 0.3); + border: 1px solid rgba(255, 255, 255, 0.1); + box-shadow: + 0 20px 40px rgba(0, 0, 0, 0.3), + inset 0 1px 0 rgba(255, 255, 255, 0.1); + animation: containerSlideIn 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) both; +} + +/* Контейнер формы */ +.auth-container { + width: 100%; + max-width: 400px; + margin: 0 auto; +} + +/* Заголовок */ +.auth-header { + text-align: center; + margin-bottom: 2rem; + animation: headerFadeIn 1s ease-out both; +} + +.auth-title { + font-size: 2rem; + font-weight: 700; + color: white; + margin: 0 0 0.5rem 0; + background: linear-gradient(135deg, #4CAF50, #45a049); + -webkit-background-clip: text; + -webkit-text-fill-color: transparent; + background-clip: text; + text-shadow: 0 2px 10px rgba(76, 175, 80, 0.3); +} + +.auth-subtitle { + font-size: 1rem; + color: rgba(255, 255, 255, 0.7); + margin: 0; + font-weight: 400; +} + +/* Форма */ +.auth-form { + display: flex; + flex-direction: column; + gap: 0; +} + +/* Сообщение об ошибке */ +.error-message { + display: flex; + align-items: center; + gap: 0.5rem; + padding: 1rem; + margin-bottom: 1.5rem; + background: rgba(244, 67, 54, 0.1); + border: 1px solid rgba(244, 67, 54, 0.3); + border-radius: 8px; + color: #ff6b6b; + font-size: 0.9rem; + backdrop-filter: blur(10px); + animation: slideUpFade 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) both; +} + +.error-icon { + font-size: 1.2rem; + color: #ff6b6b; +} + +/* Сообщение об успехе */ +.success-message { + display: flex; + align-items: center; + gap: 0.5rem; + padding: 1rem; + margin-bottom: 1.5rem; + background: rgba(76, 175, 80, 0.1); + border: 1px solid rgba(76, 175, 80, 0.3); + border-radius: 8px; + color: #4CAF50; + font-size: 0.9rem; + backdrop-filter: blur(10px); + animation: slideUpFade 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) both; +} + +.success-icon { + font-size: 1.2rem; + color: #4CAF50; + font-weight: bold; +} + +/* Ссылки */ +.auth-links { + text-align: center; + margin-top: 1.5rem; + animation: slideUpFade 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) both; +} + +.auth-links p { + color: rgba(255, 255, 255, 0.7); + margin: 0 0 0.5rem 0; + font-size: 0.9rem; +} + +.auth-link { + color: #4CAF50; + text-decoration: none; + font-weight: 600; + transition: all 0.3s ease; + position: relative; +} + +.auth-link::after { + content: ''; + position: absolute; + bottom: -2px; + left: 0; + width: 0; + height: 2px; + background: linear-gradient(90deg, #4CAF50, #45a049); + transition: width 0.3s ease; +} + +.auth-link:hover { + color: #45a049; + text-shadow: 0 0 10px rgba(76, 175, 80, 0.5); +} + +.auth-link:hover::after { + width: 100%; +} + +/* Анимации */ +@keyframes containerSlideIn { + 0% { + opacity: 0; + transform: translateY(50px) scale(0.9); + } + 100% { + opacity: 1; + transform: translateY(0) scale(1); + } +} + +@keyframes headerFadeIn { + 0% { + opacity: 0; + transform: translateY(-20px); + } + 100% { + opacity: 1; + transform: translateY(0); + } +} + +@keyframes slideUpFade { + 0% { + opacity: 0; + transform: translateY(30px); + } + 100% { + opacity: 1; + transform: translateY(0); + } +} + +/* Адаптивность */ +@media (max-width: 768px) { + .auth-page { + padding: 0.5rem; + } + + .auth-background { + padding: 1.5rem; + } + + .auth-title { + font-size: 1.75rem; + } + + .auth-subtitle { + font-size: 0.9rem; + } + + .auth-header { + margin-bottom: 1.5rem; + } +} + +@media (max-width: 480px) { + .auth-background { + padding: 1rem; + border-radius: 12px; + } + + .auth-title { + font-size: 1.5rem; + } +} \ No newline at end of file diff --git a/src/pages/Login.tsx b/src/pages/Login.tsx index b00fbbd..35f9227 100644 --- a/src/pages/Login.tsx +++ b/src/pages/Login.tsx @@ -1,6 +1,9 @@ import React, { useState } from 'react'; -import { useNavigate } from 'react-router-dom'; +import { useNavigate, Link } from 'react-router-dom'; import type { FormEvent } from 'react'; +import FormInput from '../components/FormInput'; +import FormButton from '../components/FormButton'; +import './Login.css'; export default function Login() { const [username, setUsername] = useState(''); @@ -69,29 +72,58 @@ export default function Login() { }; return ( -
-

Вход в систему

-
- setUsername(e.target.value)} - /> - setPassword(e.target.value)} - /> - - {loading &&
Загрузка...
} - {error &&
{error}
} -
+
+
+
+
+

Добро пожаловать в Кварц

+

Войдите в систему для продолжения

+
+ +
+ + + + + {error && ( +
+ ⚠ + {error} +
+ )} + + + Войти + + +
+

Нет аккаунта?

+ + Зарегистрироваться + +
+ +
+
); } \ No newline at end of file diff --git a/src/pages/PotreeViewer.tsx b/src/pages/PotreeViewer.tsx index 3c93f37..3605497 100644 --- a/src/pages/PotreeViewer.tsx +++ b/src/pages/PotreeViewer.tsx @@ -12,7 +12,7 @@ const PotreeViewer: React.FC = () => { const navigate = useNavigate(); const renderAreaRef = useRef(null); const [isLoading, setIsLoading] = useState(true); - const [loadingMessage, setLoadingMessage] = useState('Инициализация...'); + const [loadingMessage, setLoadingMessage] = useState('Подготовка к волшебству...'); const [error, setError] = useState(null); const [viewer, setViewer] = useState(null); const [showLoadingScreen, setShowLoadingScreen] = useState(true); @@ -86,7 +86,7 @@ const PotreeViewer: React.FC = () => { const loadPotreeScripts = async () => { try { console.log('loadPotreeScripts started'); - setLoadingMessage('Проверка готовности...'); + setLoadingMessage('Подготовка к волшебству...'); // Ждем, пока компонент полностью отрендерится await new Promise(resolve => setTimeout(resolve, 100)); @@ -110,7 +110,7 @@ const PotreeViewer: React.FC = () => { return; } - setLoadingMessage('Загрузка стилей...'); + setLoadingMessage('Собираем пиксели...'); // Загружаем CSS const cssLinks = [ @@ -132,19 +132,19 @@ const PotreeViewer: React.FC = () => { } }); - setLoadingMessage('Загрузка библиотек...'); + setLoadingMessage('Будим драконов...'); // Пробуем основную стратегию загрузки с проверками try { await loadScriptsWithChecks(); } catch (err) { console.warn('Main loading strategy failed, trying fallback:', err); - setLoadingMessage('Переключение на альтернативную загрузку...'); + setLoadingMessage('Ищем запасной план...'); // Если основная стратегия не сработала, пробуем простую загрузку await loadScriptsSimple(); } - setLoadingMessage('Проверка библиотек...'); + setLoadingMessage('Считаем единорогов...'); // Дополнительная проверка готовности console.log('Checking loaded libraries:', { @@ -164,7 +164,7 @@ const PotreeViewer: React.FC = () => { throw new Error('jQuery not loaded'); } - setLoadingMessage('Инициализация Potree...'); + setLoadingMessage('Запускаем квантовый двигатель...'); // Ждем немного перед инициализацией и еще раз проверяем render area await new Promise(resolve => setTimeout(resolve, 500)); @@ -178,7 +178,7 @@ const PotreeViewer: React.FC = () => { await initializePotree(); } catch (err) { console.error('Error loading Potree:', err); - setError(`Ошибка загрузки Potree: ${err.message}`); + setError(`Что-то пошло не так: ${err.message}`); setIsLoading(false); } }; @@ -278,7 +278,7 @@ const PotreeViewer: React.FC = () => { } console.log('Creating Potree viewer...'); - setLoadingMessage('Создание viewer...'); + setLoadingMessage('Строим виртуальную реальность...'); // Проверяем поддержку WebGL const canvas = document.createElement('canvas'); @@ -339,7 +339,7 @@ const PotreeViewer: React.FC = () => { } console.log('Viewer configured successfully'); - setLoadingMessage('Завершение инициализации...'); + setLoadingMessage('Полируем кнопочки...'); // Добавляем обработчик изменения размера окна const handleResize = () => { @@ -385,7 +385,7 @@ const PotreeViewer: React.FC = () => { // Загружаем GUI console.log('Loading GUI...'); - setLoadingMessage('Загрузка интерфейса...'); + setLoadingMessage('Настраиваем магию...'); try { await new Promise((resolve, reject) => { @@ -457,7 +457,7 @@ const PotreeViewer: React.FC = () => { // Загружаем облако точек console.log('Loading point cloud...'); - setLoadingMessage('Загрузка облака точек...'); + setLoadingMessage('Материализуем точки...'); const pointCloudOptions = [ { url: "/pointclouds/lion_takanawa.copc.laz", name: "lion_takanawa" }, @@ -471,7 +471,7 @@ const PotreeViewer: React.FC = () => { try { console.log(`Trying to load point cloud: ${option.url}`); - setLoadingMessage(`Загрузка ${option.name}...`); + setLoadingMessage('Материализуем точки...'); await new Promise((resolve, reject) => { const timeout = setTimeout(() => { @@ -533,7 +533,7 @@ const PotreeViewer: React.FC = () => { if (!pointCloudLoaded) { console.warn('No point cloud could be loaded, creating test point cloud...'); - setLoadingMessage('Создание тестового облака точек...'); + setLoadingMessage('Рисуем из воздуха...'); try { // Создаем простое тестовое облако точек diff --git a/src/pages/Register.tsx b/src/pages/Register.tsx new file mode 100644 index 0000000..95d7ce7 --- /dev/null +++ b/src/pages/Register.tsx @@ -0,0 +1,164 @@ +import React, { useState } from 'react'; +import { useNavigate, Link } from 'react-router-dom'; +import type { FormEvent } from 'react'; +import FormInput from '../components/FormInput'; +import FormButton from '../components/FormButton'; +import './Login.css'; // Используем те же стили + +export default function Register() { + const [username, setUsername] = useState(''); + const [email, setEmail] = useState(''); + const [password, setPassword] = useState(''); + const [confirmPassword, setConfirmPassword] = useState(''); + const [loading, setLoading] = useState(false); + const [error, setError] = useState(''); + const [success, setSuccess] = useState(''); + const navigate = useNavigate(); + + const handleSubmit = async (e: FormEvent) => { + e.preventDefault(); + setLoading(true); + setError(''); + setSuccess(''); + + // Валидация + if (password !== confirmPassword) { + setError('Пароли не совпадают'); + setLoading(false); + return; + } + + if (password.length < 6) { + setError('Пароль должен содержать минимум 6 символов'); + setLoading(false); + return; + } + + try { + console.log('Отправка данных регистрации:', { username, email, password }); + + const response = await fetch('/api/register', { + method: 'POST', + credentials: 'include', + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json' + }, + body: JSON.stringify({ username, email, password }) + }); + + console.log('Статус ответа:', response.status); + + let data; + try { + const text = await response.text(); + console.log('Текст ответа:', text); + + if (text.trim()) { + data = JSON.parse(text); + } else { + data = { success: false, message: 'Пустой ответ от сервера' }; + } + } catch (parseError) { + console.error('Ошибка при разборе JSON:', parseError); + data = { success: false, message: 'Некорректный формат ответа' }; + } + + if (response.ok && data.success) { + setSuccess('Регистрация успешна! Перенаправление...'); + setTimeout(() => { + navigate('/login'); + }, 2000); + return; + } + + setError(data.message || 'Ошибка при регистрации'); + setLoading(false); + } catch (err) { + console.error('Ошибка запроса:', err); + setError('Произошла ошибка при подключении к серверу'); + setLoading(false); + } + }; + + return ( +
+
+
+
+

Присоединяйтесь к Кварцу

+

Создайте аккаунт для начала работы

+
+ +
+ + + + + + + + + {error && ( +
+ ⚠ + {error} +
+ )} + + {success && ( +
+ ✓ + {success} +
+ )} + + + Зарегистрироваться + + +
+

Уже есть аккаунт?

+ + Войти + +
+ +
+
+
+ ); +} \ No newline at end of file