добавил страницу регистрации,
изменил стили страницы авторизации, добавил фовиконку
This commit is contained in:
parent
58f03dd078
commit
9152bd48eb
@ -3,6 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
|
||||
<title>Кварц</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
BIN
public/favicon.ico
Normal file
BIN
public/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
79
src/App.css
79
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;
|
||||
}
|
||||
@ -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() {
|
||||
<Routes>
|
||||
<Route path="/" element={<Navigate to="/login" />} />
|
||||
<Route path="/login" element={<Login />} />
|
||||
<Route path="/register" element={<Register />} />
|
||||
<Route path="/viewer" element={<PotreeViewer />} />
|
||||
{/* Все остальные маршруты ведут на логин */}
|
||||
<Route path="*" element={<Navigate to="/login" />} />
|
||||
|
||||
138
src/components/FormButton.css
Normal file
138
src/components/FormButton.css
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
43
src/components/FormButton.tsx
Normal file
43
src/components/FormButton.tsx
Normal file
@ -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<FormButtonProps> = ({
|
||||
type = 'button',
|
||||
children,
|
||||
onClick,
|
||||
disabled = false,
|
||||
loading = false,
|
||||
variant = 'primary',
|
||||
delay = 0
|
||||
}) => {
|
||||
return (
|
||||
<button
|
||||
type={type}
|
||||
onClick={onClick}
|
||||
disabled={disabled || loading}
|
||||
className={`form-button ${variant} ${loading ? 'loading' : ''}`}
|
||||
style={{ animationDelay: `${delay}ms` }}
|
||||
>
|
||||
{loading && (
|
||||
<div className="button-spinner">
|
||||
<div className="spinner-ring"></div>
|
||||
</div>
|
||||
)}
|
||||
<span className={`button-text ${loading ? 'hidden' : ''}`}>
|
||||
{children}
|
||||
</span>
|
||||
</button>
|
||||
);
|
||||
};
|
||||
|
||||
export default FormButton;
|
||||
104
src/components/FormInput.css
Normal file
104
src/components/FormInput.css
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
45
src/components/FormInput.tsx
Normal file
45
src/components/FormInput.tsx
Normal file
@ -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<FormInputProps> = ({
|
||||
type,
|
||||
placeholder,
|
||||
value,
|
||||
onChange,
|
||||
required = false,
|
||||
delay = 0
|
||||
}) => {
|
||||
const [isFocused, setIsFocused] = useState(false);
|
||||
|
||||
return (
|
||||
<div
|
||||
className="form-input-container"
|
||||
style={{ animationDelay: `${delay}ms` }}
|
||||
>
|
||||
<input
|
||||
type={type}
|
||||
value={value}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
onFocus={() => setIsFocused(true)}
|
||||
onBlur={() => setIsFocused(false)}
|
||||
required={required}
|
||||
className={`form-input ${isFocused || value ? 'focused' : ''}`}
|
||||
/>
|
||||
<label className={`form-label ${isFocused || value ? 'focused' : ''}`}>
|
||||
{placeholder}
|
||||
</label>
|
||||
<div className="form-input-border"></div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default FormInput;
|
||||
238
src/pages/Login.css
Normal file
238
src/pages/Login.css
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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 (
|
||||
<div className="login-form">
|
||||
<h2>Вход в систему</h2>
|
||||
<form onSubmit={handleSubmit}>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Имя пользователя"
|
||||
required
|
||||
value={username}
|
||||
onChange={(e) => setUsername(e.target.value)}
|
||||
/>
|
||||
<input
|
||||
type="password"
|
||||
placeholder="Пароль"
|
||||
required
|
||||
value={password}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
/>
|
||||
<button type="submit" disabled={loading}>
|
||||
Войти
|
||||
</button>
|
||||
{loading && <div className="loading">Загрузка...</div>}
|
||||
{error && <div className="error-message">{error}</div>}
|
||||
</form>
|
||||
<div className="auth-page">
|
||||
<div className="auth-background">
|
||||
<div className="auth-container">
|
||||
<div className="auth-header">
|
||||
<h1 className="auth-title">Добро пожаловать в Кварц</h1>
|
||||
<p className="auth-subtitle">Войдите в систему для продолжения</p>
|
||||
</div>
|
||||
|
||||
<form onSubmit={handleSubmit} className="auth-form">
|
||||
<FormInput
|
||||
type="text"
|
||||
placeholder="Имя пользователя"
|
||||
value={username}
|
||||
onChange={setUsername}
|
||||
required
|
||||
delay={100}
|
||||
/>
|
||||
|
||||
<FormInput
|
||||
type="password"
|
||||
placeholder="Пароль"
|
||||
value={password}
|
||||
onChange={setPassword}
|
||||
required
|
||||
delay={200}
|
||||
/>
|
||||
|
||||
{error && (
|
||||
<div className="error-message" style={{ animationDelay: '300ms' }}>
|
||||
<span className="error-icon">⚠</span>
|
||||
{error}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<FormButton
|
||||
type="submit"
|
||||
loading={loading}
|
||||
variant="primary"
|
||||
delay={300}
|
||||
>
|
||||
Войти
|
||||
</FormButton>
|
||||
|
||||
<div className="auth-links" style={{ animationDelay: '400ms' }}>
|
||||
<p>Нет аккаунта?</p>
|
||||
<Link to="/register" className="auth-link">
|
||||
Зарегистрироваться
|
||||
</Link>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@ -12,7 +12,7 @@ const PotreeViewer: React.FC = () => {
|
||||
const navigate = useNavigate();
|
||||
const renderAreaRef = useRef<HTMLDivElement>(null);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [loadingMessage, setLoadingMessage] = useState('Инициализация...');
|
||||
const [loadingMessage, setLoadingMessage] = useState('Подготовка к волшебству...');
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [viewer, setViewer] = useState<any>(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<void>((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<void>((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 {
|
||||
// Создаем простое тестовое облако точек
|
||||
|
||||
164
src/pages/Register.tsx
Normal file
164
src/pages/Register.tsx
Normal file
@ -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 (
|
||||
<div className="auth-page">
|
||||
<div className="auth-background">
|
||||
<div className="auth-container">
|
||||
<div className="auth-header">
|
||||
<h1 className="auth-title">Присоединяйтесь к Кварцу</h1>
|
||||
<p className="auth-subtitle">Создайте аккаунт для начала работы</p>
|
||||
</div>
|
||||
|
||||
<form onSubmit={handleSubmit} className="auth-form">
|
||||
<FormInput
|
||||
type="text"
|
||||
placeholder="Имя пользователя"
|
||||
value={username}
|
||||
onChange={setUsername}
|
||||
required
|
||||
delay={100}
|
||||
/>
|
||||
|
||||
<FormInput
|
||||
type="email"
|
||||
placeholder="Email"
|
||||
value={email}
|
||||
onChange={setEmail}
|
||||
required
|
||||
delay={150}
|
||||
/>
|
||||
|
||||
<FormInput
|
||||
type="password"
|
||||
placeholder="Пароль"
|
||||
value={password}
|
||||
onChange={setPassword}
|
||||
required
|
||||
delay={200}
|
||||
/>
|
||||
|
||||
<FormInput
|
||||
type="password"
|
||||
placeholder="Подтвердите пароль"
|
||||
value={confirmPassword}
|
||||
onChange={setConfirmPassword}
|
||||
required
|
||||
delay={250}
|
||||
/>
|
||||
|
||||
{error && (
|
||||
<div className="error-message" style={{ animationDelay: '300ms' }}>
|
||||
<span className="error-icon">⚠</span>
|
||||
{error}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{success && (
|
||||
<div className="success-message" style={{ animationDelay: '300ms' }}>
|
||||
<span className="success-icon">✓</span>
|
||||
{success}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<FormButton
|
||||
type="submit"
|
||||
loading={loading}
|
||||
variant="primary"
|
||||
delay={350}
|
||||
>
|
||||
Зарегистрироваться
|
||||
</FormButton>
|
||||
|
||||
<div className="auth-links" style={{ animationDelay: '400ms' }}>
|
||||
<p>Уже есть аккаунт?</p>
|
||||
<Link to="/login" className="auth-link">
|
||||
Войти
|
||||
</Link>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user