OhMyDitzzy commited on
Commit ·
99191cb
1
Parent(s): 1078fbb
comic,
Browse files- src/App.tsx +5 -1
- src/modules/comic/ComicLanding.css +457 -0
- src/modules/comic/ComicLanding.tsx +324 -0
- src/modules/comic/ComicReader.css +494 -0
- src/modules/comic/ComicReader.tsx +369 -0
- src/server/websocket.ts +121 -3
src/App.tsx
CHANGED
|
@@ -2,6 +2,8 @@ import { BrowserRouter, Route, Routes } from "react-router-dom";
|
|
| 2 |
import { NotFoundPage } from "./modules/error/NotFound";
|
| 3 |
import { HomePage } from "./modules/homepage/HomePage";
|
| 4 |
import { RegisterPage } from "./modules/register/RegisterPage";
|
|
|
|
|
|
|
| 5 |
|
| 6 |
export default function App() {
|
| 7 |
return (
|
|
@@ -9,8 +11,10 @@ export default function App() {
|
|
| 9 |
<Routes>
|
| 10 |
<Route path="/" element={<HomePage />} />
|
| 11 |
<Route path="/register/:sessionId" element={<RegisterPage />} />
|
|
|
|
|
|
|
| 12 |
<Route path="*" element={<NotFoundPage />} />
|
| 13 |
</Routes>
|
| 14 |
</BrowserRouter>
|
| 15 |
)
|
| 16 |
-
}
|
|
|
|
| 2 |
import { NotFoundPage } from "./modules/error/NotFound";
|
| 3 |
import { HomePage } from "./modules/homepage/HomePage";
|
| 4 |
import { RegisterPage } from "./modules/register/RegisterPage";
|
| 5 |
+
import { ComicLanding } from "./modules/comic/ComicLanding";
|
| 6 |
+
import { ComicReader } from "./modules/comic/ComicReader";
|
| 7 |
|
| 8 |
export default function App() {
|
| 9 |
return (
|
|
|
|
| 11 |
<Routes>
|
| 12 |
<Route path="/" element={<HomePage />} />
|
| 13 |
<Route path="/register/:sessionId" element={<RegisterPage />} />
|
| 14 |
+
<Route path="/comic/:sessionId" element={<ComicLanding />} />
|
| 15 |
+
<Route path="/read/:sessionId" element={<ComicReader />} />
|
| 16 |
<Route path="*" element={<NotFoundPage />} />
|
| 17 |
</Routes>
|
| 18 |
</BrowserRouter>
|
| 19 |
)
|
| 20 |
+
}
|
src/modules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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.comic-landing {
|
| 2 |
+
min-height: 100vh;
|
| 3 |
+
background: linear-gradient(135deg, #0f0f1e 0%, #1a1a2e 100%);
|
| 4 |
+
color: #fff;
|
| 5 |
+
}
|
| 6 |
+
|
| 7 |
+
.loading-container,
|
| 8 |
+
.error-container {
|
| 9 |
+
display: flex;
|
| 10 |
+
flex-direction: column;
|
| 11 |
+
align-items: center;
|
| 12 |
+
justify-content: center;
|
| 13 |
+
min-height: 100vh;
|
| 14 |
+
gap: 1.5rem;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
.spinner {
|
| 18 |
+
width: 50px;
|
| 19 |
+
height: 50px;
|
| 20 |
+
border: 4px solid rgba(255, 255, 255, 0.1);
|
| 21 |
+
border-top-color: #667eea;
|
| 22 |
+
border-radius: 50%;
|
| 23 |
+
animation: spin 1s linear infinite;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
@keyframes spin {
|
| 27 |
+
to { transform: rotate(360deg); }
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
.error-icon {
|
| 31 |
+
font-size: 4rem;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
.error-container h2 {
|
| 35 |
+
margin: 0;
|
| 36 |
+
font-size: 2rem;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
.error-container p {
|
| 40 |
+
margin: 0;
|
| 41 |
+
opacity: 0.7;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
.error-container button {
|
| 45 |
+
margin-top: 1rem;
|
| 46 |
+
padding: 0.75rem 2rem;
|
| 47 |
+
background: #667eea;
|
| 48 |
+
border: none;
|
| 49 |
+
border-radius: 8px;
|
| 50 |
+
color: white;
|
| 51 |
+
font-weight: 600;
|
| 52 |
+
cursor: pointer;
|
| 53 |
+
transition: all 0.3s;
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
.error-container button:hover {
|
| 57 |
+
background: #5568d3;
|
| 58 |
+
transform: translateY(-2px);
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
.auth-container {
|
| 62 |
+
display: flex;
|
| 63 |
+
align-items: center;
|
| 64 |
+
justify-content: center;
|
| 65 |
+
min-height: 100vh;
|
| 66 |
+
padding: 2rem;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
.auth-card {
|
| 70 |
+
background: rgba(255, 255, 255, 0.05);
|
| 71 |
+
backdrop-filter: blur(10px);
|
| 72 |
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
| 73 |
+
border-radius: 20px;
|
| 74 |
+
padding: 3rem;
|
| 75 |
+
max-width: 450px;
|
| 76 |
+
width: 100%;
|
| 77 |
+
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
.auth-header {
|
| 81 |
+
text-align: center;
|
| 82 |
+
margin-bottom: 2rem;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
.lock-icon {
|
| 86 |
+
font-size: 3rem;
|
| 87 |
+
margin-bottom: 1rem;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
.auth-header h2 {
|
| 91 |
+
margin: 0 0 0.5rem 0;
|
| 92 |
+
font-size: 1.75rem;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
.auth-header p {
|
| 96 |
+
margin: 0;
|
| 97 |
+
opacity: 0.7;
|
| 98 |
+
font-size: 0.95rem;
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
.auth-form {
|
| 102 |
+
display: flex;
|
| 103 |
+
flex-direction: column;
|
| 104 |
+
gap: 1.5rem;
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
.input-group {
|
| 108 |
+
position: relative;
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
.password-input {
|
| 112 |
+
width: 100%;
|
| 113 |
+
padding: 1rem;
|
| 114 |
+
background: rgba(255, 255, 255, 0.05);
|
| 115 |
+
border: 2px solid rgba(255, 255, 255, 0.1);
|
| 116 |
+
border-radius: 12px;
|
| 117 |
+
color: white;
|
| 118 |
+
font-size: 1rem;
|
| 119 |
+
transition: all 0.3s;
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
.password-input:focus {
|
| 123 |
+
outline: none;
|
| 124 |
+
border-color: #667eea;
|
| 125 |
+
background: rgba(255, 255, 255, 0.08);
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
.error-message {
|
| 129 |
+
padding: 0.75rem;
|
| 130 |
+
background: rgba(239, 68, 68, 0.1);
|
| 131 |
+
border: 1px solid rgba(239, 68, 68, 0.3);
|
| 132 |
+
border-radius: 8px;
|
| 133 |
+
color: #fca5a5;
|
| 134 |
+
font-size: 0.9rem;
|
| 135 |
+
text-align: center;
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
.submit-btn {
|
| 139 |
+
padding: 1rem;
|
| 140 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 141 |
+
border: none;
|
| 142 |
+
border-radius: 12px;
|
| 143 |
+
color: white;
|
| 144 |
+
font-size: 1.1rem;
|
| 145 |
+
font-weight: 600;
|
| 146 |
+
cursor: pointer;
|
| 147 |
+
transition: all 0.3s;
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
.submit-btn:hover {
|
| 151 |
+
transform: translateY(-2px);
|
| 152 |
+
box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
.auth-footer {
|
| 156 |
+
margin-top: 1.5rem;
|
| 157 |
+
text-align: center;
|
| 158 |
+
opacity: 0.6;
|
| 159 |
+
font-size: 0.85rem;
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
.hero-section {
|
| 163 |
+
position: relative;
|
| 164 |
+
padding: 4rem 2rem;
|
| 165 |
+
overflow: hidden;
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
.hero-backdrop {
|
| 169 |
+
position: absolute;
|
| 170 |
+
top: 0;
|
| 171 |
+
left: 0;
|
| 172 |
+
right: 0;
|
| 173 |
+
bottom: 0;
|
| 174 |
+
background-size: cover;
|
| 175 |
+
background-position: center;
|
| 176 |
+
filter: blur(20px) brightness(0.3);
|
| 177 |
+
transform: scale(1.1);
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
.hero-content {
|
| 181 |
+
position: relative;
|
| 182 |
+
max-width: 1200px;
|
| 183 |
+
margin: 0 auto;
|
| 184 |
+
display: grid;
|
| 185 |
+
grid-template-columns: 300px 1fr;
|
| 186 |
+
gap: 3rem;
|
| 187 |
+
align-items: start;
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
.hero-thumbnail {
|
| 191 |
+
position: relative;
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
.hero-thumbnail img {
|
| 195 |
+
width: 100%;
|
| 196 |
+
border-radius: 16px;
|
| 197 |
+
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
.type-badge {
|
| 201 |
+
position: absolute;
|
| 202 |
+
top: 1rem;
|
| 203 |
+
right: 1rem;
|
| 204 |
+
padding: 0.5rem 1rem;
|
| 205 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 206 |
+
border-radius: 8px;
|
| 207 |
+
font-size: 0.85rem;
|
| 208 |
+
font-weight: 600;
|
| 209 |
+
text-transform: uppercase;
|
| 210 |
+
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
.hero-info {
|
| 214 |
+
padding-top: 1rem;
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
.comic-title {
|
| 218 |
+
margin: 0 0 0.5rem 0;
|
| 219 |
+
font-size: 2.5rem;
|
| 220 |
+
font-weight: 800;
|
| 221 |
+
background: linear-gradient(135deg, #fff 0%, #667eea 100%);
|
| 222 |
+
-webkit-background-clip: text;
|
| 223 |
+
-webkit-text-fill-color: transparent;
|
| 224 |
+
background-clip: text;
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
.comic-subtitle {
|
| 228 |
+
margin: 0 0 1.5rem 0;
|
| 229 |
+
font-size: 1.25rem;
|
| 230 |
+
opacity: 0.7;
|
| 231 |
+
font-weight: 400;
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
.meta-info {
|
| 235 |
+
display: flex;
|
| 236 |
+
flex-wrap: wrap;
|
| 237 |
+
gap: 1.5rem;
|
| 238 |
+
margin-bottom: 1.5rem;
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
+
.meta-item {
|
| 242 |
+
display: flex;
|
| 243 |
+
flex-direction: column;
|
| 244 |
+
gap: 0.25rem;
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
.meta-label {
|
| 248 |
+
font-size: 0.75rem;
|
| 249 |
+
opacity: 0.6;
|
| 250 |
+
text-transform: uppercase;
|
| 251 |
+
letter-spacing: 0.5px;
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
.meta-value {
|
| 255 |
+
font-size: 1rem;
|
| 256 |
+
font-weight: 600;
|
| 257 |
+
}
|
| 258 |
+
|
| 259 |
+
.status-ongoing {
|
| 260 |
+
color: #10b981;
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
.status-completed {
|
| 264 |
+
color: #667eea;
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
.genre-tags {
|
| 268 |
+
display: flex;
|
| 269 |
+
flex-wrap: wrap;
|
| 270 |
+
gap: 0.5rem;
|
| 271 |
+
margin-bottom: 2rem;
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
.genre-tag {
|
| 275 |
+
padding: 0.5rem 1rem;
|
| 276 |
+
background: rgba(102, 126, 234, 0.2);
|
| 277 |
+
border: 1px solid rgba(102, 126, 234, 0.3);
|
| 278 |
+
border-radius: 20px;
|
| 279 |
+
font-size: 0.85rem;
|
| 280 |
+
font-weight: 500;
|
| 281 |
+
}
|
| 282 |
+
|
| 283 |
+
.synopsis {
|
| 284 |
+
background: rgba(255, 255, 255, 0.05);
|
| 285 |
+
padding: 1.5rem;
|
| 286 |
+
border-radius: 12px;
|
| 287 |
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
.synopsis h3 {
|
| 291 |
+
margin: 0 0 1rem 0;
|
| 292 |
+
font-size: 1.25rem;
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
.synopsis p {
|
| 296 |
+
margin: 0;
|
| 297 |
+
line-height: 1.7;
|
| 298 |
+
opacity: 0.85;
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
.chapters-section {
|
| 302 |
+
max-width: 1200px;
|
| 303 |
+
margin: 0 auto;
|
| 304 |
+
padding: 3rem 2rem;
|
| 305 |
+
}
|
| 306 |
+
|
| 307 |
+
.chapters-header {
|
| 308 |
+
display: flex;
|
| 309 |
+
justify-content: space-between;
|
| 310 |
+
align-items: center;
|
| 311 |
+
margin-bottom: 2rem;
|
| 312 |
+
flex-wrap: wrap;
|
| 313 |
+
gap: 1rem;
|
| 314 |
+
}
|
| 315 |
+
|
| 316 |
+
.chapters-header h2 {
|
| 317 |
+
margin: 0;
|
| 318 |
+
font-size: 2rem;
|
| 319 |
+
}
|
| 320 |
+
|
| 321 |
+
.chapters-controls {
|
| 322 |
+
display: flex;
|
| 323 |
+
gap: 1rem;
|
| 324 |
+
align-items: center;
|
| 325 |
+
}
|
| 326 |
+
|
| 327 |
+
.search-box input {
|
| 328 |
+
padding: 0.75rem 1rem;
|
| 329 |
+
background: rgba(255, 255, 255, 0.05);
|
| 330 |
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
| 331 |
+
border-radius: 10px;
|
| 332 |
+
color: white;
|
| 333 |
+
font-size: 0.95rem;
|
| 334 |
+
width: 250px;
|
| 335 |
+
transition: all 0.3s;
|
| 336 |
+
}
|
| 337 |
+
|
| 338 |
+
.search-box input:focus {
|
| 339 |
+
outline: none;
|
| 340 |
+
border-color: #667eea;
|
| 341 |
+
background: rgba(255, 255, 255, 0.08);
|
| 342 |
+
}
|
| 343 |
+
|
| 344 |
+
.sort-btn {
|
| 345 |
+
padding: 0.75rem 1.25rem;
|
| 346 |
+
background: rgba(255, 255, 255, 0.05);
|
| 347 |
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
| 348 |
+
border-radius: 10px;
|
| 349 |
+
color: white;
|
| 350 |
+
font-size: 0.9rem;
|
| 351 |
+
font-weight: 500;
|
| 352 |
+
cursor: pointer;
|
| 353 |
+
transition: all 0.3s;
|
| 354 |
+
white-space: nowrap;
|
| 355 |
+
}
|
| 356 |
+
|
| 357 |
+
.sort-btn:hover {
|
| 358 |
+
background: rgba(255, 255, 255, 0.1);
|
| 359 |
+
border-color: #667eea;
|
| 360 |
+
}
|
| 361 |
+
|
| 362 |
+
.chapters-list {
|
| 363 |
+
display: flex;
|
| 364 |
+
flex-direction: column;
|
| 365 |
+
gap: 0.75rem;
|
| 366 |
+
}
|
| 367 |
+
|
| 368 |
+
.chapter-item {
|
| 369 |
+
display: flex;
|
| 370 |
+
justify-content: space-between;
|
| 371 |
+
align-items: center;
|
| 372 |
+
padding: 1.25rem 1.5rem;
|
| 373 |
+
background: rgba(255, 255, 255, 0.03);
|
| 374 |
+
border: 1px solid rgba(255, 255, 255, 0.08);
|
| 375 |
+
border-radius: 12px;
|
| 376 |
+
cursor: pointer;
|
| 377 |
+
transition: all 0.3s;
|
| 378 |
+
}
|
| 379 |
+
|
| 380 |
+
.chapter-item:hover {
|
| 381 |
+
background: rgba(255, 255, 255, 0.08);
|
| 382 |
+
border-color: #667eea;
|
| 383 |
+
transform: translateX(4px);
|
| 384 |
+
}
|
| 385 |
+
|
| 386 |
+
.chapter-info {
|
| 387 |
+
display: flex;
|
| 388 |
+
flex-direction: column;
|
| 389 |
+
gap: 0.5rem;
|
| 390 |
+
flex: 1;
|
| 391 |
+
}
|
| 392 |
+
|
| 393 |
+
.chapter-number {
|
| 394 |
+
font-size: 1.1rem;
|
| 395 |
+
font-weight: 600;
|
| 396 |
+
}
|
| 397 |
+
|
| 398 |
+
.chapter-meta {
|
| 399 |
+
display: flex;
|
| 400 |
+
gap: 1rem;
|
| 401 |
+
font-size: 0.85rem;
|
| 402 |
+
opacity: 0.6;
|
| 403 |
+
}
|
| 404 |
+
|
| 405 |
+
.chapter-action {
|
| 406 |
+
display: flex;
|
| 407 |
+
align-items: center;
|
| 408 |
+
}
|
| 409 |
+
|
| 410 |
+
.read-btn {
|
| 411 |
+
font-weight: 600;
|
| 412 |
+
color: #667eea;
|
| 413 |
+
transition: all 0.3s;
|
| 414 |
+
}
|
| 415 |
+
|
| 416 |
+
.chapter-item:hover .read-btn {
|
| 417 |
+
transform: translateX(4px);
|
| 418 |
+
}
|
| 419 |
+
|
| 420 |
+
.no-results {
|
| 421 |
+
text-align: center;
|
| 422 |
+
padding: 3rem;
|
| 423 |
+
opacity: 0.5;
|
| 424 |
+
}
|
| 425 |
+
|
| 426 |
+
@media (max-width: 768px) {
|
| 427 |
+
.hero-content {
|
| 428 |
+
grid-template-columns: 1fr;
|
| 429 |
+
gap: 2rem;
|
| 430 |
+
}
|
| 431 |
+
|
| 432 |
+
.hero-thumbnail {
|
| 433 |
+
max-width: 250px;
|
| 434 |
+
margin: 0 auto;
|
| 435 |
+
}
|
| 436 |
+
|
| 437 |
+
.comic-title {
|
| 438 |
+
font-size: 2rem;
|
| 439 |
+
}
|
| 440 |
+
|
| 441 |
+
.chapters-header {
|
| 442 |
+
flex-direction: column;
|
| 443 |
+
align-items: stretch;
|
| 444 |
+
}
|
| 445 |
+
|
| 446 |
+
.chapters-controls {
|
| 447 |
+
flex-direction: column;
|
| 448 |
+
}
|
| 449 |
+
|
| 450 |
+
.search-box input {
|
| 451 |
+
width: 100%;
|
| 452 |
+
}
|
| 453 |
+
|
| 454 |
+
.auth-card {
|
| 455 |
+
padding: 2rem;
|
| 456 |
+
}
|
| 457 |
+
}
|
src/modules/comic/ComicLanding.tsx
ADDED
|
@@ -0,0 +1,324 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useEffect, useState } from 'react';
|
| 2 |
+
import { useParams, useNavigate } from 'react-router-dom';
|
| 3 |
+
import './ComicLanding.css';
|
| 4 |
+
|
| 5 |
+
interface Chapter {
|
| 6 |
+
slug: string;
|
| 7 |
+
chapter: string;
|
| 8 |
+
date: string;
|
| 9 |
+
views: string;
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
interface ComicData {
|
| 13 |
+
slug: string;
|
| 14 |
+
title: string;
|
| 15 |
+
indonesiaTitle: string;
|
| 16 |
+
type: string;
|
| 17 |
+
author: string;
|
| 18 |
+
status: string;
|
| 19 |
+
genre: string[];
|
| 20 |
+
synopsis: string;
|
| 21 |
+
thumbnailUrl: string;
|
| 22 |
+
chapters: Chapter[];
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
export function ComicLanding() {
|
| 26 |
+
const { sessionId } = useParams();
|
| 27 |
+
const navigate = useNavigate();
|
| 28 |
+
|
| 29 |
+
const [isAuth, setIsAuth] = useState(false);
|
| 30 |
+
const [password, setPassword] = useState('');
|
| 31 |
+
const [comicData, setComicData] = useState<ComicData | null>(null);
|
| 32 |
+
const [loading, setLoading] = useState(true);
|
| 33 |
+
const [error, setError] = useState('');
|
| 34 |
+
const [searchQuery, setSearchQuery] = useState('');
|
| 35 |
+
const [sortOrder, setSortOrder] = useState<'asc' | 'desc'>('desc');
|
| 36 |
+
|
| 37 |
+
const [ws, setWs] = useState<WebSocket | null>(null);
|
| 38 |
+
|
| 39 |
+
useEffect(() => {
|
| 40 |
+
const storedSession = sessionStorage.getItem(`comic_${sessionId}`);
|
| 41 |
+
if (storedSession) {
|
| 42 |
+
const session = JSON.parse(storedSession);
|
| 43 |
+
const now = Date.now();
|
| 44 |
+
|
| 45 |
+
if (now < session.expiresAt) {
|
| 46 |
+
setIsAuth(true);
|
| 47 |
+
setPassword(session.password);
|
| 48 |
+
return;
|
| 49 |
+
} else {
|
| 50 |
+
sessionStorage.removeItem(`comic_${sessionId}`);
|
| 51 |
+
}
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
| 55 |
+
const wsUrl = `${protocol}//${window.location.host}/ws`;
|
| 56 |
+
const websocket = new WebSocket(wsUrl);
|
| 57 |
+
|
| 58 |
+
websocket.onopen = () => {
|
| 59 |
+
console.log('[WS] Connected');
|
| 60 |
+
websocket.send(JSON.stringify({
|
| 61 |
+
type: 'validate_comic_password',
|
| 62 |
+
sessionId
|
| 63 |
+
}));
|
| 64 |
+
};
|
| 65 |
+
|
| 66 |
+
websocket.onmessage = (event) => {
|
| 67 |
+
const message = JSON.parse(event.data);
|
| 68 |
+
|
| 69 |
+
if (message.type === 'password_validation_response') {
|
| 70 |
+
if (!message.success) {
|
| 71 |
+
setError(message.error || 'Session tidak valid');
|
| 72 |
+
setLoading(false);
|
| 73 |
+
} else {
|
| 74 |
+
setLoading(false);
|
| 75 |
+
}
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
if (message.type === 'comic_data_response') {
|
| 79 |
+
if (message.success) {
|
| 80 |
+
setComicData(message.data);
|
| 81 |
+
setIsAuth(true);
|
| 82 |
+
sessionStorage.setItem(`comic_${sessionId}`, JSON.stringify({
|
| 83 |
+
password,
|
| 84 |
+
expiresAt: message.expiresAt
|
| 85 |
+
}));
|
| 86 |
+
} else {
|
| 87 |
+
setError(message.error || 'Gagal memuat data');
|
| 88 |
+
}
|
| 89 |
+
}
|
| 90 |
+
};
|
| 91 |
+
|
| 92 |
+
websocket.onerror = () => {
|
| 93 |
+
setError('Koneksi WebSocket gagal');
|
| 94 |
+
setLoading(false);
|
| 95 |
+
};
|
| 96 |
+
|
| 97 |
+
setWs(websocket);
|
| 98 |
+
|
| 99 |
+
return () => {
|
| 100 |
+
websocket.close();
|
| 101 |
+
};
|
| 102 |
+
}, [sessionId]);
|
| 103 |
+
|
| 104 |
+
useEffect(() => {
|
| 105 |
+
if (isAuth && ws && !comicData) {
|
| 106 |
+
ws.send(JSON.stringify({
|
| 107 |
+
type: 'request_comic_data',
|
| 108 |
+
sessionId,
|
| 109 |
+
password
|
| 110 |
+
}));
|
| 111 |
+
}
|
| 112 |
+
}, [isAuth, ws, comicData, sessionId, password]);
|
| 113 |
+
|
| 114 |
+
const handlePasswordSubmit = (e: React.FormEvent) => {
|
| 115 |
+
e.preventDefault();
|
| 116 |
+
|
| 117 |
+
if (!password.trim()) {
|
| 118 |
+
setError('Password tidak boleh kosong');
|
| 119 |
+
return;
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
if (ws) {
|
| 123 |
+
ws.send(JSON.stringify({
|
| 124 |
+
type: 'request_comic_data',
|
| 125 |
+
sessionId,
|
| 126 |
+
password: password.trim()
|
| 127 |
+
}));
|
| 128 |
+
}
|
| 129 |
+
};
|
| 130 |
+
|
| 131 |
+
const handleReadChapter = (chapterSlug: string) => {
|
| 132 |
+
const chapterSessionId = `chapter_${sessionId}_${chapterSlug}`;
|
| 133 |
+
navigate(`/read/${chapterSessionId}`, {
|
| 134 |
+
state: {
|
| 135 |
+
chapterSlug,
|
| 136 |
+
password,
|
| 137 |
+
comicTitle: comicData?.title
|
| 138 |
+
}
|
| 139 |
+
});
|
| 140 |
+
};
|
| 141 |
+
|
| 142 |
+
const filteredChapters = comicData?.chapters.filter(ch =>
|
| 143 |
+
ch.chapter.toLowerCase().includes(searchQuery.toLowerCase())
|
| 144 |
+
) || [];
|
| 145 |
+
|
| 146 |
+
const sortedChapters = [...filteredChapters].sort((a, b) => {
|
| 147 |
+
const numA = parseFloat(a.chapter.match(/[\d.]+/)?.[0] || '0');
|
| 148 |
+
const numB = parseFloat(b.chapter.match(/[\d.]+/)?.[0] || '0');
|
| 149 |
+
return sortOrder === 'asc' ? numA - numB : numB - numA;
|
| 150 |
+
});
|
| 151 |
+
|
| 152 |
+
if (loading) {
|
| 153 |
+
return (
|
| 154 |
+
<div className="comic-landing">
|
| 155 |
+
<div className="loading-container">
|
| 156 |
+
<div className="spinner"></div>
|
| 157 |
+
<p>Loading...</p>
|
| 158 |
+
</div>
|
| 159 |
+
</div>
|
| 160 |
+
);
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
if (error && !isAuth) {
|
| 164 |
+
return (
|
| 165 |
+
<div className="comic-landing">
|
| 166 |
+
<div className="error-container">
|
| 167 |
+
<div className="error-icon">⚠️</div>
|
| 168 |
+
<h2>Oops!</h2>
|
| 169 |
+
<p>{error}</p>
|
| 170 |
+
<button onClick={() => navigate('/')}>Kembali ke Home</button>
|
| 171 |
+
</div>
|
| 172 |
+
</div>
|
| 173 |
+
);
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
if (!isAuth) {
|
| 177 |
+
return (
|
| 178 |
+
<div className="comic-landing">
|
| 179 |
+
<div className="auth-container">
|
| 180 |
+
<div className="auth-card">
|
| 181 |
+
<div className="auth-header">
|
| 182 |
+
<div className="lock-icon">🔒</div>
|
| 183 |
+
<h2>Protected Content</h2>
|
| 184 |
+
<p>Masukkan password untuk melanjutkan</p>
|
| 185 |
+
</div>
|
| 186 |
+
|
| 187 |
+
<form onSubmit={handlePasswordSubmit} className="auth-form">
|
| 188 |
+
<div className="input-group">
|
| 189 |
+
<input
|
| 190 |
+
type="password"
|
| 191 |
+
placeholder="Masukkan password"
|
| 192 |
+
value={password}
|
| 193 |
+
onChange={(e) => setPassword(e.target.value)}
|
| 194 |
+
className="password-input"
|
| 195 |
+
autoFocus
|
| 196 |
+
/>
|
| 197 |
+
</div>
|
| 198 |
+
|
| 199 |
+
{error && <div className="error-message">{error}</div>}
|
| 200 |
+
|
| 201 |
+
<button type="submit" className="submit-btn">
|
| 202 |
+
Unlock
|
| 203 |
+
</button>
|
| 204 |
+
</form>
|
| 205 |
+
|
| 206 |
+
<div className="auth-footer">
|
| 207 |
+
<p>Password adalah yang kamu set di bot WhatsApp</p>
|
| 208 |
+
</div>
|
| 209 |
+
</div>
|
| 210 |
+
</div>
|
| 211 |
+
</div>
|
| 212 |
+
);
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
if (!comicData) {
|
| 216 |
+
return (
|
| 217 |
+
<div className="comic-landing">
|
| 218 |
+
<div className="loading-container">
|
| 219 |
+
<div className="spinner"></div>
|
| 220 |
+
<p>Memuat data comic...</p>
|
| 221 |
+
</div>
|
| 222 |
+
</div>
|
| 223 |
+
);
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
return (
|
| 227 |
+
<div className="comic-landing">
|
| 228 |
+
<div className="hero-section">
|
| 229 |
+
<div className="hero-backdrop" style={{ backgroundImage: `url(${comicData.thumbnailUrl})` }}></div>
|
| 230 |
+
<div className="hero-content">
|
| 231 |
+
<div className="hero-thumbnail">
|
| 232 |
+
<img src={comicData.thumbnailUrl} alt={comicData.title} />
|
| 233 |
+
<div className="type-badge">{comicData.type}</div>
|
| 234 |
+
</div>
|
| 235 |
+
|
| 236 |
+
<div className="hero-info">
|
| 237 |
+
<h1 className="comic-title">{comicData.title}</h1>
|
| 238 |
+
{comicData.indonesiaTitle && (
|
| 239 |
+
<h2 className="comic-subtitle">{comicData.indonesiaTitle}</h2>
|
| 240 |
+
)}
|
| 241 |
+
|
| 242 |
+
<div className="meta-info">
|
| 243 |
+
<div className="meta-item">
|
| 244 |
+
<span className="meta-label">Author:</span>
|
| 245 |
+
<span className="meta-value">{comicData.author}</span>
|
| 246 |
+
</div>
|
| 247 |
+
<div className="meta-item">
|
| 248 |
+
<span className="meta-label">Status:</span>
|
| 249 |
+
<span className={`meta-value status-${comicData.status.toLowerCase()}`}>
|
| 250 |
+
{comicData.status}
|
| 251 |
+
</span>
|
| 252 |
+
</div>
|
| 253 |
+
<div className="meta-item">
|
| 254 |
+
<span className="meta-label">Total Chapters:</span>
|
| 255 |
+
<span className="meta-value">{comicData.chapters.length}</span>
|
| 256 |
+
</div>
|
| 257 |
+
</div>
|
| 258 |
+
|
| 259 |
+
<div className="genre-tags">
|
| 260 |
+
{comicData.genre.map((g, i) => (
|
| 261 |
+
<span key={i} className="genre-tag">{g}</span>
|
| 262 |
+
))}
|
| 263 |
+
</div>
|
| 264 |
+
|
| 265 |
+
<div className="synopsis">
|
| 266 |
+
<h3>Synopsis</h3>
|
| 267 |
+
<p>{comicData.synopsis}</p>
|
| 268 |
+
</div>
|
| 269 |
+
</div>
|
| 270 |
+
</div>
|
| 271 |
+
</div>
|
| 272 |
+
<div className="chapters-section">
|
| 273 |
+
<div className="chapters-header">
|
| 274 |
+
<h2>Chapters</h2>
|
| 275 |
+
|
| 276 |
+
<div className="chapters-controls">
|
| 277 |
+
<div className="search-box">
|
| 278 |
+
<input
|
| 279 |
+
type="text"
|
| 280 |
+
placeholder="Search chapters..."
|
| 281 |
+
value={searchQuery}
|
| 282 |
+
onChange={(e) => setSearchQuery(e.target.value)}
|
| 283 |
+
/>
|
| 284 |
+
</div>
|
| 285 |
+
|
| 286 |
+
<button
|
| 287 |
+
className="sort-btn"
|
| 288 |
+
onClick={() => setSortOrder(sortOrder === 'asc' ? 'desc' : 'asc')}
|
| 289 |
+
>
|
| 290 |
+
{sortOrder === 'asc' ? '↑ Oldest First' : '↓ Latest First'}
|
| 291 |
+
</button>
|
| 292 |
+
</div>
|
| 293 |
+
</div>
|
| 294 |
+
|
| 295 |
+
<div className="chapters-list">
|
| 296 |
+
{sortedChapters.length === 0 ? (
|
| 297 |
+
<div className="no-results">
|
| 298 |
+
<p>No chapters found</p>
|
| 299 |
+
</div>
|
| 300 |
+
) : (
|
| 301 |
+
sortedChapters.map((chapter, index) => (
|
| 302 |
+
<div
|
| 303 |
+
key={index}
|
| 304 |
+
className="chapter-item"
|
| 305 |
+
onClick={() => handleReadChapter(chapter.slug)}
|
| 306 |
+
>
|
| 307 |
+
<div className="chapter-info">
|
| 308 |
+
<div className="chapter-number">{chapter.chapter}</div>
|
| 309 |
+
<div className="chapter-meta">
|
| 310 |
+
<span className="chapter-date">{chapter.date}</span>
|
| 311 |
+
<span className="chapter-views">{chapter.views}</span>
|
| 312 |
+
</div>
|
| 313 |
+
</div>
|
| 314 |
+
<div className="chapter-action">
|
| 315 |
+
<span className="read-btn">Read →</span>
|
| 316 |
+
</div>
|
| 317 |
+
</div>
|
| 318 |
+
))
|
| 319 |
+
)}
|
| 320 |
+
</div>
|
| 321 |
+
</div>
|
| 322 |
+
</div>
|
| 323 |
+
);
|
| 324 |
+
}
|
src/modules/comic/ComicReader.css
ADDED
|
@@ -0,0 +1,494 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.comic-reader {
|
| 2 |
+
position: fixed;
|
| 3 |
+
top: 0;
|
| 4 |
+
left: 0;
|
| 5 |
+
right: 0;
|
| 6 |
+
bottom: 0;
|
| 7 |
+
background: #0a0a0a;
|
| 8 |
+
color: #fff;
|
| 9 |
+
overflow: hidden;
|
| 10 |
+
display: flex;
|
| 11 |
+
flex-direction: column;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
.reader-loading,
|
| 15 |
+
.reader-error {
|
| 16 |
+
display: flex;
|
| 17 |
+
flex-direction: column;
|
| 18 |
+
align-items: center;
|
| 19 |
+
justify-content: center;
|
| 20 |
+
height: 100vh;
|
| 21 |
+
gap: 1.5rem;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
.reader-error .error-icon {
|
| 25 |
+
font-size: 4rem;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
.reader-error h2 {
|
| 29 |
+
margin: 0;
|
| 30 |
+
font-size: 2rem;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
.reader-error p {
|
| 34 |
+
margin: 0;
|
| 35 |
+
opacity: 0.7;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
.reader-error button {
|
| 39 |
+
margin-top: 1rem;
|
| 40 |
+
padding: 0.75rem 2rem;
|
| 41 |
+
background: #667eea;
|
| 42 |
+
border: none;
|
| 43 |
+
border-radius: 8px;
|
| 44 |
+
color: white;
|
| 45 |
+
font-weight: 600;
|
| 46 |
+
cursor: pointer;
|
| 47 |
+
transition: all 0.3s;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
.reader-error button:hover {
|
| 51 |
+
background: #5568d3;
|
| 52 |
+
transform: translateY(-2px);
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
.reader-header {
|
| 56 |
+
display: flex;
|
| 57 |
+
align-items: center;
|
| 58 |
+
justify-content: space-between;
|
| 59 |
+
padding: 1rem 1.5rem;
|
| 60 |
+
background: rgba(0, 0, 0, 0.9);
|
| 61 |
+
backdrop-filter: blur(10px);
|
| 62 |
+
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
| 63 |
+
position: relative;
|
| 64 |
+
z-index: 100;
|
| 65 |
+
transition: transform 0.3s;
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
.comic-reader.hide-controls .reader-header {
|
| 69 |
+
transform: translateY(-100%);
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
.back-btn {
|
| 73 |
+
padding: 0.5rem 1rem;
|
| 74 |
+
background: rgba(255, 255, 255, 0.1);
|
| 75 |
+
border: 1px solid rgba(255, 255, 255, 0.2);
|
| 76 |
+
border-radius: 8px;
|
| 77 |
+
color: white;
|
| 78 |
+
font-size: 0.95rem;
|
| 79 |
+
cursor: pointer;
|
| 80 |
+
transition: all 0.3s;
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
.back-btn:hover {
|
| 84 |
+
background: rgba(255, 255, 255, 0.2);
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
.reader-title {
|
| 88 |
+
flex: 1;
|
| 89 |
+
text-align: center;
|
| 90 |
+
padding: 0 2rem;
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
.reader-title h1 {
|
| 94 |
+
margin: 0;
|
| 95 |
+
font-size: 1.25rem;
|
| 96 |
+
font-weight: 600;
|
| 97 |
+
white-space: nowrap;
|
| 98 |
+
overflow: hidden;
|
| 99 |
+
text-overflow: ellipsis;
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
.page-indicator {
|
| 103 |
+
font-size: 0.85rem;
|
| 104 |
+
opacity: 0.7;
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
.reader-actions {
|
| 108 |
+
display: flex;
|
| 109 |
+
gap: 0.5rem;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
.reader-actions button {
|
| 113 |
+
width: 40px;
|
| 114 |
+
height: 40px;
|
| 115 |
+
background: rgba(255, 255, 255, 0.1);
|
| 116 |
+
border: 1px solid rgba(255, 255, 255, 0.2);
|
| 117 |
+
border-radius: 8px;
|
| 118 |
+
color: white;
|
| 119 |
+
font-size: 1.2rem;
|
| 120 |
+
cursor: pointer;
|
| 121 |
+
transition: all 0.3s;
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
.reader-actions button:hover {
|
| 125 |
+
background: rgba(255, 255, 255, 0.2);
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
.page-jump-modal {
|
| 129 |
+
position: fixed;
|
| 130 |
+
top: 0;
|
| 131 |
+
left: 0;
|
| 132 |
+
right: 0;
|
| 133 |
+
bottom: 0;
|
| 134 |
+
background: rgba(0, 0, 0, 0.8);
|
| 135 |
+
display: flex;
|
| 136 |
+
align-items: center;
|
| 137 |
+
justify-content: center;
|
| 138 |
+
z-index: 200;
|
| 139 |
+
animation: fadeIn 0.2s;
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
@keyframes fadeIn {
|
| 143 |
+
from { opacity: 0; }
|
| 144 |
+
to { opacity: 1; }
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
.page-jump-content {
|
| 148 |
+
background: #1a1a1a;
|
| 149 |
+
padding: 2rem;
|
| 150 |
+
border-radius: 16px;
|
| 151 |
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
| 152 |
+
min-width: 300px;
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
.page-jump-content h3 {
|
| 156 |
+
margin: 0 0 1rem 0;
|
| 157 |
+
font-size: 1.25rem;
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
.page-jump-content input {
|
| 161 |
+
width: 100%;
|
| 162 |
+
padding: 0.75rem;
|
| 163 |
+
background: rgba(255, 255, 255, 0.05);
|
| 164 |
+
border: 1px solid rgba(255, 255, 255, 0.2);
|
| 165 |
+
border-radius: 8px;
|
| 166 |
+
color: white;
|
| 167 |
+
font-size: 1rem;
|
| 168 |
+
margin-bottom: 1rem;
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
.page-jump-content input:focus {
|
| 172 |
+
outline: none;
|
| 173 |
+
border-color: #667eea;
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
.page-jump-actions {
|
| 177 |
+
display: flex;
|
| 178 |
+
gap: 0.5rem;
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
.page-jump-actions button {
|
| 182 |
+
flex: 1;
|
| 183 |
+
padding: 0.75rem;
|
| 184 |
+
border: none;
|
| 185 |
+
border-radius: 8px;
|
| 186 |
+
font-weight: 600;
|
| 187 |
+
cursor: pointer;
|
| 188 |
+
transition: all 0.3s;
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
.page-jump-actions button:first-child {
|
| 192 |
+
background: #667eea;
|
| 193 |
+
color: white;
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
.page-jump-actions button:first-child:hover {
|
| 197 |
+
background: #5568d3;
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
.page-jump-actions button:last-child {
|
| 201 |
+
background: rgba(255, 255, 255, 0.1);
|
| 202 |
+
color: white;
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
.page-jump-actions button:last-child:hover {
|
| 206 |
+
background: rgba(255, 255, 255, 0.2);
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
.view-mode-toggle {
|
| 210 |
+
position: fixed;
|
| 211 |
+
top: 50%;
|
| 212 |
+
right: 1rem;
|
| 213 |
+
transform: translateY(-50%);
|
| 214 |
+
display: flex;
|
| 215 |
+
flex-direction: column;
|
| 216 |
+
gap: 0.5rem;
|
| 217 |
+
z-index: 90;
|
| 218 |
+
transition: opacity 0.3s;
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
.comic-reader.hide-controls .view-mode-toggle {
|
| 222 |
+
opacity: 0;
|
| 223 |
+
pointer-events: none;
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
.view-mode-toggle button {
|
| 227 |
+
width: 48px;
|
| 228 |
+
height: 48px;
|
| 229 |
+
background: rgba(0, 0, 0, 0.7);
|
| 230 |
+
backdrop-filter: blur(10px);
|
| 231 |
+
border: 1px solid rgba(255, 255, 255, 0.2);
|
| 232 |
+
border-radius: 12px;
|
| 233 |
+
color: white;
|
| 234 |
+
font-size: 1.5rem;
|
| 235 |
+
cursor: pointer;
|
| 236 |
+
transition: all 0.3s;
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
.view-mode-toggle button:hover,
|
| 240 |
+
.view-mode-toggle button.active {
|
| 241 |
+
background: #667eea;
|
| 242 |
+
border-color: #667eea;
|
| 243 |
+
transform: scale(1.1);
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
.reader-content {
|
| 247 |
+
flex: 1;
|
| 248 |
+
overflow: auto;
|
| 249 |
+
position: relative;
|
| 250 |
+
background: #000;
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
.scroll-container {
|
| 254 |
+
display: flex;
|
| 255 |
+
flex-direction: column;
|
| 256 |
+
align-items: center;
|
| 257 |
+
padding: 2rem 0;
|
| 258 |
+
gap: 1rem;
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
.scroll-container img {
|
| 262 |
+
max-width: 100%;
|
| 263 |
+
height: auto;
|
| 264 |
+
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
|
| 265 |
+
transition: all 0.3s;
|
| 266 |
+
}
|
| 267 |
+
|
| 268 |
+
.scroll-container img.current-page {
|
| 269 |
+
box-shadow: 0 0 0 3px #667eea;
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
.single-container {
|
| 273 |
+
display: flex;
|
| 274 |
+
align-items: center;
|
| 275 |
+
justify-content: center;
|
| 276 |
+
height: 100%;
|
| 277 |
+
position: relative;
|
| 278 |
+
padding: 2rem;
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
.single-container img {
|
| 282 |
+
max-width: 100%;
|
| 283 |
+
max-height: 100%;
|
| 284 |
+
object-fit: contain;
|
| 285 |
+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
.double-container {
|
| 289 |
+
display: flex;
|
| 290 |
+
align-items: center;
|
| 291 |
+
justify-content: center;
|
| 292 |
+
height: 100%;
|
| 293 |
+
position: relative;
|
| 294 |
+
padding: 2rem;
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
.double-pages {
|
| 298 |
+
display: flex;
|
| 299 |
+
gap: 1rem;
|
| 300 |
+
max-height: 100%;
|
| 301 |
+
align-items: center;
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
+
.double-pages img {
|
| 305 |
+
max-height: 100%;
|
| 306 |
+
max-width: 45%;
|
| 307 |
+
object-fit: contain;
|
| 308 |
+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
|
| 309 |
+
}
|
| 310 |
+
|
| 311 |
+
.nav-btn {
|
| 312 |
+
position: absolute;
|
| 313 |
+
top: 50%;
|
| 314 |
+
transform: translateY(-50%);
|
| 315 |
+
width: 60px;
|
| 316 |
+
height: 60px;
|
| 317 |
+
background: rgba(0, 0, 0, 0.5);
|
| 318 |
+
backdrop-filter: blur(10px);
|
| 319 |
+
border: 1px solid rgba(255, 255, 255, 0.2);
|
| 320 |
+
border-radius: 50%;
|
| 321 |
+
color: white;
|
| 322 |
+
font-size: 2rem;
|
| 323 |
+
cursor: pointer;
|
| 324 |
+
transition: all 0.3s;
|
| 325 |
+
z-index: 10;
|
| 326 |
+
}
|
| 327 |
+
|
| 328 |
+
.nav-btn:hover:not(:disabled) {
|
| 329 |
+
background: rgba(102, 126, 234, 0.8);
|
| 330 |
+
transform: translateY(-50%) scale(1.1);
|
| 331 |
+
}
|
| 332 |
+
|
| 333 |
+
.nav-btn:disabled {
|
| 334 |
+
opacity: 0.3;
|
| 335 |
+
cursor: not-allowed;
|
| 336 |
+
}
|
| 337 |
+
|
| 338 |
+
.nav-btn.prev {
|
| 339 |
+
left: 1rem;
|
| 340 |
+
}
|
| 341 |
+
|
| 342 |
+
.nav-btn.next {
|
| 343 |
+
right: 1rem;
|
| 344 |
+
}
|
| 345 |
+
|
| 346 |
+
.reader-footer {
|
| 347 |
+
padding: 1rem 1.5rem;
|
| 348 |
+
background: rgba(0, 0, 0, 0.9);
|
| 349 |
+
backdrop-filter: blur(10px);
|
| 350 |
+
border-top: 1px solid rgba(255, 255, 255, 0.1);
|
| 351 |
+
position: relative;
|
| 352 |
+
z-index: 100;
|
| 353 |
+
transition: transform 0.3s;
|
| 354 |
+
}
|
| 355 |
+
|
| 356 |
+
.comic-reader.hide-controls .reader-footer {
|
| 357 |
+
transform: translateY(100%);
|
| 358 |
+
}
|
| 359 |
+
|
| 360 |
+
.chapter-navigation {
|
| 361 |
+
display: flex;
|
| 362 |
+
align-items: center;
|
| 363 |
+
gap: 1rem;
|
| 364 |
+
}
|
| 365 |
+
|
| 366 |
+
.chapter-nav-btn {
|
| 367 |
+
padding: 0.75rem 1.5rem;
|
| 368 |
+
background: rgba(102, 126, 234, 0.2);
|
| 369 |
+
border: 1px solid rgba(102, 126, 234, 0.4);
|
| 370 |
+
border-radius: 8px;
|
| 371 |
+
color: white;
|
| 372 |
+
font-size: 0.9rem;
|
| 373 |
+
font-weight: 500;
|
| 374 |
+
cursor: pointer;
|
| 375 |
+
transition: all 0.3s;
|
| 376 |
+
white-space: nowrap;
|
| 377 |
+
}
|
| 378 |
+
|
| 379 |
+
.chapter-nav-btn:hover {
|
| 380 |
+
background: rgba(102, 126, 234, 0.4);
|
| 381 |
+
transform: translateY(-2px);
|
| 382 |
+
}
|
| 383 |
+
|
| 384 |
+
.page-slider {
|
| 385 |
+
flex: 1;
|
| 386 |
+
padding: 0 1rem;
|
| 387 |
+
}
|
| 388 |
+
|
| 389 |
+
.page-slider input[type="range"] {
|
| 390 |
+
width: 100%;
|
| 391 |
+
height: 6px;
|
| 392 |
+
background: rgba(255, 255, 255, 0.1);
|
| 393 |
+
border-radius: 3px;
|
| 394 |
+
outline: none;
|
| 395 |
+
-webkit-appearance: none;
|
| 396 |
+
}
|
| 397 |
+
|
| 398 |
+
.page-slider input[type="range"]::-webkit-slider-thumb {
|
| 399 |
+
-webkit-appearance: none;
|
| 400 |
+
width: 18px;
|
| 401 |
+
height: 18px;
|
| 402 |
+
background: #667eea;
|
| 403 |
+
border-radius: 50%;
|
| 404 |
+
cursor: pointer;
|
| 405 |
+
transition: all 0.3s;
|
| 406 |
+
}
|
| 407 |
+
|
| 408 |
+
.page-slider input[type="range"]::-webkit-slider-thumb:hover {
|
| 409 |
+
background: #5568d3;
|
| 410 |
+
transform: scale(1.2);
|
| 411 |
+
}
|
| 412 |
+
|
| 413 |
+
.page-slider input[type="range"]::-moz-range-thumb {
|
| 414 |
+
width: 18px;
|
| 415 |
+
height: 18px;
|
| 416 |
+
background: #667eea;
|
| 417 |
+
border: none;
|
| 418 |
+
border-radius: 50%;
|
| 419 |
+
cursor: pointer;
|
| 420 |
+
transition: all 0.3s;
|
| 421 |
+
}
|
| 422 |
+
|
| 423 |
+
.page-slider input[type="range"]::-moz-range-thumb:hover {
|
| 424 |
+
background: #5568d3;
|
| 425 |
+
transform: scale(1.2);
|
| 426 |
+
}
|
| 427 |
+
|
| 428 |
+
.shortcuts-hint {
|
| 429 |
+
position: fixed;
|
| 430 |
+
bottom: 1rem;
|
| 431 |
+
left: 50%;
|
| 432 |
+
transform: translateX(-50%);
|
| 433 |
+
padding: 0.5rem 1rem;
|
| 434 |
+
background: rgba(0, 0, 0, 0.7);
|
| 435 |
+
backdrop-filter: blur(10px);
|
| 436 |
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
| 437 |
+
border-radius: 20px;
|
| 438 |
+
font-size: 0.75rem;
|
| 439 |
+
opacity: 0.6;
|
| 440 |
+
pointer-events: none;
|
| 441 |
+
z-index: 80;
|
| 442 |
+
transition: opacity 0.3s;
|
| 443 |
+
}
|
| 444 |
+
|
| 445 |
+
.comic-reader.hide-controls .shortcuts-hint {
|
| 446 |
+
opacity: 0;
|
| 447 |
+
}
|
| 448 |
+
|
| 449 |
+
@media (max-width: 768px) {
|
| 450 |
+
.reader-header {
|
| 451 |
+
padding: 0.75rem 1rem;
|
| 452 |
+
}
|
| 453 |
+
|
| 454 |
+
.reader-title h1 {
|
| 455 |
+
font-size: 1rem;
|
| 456 |
+
}
|
| 457 |
+
|
| 458 |
+
.reader-title {
|
| 459 |
+
padding: 0 1rem;
|
| 460 |
+
}
|
| 461 |
+
|
| 462 |
+
.view-mode-toggle {
|
| 463 |
+
right: 0.5rem;
|
| 464 |
+
}
|
| 465 |
+
|
| 466 |
+
.view-mode-toggle button {
|
| 467 |
+
width: 40px;
|
| 468 |
+
height: 40px;
|
| 469 |
+
font-size: 1.2rem;
|
| 470 |
+
}
|
| 471 |
+
|
| 472 |
+
.nav-btn {
|
| 473 |
+
width: 50px;
|
| 474 |
+
height: 50px;
|
| 475 |
+
font-size: 1.5rem;
|
| 476 |
+
}
|
| 477 |
+
|
| 478 |
+
.chapter-nav-btn {
|
| 479 |
+
padding: 0.5rem 1rem;
|
| 480 |
+
font-size: 0.8rem;
|
| 481 |
+
}
|
| 482 |
+
|
| 483 |
+
.double-pages {
|
| 484 |
+
flex-direction: column;
|
| 485 |
+
}
|
| 486 |
+
|
| 487 |
+
.double-pages img {
|
| 488 |
+
max-width: 100%;
|
| 489 |
+
}
|
| 490 |
+
|
| 491 |
+
.shortcuts-hint {
|
| 492 |
+
display: none;
|
| 493 |
+
}
|
| 494 |
+
}
|
src/modules/comic/ComicReader.tsx
ADDED
|
@@ -0,0 +1,369 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useEffect, useState, useRef } from 'react';
|
| 2 |
+
import { useParams, useNavigate, useLocation } from 'react-router-dom';
|
| 3 |
+
import './ComicReader.css';
|
| 4 |
+
|
| 5 |
+
interface ComicImage {
|
| 6 |
+
index: number;
|
| 7 |
+
imageUrl: string;
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
interface ChapterInfo {
|
| 11 |
+
slug: string;
|
| 12 |
+
chapter: string;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
interface ReaderData {
|
| 16 |
+
slug: string;
|
| 17 |
+
title: string;
|
| 18 |
+
images: ComicImage[];
|
| 19 |
+
totalImages: number;
|
| 20 |
+
prevChapter?: ChapterInfo | null;
|
| 21 |
+
nextChapter?: ChapterInfo | null;
|
| 22 |
+
allChapters?: ChapterInfo[];
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
export function ComicReader() {
|
| 26 |
+
const { sessionId } = useParams();
|
| 27 |
+
const navigate = useNavigate();
|
| 28 |
+
const location = useLocation();
|
| 29 |
+
const [data, setData] = useState<ReaderData | null>(null);
|
| 30 |
+
const [loading, setLoading] = useState(true);
|
| 31 |
+
const [error, setError] = useState('');
|
| 32 |
+
const [currentPage, setCurrentPage] = useState(1);
|
| 33 |
+
const [viewMode, setViewMode] = useState<'single' | 'double' | 'scroll'>('scroll');
|
| 34 |
+
const [showControls, setShowControls] = useState(true);
|
| 35 |
+
const [showPageJump, setShowPageJump] = useState(false);
|
| 36 |
+
const [jumpPage, setJumpPage] = useState('');
|
| 37 |
+
const [ws, setWs] = useState<WebSocket | null>(null);
|
| 38 |
+
const imageRefs = useRef<{ [key: number]: HTMLImageElement | null }>({});
|
| 39 |
+
const controlsTimeout = useRef<number | null>(null);
|
| 40 |
+
|
| 41 |
+
const password = location.state?.password ||
|
| 42 |
+
JSON.parse(sessionStorage.getItem(`comic_${sessionId}`) || '{}').password;
|
| 43 |
+
|
| 44 |
+
useEffect(() => {
|
| 45 |
+
if (!password) {
|
| 46 |
+
setError('Unauthorized access');
|
| 47 |
+
setLoading(false);
|
| 48 |
+
return;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
| 52 |
+
const wsUrl = `${protocol}//${window.location.host}/ws`;
|
| 53 |
+
const websocket = new WebSocket(wsUrl);
|
| 54 |
+
|
| 55 |
+
websocket.onopen = () => {
|
| 56 |
+
websocket.send(JSON.stringify({
|
| 57 |
+
type: 'request_comic_data',
|
| 58 |
+
sessionId,
|
| 59 |
+
password
|
| 60 |
+
}));
|
| 61 |
+
};
|
| 62 |
+
|
| 63 |
+
websocket.onmessage = (event) => {
|
| 64 |
+
const message = JSON.parse(event.data);
|
| 65 |
+
|
| 66 |
+
if (message.type === 'comic_data_response') {
|
| 67 |
+
if (message.success) {
|
| 68 |
+
setData(message.data);
|
| 69 |
+
setLoading(false);
|
| 70 |
+
} else {
|
| 71 |
+
setError(message.error || 'Failed to load chapter');
|
| 72 |
+
setLoading(false);
|
| 73 |
+
}
|
| 74 |
+
}
|
| 75 |
+
};
|
| 76 |
+
|
| 77 |
+
websocket.onerror = () => {
|
| 78 |
+
setError('WebSocket connection failed');
|
| 79 |
+
setLoading(false);
|
| 80 |
+
};
|
| 81 |
+
|
| 82 |
+
setWs(websocket);
|
| 83 |
+
|
| 84 |
+
return () => {
|
| 85 |
+
websocket.close();
|
| 86 |
+
};
|
| 87 |
+
}, [sessionId, password]);
|
| 88 |
+
|
| 89 |
+
useEffect(() => {
|
| 90 |
+
const resetTimeout = () => {
|
| 91 |
+
if (controlsTimeout.current) {
|
| 92 |
+
clearTimeout(controlsTimeout.current);
|
| 93 |
+
}
|
| 94 |
+
setShowControls(true);
|
| 95 |
+
controlsTimeout.current = window.setTimeout(() => {
|
| 96 |
+
setShowControls(false);
|
| 97 |
+
}, 3000);
|
| 98 |
+
};
|
| 99 |
+
|
| 100 |
+
const handleMove = () => resetTimeout();
|
| 101 |
+
|
| 102 |
+
window.addEventListener('mousemove', handleMove);
|
| 103 |
+
window.addEventListener('touchstart', handleMove);
|
| 104 |
+
|
| 105 |
+
return () => {
|
| 106 |
+
window.removeEventListener('mousemove', handleMove);
|
| 107 |
+
window.removeEventListener('touchstart', handleMove);
|
| 108 |
+
if (controlsTimeout.current) {
|
| 109 |
+
clearTimeout(controlsTimeout.current);
|
| 110 |
+
}
|
| 111 |
+
};
|
| 112 |
+
}, []);
|
| 113 |
+
|
| 114 |
+
useEffect(() => {
|
| 115 |
+
const handleKeyPress = (e: KeyboardEvent) => {
|
| 116 |
+
if (e.key === 'ArrowRight') nextPage();
|
| 117 |
+
if (e.key === 'ArrowLeft') prevPage();
|
| 118 |
+
if (e.key === 'Home') setCurrentPage(1);
|
| 119 |
+
if (e.key === 'End') setCurrentPage(data?.totalImages || 1);
|
| 120 |
+
if (e.key === 'f') toggleFullscreen();
|
| 121 |
+
};
|
| 122 |
+
|
| 123 |
+
window.addEventListener('keydown', handleKeyPress);
|
| 124 |
+
return () => window.removeEventListener('keydown', handleKeyPress);
|
| 125 |
+
}, [currentPage, data]);
|
| 126 |
+
|
| 127 |
+
useEffect(() => {
|
| 128 |
+
if (viewMode === 'scroll' && imageRefs.current[currentPage]) {
|
| 129 |
+
imageRefs.current[currentPage]?.scrollIntoView({
|
| 130 |
+
behavior: 'smooth',
|
| 131 |
+
block: 'center'
|
| 132 |
+
});
|
| 133 |
+
}
|
| 134 |
+
}, [currentPage, viewMode]);
|
| 135 |
+
|
| 136 |
+
const nextPage = () => {
|
| 137 |
+
if (!data) return;
|
| 138 |
+
if (currentPage < data.totalImages) {
|
| 139 |
+
setCurrentPage(currentPage + 1);
|
| 140 |
+
} else if (data.nextChapter) {
|
| 141 |
+
handleChapterNavigation(data.nextChapter.slug);
|
| 142 |
+
}
|
| 143 |
+
};
|
| 144 |
+
|
| 145 |
+
const prevPage = () => {
|
| 146 |
+
if (currentPage > 1) {
|
| 147 |
+
setCurrentPage(currentPage - 1);
|
| 148 |
+
} else if (data?.prevChapter) {
|
| 149 |
+
handleChapterNavigation(data.prevChapter.slug);
|
| 150 |
+
}
|
| 151 |
+
};
|
| 152 |
+
|
| 153 |
+
const handleChapterNavigation = (chapterSlug: string) => {
|
| 154 |
+
const newSessionId = `chapter_${Date.now()}_${chapterSlug}`;
|
| 155 |
+
navigate(`/read/${newSessionId}`, {
|
| 156 |
+
state: {
|
| 157 |
+
chapterSlug,
|
| 158 |
+
password,
|
| 159 |
+
comicTitle: data?.title
|
| 160 |
+
}
|
| 161 |
+
});
|
| 162 |
+
};
|
| 163 |
+
|
| 164 |
+
const handlePageJump = () => {
|
| 165 |
+
const page = parseInt(jumpPage);
|
| 166 |
+
if (page >= 1 && page <= (data?.totalImages || 1)) {
|
| 167 |
+
setCurrentPage(page);
|
| 168 |
+
setShowPageJump(false);
|
| 169 |
+
setJumpPage('');
|
| 170 |
+
}
|
| 171 |
+
};
|
| 172 |
+
|
| 173 |
+
const toggleFullscreen = () => {
|
| 174 |
+
if (!document.fullscreenElement) {
|
| 175 |
+
document.documentElement.requestFullscreen();
|
| 176 |
+
} else {
|
| 177 |
+
document.exitFullscreen();
|
| 178 |
+
}
|
| 179 |
+
};
|
| 180 |
+
|
| 181 |
+
if (loading) {
|
| 182 |
+
return (
|
| 183 |
+
<div className="reader-loading">
|
| 184 |
+
<div className="spinner"></div>
|
| 185 |
+
<p>Loading chapter...</p>
|
| 186 |
+
</div>
|
| 187 |
+
);
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
if (error || !data) {
|
| 191 |
+
return (
|
| 192 |
+
<div className="reader-error">
|
| 193 |
+
<div className="error-icon">⚠️</div>
|
| 194 |
+
<h2>Error</h2>
|
| 195 |
+
<p>{error || 'Failed to load chapter'}</p>
|
| 196 |
+
<button onClick={() => navigate(-1)}>Go Back</button>
|
| 197 |
+
</div>
|
| 198 |
+
);
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
return (
|
| 202 |
+
<div className={`comic-reader ${viewMode}-mode ${!showControls ? 'hide-controls' : ''}`}>
|
| 203 |
+
<div className="reader-header">
|
| 204 |
+
<button className="back-btn" onClick={() => navigate(-1)}>
|
| 205 |
+
← Back
|
| 206 |
+
</button>
|
| 207 |
+
|
| 208 |
+
<div className="reader-title">
|
| 209 |
+
<h1>{data.title}</h1>
|
| 210 |
+
<span className="page-indicator">
|
| 211 |
+
Page {currentPage} / {data.totalImages}
|
| 212 |
+
</span>
|
| 213 |
+
</div>
|
| 214 |
+
|
| 215 |
+
<div className="reader-actions">
|
| 216 |
+
<button onClick={() => setShowPageJump(!showPageJump)} title="Jump to page">
|
| 217 |
+
📍
|
| 218 |
+
</button>
|
| 219 |
+
<button onClick={toggleFullscreen} title="Fullscreen">
|
| 220 |
+
⛶
|
| 221 |
+
</button>
|
| 222 |
+
</div>
|
| 223 |
+
</div>
|
| 224 |
+
{showPageJump && (
|
| 225 |
+
<div className="page-jump-modal" onClick={() => setShowPageJump(false)}>
|
| 226 |
+
<div className="page-jump-content" onClick={(e) => e.stopPropagation()}>
|
| 227 |
+
<h3>Jump to Page</h3>
|
| 228 |
+
<input
|
| 229 |
+
type="number"
|
| 230 |
+
min="1"
|
| 231 |
+
max={data.totalImages}
|
| 232 |
+
value={jumpPage}
|
| 233 |
+
onChange={(e) => setJumpPage(e.target.value)}
|
| 234 |
+
placeholder={`1-${data.totalImages}`}
|
| 235 |
+
autoFocus
|
| 236 |
+
onKeyPress={(e) => e.key === 'Enter' && handlePageJump()}
|
| 237 |
+
/>
|
| 238 |
+
<div className="page-jump-actions">
|
| 239 |
+
<button onClick={handlePageJump}>Go</button>
|
| 240 |
+
<button onClick={() => setShowPageJump(false)}>Cancel</button>
|
| 241 |
+
</div>
|
| 242 |
+
</div>
|
| 243 |
+
</div>
|
| 244 |
+
)}
|
| 245 |
+
<div className="view-mode-toggle">
|
| 246 |
+
<button
|
| 247 |
+
className={viewMode === 'single' ? 'active' : ''}
|
| 248 |
+
onClick={() => setViewMode('single')}
|
| 249 |
+
title="Single page"
|
| 250 |
+
>
|
| 251 |
+
📄
|
| 252 |
+
</button>
|
| 253 |
+
<button
|
| 254 |
+
className={viewMode === 'double' ? 'active' : ''}
|
| 255 |
+
onClick={() => setViewMode('double')}
|
| 256 |
+
title="Double page"
|
| 257 |
+
>
|
| 258 |
+
📑
|
| 259 |
+
</button>
|
| 260 |
+
<button
|
| 261 |
+
className={viewMode === 'scroll' ? 'active' : ''}
|
| 262 |
+
onClick={() => setViewMode('scroll')}
|
| 263 |
+
title="Scroll"
|
| 264 |
+
>
|
| 265 |
+
📜
|
| 266 |
+
</button>
|
| 267 |
+
</div>
|
| 268 |
+
<div className="reader-content">
|
| 269 |
+
{viewMode === 'scroll' ? (
|
| 270 |
+
<div className="scroll-container">
|
| 271 |
+
{data.images.map((img) => (
|
| 272 |
+
<img
|
| 273 |
+
key={img.index}
|
| 274 |
+
ref={(el) => (imageRefs.current[img.index] = el)}
|
| 275 |
+
src={img.imageUrl}
|
| 276 |
+
alt={`Page ${img.index}`}
|
| 277 |
+
className={currentPage === img.index ? 'current-page' : ''}
|
| 278 |
+
loading="lazy"
|
| 279 |
+
onError={(e) => {
|
| 280 |
+
(e.target as HTMLImageElement).src = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg"><text x="50%" y="50%" text-anchor="middle">Failed to load</text></svg>';
|
| 281 |
+
}}
|
| 282 |
+
/>
|
| 283 |
+
))}
|
| 284 |
+
</div>
|
| 285 |
+
) : viewMode === 'single' ? (
|
| 286 |
+
<div className="single-container">
|
| 287 |
+
<button className="nav-btn prev" onClick={prevPage} disabled={currentPage === 1 && !data.prevChapter}>
|
| 288 |
+
‹
|
| 289 |
+
</button>
|
| 290 |
+
<img
|
| 291 |
+
src={data.images[currentPage - 1]?.imageUrl}
|
| 292 |
+
alt={`Page ${currentPage}`}
|
| 293 |
+
onError={(e) => {
|
| 294 |
+
(e.target as HTMLImageElement).src = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg"><text x="50%" y="50%" text-anchor="middle">Failed to load</text></svg>';
|
| 295 |
+
}}
|
| 296 |
+
/>
|
| 297 |
+
<button className="nav-btn next" onClick={nextPage} disabled={currentPage === data.totalImages && !data.nextChapter}>
|
| 298 |
+
›
|
| 299 |
+
</button>
|
| 300 |
+
</div>
|
| 301 |
+
) : (
|
| 302 |
+
<div className="double-container">
|
| 303 |
+
<button className="nav-btn prev" onClick={prevPage} disabled={currentPage === 1 && !data.prevChapter}>
|
| 304 |
+
‹
|
| 305 |
+
</button>
|
| 306 |
+
<div className="double-pages">
|
| 307 |
+
{currentPage % 2 === 0 && currentPage > 1 && (
|
| 308 |
+
<img
|
| 309 |
+
src={data.images[currentPage - 2]?.imageUrl}
|
| 310 |
+
alt={`Page ${currentPage - 1}`}
|
| 311 |
+
className="left-page"
|
| 312 |
+
/>
|
| 313 |
+
)}
|
| 314 |
+
<img
|
| 315 |
+
src={data.images[currentPage - 1]?.imageUrl}
|
| 316 |
+
alt={`Page ${currentPage}`}
|
| 317 |
+
className={currentPage % 2 === 0 ? 'right-page' : 'left-page'}
|
| 318 |
+
/>
|
| 319 |
+
{currentPage % 2 !== 0 && currentPage < data.totalImages && (
|
| 320 |
+
<img
|
| 321 |
+
src={data.images[currentPage]?.imageUrl}
|
| 322 |
+
alt={`Page ${currentPage + 1}`}
|
| 323 |
+
className="right-page"
|
| 324 |
+
/>
|
| 325 |
+
)}
|
| 326 |
+
</div>
|
| 327 |
+
<button className="nav-btn next" onClick={nextPage} disabled={currentPage === data.totalImages && !data.nextChapter}>
|
| 328 |
+
›
|
| 329 |
+
</button>
|
| 330 |
+
</div>
|
| 331 |
+
)}
|
| 332 |
+
</div>
|
| 333 |
+
<div className="reader-footer">
|
| 334 |
+
<div className="chapter-navigation">
|
| 335 |
+
{data.prevChapter && (
|
| 336 |
+
<button
|
| 337 |
+
className="chapter-nav-btn"
|
| 338 |
+
onClick={() => handleChapterNavigation(data.prevChapter!.slug)}
|
| 339 |
+
>
|
| 340 |
+
← {data.prevChapter.chapter}
|
| 341 |
+
</button>
|
| 342 |
+
)}
|
| 343 |
+
|
| 344 |
+
<div className="page-slider">
|
| 345 |
+
<input
|
| 346 |
+
type="range"
|
| 347 |
+
min="1"
|
| 348 |
+
max={data.totalImages}
|
| 349 |
+
value={currentPage}
|
| 350 |
+
onChange={(e) => setCurrentPage(parseInt(e.target.value))}
|
| 351 |
+
/>
|
| 352 |
+
</div>
|
| 353 |
+
|
| 354 |
+
{data.nextChapter && (
|
| 355 |
+
<button
|
| 356 |
+
className="chapter-nav-btn"
|
| 357 |
+
onClick={() => handleChapterNavigation(data.nextChapter!.slug)}
|
| 358 |
+
>
|
| 359 |
+
{data.nextChapter.chapter} →
|
| 360 |
+
</button>
|
| 361 |
+
)}
|
| 362 |
+
</div>
|
| 363 |
+
</div>
|
| 364 |
+
<div className="shortcuts-hint">
|
| 365 |
+
← → Navigate | Home/End | F Fullscreen
|
| 366 |
+
</div>
|
| 367 |
+
</div>
|
| 368 |
+
);
|
| 369 |
+
}
|
src/server/websocket.ts
CHANGED
|
@@ -7,8 +7,17 @@ interface Session {
|
|
| 7 |
ws?: ServerWebSocket;
|
| 8 |
}
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
|
|
|
|
|
|
| 12 |
const botConnections = new Set<ServerWebSocket>();
|
| 13 |
|
| 14 |
export function handleWebSocketConnection(ws: ServerWebSocket) {
|
|
@@ -20,7 +29,7 @@ export function handleWebSocketConnection(ws: ServerWebSocket) {
|
|
| 20 |
|
| 21 |
ws.send(JSON.stringify({
|
| 22 |
type: 'connected',
|
| 23 |
-
message: 'Connected to
|
| 24 |
}));
|
| 25 |
}
|
| 26 |
|
|
@@ -62,11 +71,112 @@ function handleMessage(ws: ServerWebSocket, message: any) {
|
|
| 62 |
handleRegistrationSubmit(sessionId, message.data);
|
| 63 |
break;
|
| 64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
default:
|
| 66 |
console.log('[WebSocket] Unknown message type:', type);
|
| 67 |
}
|
| 68 |
}
|
| 69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
function handleRegistrationSubmit(sessionId: string, data: any) {
|
| 71 |
const session = sessions.get(sessionId);
|
| 72 |
if (!session) {
|
|
@@ -138,10 +248,18 @@ function cleanup(ws: ServerWebSocket) {
|
|
| 138 |
|
| 139 |
setInterval(() => {
|
| 140 |
const now = Date.now();
|
|
|
|
| 141 |
for (const [sessionId, session] of sessions.entries()) {
|
| 142 |
if (now - session.createdAt > 600000) {
|
| 143 |
sessions.delete(sessionId);
|
| 144 |
console.log('[WebSocket] Cleaned up expired session:', sessionId);
|
| 145 |
}
|
| 146 |
}
|
| 147 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
ws?: ServerWebSocket;
|
| 8 |
}
|
| 9 |
|
| 10 |
+
interface ComicSession {
|
| 11 |
+
sessionId: string;
|
| 12 |
+
sender: string;
|
| 13 |
+
password: string;
|
| 14 |
+
data: any;
|
| 15 |
+
createdAt: number;
|
| 16 |
+
expiresAt: number;
|
| 17 |
+
}
|
| 18 |
|
| 19 |
+
const sessions = new Map<string, Session>();
|
| 20 |
+
const comicSessions = new Map<string, ComicSession>();
|
| 21 |
const botConnections = new Set<ServerWebSocket>();
|
| 22 |
|
| 23 |
export function handleWebSocketConnection(ws: ServerWebSocket) {
|
|
|
|
| 29 |
|
| 30 |
ws.send(JSON.stringify({
|
| 31 |
type: 'connected',
|
| 32 |
+
message: 'Connected to server'
|
| 33 |
}));
|
| 34 |
}
|
| 35 |
|
|
|
|
| 71 |
handleRegistrationSubmit(sessionId, message.data);
|
| 72 |
break;
|
| 73 |
|
| 74 |
+
case 'comic_stream':
|
| 75 |
+
case 'chapter_stream':
|
| 76 |
+
handleComicStream(message);
|
| 77 |
+
break;
|
| 78 |
+
|
| 79 |
+
case 'request_comic_data':
|
| 80 |
+
handleComicDataRequest(ws, message);
|
| 81 |
+
break;
|
| 82 |
+
|
| 83 |
+
case 'validate_comic_password':
|
| 84 |
+
handlePasswordValidation(ws, message);
|
| 85 |
+
break;
|
| 86 |
+
|
| 87 |
default:
|
| 88 |
console.log('[WebSocket] Unknown message type:', type);
|
| 89 |
}
|
| 90 |
}
|
| 91 |
|
| 92 |
+
function handleComicStream(message: any) {
|
| 93 |
+
const { sessionId, sender, password, data, type } = message;
|
| 94 |
+
const expiresAt = Date.now() + (24 * 60 * 60 * 1000);
|
| 95 |
+
|
| 96 |
+
comicSessions.set(sessionId, {
|
| 97 |
+
sessionId,
|
| 98 |
+
sender,
|
| 99 |
+
password,
|
| 100 |
+
data,
|
| 101 |
+
createdAt: Date.now(),
|
| 102 |
+
expiresAt
|
| 103 |
+
});
|
| 104 |
+
|
| 105 |
+
console.log(`[WebSocket] Comic stream created: ${sessionId}, type: ${type}`);
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
function handleComicDataRequest(ws: ServerWebSocket, message: any) {
|
| 109 |
+
const { sessionId, password } = message;
|
| 110 |
+
|
| 111 |
+
const comicSession = comicSessions.get(sessionId);
|
| 112 |
+
|
| 113 |
+
if (!comicSession) {
|
| 114 |
+
ws.send(JSON.stringify({
|
| 115 |
+
type: 'comic_data_response',
|
| 116 |
+
success: false,
|
| 117 |
+
error: 'Session not found or expired'
|
| 118 |
+
}));
|
| 119 |
+
return;
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
if (comicSession.password !== password) {
|
| 123 |
+
ws.send(JSON.stringify({
|
| 124 |
+
type: 'comic_data_response',
|
| 125 |
+
success: false,
|
| 126 |
+
error: 'Invalid password'
|
| 127 |
+
}));
|
| 128 |
+
return;
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
if (Date.now() > comicSession.expiresAt) {
|
| 132 |
+
comicSessions.delete(sessionId);
|
| 133 |
+
ws.send(JSON.stringify({
|
| 134 |
+
type: 'comic_data_response',
|
| 135 |
+
success: false,
|
| 136 |
+
error: 'Session expired'
|
| 137 |
+
}));
|
| 138 |
+
return;
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
ws.send(JSON.stringify({
|
| 142 |
+
type: 'comic_data_response',
|
| 143 |
+
success: true,
|
| 144 |
+
data: comicSession.data,
|
| 145 |
+
expiresAt: comicSession.expiresAt
|
| 146 |
+
}));
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
function handlePasswordValidation(ws: ServerWebSocket, message: any) {
|
| 150 |
+
const { sessionId } = message;
|
| 151 |
+
|
| 152 |
+
const comicSession = comicSessions.get(sessionId);
|
| 153 |
+
|
| 154 |
+
if (!comicSession) {
|
| 155 |
+
ws.send(JSON.stringify({
|
| 156 |
+
type: 'password_validation_response',
|
| 157 |
+
success: false,
|
| 158 |
+
error: 'Session not found or expired'
|
| 159 |
+
}));
|
| 160 |
+
return;
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
if (Date.now() > comicSession.expiresAt) {
|
| 164 |
+
comicSessions.delete(sessionId);
|
| 165 |
+
ws.send(JSON.stringify({
|
| 166 |
+
type: 'password_validation_response',
|
| 167 |
+
success: false,
|
| 168 |
+
error: 'Session expired'
|
| 169 |
+
}));
|
| 170 |
+
return;
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
ws.send(JSON.stringify({
|
| 174 |
+
type: 'password_validation_response',
|
| 175 |
+
success: true,
|
| 176 |
+
requiresPassword: true
|
| 177 |
+
}));
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
function handleRegistrationSubmit(sessionId: string, data: any) {
|
| 181 |
const session = sessions.get(sessionId);
|
| 182 |
if (!session) {
|
|
|
|
| 248 |
|
| 249 |
setInterval(() => {
|
| 250 |
const now = Date.now();
|
| 251 |
+
|
| 252 |
for (const [sessionId, session] of sessions.entries()) {
|
| 253 |
if (now - session.createdAt > 600000) {
|
| 254 |
sessions.delete(sessionId);
|
| 255 |
console.log('[WebSocket] Cleaned up expired session:', sessionId);
|
| 256 |
}
|
| 257 |
}
|
| 258 |
+
|
| 259 |
+
for (const [sessionId, comicSession] of comicSessions.entries()) {
|
| 260 |
+
if (now > comicSession.expiresAt) {
|
| 261 |
+
comicSessions.delete(sessionId);
|
| 262 |
+
console.log('[WebSocket] Cleaned up expired comic session:', sessionId);
|
| 263 |
+
}
|
| 264 |
+
}
|
| 265 |
+
}, 60 * 60 * 1000);
|