tryprogram commited on
Commit
ef785b2
·
verified ·
1 Parent(s): 64fac06

Upload 13 files

Browse files
src/App.css ADDED
@@ -0,0 +1,1302 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ :root {
2
+ --color-primary: #4F46E5;
3
+ --color-primary-light: #6366F1;
4
+ --color-primary-dark: #3730A3;
5
+ --color-success: #10B981;
6
+ --color-warning: #F59E0B;
7
+ --color-error: #EF4444;
8
+ --color-info: #3B82F6;
9
+ --color-bg: #F3F4F6;
10
+ --color-bg-white: #FFFFFF;
11
+ --color-text: #1F2937;
12
+ --color-text-secondary: #6B7280;
13
+ --color-text-light: #9CA3AF;
14
+ --color-text-muted: #4B5563;
15
+ --color-border: #E5E7EB;
16
+ --color-border-light: #F3F4F6;
17
+ --color-bg-warning-soft: rgba(245, 158, 11, 0.08);
18
+ --color-bg-error-soft: rgba(239, 68, 68, 0.08);
19
+ --color-bg-primary-soft: rgba(79, 70, 229, 0.06);
20
+ --color-bg-success-soft: rgba(16, 185, 129, 0.08);
21
+ --color-bg-info-soft: #EFF6FF;
22
+ --color-bg-light: #F9FAFB;
23
+ --color-tag-bg: #EEF2FF;
24
+ --color-tag-border: #C7D2FE;
25
+ --color-tag-text: #4338CA;
26
+ --color-tip-text: #92400E;
27
+ --color-signal-text: #1D4ED8;
28
+ --color-primary-alpha-20: rgba(79, 70, 229, 0.2);
29
+ --color-primary-alpha-10: rgba(79, 70, 229, 0.1);
30
+ --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
31
+ --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
32
+ --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
33
+ --radius-sm: 6px;
34
+ --radius-md: 8px;
35
+ --radius-lg: 12px;
36
+ --radius-xl: 16px;
37
+ --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
38
+ --nav-height: 56px;
39
+ --content-max-width: 1200px;
40
+ }
41
+
42
+ *,
43
+ *::before,
44
+ *::after {
45
+ margin: 0;
46
+ padding: 0;
47
+ box-sizing: border-box;
48
+ }
49
+
50
+ html {
51
+ font-size: 16px;
52
+ -webkit-font-smoothing: antialiased;
53
+ -moz-osx-font-smoothing: grayscale;
54
+ }
55
+
56
+ body {
57
+ font-family: var(--font-family);
58
+ font-size: 14px;
59
+ line-height: 1.6;
60
+ color: var(--color-text);
61
+ background-color: var(--color-bg);
62
+ }
63
+
64
+ #app {
65
+ min-height: 100vh;
66
+ }
67
+
68
+ .app {
69
+ min-height: 100vh;
70
+ display: flex;
71
+ flex-direction: column;
72
+ }
73
+
74
+ /* Navigation */
75
+
76
+ .nav-bar {
77
+ background-color: var(--color-bg-white);
78
+ border-bottom: 1px solid var(--color-border);
79
+ box-shadow: var(--shadow-sm);
80
+ position: sticky;
81
+ top: 0;
82
+ z-index: 100;
83
+ }
84
+
85
+ .nav-inner {
86
+ max-width: var(--content-max-width);
87
+ margin: 0 auto;
88
+ padding: 0 24px;
89
+ height: var(--nav-height);
90
+ display: flex;
91
+ align-items: center;
92
+ justify-content: space-between;
93
+ }
94
+
95
+ .nav-logo {
96
+ font-size: 18px;
97
+ font-weight: 700;
98
+ color: var(--color-primary);
99
+ cursor: pointer;
100
+ user-select: none;
101
+ }
102
+
103
+ .nav-links {
104
+ display: flex;
105
+ align-items: center;
106
+ gap: 8px;
107
+ }
108
+
109
+ .nav-link {
110
+ padding: 6px 16px;
111
+ font-size: 14px;
112
+ font-weight: 500;
113
+ color: var(--color-text-secondary);
114
+ cursor: pointer;
115
+ border-radius: var(--radius-sm);
116
+ transition: color 0.2s, background-color 0.2s;
117
+ user-select: none;
118
+ }
119
+
120
+ .nav-link:hover {
121
+ color: var(--color-primary);
122
+ background-color: var(--color-bg-primary-soft);
123
+ }
124
+
125
+ .nav-link.active {
126
+ color: var(--color-primary);
127
+ background-color: var(--color-primary-alpha-10);
128
+ font-weight: 600;
129
+ }
130
+
131
+ /* Layout */
132
+
133
+ .page-container {
134
+ flex: 1;
135
+ max-width: var(--content-max-width);
136
+ width: 100%;
137
+ margin: 0 auto;
138
+ padding: 32px 24px;
139
+ }
140
+
141
+ /* Flex & Grid */
142
+
143
+ .flex {
144
+ display: flex;
145
+ }
146
+
147
+ .flex-col {
148
+ flex-direction: column;
149
+ }
150
+
151
+ .flex-center {
152
+ display: flex;
153
+ align-items: center;
154
+ justify-content: center;
155
+ }
156
+
157
+ .flex-between {
158
+ display: flex;
159
+ align-items: center;
160
+ justify-content: space-between;
161
+ }
162
+
163
+ .flex-wrap {
164
+ flex-wrap: wrap;
165
+ }
166
+
167
+ .inline-flex {
168
+ display: inline-flex;
169
+ }
170
+
171
+ .flex-1 {
172
+ flex: 1;
173
+ }
174
+
175
+ .flex-shrink-0 {
176
+ flex-shrink: 0;
177
+ }
178
+
179
+ .items-start {
180
+ align-items: flex-start;
181
+ }
182
+
183
+ .items-center {
184
+ align-items: center;
185
+ }
186
+
187
+ .justify-end {
188
+ justify-content: flex-end;
189
+ }
190
+
191
+ .gap-4 {
192
+ gap: 4px;
193
+ }
194
+
195
+ .gap-6 {
196
+ gap: 6px;
197
+ }
198
+
199
+ .gap-8 {
200
+ gap: 8px;
201
+ }
202
+
203
+ .gap-12 {
204
+ gap: 12px;
205
+ }
206
+
207
+ .gap-16 {
208
+ gap: 16px;
209
+ }
210
+
211
+ .gap-24 {
212
+ gap: 24px;
213
+ }
214
+
215
+ .grid-2 {
216
+ display: grid;
217
+ grid-template-columns: repeat(2, 1fr);
218
+ gap: 24px;
219
+ }
220
+
221
+ .grid-3 {
222
+ display: grid;
223
+ grid-template-columns: repeat(3, 1fr);
224
+ gap: 24px;
225
+ }
226
+
227
+ .grid-auto-fit {
228
+ display: grid;
229
+ grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
230
+ gap: 8px;
231
+ }
232
+
233
+ /* Buttons */
234
+
235
+ .btn {
236
+ display: inline-flex;
237
+ align-items: center;
238
+ justify-content: center;
239
+ gap: 8px;
240
+ padding: 10px 20px;
241
+ font-size: 14px;
242
+ font-weight: 500;
243
+ line-height: 1;
244
+ border: 1px solid transparent;
245
+ border-radius: var(--radius-sm);
246
+ cursor: pointer;
247
+ transition: all 0.2s;
248
+ user-select: none;
249
+ white-space: nowrap;
250
+ }
251
+
252
+ .btn:disabled {
253
+ opacity: 0.5;
254
+ cursor: not-allowed;
255
+ }
256
+
257
+ .btn-primary {
258
+ background-color: var(--color-primary);
259
+ color: var(--color-bg-white);
260
+ border-color: var(--color-primary);
261
+ }
262
+
263
+ .btn-primary:hover:not(:disabled) {
264
+ background-color: var(--color-primary-dark);
265
+ border-color: var(--color-primary-dark);
266
+ }
267
+
268
+ .btn-secondary {
269
+ background-color: var(--color-bg-white);
270
+ color: var(--color-text);
271
+ border-color: var(--color-border);
272
+ }
273
+
274
+ .btn-secondary:hover:not(:disabled) {
275
+ background-color: var(--color-border-light);
276
+ border-color: var(--color-border);
277
+ }
278
+
279
+ .btn-outline {
280
+ background-color: transparent;
281
+ color: var(--color-primary);
282
+ border-color: var(--color-primary);
283
+ }
284
+
285
+ .btn-outline:hover:not(:disabled) {
286
+ background-color: var(--color-bg-primary-soft);
287
+ }
288
+
289
+ .btn-sm {
290
+ padding: 6px 12px;
291
+ font-size: 13px;
292
+ }
293
+
294
+ .btn-lg {
295
+ padding: 14px 28px;
296
+ font-size: 16px;
297
+ }
298
+
299
+ /* Cards */
300
+
301
+ .card {
302
+ background-color: var(--color-bg-white);
303
+ border: 1px solid var(--color-border);
304
+ border-radius: var(--radius-lg);
305
+ box-shadow: var(--shadow-sm);
306
+ padding: 24px;
307
+ transition: box-shadow 0.2s;
308
+ }
309
+
310
+ .card:hover {
311
+ box-shadow: var(--shadow-md);
312
+ }
313
+
314
+ /* Typography */
315
+
316
+ .text-primary {
317
+ color: var(--color-primary);
318
+ }
319
+
320
+ .text-primary-dark {
321
+ color: var(--color-primary-dark);
322
+ }
323
+
324
+ .text-success {
325
+ color: var(--color-success);
326
+ }
327
+
328
+ .text-warning {
329
+ color: var(--color-warning);
330
+ }
331
+
332
+ .text-error {
333
+ color: var(--color-error);
334
+ }
335
+
336
+ .text-secondary {
337
+ color: var(--color-text-secondary);
338
+ }
339
+
340
+ .text-light {
341
+ color: var(--color-text-light);
342
+ }
343
+
344
+ .text-muted {
345
+ color: var(--color-text-muted);
346
+ }
347
+
348
+ .text-center {
349
+ text-align: center;
350
+ }
351
+
352
+ .text-right {
353
+ text-align: right;
354
+ }
355
+
356
+ .text-left {
357
+ text-align: left;
358
+ }
359
+
360
+ .text-sm {
361
+ font-size: 13px;
362
+ }
363
+
364
+ .text-xs {
365
+ font-size: 12px;
366
+ }
367
+
368
+ .text-lg {
369
+ font-size: 16px;
370
+ }
371
+
372
+ .text-xl {
373
+ font-size: 20px;
374
+ }
375
+
376
+ .text-2xl {
377
+ font-size: 24px;
378
+ }
379
+
380
+ .font-bold {
381
+ font-weight: 600;
382
+ }
383
+
384
+ .italic {
385
+ font-style: italic;
386
+ }
387
+
388
+ .leading-normal {
389
+ line-height: 1.5;
390
+ }
391
+
392
+ .leading-relaxed {
393
+ line-height: 1.6;
394
+ }
395
+
396
+ /* Margins */
397
+
398
+ .mt-4 {
399
+ margin-top: 4px;
400
+ }
401
+
402
+ .mt-6 {
403
+ margin-top: 6px;
404
+ }
405
+
406
+ .mt-8 {
407
+ margin-top: 8px;
408
+ }
409
+
410
+ .mt-12 {
411
+ margin-top: 12px;
412
+ }
413
+
414
+ .mt-16 {
415
+ margin-top: 16px;
416
+ }
417
+
418
+ .mt-24 {
419
+ margin-top: 24px;
420
+ }
421
+
422
+ .mb-4 {
423
+ margin-bottom: 4px;
424
+ }
425
+
426
+ .mb-6 {
427
+ margin-bottom: 6px;
428
+ }
429
+
430
+ .mb-8 {
431
+ margin-bottom: 8px;
432
+ }
433
+
434
+ .mb-12 {
435
+ margin-bottom: 12px;
436
+ }
437
+
438
+ .mb-16 {
439
+ margin-bottom: 16px;
440
+ }
441
+
442
+ .mb-24 {
443
+ margin-bottom: 24px;
444
+ }
445
+
446
+ .ml-4 {
447
+ margin-left: 4px;
448
+ }
449
+
450
+ .ml-8 {
451
+ margin-left: 8px;
452
+ }
453
+
454
+ .mr-4 {
455
+ margin-right: 4px;
456
+ }
457
+
458
+ .mx-auto {
459
+ margin-left: auto;
460
+ margin-right: auto;
461
+ }
462
+
463
+ /* State Components */
464
+
465
+ .empty-state {
466
+ display: flex;
467
+ flex-direction: column;
468
+ align-items: center;
469
+ justify-content: center;
470
+ padding: 64px 24px;
471
+ text-align: center;
472
+ }
473
+
474
+ .empty-state-icon {
475
+ font-size: 48px;
476
+ margin-bottom: 16px;
477
+ color: var(--color-text-light);
478
+ }
479
+
480
+ .empty-state-text {
481
+ font-size: 16px;
482
+ color: var(--color-text-secondary);
483
+ margin-bottom: 24px;
484
+ }
485
+
486
+ .error-state {
487
+ display: flex;
488
+ flex-direction: column;
489
+ align-items: center;
490
+ justify-content: center;
491
+ padding: 48px 24px;
492
+ text-align: center;
493
+ }
494
+
495
+ .error-state-text {
496
+ font-size: 15px;
497
+ color: var(--color-error);
498
+ margin-bottom: 16px;
499
+ }
500
+
501
+ .loading-state {
502
+ display: flex;
503
+ flex-direction: column;
504
+ align-items: center;
505
+ justify-content: center;
506
+ padding: 48px 24px;
507
+ }
508
+
509
+ /* Animations */
510
+
511
+ @keyframes spin {
512
+ from { transform: rotate(0deg); }
513
+ to { transform: rotate(360deg); }
514
+ }
515
+
516
+ @keyframes pulse {
517
+ 0%, 100% { opacity: 1; }
518
+ 50% { opacity: 0.5; }
519
+ }
520
+
521
+ @keyframes shimmer {
522
+ 0% { background-position: -200% 0; }
523
+ 100% { background-position: 200% 0; }
524
+ }
525
+
526
+ .loading-spinner {
527
+ width: 32px;
528
+ height: 32px;
529
+ border: 3px solid var(--color-border);
530
+ border-top-color: var(--color-primary);
531
+ border-radius: 50%;
532
+ animation: spin 0.8s linear infinite;
533
+ }
534
+
535
+ .loading-spinner-sm {
536
+ width: 20px;
537
+ height: 20px;
538
+ border-width: 2px;
539
+ }
540
+
541
+ .loading-spinner-lg {
542
+ width: 48px;
543
+ height: 48px;
544
+ border-width: 4px;
545
+ }
546
+
547
+ .skeleton {
548
+ background: linear-gradient(90deg, var(--color-border-light) 25%, var(--color-border) 50%, var(--color-border-light) 75%);
549
+ background-size: 200% 100%;
550
+ animation: shimmer 1.5s ease-in-out infinite;
551
+ border-radius: var(--radius-sm);
552
+ }
553
+
554
+ /* Tags & Chips */
555
+
556
+ .tag {
557
+ display: inline-block;
558
+ padding: 2px 8px;
559
+ font-size: 12px;
560
+ border-radius: var(--radius-sm);
561
+ background-color: rgba(79, 70, 229, 0.08);
562
+ color: var(--color-primary);
563
+ }
564
+
565
+ .tag-sm {
566
+ padding: 3px 10px;
567
+ font-size: 12px;
568
+ display: inline-block;
569
+ border-radius: var(--radius-sm);
570
+ margin-bottom: 4px;
571
+ line-height: 1.6;
572
+ background-color: var(--color-bg-info-soft);
573
+ color: var(--color-signal-text);
574
+ }
575
+
576
+ .signal-tag {
577
+ display: flex;
578
+ flex-direction: column;
579
+ gap: 4px;
580
+ padding: 8px 12px;
581
+ background-color: var(--color-tag-bg);
582
+ border: 1px solid var(--color-tag-border);
583
+ border-radius: var(--radius-sm);
584
+ }
585
+
586
+ .signal-tag-name {
587
+ font-size: 14px;
588
+ font-weight: 600;
589
+ color: var(--color-tag-text);
590
+ }
591
+
592
+ .signal-tag-evidence {
593
+ font-size: 12px;
594
+ color: var(--color-text-secondary);
595
+ }
596
+
597
+ .signal-chip {
598
+ display: inline-block;
599
+ padding: 3px 10px;
600
+ font-size: 12px;
601
+ border-radius: var(--radius-sm);
602
+ margin-bottom: 4px;
603
+ line-height: 1.6;
604
+ background-color: var(--color-bg-info-soft);
605
+ color: var(--color-signal-text);
606
+ }
607
+
608
+ .signal-chip-primary {
609
+ display: inline-block;
610
+ padding: 3px 10px;
611
+ font-size: 12px;
612
+ border-radius: var(--radius-sm);
613
+ margin-bottom: 4px;
614
+ line-height: 1.6;
615
+ background-color: color-mix(in srgb, var(--color-primary) 8%, transparent);
616
+ color: var(--color-primary);
617
+ }
618
+
619
+ .signal-chip-evidence {
620
+ font-size: 11px;
621
+ color: var(--color-text-secondary);
622
+ margin-left: 4px;
623
+ }
624
+
625
+ .signal-evidence {
626
+ font-size: 11px;
627
+ color: var(--color-text-secondary);
628
+ margin-left: 4px;
629
+ }
630
+
631
+ /* Form Elements */
632
+
633
+ .input {
634
+ width: 100%;
635
+ padding: 10px 12px;
636
+ font-size: 14px;
637
+ border: 1px solid var(--color-border);
638
+ border-radius: var(--radius-sm);
639
+ outline: none;
640
+ transition: border-color 0.2s;
641
+ font-family: inherit;
642
+ background-color: var(--color-bg-white);
643
+ }
644
+
645
+ .input:focus {
646
+ border-color: var(--color-primary);
647
+ }
648
+
649
+ /* Pipeline Flow */
650
+
651
+ .pipeline-node {
652
+ width: 40px;
653
+ height: 40px;
654
+ border-radius: 50%;
655
+ display: flex;
656
+ align-items: center;
657
+ justify-content: center;
658
+ font-size: 16px;
659
+ font-weight: 600;
660
+ border: 2px solid var(--color-border);
661
+ color: var(--color-text-light);
662
+ background-color: var(--color-bg-white);
663
+ transition: all 0.3s;
664
+ }
665
+
666
+ .pipeline-node-idle {
667
+ border-color: var(--color-border);
668
+ color: var(--color-text-light);
669
+ }
670
+
671
+ .pipeline-node-running {
672
+ border-color: var(--color-primary);
673
+ color: var(--color-primary);
674
+ }
675
+
676
+ .pipeline-node-completed {
677
+ border-color: var(--color-success);
678
+ color: var(--color-success);
679
+ background-color: var(--color-bg-success-soft);
680
+ }
681
+
682
+ .pipeline-node-error {
683
+ border-color: var(--color-error);
684
+ color: var(--color-error);
685
+ background-color: var(--color-bg-error-soft);
686
+ }
687
+
688
+ .pipeline-step-running {
689
+ animation: spin 1s linear infinite;
690
+ }
691
+
692
+ .pipeline-step-pulse {
693
+ animation: pulse 1.5s ease-in-out infinite;
694
+ }
695
+
696
+ .pipeline-connector {
697
+ width: 60px;
698
+ height: 2px;
699
+ transition: background-color 0.3s;
700
+ }
701
+
702
+ .pipeline-connector-completed {
703
+ background-color: var(--color-success);
704
+ }
705
+
706
+ .pipeline-connector-idle {
707
+ background-color: var(--color-border);
708
+ }
709
+
710
+ .pipeline-label-idle {
711
+ color: var(--color-text-light);
712
+ }
713
+
714
+ .pipeline-label-running {
715
+ color: var(--color-primary);
716
+ }
717
+
718
+ .pipeline-label-completed {
719
+ color: var(--color-success);
720
+ }
721
+
722
+ .pipeline-label-error {
723
+ color: var(--color-error);
724
+ }
725
+
726
+ /* Status Messages */
727
+
728
+ .divider {
729
+ border: none;
730
+ border-top: 1px solid var(--color-border);
731
+ }
732
+
733
+ .msg-warning {
734
+ padding: 8px 12px;
735
+ background-color: var(--color-bg-warning-soft);
736
+ border-radius: var(--radius-sm);
737
+ color: var(--color-warning);
738
+ }
739
+
740
+ .msg-error {
741
+ padding: 8px 12px;
742
+ background-color: var(--color-bg-error-soft);
743
+ border-radius: var(--radius-sm);
744
+ color: var(--color-error);
745
+ }
746
+
747
+ /* Info & Tip Boxes */
748
+
749
+ .info-box {
750
+ padding: 8px 12px;
751
+ background-color: var(--color-border-light);
752
+ border-radius: var(--radius-sm);
753
+ border: 1px solid var(--color-border);
754
+ }
755
+
756
+ .info-box-sm {
757
+ padding: 8px 12px;
758
+ background-color: var(--color-bg-light);
759
+ border-radius: var(--radius-sm);
760
+ }
761
+
762
+ .tip-box {
763
+ padding: 10px 14px;
764
+ background-color: var(--color-bg-warning-soft);
765
+ border-radius: var(--radius-sm);
766
+ line-height: 1.6;
767
+ color: var(--color-tip-text);
768
+ }
769
+
770
+ .tip-box-text {
771
+ font-size: 12px;
772
+ }
773
+
774
+ /* HR View Components */
775
+
776
+ .hr-quote-box {
777
+ padding: 12px 16px;
778
+ background-color: color-mix(in srgb, var(--color-primary) 6%, transparent);
779
+ border-radius: var(--radius-sm);
780
+ border-left: 3px solid var(--color-primary);
781
+ }
782
+
783
+ .hr-quote-text {
784
+ font-size: 14px;
785
+ font-style: italic;
786
+ }
787
+
788
+ .hr-concern-tag {
789
+ font-weight: 700;
790
+ padding: 2px 8px;
791
+ font-size: 12px;
792
+ border-radius: var(--radius-sm);
793
+ }
794
+
795
+ .hr-summary-box {
796
+ padding: 12px;
797
+ background-color: color-mix(in srgb, var(--color-success) 6%, transparent);
798
+ border-radius: var(--radius-sm);
799
+ }
800
+
801
+ .attention-point-box {
802
+ padding: 12px;
803
+ background-color: var(--color-border-light);
804
+ border-radius: var(--radius-sm);
805
+ }
806
+
807
+ .jd-quote-box {
808
+ padding: 12px;
809
+ border: 1px solid var(--color-border);
810
+ border-radius: var(--radius-sm);
811
+ background-color: color-mix(in srgb, var(--color-primary) 4%, transparent);
812
+ }
813
+
814
+ .resume-quote-box {
815
+ padding: 12px;
816
+ border: 1px solid var(--color-border);
817
+ border-radius: var(--radius-sm);
818
+ background-color: color-mix(in srgb, var(--color-success) 4%, transparent);
819
+ }
820
+
821
+ .evidence-list {
822
+ list-style: none;
823
+ }
824
+
825
+ .evidence-item {
826
+ margin-top: 4px;
827
+ }
828
+
829
+ .evidence-source {
830
+ color: var(--color-text-light);
831
+ margin-left: 4px;
832
+ }
833
+
834
+ /* Drop Zone */
835
+
836
+ .drop-zone {
837
+ border: 2px dashed var(--color-border);
838
+ border-radius: var(--radius-lg);
839
+ padding: 48px;
840
+ cursor: pointer;
841
+ text-align: center;
842
+ transition: border-color 0.2s, background-color 0.2s;
843
+ }
844
+
845
+ .drop-zone:hover {
846
+ border-color: var(--color-primary);
847
+ background-color: var(--color-bg-primary-soft);
848
+ }
849
+
850
+ /* Job Components */
851
+
852
+ .job-preview-item {
853
+ display: flex;
854
+ align-items: center;
855
+ justify-content: space-between;
856
+ padding: 8px 12px;
857
+ background-color: var(--color-bg-light);
858
+ border-radius: var(--radius-sm);
859
+ }
860
+
861
+ .process-card {
862
+ padding: 8px 12px;
863
+ border-radius: var(--radius-sm);
864
+ }
865
+
866
+ .step-card {
867
+ padding: 10px 14px;
868
+ background-color: var(--color-bg-light);
869
+ border-radius: var(--radius-sm);
870
+ }
871
+
872
+ /* Progress Bars */
873
+
874
+ .progress-track {
875
+ height: 4px;
876
+ background-color: var(--color-border);
877
+ border-radius: 2px;
878
+ overflow: hidden;
879
+ }
880
+
881
+ .progress-bar {
882
+ height: 100%;
883
+ border-radius: 2px;
884
+ transition: width 0.5s ease;
885
+ }
886
+
887
+ .progress-bar-sm {
888
+ height: 6px;
889
+ border-radius: 3px;
890
+ overflow: hidden;
891
+ }
892
+
893
+ .progress-bar-bg-sm {
894
+ background-color: var(--color-border);
895
+ }
896
+
897
+ .progress-bar-md {
898
+ height: 8px;
899
+ border-radius: 4px;
900
+ overflow: hidden;
901
+ }
902
+
903
+ .progress-bar-bg-md {
904
+ background-color: var(--color-border-light);
905
+ }
906
+
907
+ .progress-bar-bg {
908
+ height: 8px;
909
+ background-color: var(--color-bg);
910
+ border-radius: 4px;
911
+ overflow: hidden;
912
+ }
913
+
914
+ .progress-bar-fill {
915
+ height: 100%;
916
+ transition: width 0.5s ease;
917
+ }
918
+
919
+ .bar-label {
920
+ width: 56px;
921
+ font-size: 12px;
922
+ flex-shrink: 0;
923
+ }
924
+
925
+ .bar-value {
926
+ width: 32px;
927
+ font-size: 12px;
928
+ font-weight: 600;
929
+ text-align: right;
930
+ }
931
+
932
+ .bar-weight {
933
+ width: 28px;
934
+ font-size: 12px;
935
+ text-align: right;
936
+ color: var(--color-text-light);
937
+ }
938
+
939
+ .bar-divider {
940
+ border-top: 1px solid var(--color-border);
941
+ padding-top: 8px;
942
+ margin-top: 8px;
943
+ }
944
+
945
+ /* Width / Height / Spacing Utilities */
946
+
947
+ .max-w-50p {
948
+ max-width: 50%;
949
+ }
950
+
951
+ .max-w-640 {
952
+ max-width: 640px;
953
+ }
954
+
955
+ .mw-80 {
956
+ min-width: 80px;
957
+ }
958
+
959
+ .mw-140 {
960
+ min-width: 140px;
961
+ }
962
+
963
+ .w-120 {
964
+ width: 120px;
965
+ }
966
+
967
+ .w-56 {
968
+ width: 56px;
969
+ }
970
+
971
+ .w-full {
972
+ width: 100%;
973
+ }
974
+
975
+ .h-320 {
976
+ height: 320px;
977
+ }
978
+
979
+ .h-8 {
980
+ height: 8px;
981
+ }
982
+
983
+ .h-6 {
984
+ height: 6px;
985
+ }
986
+
987
+ .h-4 {
988
+ height: 4px;
989
+ }
990
+
991
+ .mh-320 {
992
+ min-height: 320px;
993
+ }
994
+
995
+ .p-48 {
996
+ padding: 48px;
997
+ }
998
+
999
+ .p-10 {
1000
+ padding: 10px;
1001
+ }
1002
+
1003
+ .p-8 {
1004
+ padding: 8px;
1005
+ }
1006
+
1007
+ .p-12 {
1008
+ padding: 12px;
1009
+ }
1010
+
1011
+ .p-16 {
1012
+ padding: 16px;
1013
+ }
1014
+
1015
+ .p-24 {
1016
+ padding: 24px;
1017
+ }
1018
+
1019
+ .pt-8 {
1020
+ padding-top: 8px;
1021
+ }
1022
+
1023
+ .pb-8 {
1024
+ padding-bottom: 8px;
1025
+ }
1026
+
1027
+ .py-8 {
1028
+ padding-top: 8px;
1029
+ padding-bottom: 8px;
1030
+ }
1031
+
1032
+ .py-10 {
1033
+ padding-top: 10px;
1034
+ padding-bottom: 10px;
1035
+ }
1036
+
1037
+ .py-12 {
1038
+ padding-top: 12px;
1039
+ padding-bottom: 12px;
1040
+ }
1041
+
1042
+ .py-16 {
1043
+ padding-top: 16px;
1044
+ padding-bottom: 16px;
1045
+ }
1046
+
1047
+ .py-24 {
1048
+ padding-top: 24px;
1049
+ padding-bottom: 24px;
1050
+ }
1051
+
1052
+ .px-8 {
1053
+ padding-left: 8px;
1054
+ padding-right: 8px;
1055
+ }
1056
+
1057
+ .px-10 {
1058
+ padding-left: 10px;
1059
+ padding-right: 10px;
1060
+ }
1061
+
1062
+ .px-12 {
1063
+ padding-left: 12px;
1064
+ padding-right: 12px;
1065
+ }
1066
+
1067
+ .px-16 {
1068
+ padding-left: 16px;
1069
+ padding-right: 16px;
1070
+ }
1071
+
1072
+ .px-24 {
1073
+ padding-left: 24px;
1074
+ padding-right: 24px;
1075
+ }
1076
+
1077
+ /* Other Utilities */
1078
+
1079
+ .min-width-0 {
1080
+ min-width: 0;
1081
+ }
1082
+
1083
+ .hidden {
1084
+ display: none;
1085
+ }
1086
+
1087
+ .overflow-hidden {
1088
+ overflow: hidden;
1089
+ }
1090
+
1091
+ .whitespace-pre-wrap {
1092
+ white-space: pre-wrap;
1093
+ }
1094
+
1095
+ .cursor-pointer {
1096
+ cursor: pointer;
1097
+ }
1098
+
1099
+ .list-none {
1100
+ list-style: none;
1101
+ }
1102
+
1103
+ .fs-11 {
1104
+ font-size: 11px;
1105
+ }
1106
+
1107
+ .border-bottom {
1108
+ border-bottom: 1px solid var(--color-border);
1109
+ }
1110
+
1111
+ .bg-light {
1112
+ background-color: var(--color-bg-light);
1113
+ }
1114
+
1115
+ .bg-bg {
1116
+ background-color: var(--color-bg);
1117
+ }
1118
+
1119
+ .bg-white {
1120
+ background-color: var(--color-bg-white);
1121
+ }
1122
+
1123
+ .bg-primary-soft {
1124
+ background-color: var(--color-bg-primary-soft);
1125
+ }
1126
+
1127
+ .bg-warning-soft {
1128
+ background-color: var(--color-bg-warning-soft);
1129
+ }
1130
+
1131
+ .bg-error-soft {
1132
+ background-color: var(--color-bg-error-soft);
1133
+ }
1134
+
1135
+ .bg-success-soft {
1136
+ background-color: var(--color-bg-success-soft);
1137
+ }
1138
+
1139
+ .opacity-5 {
1140
+ opacity: 0.5;
1141
+ }
1142
+
1143
+ .rounded-sm {
1144
+ border-radius: var(--radius-sm);
1145
+ }
1146
+
1147
+ /* Mobile: max-width 767px */
1148
+
1149
+ @media (max-width: 767px) {
1150
+ .page-container {
1151
+ padding: 20px 16px;
1152
+ }
1153
+
1154
+ .nav-inner {
1155
+ padding: 0 16px;
1156
+ }
1157
+
1158
+ .nav-links {
1159
+ gap: 4px;
1160
+ flex-wrap: wrap;
1161
+ }
1162
+
1163
+ .nav-link {
1164
+ padding: 6px 10px;
1165
+ font-size: 13px;
1166
+ }
1167
+
1168
+ .flex-between {
1169
+ flex-wrap: wrap;
1170
+ row-gap: 12px;
1171
+ }
1172
+
1173
+ .grid-2 {
1174
+ grid-template-columns: 1fr;
1175
+ gap: 16px;
1176
+ }
1177
+
1178
+ .grid-3 {
1179
+ grid-template-columns: 1fr;
1180
+ gap: 16px;
1181
+ }
1182
+
1183
+ .card {
1184
+ padding: 16px;
1185
+ }
1186
+
1187
+ .card .cursor-pointer > .flex.items-center {
1188
+ flex-direction: column;
1189
+ align-items: stretch;
1190
+ }
1191
+
1192
+ .card .flex-shrink-0 svg {
1193
+ width: 64px;
1194
+ height: 64px;
1195
+ }
1196
+
1197
+ .flex-wrap-mobile {
1198
+ flex-wrap: wrap;
1199
+ }
1200
+
1201
+ .hidden-mobile {
1202
+ display: none;
1203
+ }
1204
+
1205
+ .text-xl {
1206
+ font-size: 18px;
1207
+ }
1208
+
1209
+ .text-2xl {
1210
+ font-size: 20px;
1211
+ }
1212
+
1213
+ .drop-zone {
1214
+ padding: 32px 16px;
1215
+ }
1216
+
1217
+ .max-w-50p {
1218
+ max-width: 100% !important;
1219
+ }
1220
+
1221
+ .max-w-640 {
1222
+ max-width: 100% !important;
1223
+ }
1224
+
1225
+ .mw-140 {
1226
+ min-width: auto !important;
1227
+ min-width: 100% !important;
1228
+ }
1229
+
1230
+ .h-320 {
1231
+ height: 240px !important;
1232
+ }
1233
+
1234
+ .loading-state {
1235
+ padding: 32px 16px;
1236
+ }
1237
+
1238
+ .empty-state {
1239
+ padding: 40px 16px;
1240
+ }
1241
+
1242
+ .error-state {
1243
+ padding: 32px 16px;
1244
+ }
1245
+
1246
+ .pipeline-connector {
1247
+ width: 32px;
1248
+ }
1249
+
1250
+ .flex-col-mobile {
1251
+ flex-direction: column;
1252
+ }
1253
+
1254
+ .gap-mobile-8 {
1255
+ gap: 8px;
1256
+ }
1257
+
1258
+ .grid-auto-fit {
1259
+ grid-template-columns: 1fr;
1260
+ }
1261
+ }
1262
+
1263
+ /* Tablet: 768px–1023px */
1264
+
1265
+ @media (min-width: 768px) and (max-width: 1023px) {
1266
+ .page-container {
1267
+ padding: 32px 24px;
1268
+ }
1269
+
1270
+ .grid-2 {
1271
+ gap: 20px;
1272
+ }
1273
+
1274
+ .grid-3 {
1275
+ grid-template-columns: repeat(2, 1fr);
1276
+ gap: 20px;
1277
+ }
1278
+ }
1279
+
1280
+ /* Tablet+ (768px+) */
1281
+
1282
+ @media (min-width: 768px) {
1283
+ .page-container {
1284
+ padding: 40px 32px;
1285
+ }
1286
+ }
1287
+
1288
+ /* Desktop (1024px+) */
1289
+
1290
+ @media (min-width: 1024px) {
1291
+ .page-container {
1292
+ padding: 48px 32px;
1293
+ }
1294
+
1295
+ .grid-2 {
1296
+ gap: 32px;
1297
+ }
1298
+
1299
+ .grid-3 {
1300
+ gap: 32px;
1301
+ }
1302
+ }
src/App.jsx ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useState, useEffect } from 'react'
2
+ import { confirmResume } from './api'
3
+ import HomePage from './pages/HomePage'
4
+ import RecommendPage from './pages/RecommendPage'
5
+ import DiagnosePage from './pages/DiagnosePage'
6
+ import SuggestPage from './pages/SuggestPage'
7
+
8
+ function App() {
9
+ const [currentPage, setCurrentPage] = useState('recommend')
10
+ const [resumeData, setResumeData] = useState(null)
11
+ const [selectedJobId, setSelectedJobId] = useState(null)
12
+ const [selectedJob, setSelectedJob] = useState(null)
13
+ const [advice, setAdvice] = useState(null)
14
+ const [pendingJobForDiagnose, setPendingJobForDiagnose] = useState(null)
15
+
16
+ useEffect(() => {
17
+ const saved = localStorage.getItem('offer_resume_data')
18
+ if (saved) {
19
+ try { setResumeData(JSON.parse(saved)) } catch {}
20
+ }
21
+ }, [])
22
+
23
+ useEffect(() => {
24
+ if (resumeData) {
25
+ localStorage.setItem('offer_resume_data', JSON.stringify(resumeData))
26
+ }
27
+ }, [resumeData])
28
+
29
+ const goToHome = () => {
30
+ setCurrentPage('home')
31
+ }
32
+
33
+ const goToRecommend = () => {
34
+ setCurrentPage('recommend')
35
+ }
36
+
37
+ const goToDiagnose = (jobId, jobData) => {
38
+ if (!jobId) return
39
+ setSelectedJobId(jobId)
40
+ setSelectedJob(jobData || null)
41
+ setCurrentPage('diagnose')
42
+ }
43
+
44
+ const goToSuggest = (payload) => {
45
+ if (payload?.advice) setAdvice(payload.advice)
46
+ setCurrentPage('suggest')
47
+ }
48
+
49
+ const handleNavDiagnose = () => {
50
+ if (!selectedJobId) return
51
+ setCurrentPage('diagnose')
52
+ }
53
+
54
+ const handleConfirmResume = async (data) => {
55
+ let resolved = data
56
+ try {
57
+ const res = await confirmResume(data)
58
+ if (res.data?.data) {
59
+ resolved = res.data.data
60
+ }
61
+ } catch {}
62
+ setResumeData(resolved)
63
+ if (pendingJobForDiagnose) {
64
+ const { jobId, jobData } = pendingJobForDiagnose
65
+ setPendingJobForDiagnose(null)
66
+ setSelectedJobId(jobId)
67
+ setSelectedJob(jobData || null)
68
+ setCurrentPage('diagnose')
69
+ } else {
70
+ setCurrentPage('recommend')
71
+ }
72
+ }
73
+
74
+ const goHomeFromDiagnose = () => {
75
+ if (selectedJobId && !resumeData) {
76
+ setPendingJobForDiagnose({ jobId: selectedJobId, jobData: selectedJob })
77
+ }
78
+ setCurrentPage('home')
79
+ }
80
+
81
+ const renderNav = () => (
82
+ <nav className="nav-bar">
83
+ <div className="nav-inner">
84
+ <span className="nav-logo" onClick={goToRecommend}>Offer 捕手</span>
85
+ <div className="nav-links">
86
+ <span className={`nav-link${currentPage === 'home' ? ' active' : ''}`} onClick={goToHome}>个人中心</span>
87
+ <span className={`nav-link${currentPage === 'recommend' ? ' active' : ''}`} onClick={goToRecommend}>推荐岗位</span>
88
+ <span className={`nav-link${currentPage === 'diagnose' ? ' active' : ''}`} onClick={handleNavDiagnose}>匹配诊断</span>
89
+ <span className={`nav-link${currentPage === 'suggest' ? ' active' : ''}`} onClick={() => goToSuggest()}>改进建议</span>
90
+ </div>
91
+ </div>
92
+ </nav>
93
+ )
94
+
95
+ const renderPage = () => {
96
+ switch (currentPage) {
97
+ case 'home':
98
+ return <HomePage resumeData={resumeData} onConfirm={handleConfirmResume} onGoRecommend={goToRecommend} />
99
+ case 'recommend':
100
+ return <RecommendPage
101
+ resumeData={resumeData}
102
+ onSelectJob={(jobId, jobData) => goToDiagnose(jobId, jobData)}
103
+ onGoHome={goToHome}
104
+ />
105
+ case 'diagnose':
106
+ return <DiagnosePage jobId={selectedJobId} jobData={selectedJob} resumeData={resumeData} onComplete={(payload) => goToSuggest(payload)} onBack={() => setCurrentPage('recommend')} onGoHome={goHomeFromDiagnose} />
107
+ case 'suggest':
108
+ return <SuggestPage jobId={selectedJobId} resumeData={resumeData} advice={advice} onBack={() => setCurrentPage('diagnose')} />
109
+ default:
110
+ return <RecommendPage resumeData={resumeData} onSelectJob={(jobId, jobData) => goToDiagnose(jobId, jobData)} />
111
+ }
112
+ }
113
+
114
+ return (
115
+ <div className="app">
116
+ {renderNav()}
117
+ <main className="page-container">{renderPage()}</main>
118
+ </div>
119
+ )
120
+ }
121
+
122
+ export default App
src/api/index.js ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import axios from 'axios'
2
+ import { getMockResumeData, getMockJobs, getMockReport, getMockSuggestions } from './mock'
3
+
4
+ const USE_MOCK = false
5
+
6
+ function delay(ms) {
7
+ return new Promise(resolve => setTimeout(resolve, ms))
8
+ }
9
+
10
+ const api = axios.create({
11
+ baseURL: '',
12
+ timeout: 10000,
13
+ })
14
+
15
+ api.interceptors.response.use(
16
+ (response) => response,
17
+ (error) => {
18
+ if (error.response) {
19
+ const status = error.response.status
20
+ if (status >= 500) {
21
+ console.error('服务器错误,请稍后重试')
22
+ } else if (status >= 400) {
23
+ console.error('请求错误,请检查输入')
24
+ }
25
+ } else if (error.request) {
26
+ console.error('网络连接失败,请检查网络')
27
+ }
28
+ return Promise.reject(error)
29
+ }
30
+ )
31
+
32
+ export async function uploadResume(file) {
33
+ if (USE_MOCK) {
34
+ await delay(800)
35
+ return getMockResumeData()
36
+ }
37
+ const formData = new FormData()
38
+ formData.append('file', file)
39
+ return api.post('/api/resume/upload', formData, {
40
+ headers: { 'Content-Type': 'multipart/form-data' },
41
+ })
42
+ }
43
+
44
+ export async function getRecommendJobs(resumeId) {
45
+ if (USE_MOCK) {
46
+ await delay(500)
47
+ return getMockJobs()
48
+ }
49
+ const res = await api.get('/api/jobs/recommend', { params: { resume_id: resumeId } })
50
+ const list = (res.data?.jobs || []).map(job => ({
51
+ ...job,
52
+ match_rate: Math.round((job.match_rate || 0) * 100)
53
+ }))
54
+ return { data: { jobs: list } }
55
+ }
56
+
57
+ export async function generateReport(jobId, resumeData) {
58
+ if (USE_MOCK) {
59
+ const encoder = new TextEncoder()
60
+ const report = getMockReport()
61
+ const suggestions = getMockSuggestions()
62
+ const stream = new ReadableStream({
63
+ async start(controller) {
64
+ const events = [
65
+ { type: 'agent_start', agent: 'agent1' },
66
+ { type: 'agent_complete', agent: 'agent1', data: { must_have: ['Python', 'Redis', '分布式系统'], nice_to_have: ['Go', '微服务'], position_summary: '后端开发实习生 - 腾讯' } },
67
+ { type: 'agent_start', agent: 'agent2' },
68
+ { type: 'agent_complete', agent: 'agent2', data: { dimensions: report.dimensions, total_score: report.total_score, strength: report.strength, gap: report.gap, hr_view: report.hr_view } },
69
+ { type: 'agent_start', agent: 'agent3' },
70
+ { type: 'agent_complete', agent: 'agent3', data: suggestions },
71
+ { type: 'report_complete', data: { jd_parsed: { must_have: ['Python', 'Redis', '分布式系统'], nice_to_have: ['Go', '微服务'], position_summary: '后端开发实习生 - 腾讯' }, match_report: { dimensions: report.dimensions, total_score: report.total_score, strength: report.strength, gap: report.gap, hr_view: report.hr_view }, advice: suggestions } },
72
+ ]
73
+ for (const event of events) {
74
+ await delay(600)
75
+ const line = JSON.stringify(event) + '\n'
76
+ controller.enqueue(encoder.encode(line))
77
+ }
78
+ controller.close()
79
+ }
80
+ })
81
+ return { ok: true, body: { getReader: () => stream.getReader() } }
82
+ }
83
+ const body = { job_id: jobId }
84
+ if (resumeData) {
85
+ const normalizeSkills = (s) => typeof s === 'string' ? s : (s.name || s)
86
+ const normalizeProjects = (p) => typeof p === 'string' ? p : (p.name || JSON.stringify(p))
87
+ const normalizeString = (v) => {
88
+ if (typeof v === 'string') return v
89
+ if (v && typeof v === 'object') return v.school || v.name || JSON.stringify(v)
90
+ return ''
91
+ }
92
+ body.resume_data = {
93
+ name: resumeData.name || '',
94
+ school: normalizeString(resumeData.school),
95
+ major: normalizeString(resumeData.major),
96
+ grade: normalizeString(resumeData.grade),
97
+ skills: (resumeData.skills || []).map(normalizeSkills),
98
+ projects: (resumeData.projects || []).map(normalizeProjects),
99
+ summary: resumeData.summary || '',
100
+ experience: resumeData.experience || '',
101
+ education: normalizeString(resumeData.education),
102
+ }
103
+ }
104
+ return fetch('/api/report/generate', {
105
+ method: 'POST',
106
+ headers: { 'Content-Type': 'application/json' },
107
+ body: JSON.stringify(body),
108
+ })
109
+ }
110
+
111
+ export async function rerankReport(jobId, editedResume) {
112
+ if (USE_MOCK) {
113
+ await delay(800)
114
+ return { data: { match_rate: Math.floor(Math.random() * 30) + 60, previous_rate: 62 } }
115
+ }
116
+ return api.post('/api/report/rerank', {
117
+ job_id: jobId,
118
+ edited_resume: editedResume,
119
+ })
120
+ }
121
+
122
+ export async function confirmResume(resumeData) {
123
+ if (USE_MOCK) {
124
+ await delay(300)
125
+ return { data: { success: true, data: resumeData } }
126
+ }
127
+ return api.post('/api/resume/confirm', resumeData)
128
+ }
129
+
130
+ export default api
src/api/mock.js ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const mockJobs = [
2
+ { job_id: 1, name: '后端开发实习生', company: '腾讯', city: '深圳', salary: '200-250/天', match_rate: 85, tags: ['Python', 'Go', '后端'], description: '负责后端服务开发和维护,参与微服务架构设计', requirements: '熟悉Python/Go,了解分布式系统', expectation_signals: [{"tag":"加班强度大","evidence":"腾讯核心部门普遍加班,尤其是云业务线交付压力大","confidence":0.75},{"tag":"技术氛围浓厚","evidence":"腾讯以技术驱动著称,内部技术分享和开源文化丰富","confidence":0.85},{"tag":"待遇高于行业平均","evidence":"200-250元/天在实习岗位中属于较高水平","confidence":0.8},{"tag":"核心业务参与","evidence":"腾讯云核心服务直接服务于公司战略级业务","confidence":0.85}] },
3
+ { job_id: 2, name: 'AI算法实习生', company: '字节跳动', city: '北京', salary: '250-300/天', match_rate: 72, tags: ['机器学习', 'Python', '深度学习'], description: '参与推荐系统算法优化,提升推荐准确率', requirements: '熟悉机器学习基础,有相关项目经验优先', expectation_signals: [{"tag":"加班强度大","evidence":"字节跳动以快速迭代和高强度工作节奏著称","confidence":0.8},{"tag":"AI前沿方向","evidence":"LLM训练与推理优化处于AI技术最前沿","confidence":0.9},{"tag":"待遇优厚","evidence":"250-300元/天在算法实习岗位中极具竞争力","confidence":0.85},{"tag":"技术驱动文化","evidence":"字节跳动重视技术投入,AI团队资源充足","confidence":0.85}] },
4
+ { job_id: 3, name: '前端开发实习生', company: '阿里巴巴', city: '杭州', salary: '200-250/天', match_rate: 68, tags: ['React', 'TypeScript', '前端'], description: '参与中后台系统前端开发', requirements: '熟悉React/Vue,了解前端工程化', expectation_signals: [{"tag":"大促期间加班","evidence":"阿里大促期间前端需随时待命保障页面稳定","confidence":0.7},{"tag":"技术沉淀深厚","evidence":"阿里前端技术生态成熟,具有业界领先的组件库体系","confidence":0.8},{"tag":"待遇中等偏上","evidence":"200-250元/天在前端实习中属于中等偏上","confidence":0.75},{"tag":"高流量业务场景","evidence":"淘宝/天猫商家端服务千万级商家,流量巨大","confidence":0.85}] },
5
+ { job_id: 4, name: '产品经理实习生', company: '美团', city: '北京', salary: '180-220/天', match_rate: 55, tags: ['产品设计', '数据分析', '用户研究'], description: '负责B端产品功能设计和迭代', requirements: '有产品实习经验优先,逻辑清晰', expectation_signals: [{"tag":"业务竞争激烈","evidence":"美团所处生活服务赛道竞争激烈,产品推进速度要快","confidence":0.7},{"tag":"数据驱动文化","evidence":"美团以数据驱动运营决策著称,产品岗需强分析能力","confidence":0.85},{"tag":"待遇行业中等","evidence":"180-220元/天在产品实习岗位中属中等水平","confidence":0.7},{"tag":"核心业务板块","evidence":"美团到店/外卖是公司核心业务之一,成长空间大","confidence":0.8}] },
6
+ { job_id: 5, name: '数据分析实习生', company: '快手', city: '北京', salary: '200-250/天', match_rate: 78, tags: ['SQL', 'Python', '数据分析'], description: '负责业务数据分析和报表建设', requirements: '熟练使用SQL和Python,有数据分析项目经验', expectation_signals: [{"tag":"工作节奏较快","evidence":"快手增长团队工作节奏快,数据产出时效性要求高","confidence":0.65},{"tag":"数据导向文化","evidence":"快手高度重视数据驱动业务决策,数据岗位话语权强","confidence":0.85},{"tag":"待遇中等偏上","evidence":"200-250元/天在数据分析实习中属于较高水平","confidence":0.75},{"tag":"核心业务指标","evidence":"DAU增长方向直接关系公司核心KPI","confidence":0.85}] },
7
+ ]
8
+
9
+ const mockReport = {
10
+ dimensions: [
11
+ { name: '技能匹配', score: 80, evidence: { jd_quote: '熟悉Python', resume_quote: '熟练使用Python进行数据处理和模型开发' } },
12
+ { name: '经验匹配', score: 40, evidence: { jd_quote: '3年以上相关经验', resume_quote: '6个月实习经历' } },
13
+ { name: '学历匹配', score: 100, evidence: { jd_quote: '计算机相关专业', resume_quote: '计算机科学与技术专业' } },
14
+ { name: '项目契合', score: 65, evidence: { jd_quote: '有推荐系统经验优先', resume_quote: '课程项目实现了协同过滤推荐算法' } },
15
+ { name: '软性素质', score: 75, evidence: { jd_quote: '具备团队协作能力', resume_quote: '与3名同学协作完成课程项目' } },
16
+ ],
17
+ total_score: 72,
18
+ strength: '技能基础扎实,学历完全符合要求',
19
+ gap: '缺乏全职工作经验,项目深度有待提升',
20
+ hr_view: {
21
+ first_impression: '技能列表与 JD 匹配度高,但项目描述缺乏量化成果,简历整体合格',
22
+ attention_points: [
23
+ { aspect: '技能栈匹配', finding: 'Python/Flask 完全覆盖 JD 要求', concern: '无' },
24
+ { aspect: '项目深度', finding: '仅课程项目,无企业级实践', concern: '项目描述偏功能实现,未见性能优化或架构设计' },
25
+ { aspect: '学历背景', finding: '985 计算机专业,符合门槛', concern: '无' },
26
+ ],
27
+ hr_concern_level: 'medium',
28
+ screen_summary: '简历整体合格,项目深度是最大短板,建议补充量化成果',
29
+ },
30
+ }
31
+
32
+ const mockSuggestions = {
33
+ rewrite_suggestions: [
34
+ { dimension: '项目契合', issue: '项目描述侧重原理,未体现工程落地能力', original: '使用协同过滤算法实现推荐系统', suggestion: '独立设计并实现基于协同过滤的推荐系统,使用Python+Flask搭建Web服务,处理了10000+用户行为数据,推荐准确率达到85%', reason: 'JD偏向工程落地,HR更关注实际产出而非原理' },
35
+ { dimension: '技能匹配', issue: 'JD要求Redis但简历未提及', original: '无', suggestion: '在技能列表或项目描述中补充Redis使用经验,如"使用Redis缓存热点数据,查询响应时间降低60%"', reason: 'Redis是JD明确要求的技能,不提及会被直接筛掉' },
36
+ ],
37
+ interview_tips: [
38
+ { topic: 'Redis缓存', reason: 'JD要求熟悉Redis但简历未提及', tip: '准备Redis基础数据结构、缓存穿透/击穿/雪崩、在推荐系统中如何使用缓存' },
39
+ { topic: '项目深挖', reason: '项目描述较浅', tip: '准备:项目的技术选型原因、遇到的难点和解决方案、如果重做会怎么改进' },
40
+ ],
41
+ encouragement: '你的专业背景和技能基础与岗位匹配度不错,只需在项目描述上做针对性调整,命中率会明显提升',
42
+ }
43
+
44
+ const mockResumeData = {
45
+ name: '张三',
46
+ school: '华南理工大学',
47
+ major: '计算机科学与技术',
48
+ grade: '研二',
49
+ skills: ['Python', 'Java', 'SQL', 'PyTorch', 'Flask'],
50
+ projects: [
51
+ { name: '基于协同过滤的推荐系统', desc: '使用协同过滤算法实现电影推荐,处理了MovieLens数据集' },
52
+ { name: '在线商城后端开发', desc: '使用Spring Boot实现RESTful API,包括用户管理、商品管理模块' },
53
+ ],
54
+ experience: '在字节跳动有过6个月后端开发实习经历,参与推荐系统数据管道维护',
55
+ education: { school: '华南理工大学', major: '计算机科学与技术', degree: '硕士', startYear: '2023', endYear: '2025' },
56
+ summary: '技术栈集中在Python/Java后端开发,有推荐系统和Web开发项目经验,适合投递后端开发/算法类岗位',
57
+ }
58
+
59
+ export function getMockResumeData() {
60
+ return { data: mockResumeData }
61
+ }
62
+
63
+ export function getMockJobs() {
64
+ return { data: { jobs: mockJobs } }
65
+ }
66
+
67
+ export function getMockReport() {
68
+ return mockReport
69
+ }
70
+
71
+ export function getMockSuggestions() {
72
+ return mockSuggestions
73
+ }
src/components/JobCard.jsx ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useState, useEffect } from 'react'
2
+
3
+ const RADIUS = 40
4
+ const CIRCUMFERENCE = 2 * Math.PI * RADIUS
5
+
6
+ function MatchRing({ rate }) {
7
+ const [small, setSmall] = useState(window.innerWidth <= 767)
8
+
9
+ useEffect(() => {
10
+ const mq = window.matchMedia('(max-width: 767px)')
11
+ const handler = (e) => setSmall(e.matches)
12
+ mq.addEventListener('change', handler)
13
+ return () => mq.removeEventListener('change', handler)
14
+ }, [])
15
+
16
+ const size = small ? 64 : 96
17
+ const colorVar = rate >= 80 ? 'var(--color-success)' : rate >= 60 ? 'var(--color-warning)' : 'var(--color-error)'
18
+ const offset = CIRCUMFERENCE * (1 - rate / 100)
19
+
20
+ return (
21
+ <svg width={size} height={size} viewBox="0 0 96 96">
22
+ <circle cx="48" cy="48" r={RADIUS} fill="none" stroke="var(--color-border)" strokeWidth="8" />
23
+ <circle
24
+ cx="48" cy="48" r={RADIUS}
25
+ fill="none"
26
+ stroke={colorVar}
27
+ strokeWidth="8"
28
+ strokeDasharray={CIRCUMFERENCE}
29
+ strokeDashoffset={offset}
30
+ strokeLinecap="round"
31
+ transform="rotate(-90 48 48)"
32
+ style={{ transition: 'stroke-dashoffset 0.6s ease' }}
33
+ />
34
+ <text
35
+ x="48" y="48"
36
+ textAnchor="middle"
37
+ dominantBaseline="central"
38
+ fontSize="20"
39
+ fontWeight="700"
40
+ fill={colorVar}
41
+ >
42
+ {rate}%
43
+ </text>
44
+ </svg>
45
+ )
46
+ }
47
+
48
+ function MatchBreakdown({ detail, rate }) {
49
+ if (!detail) return null
50
+ const bars = [
51
+ { key: 'semantic', label: '语义匹配', weight: 40, color: 'var(--color-primary-light)' },
52
+ { key: 'tags', label: '技能匹配', weight: 35, color: 'var(--color-success)' },
53
+ { key: 'education', label: '学历匹配', weight: 25, color: 'var(--color-warning)' },
54
+ ]
55
+ const rateClass = rate >= 80 ? 'text-success' : rate >= 60 ? 'text-warning' : 'text-error'
56
+ return (
57
+ <div className="mt-16 px-16 py-12 info-box">
58
+ <div className="flex-between mb-8">
59
+ <h4 className="font-bold text-sm">匹配度计算</h4>
60
+ <span className="text-xs text-light">总分 = 语义×40% + 技能×35% + 学历×25%</span>
61
+ </div>
62
+ {bars.map(b => {
63
+ const val = detail[b.key] || 0
64
+ const pct = Math.round(val * 100)
65
+ return (
66
+ <div key={b.key} className="flex items-center gap-8 mb-8">
67
+ <span className="bar-label">{b.label}</span>
68
+ <div className="flex-1 progress-bar-md progress-bar-bg-md">
69
+ <div className="progress-bar-fill" style={{ width: pct + '%', backgroundColor: b.color }} />
70
+ </div>
71
+ <span className="bar-value" style={{ color: b.color }}>{pct}%</span>
72
+ <span className="bar-weight">×{b.weight}%</span>
73
+ </div>
74
+ )
75
+ })}
76
+ <div className="flex-between bar-divider">
77
+ <span className="text-sm font-bold">最终匹配度</span>
78
+ <span className={`text-sm font-bold ${rateClass}`}>{rate}%</span>
79
+ </div>
80
+ </div>
81
+ )
82
+ }
83
+
84
+ function ExpectationSignals({ signals }) {
85
+ if (!signals || signals.length === 0) return null
86
+ return (
87
+ <div className="mt-12">
88
+ <h4 className="font-bold text-sm mb-8">岗位画像</h4>
89
+ <div className="flex flex-wrap gap-8">
90
+ {signals.map((signal, i) => (
91
+ <div key={i} className="signal-tag">
92
+ <span className="signal-tag-name">{signal.name || signal.tag}</span>
93
+ {signal.evidence && (
94
+ <span className="signal-tag-evidence">{signal.evidence}</span>
95
+ )}
96
+ {signal.confidence !== undefined && (
97
+ <div className="flex items-center gap-4">
98
+ <span className="text-xs text-light">置信度</span>
99
+ <div className="flex-1 progress-bar-sm progress-bar-bg-sm">
100
+ <div className="progress-bar-fill" style={{ width: `${Math.round(signal.confidence * 100)}%`, backgroundColor: 'var(--color-primary-light)' }} />
101
+ </div>
102
+ <span className="text-xs font-bold text-primary">
103
+ {Math.round(signal.confidence * 100)}%
104
+ </span>
105
+ </div>
106
+ )}
107
+ </div>
108
+ ))}
109
+ </div>
110
+ </div>
111
+ )
112
+ }
113
+
114
+ function JobCard({ job, onClick, lowMatchWarning, showMatch = true, onUploadClick }) {
115
+ const { job_id, name: title, company, city, match_rate, match_detail, tags = [], description, requirements, expectation_signals } = job
116
+ const [expanded, setExpanded] = useState(false)
117
+
118
+ const visibleTags = tags.slice(0, 3)
119
+ const extraCount = tags.length - 3
120
+ const descSummary = description && description.length > 80
121
+ ? description.slice(0, 80) + '...'
122
+ : description
123
+
124
+ return (
125
+ <div className="card">
126
+ <div className="cursor-pointer" onClick={() => setExpanded(!expanded)}>
127
+ <div className="flex gap-16 items-center flex-col-mobile gap-mobile-8">
128
+ {showMatch && (
129
+ <div className="flex-shrink-0">
130
+ <MatchRing rate={match_rate} />
131
+ </div>
132
+ )}
133
+ <div className="flex-1 min-width-0">
134
+ <h3 className="font-bold text-lg">{title}</h3>
135
+ <p className="text-secondary mt-8">{company}</p>
136
+ <div className="flex flex-wrap gap-8 mt-12">
137
+ <span className="text-sm text-secondary">{city}</span>
138
+ {visibleTags.map((tag, i) => (
139
+ <span key={i} className="tag">{tag}</span>
140
+ ))}
141
+ {extraCount > 0 && (
142
+ <span className="text-sm text-light">+{extraCount}</span>
143
+ )}
144
+ </div>
145
+ </div>
146
+ </div>
147
+ {showMatch && lowMatchWarning && (
148
+ <div className="text-sm text-warning mt-12">
149
+ {match_rate < 60 ? '匹配度较低,别灰心,看看建议提升一下吧' : '匹配度较低'}
150
+ </div>
151
+ )}
152
+ {descSummary && (
153
+ <p className="text-sm text-secondary mt-12 leading-normal">{descSummary}</p>
154
+ )}
155
+ </div>
156
+
157
+ {expanded && (
158
+ <div className="p-16 mt-12 info-box">
159
+ {description && (
160
+ <div className="mb-12">
161
+ <h4 className="font-bold text-sm mb-4">职位描述</h4>
162
+ <p className="text-sm text-secondary">{description}</p>
163
+ </div>
164
+ )}
165
+ {requirements && (
166
+ <div className="mb-12">
167
+ <h4 className="font-bold text-sm mb-4">职位要求</h4>
168
+ <p className="text-sm text-secondary">{requirements}</p>
169
+ </div>
170
+ )}
171
+ {showMatch && match_detail && <MatchBreakdown detail={match_detail} rate={match_rate} />}
172
+ <ExpectationSignals signals={expectation_signals} />
173
+ <div className="mt-12 flex-center gap-8">
174
+ {showMatch ? (
175
+ <button className="btn btn-primary btn-sm" onClick={(e) => { e.stopPropagation(); onClick && onClick(job_id, { job_id, name: title, company, city, match_rate, tags, description, requirements, expectation_signals }) }}>
176
+ 查看匹配诊断
177
+ </button>
178
+ ) : (
179
+ <button className="btn btn-primary btn-sm" onClick={(e) => { e.stopPropagation(); onUploadClick && onUploadClick() }}>
180
+ 上传简历后使用匹配
181
+ </button>
182
+ )}
183
+ </div>
184
+ </div>
185
+ )}
186
+ </div>
187
+ )
188
+ }
189
+
190
+ export default JobCard
src/components/PipelineFlow.jsx ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function PipelineFlow({ steps = [] }) {
2
+ return (
3
+ <div className="flex-center" style={{ padding: '24px 0' }}>
4
+ {steps.map((step, index) => {
5
+ const isLast = index === steps.length - 1
6
+ return (
7
+ <div key={step.id} className="flex-center">
8
+ <div className="flex flex-col flex-center gap-8">
9
+ <div
10
+ className={`pipeline-node pipeline-node-${step.status}`}
11
+ >
12
+ {step.status === 'completed' && '✓'}
13
+ {step.status === 'error' && '❗'}
14
+ {(step.status === 'idle' || step.status === 'running') && (
15
+ <span className={step.status === 'running' ? 'pipeline-step-running' : ''}>
16
+ {step.icon || '○'}
17
+ </span>
18
+ )}
19
+ </div>
20
+ <span className={`text-sm pipeline-label-${step.status}`}>
21
+ {step.label}
22
+ </span>
23
+ {step.status === 'error' && (
24
+ <span className="text-sm text-error">暂不可用</span>
25
+ )}
26
+ </div>
27
+ {!isLast && (
28
+ <div
29
+ className={`pipeline-connector pipeline-connector-${step.status === 'completed' ? 'completed' : 'idle'}`}
30
+ />
31
+ )}
32
+ </div>
33
+ )
34
+ })}
35
+ </div>
36
+ )
37
+ }
38
+
39
+ export default PipelineFlow
src/components/RadarChart.jsx ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import ReactECharts from 'echarts-for-react'
2
+
3
+ function RadarChart({ dimensions = [], scores = [], loading = false }) {
4
+ if (loading) {
5
+ return (
6
+ <div className="loading-state" style={{ height: 320 }}>
7
+ <div className="loading-spinner loading-spinner-lg" />
8
+ <p className="text-secondary mt-16">加载中...</p>
9
+ </div>
10
+ )
11
+ }
12
+
13
+ const isEmpty = !dimensions.length || !scores.length || scores.every((s) => s === 0)
14
+
15
+ if (isEmpty) {
16
+ return (
17
+ <div className="flex-center" style={{ height: 320 }}>
18
+ <p className="text-secondary">图表数据暂不可用</p>
19
+ </div>
20
+ )
21
+ }
22
+
23
+ const option = {
24
+ radar: {
25
+ indicator: dimensions.map((name) => ({ name, max: 100 })),
26
+ center: ['50%', '50%'],
27
+ radius: '65%',
28
+ },
29
+ series: [
30
+ {
31
+ type: 'radar',
32
+ data: [{ value: scores, name: '匹配得分' }],
33
+ areaStyle: { color: 'rgba(79, 70, 229, 0.2)' },
34
+ lineStyle: { color: '#4F46E5' },
35
+ itemStyle: { color: '#4F46E5' },
36
+ },
37
+ ],
38
+ animationDuration: 1000,
39
+ animationEasing: 'cubicOut',
40
+ }
41
+
42
+ return (
43
+ <div style={{ height: 320 }}>
44
+ <ReactECharts option={option} style={{ height: '100%' }} />
45
+ </div>
46
+ )
47
+ }
48
+
49
+ export default RadarChart
src/components/ReportCard.jsx ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function ReportCard({ dimension, score, evidence = [], viewType, footnote, dataUnavailable, hrView }) {
2
+ if (viewType === 'hr' && hrView && hrView.first_impression) {
3
+ const concernLevel = hrView.hr_concern_level
4
+ const levelColor = concernLevel === 'low' ? 'var(--color-success)' : concernLevel === 'medium' ? 'var(--color-warning)' : 'var(--color-error)'
5
+ const levelLabel = concernLevel === 'low' ? '低' : concernLevel === 'medium' ? '中' : '高'
6
+ return (
7
+ <div className="card">
8
+ <h4 className="font-bold mb-12">{dimension}</h4>
9
+ <div className="hr-quote-box mb-16">
10
+ <p className="text-sm italic">"{hrView.first_impression}"</p>
11
+ </div>
12
+ <div className="flex flex-col gap-12 mb-16">
13
+ {hrView.attention_points && hrView.attention_points.map((point, i) => (
14
+ <div key={i} className="attention-point-box">
15
+ <p className="font-bold text-sm">{point.aspect}</p>
16
+ <p className="text-sm text-secondary mt-4" style={{ wordBreak: 'break-word' }}>{point.finding}</p>
17
+ {point.concern && point.concern !== '无' && (
18
+ <p className="text-sm text-error mt-4" style={{ wordBreak: 'break-word' }}>关注点: {point.concern}</p>
19
+ )}
20
+ </div>
21
+ ))}
22
+ </div>
23
+ <div className="flex items-center gap-8 mb-16">
24
+ <span className="text-sm text-secondary">HR 关注度:</span>
25
+ <span className="hr-concern-tag" style={{ color: levelColor, backgroundColor: `color-mix(in srgb, ${levelColor} 15%, transparent)`, border: `1px solid color-mix(in srgb, ${levelColor} 25%, transparent)` }}>{levelLabel}</span>
26
+ </div>
27
+ {hrView.screen_summary && (
28
+ <p className="hr-summary-box">
29
+ <span className="font-bold">筛选总结: </span>{hrView.screen_summary}
30
+ </p>
31
+ )}
32
+ </div>
33
+ )
34
+ }
35
+
36
+ if (dataUnavailable) {
37
+ return (
38
+ <div className="card opacity-5">
39
+ <h4 className="font-bold">{dimension}</h4>
40
+ <p className="text-secondary mt-8">数据暂不可用</p>
41
+ </div>
42
+ )
43
+ }
44
+
45
+ if (viewType === 'hr') {
46
+ const conclusion = score >= 70 ? 'OK ✓' : score >= 40 ? '⚠️' : '✗'
47
+ const finding = evidence.length > 0 ? evidence[0].text : '暂无关键发现'
48
+ return (
49
+ <div className="card">
50
+ <div className="flex-between flex-wrap-mobile">
51
+ <h4 className="font-bold">{dimension}</h4>
52
+ <span className="text-lg font-bold">{conclusion}</span>
53
+ </div>
54
+ <p className="text-secondary mt-8">{finding}</p>
55
+ {footnote && (
56
+ <p className="text-sm text-light mt-8 py-8 px-12 bg-primary-soft">
57
+ {footnote}
58
+ </p>
59
+ )}
60
+ </div>
61
+ )
62
+ }
63
+
64
+ const evidenceObj = Array.isArray(evidence) ? (evidence.length > 0 ? evidence[0] : null) : evidence
65
+ const hasJdQuote = evidenceObj && (evidenceObj.jd_quote || evidenceObj.resume_quote)
66
+
67
+ if (hasJdQuote) {
68
+ return (
69
+ <div className="card">
70
+ <div className="flex-between flex-wrap-mobile">
71
+ <h4 className="font-bold">{dimension}</h4>
72
+ <span className="text-lg font-bold">{score}%</span>
73
+ </div>
74
+ <div className="progress-bar-md progress-bar-bg-md mt-12">
75
+ <div className="progress-bar-fill" style={{ width: `${score}%`, backgroundColor: 'var(--color-primary)' }} />
76
+ </div>
77
+ <div className="grid-2 gap-12 mt-16">
78
+ <div className="jd-quote-box">
79
+ <p className="font-bold text-sm mb-4">📋 JD要求</p>
80
+ <p className="text-sm text-secondary" style={{ wordBreak: 'break-word' }}>{evidenceObj.jd_quote}</p>
81
+ </div>
82
+ <div className="resume-quote-box">
83
+ <p className="font-bold text-sm mb-4">📝 简历匹配</p>
84
+ <p className="text-sm text-secondary" style={{ wordBreak: 'break-word' }}>{evidenceObj.resume_quote}</p>
85
+ </div>
86
+ </div>
87
+ </div>
88
+ )
89
+ }
90
+
91
+ return (
92
+ <div className="card">
93
+ <div className="flex-between flex-wrap-mobile">
94
+ <h4 className="font-bold">{dimension}</h4>
95
+ <span className="text-lg font-bold">{score}%</span>
96
+ </div>
97
+ <div className="progress-bar-md progress-bar-bg-md mt-12">
98
+ <div className="progress-bar-fill" style={{ width: `${score}%`, backgroundColor: 'var(--color-primary)' }} />
99
+ </div>
100
+ {(Array.isArray(evidence) && evidence.length > 0) && (
101
+ <ul className="mt-16 evidence-list">
102
+ {evidence.map((item, i) => (
103
+ <li key={i} className="evidence-item">
104
+ <span className="text-primary" style={{ wordBreak: 'break-word' }}>{item.text}</span>
105
+ {item.source && (
106
+ <span className="evidence-source">— {item.source}</span>
107
+ )}
108
+ </li>
109
+ ))}
110
+ </ul>
111
+ )}
112
+ </div>
113
+ )
114
+ }
115
+
116
+ export default ReportCard
src/main.jsx ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from 'react'
2
+ import ReactDOM from 'react-dom/client'
3
+ import App from './App'
4
+ import './App.css'
5
+
6
+ ReactDOM.createRoot(document.getElementById('app')).render(
7
+ <React.StrictMode>
8
+ <App />
9
+ </React.StrictMode>
10
+ )
src/pages/DiagnosePage.jsx ADDED
@@ -0,0 +1,277 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useState, useRef, useCallback, useEffect } from 'react'
2
+ import { generateReport } from '../api'
3
+ import PipelineFlow from '../components/PipelineFlow'
4
+ import RadarChart from '../components/RadarChart'
5
+ import ReportCard from '../components/ReportCard'
6
+
7
+ const INITIAL_STEPS = [
8
+ { id: 'agent1', label: '简历解析', status: 'idle' },
9
+ { id: 'agent2', label: '匹配诊断', status: 'idle' },
10
+ { id: 'agent3', label: '报告生成', status: 'idle' },
11
+ ]
12
+
13
+ function DiagnosePage({ jobId, jobData, resumeData, onComplete, onBack, onGoHome }) {
14
+ const [pageStatus, setPageStatus] = useState('idle')
15
+ const [steps, setSteps] = useState(INITIAL_STEPS)
16
+ const [viewType, setViewType] = useState('student')
17
+ const [jdParsed, setJdParsed] = useState(null)
18
+ const [matchReport, setMatchReport] = useState(null)
19
+ const [advice, setAdvice] = useState(null)
20
+ const [errorMsg, setErrorMsg] = useState('')
21
+ const abortRef = useRef(null)
22
+ const retryCountRef = useRef(0)
23
+ const retryTimeoutRef = useRef(null)
24
+
25
+ const jobInfo = jobData || {
26
+ name: '岗位名称',
27
+ company: '公司名称',
28
+ city: '',
29
+ salary: '',
30
+ tags: [],
31
+ description: '',
32
+ requirements: '',
33
+ expectation_signals: []
34
+ }
35
+
36
+ const updateStep = useCallback((agentId, newStatus) => {
37
+ setSteps((prev) => prev.map((s) => (s.id === agentId ? { ...s, status: newStatus } : s)))
38
+ }, [])
39
+
40
+ const handleAnalyze = useCallback(async () => {
41
+ setPageStatus('loading')
42
+ setSteps(INITIAL_STEPS.map((s) => ({ ...s, status: 'idle' })))
43
+ setJdParsed(null)
44
+ setMatchReport(null)
45
+ setAdvice(null)
46
+ retryCountRef.current = 0
47
+
48
+ const controller = new AbortController()
49
+ abortRef.current = controller
50
+
51
+ const doFetch = async () => {
52
+ try {
53
+ const response = await generateReport(jobId, resumeData)
54
+ if (!response.ok) throw new Error('请求失败')
55
+ const reader = response.body.getReader()
56
+ const decoder = new TextDecoder()
57
+ let buffer = ''
58
+
59
+ while (true) {
60
+ const { done, value } = await reader.read()
61
+ if (done) break
62
+
63
+ buffer += decoder.decode(value, { stream: true })
64
+ const lines = buffer.split('\n')
65
+ buffer = lines.pop() || ''
66
+
67
+ for (const line of lines) {
68
+ const trimmed = line.trim()
69
+ if (!trimmed) continue
70
+ const jsonStr = trimmed.startsWith('data: ') ? trimmed.slice(6).trim() : trimmed
71
+ if (!jsonStr) continue
72
+ try {
73
+ const event = JSON.parse(jsonStr)
74
+ const { type, agent, data } = event
75
+
76
+ if (type === 'agent_start') {
77
+ updateStep(agent, 'running')
78
+ } else if (type === 'agent_complete') {
79
+ updateStep(agent, 'completed')
80
+ if (agent === 'agent1' && data) setJdParsed(data)
81
+ if (agent === 'agent2' && data) setMatchReport(data)
82
+ if (agent === 'agent3' && data) setAdvice(data)
83
+ } else if (type === 'report_complete') {
84
+ if (data) {
85
+ if (data.jd_parsed) setJdParsed(data.jd_parsed)
86
+ if (data.match_report) setMatchReport(data.match_report)
87
+ if (data.advice) setAdvice(data.advice)
88
+ }
89
+ } else if (type === 'error') {
90
+ updateStep(agent || 'agent3', 'error')
91
+ }
92
+ } catch {
93
+ // skip
94
+ }
95
+ }
96
+ }
97
+
98
+ setPageStatus('success')
99
+ } catch (err) {
100
+ if (err.name === 'AbortError') return
101
+ retryCountRef.current += 1
102
+ if (retryCountRef.current <= 3) {
103
+ const delay = retryCountRef.current * 1000
104
+ retryTimeoutRef.current = setTimeout(doFetch, delay)
105
+ } else {
106
+ setPageStatus('error')
107
+ setErrorMsg('连接中断,请刷新页面')
108
+ }
109
+ }
110
+ }
111
+
112
+ doFetch()
113
+ }, [jobId, updateStep])
114
+
115
+ const abort = useCallback(() => {
116
+ clearTimeout(retryTimeoutRef.current)
117
+ abortRef.current?.abort()
118
+ setPageStatus('idle')
119
+ }, [])
120
+
121
+ useEffect(() => {
122
+ return () => {
123
+ clearTimeout(retryTimeoutRef.current)
124
+ abortRef.current?.abort()
125
+ }
126
+ }, [])
127
+
128
+ const studentDims = matchReport?.dimensions?.map(d => d.name) || []
129
+ const studentScores = matchReport?.dimensions?.map(d => d.score) || []
130
+ const studentEvidence = matchReport?.dimensions?.map(d => d.evidence) || []
131
+
132
+ const hrViewData = matchReport?.hr_view || {}
133
+
134
+ const showResults = pageStatus === 'loading' || pageStatus === 'success' || pageStatus === 'error'
135
+ const analyzeDone = pageStatus === 'success'
136
+
137
+ if (!resumeData) {
138
+ return (
139
+ <div className="empty-state card">
140
+ <h2 className="font-bold text-xl mb-16">匹配诊断</h2>
141
+ <p className="text-secondary mb-24">请先上传或填写简历,才能进行匹配诊断</p>
142
+ <div className="flex-center gap-12">
143
+ <button className="btn btn-primary" onClick={onGoHome}>上传简历</button>
144
+ <button className="btn btn-secondary" onClick={onGoHome}>手工填写</button>
145
+ </div>
146
+ <div className="mt-16">
147
+ <button className="btn btn-secondary" onClick={onBack}>返回推荐</button>
148
+ </div>
149
+ </div>
150
+ )
151
+ }
152
+
153
+ return (
154
+ <div>
155
+ <div className="card mb-24">
156
+ <div className="flex-between mb-8 flex-wrap">
157
+ <div className="min-width-0 flex-1">
158
+ <h2 className="font-bold text-xl">{jobInfo.name}</h2>
159
+ <p className="text-secondary">{jobInfo.company} · {jobInfo.city || ''} {jobInfo.salary ? '· ' + jobInfo.salary : ''}</p>
160
+ </div>
161
+ <div className="flex gap-8 flex-wrap justify-end max-w-50p">
162
+ {(jobInfo.tags || []).map((tag, i) => (
163
+ <span key={i} className="tag">{tag}</span>
164
+ ))}
165
+ </div>
166
+ </div>
167
+
168
+ {jobInfo.description && (
169
+ <div className="mb-12">
170
+ <h4 className="font-bold text-sm mb-4">职位描述</h4>
171
+ <p className="text-sm text-secondary whitespace-pre-wrap">{jobInfo.description}</p>
172
+ </div>
173
+ )}
174
+
175
+ {jobInfo.requirements && (
176
+ <div className="mb-12">
177
+ <h4 className="font-bold text-sm mb-4">职位要求</h4>
178
+ <p className="text-sm text-secondary whitespace-pre-wrap">{jobInfo.requirements}</p>
179
+ </div>
180
+ )}
181
+
182
+ {jobInfo.expectation_signals && jobInfo.expectation_signals.length > 0 && (
183
+ <div className="mb-12">
184
+ <h4 className="font-bold text-sm mb-4">岗位画像</h4>
185
+ <div className="flex flex-col gap-8">
186
+ {jobInfo.expectation_signals.map((signal, i) => {
187
+ const pct = Math.round((signal.confidence || 0) * 100)
188
+ const barColor = (signal.confidence || 0) > 0.7
189
+ ? 'var(--color-success)'
190
+ : (signal.confidence || 0) > 0.4
191
+ ? 'var(--color-warning)'
192
+ : 'var(--color-error)'
193
+ return (
194
+ <div key={i} className="info-box">
195
+ <div className="flex-between mb-4">
196
+ <span className="text-sm font-bold">{signal.tag || signal.name}</span>
197
+ <span className="text-xs text-light">可信度 {pct}%</span>
198
+ </div>
199
+ <p className="text-xs text-secondary mb-4">{signal.evidence || ''}</p>
200
+ <div className="progress-track">
201
+ <div className="progress-bar" style={{ width: `${pct}%`, backgroundColor: barColor }} />
202
+ </div>
203
+ </div>
204
+ )
205
+ })}
206
+ </div>
207
+ </div>
208
+ )}
209
+ </div>
210
+
211
+ {pageStatus === 'idle' && (
212
+ <div className="card mb-24 bg-light">
213
+ <h4 className="font-bold mb-8">分析流程说明</h4>
214
+ <p className="text-sm text-secondary mb-12">分析将由 3 个 AI Agent 依次完成:</p>
215
+ <div className="flex flex-col gap-8">
216
+ <div className="card p-8 px-12">
217
+ <span className="text-sm font-bold">① JD 解析器</span>
218
+ <p className="text-xs text-secondary mt-4">提取岗位核心要求、技术栈、加分项、文化信号</p>
219
+ </div>
220
+ <div className="card p-8 px-12">
221
+ <span className="text-sm font-bold">② 匹配诊断器</span>
222
+ <p className="text-xs text-secondary mt-4">多维度拆解匹配度,输出分数和引用证据</p>
223
+ </div>
224
+ <div className="card p-8 px-12">
225
+ <span className="text-sm font-bold">③ 建议生成器</span>
226
+ <p className="text-xs text-secondary mt-4">生成简历修改建议和面试准备方向</p>
227
+ </div>
228
+ </div>
229
+ <button className="btn btn-primary mt-16" onClick={handleAnalyze}>开始分析</button>
230
+ </div>
231
+ )}
232
+
233
+ {showResults && (
234
+ <>
235
+ <div className="card mb-24"><PipelineFlow steps={steps} /></div>
236
+ {pageStatus !== 'loading' && matchReport && (
237
+ <>
238
+ <div className="flex gap-12 mb-24 flex-wrap">
239
+ <button className={`btn ${viewType === 'student' ? 'btn-primary' : 'btn-secondary'}`} onClick={() => setViewType('student')}>学生视角</button>
240
+ <button className={`btn ${viewType === 'hr' ? 'btn-primary' : 'btn-secondary'}`} onClick={() => setViewType('hr')}>HR 视角</button>
241
+ </div>
242
+ {viewType === 'student' ? (
243
+ <>
244
+ <div className="card mb-24"><RadarChart dimensions={studentDims} scores={studentScores} /></div>
245
+ <div className="flex flex-col gap-16">
246
+ {studentDims.map((dim, i) => (
247
+ <ReportCard key={dim} dimension={dim} score={studentScores[i]} evidence={studentEvidence[i]} viewType={viewType} />
248
+ ))}
249
+ </div>
250
+ </>
251
+ ) : (
252
+ <div className="flex flex-col gap-16">
253
+ <ReportCard dimension="HR 快速筛查模拟" viewType="hr" hrView={hrViewData} />
254
+ </div>
255
+ )}
256
+ </>
257
+ )}
258
+ {pageStatus === 'error' && (
259
+ <div className="error-state">
260
+ <p className="error-state-text">{errorMsg}</p>
261
+ <button className="btn btn-primary" onClick={handleAnalyze}>重新分析</button>
262
+ </div>
263
+ )}
264
+ </>
265
+ )}
266
+
267
+ {analyzeDone && (
268
+ <div className="mt-24 flex-center gap-12 flex-wrap">
269
+ <button className="btn btn-primary" onClick={() => onComplete({ advice })}>查看改进建议</button>
270
+ <button className="btn btn-secondary" onClick={onBack}>返回推荐</button>
271
+ </div>
272
+ )}
273
+ </div>
274
+ )
275
+ }
276
+
277
+ export default DiagnosePage
src/pages/HomePage.jsx ADDED
@@ -0,0 +1,541 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useState, useEffect, useRef, useCallback } from 'react'
2
+ import { uploadResume, getRecommendJobs } from '../api'
3
+ import RadarChart from '../components/RadarChart'
4
+
5
+ const SKILL_LEVELS = ['精通', '熟悉', '了解']
6
+
7
+ function HomePage({ resumeData, onConfirm, onGoRecommend }) {
8
+ const [status, setStatus] = useState(resumeData ? 'dashboard' : 'idle')
9
+ const [errorMsg, setErrorMsg] = useState('')
10
+ const [localParsed, setLocalParsed] = useState(null)
11
+ const [failCount, setFailCount] = useState(0)
12
+ const [manualMode, setManualMode] = useState(false)
13
+ const [autoTriggered, setAutoTriggered] = useState(false)
14
+ const [previewJobs, setPreviewJobs] = useState([])
15
+ const inputRef = useRef(null)
16
+
17
+ const [formData, setFormData] = useState({
18
+ skillInput: '',
19
+ skills: [],
20
+ projects: [{ name: '', description: '', techStack: '' }],
21
+ experience: '',
22
+ education: { school: '', major: '', degree: '', startYear: '', endYear: '' }
23
+ })
24
+
25
+ const [editValues, setEditValues] = useState({ name: '', school: '', major: '', grade: '', skills: '', projects: '', summary: '', experience: '', education: '' })
26
+
27
+ useEffect(() => {
28
+ if (localParsed) {
29
+ const projToString = (p) => typeof p === 'string' ? p : (p.name || p.title || JSON.stringify(p))
30
+ setEditValues({
31
+ name: localParsed.name || '',
32
+ school: localParsed.school || '',
33
+ major: localParsed.major || '',
34
+ grade: localParsed.grade || '',
35
+ skills: (localParsed.skills || []).join(', '),
36
+ projects: (localParsed.projects || []).map(projToString).join(', '),
37
+ summary: localParsed.summary || '',
38
+ experience: localParsed.experience || '',
39
+ education: localParsed.education || '',
40
+ })
41
+ }
42
+ }, [localParsed])
43
+
44
+ useEffect(() => {
45
+ if (manualMode && !localParsed && !resumeData) {
46
+ const s = formData.skillInput || formData.skills.length > 0 || formData.projects.some(p => p.name)
47
+ if (!s) handleReEdit()
48
+ }
49
+ }, [manualMode])
50
+
51
+ useEffect(() => {
52
+ if (localParsed || resumeData) {
53
+ const fetchPreview = async () => {
54
+ try {
55
+ const resumeId = (localParsed || resumeData)?.id || 1
56
+ const res = await getRecommendJobs(resumeId)
57
+ const list = res.data?.jobs || []
58
+ setPreviewJobs(list.slice(0, 3))
59
+ } catch {
60
+ setPreviewJobs([])
61
+ }
62
+ }
63
+ fetchPreview()
64
+ }
65
+ }, [localParsed, resumeData])
66
+
67
+ useEffect(() => {
68
+ if (resumeData) {
69
+ setStatus('dashboard')
70
+ }
71
+ }, [resumeData])
72
+
73
+ const handleFile = useCallback(async (selectedFile) => {
74
+ if (!selectedFile) return
75
+ if (selectedFile.type !== 'application/pdf') {
76
+ setFailCount(c => { const n = c + 1; if (n >= 3) { setManualMode(true); setAutoTriggered(true) }; return n })
77
+ setStatus('error'); setErrorMsg('请上传 PDF 格式简历'); return
78
+ }
79
+ setStatus('uploading')
80
+ try {
81
+ setStatus('loading')
82
+ const res = await uploadResume(selectedFile)
83
+ const parsed = res.data?.data || res.data
84
+ setLocalParsed(parsed)
85
+ setStatus('preview')
86
+ setFailCount(0)
87
+ } catch {
88
+ setFailCount(c => { const n = c + 1; if (n >= 3) { setManualMode(true); setAutoTriggered(true) }; return n })
89
+ setStatus('error'); setErrorMsg('简历解析失败,请重新上传或手工填写')
90
+ }
91
+ }, [])
92
+
93
+ const handleConfirm = (formData) => {
94
+ const data = formData || localParsed
95
+ if (data) {
96
+ const confirmed = {
97
+ ...data,
98
+ name: data.name || localParsed?.name || '',
99
+ school: data.school || localParsed?.school || '',
100
+ major: data.major || localParsed?.major || '',
101
+ grade: data.grade || localParsed?.grade || '',
102
+ skills: typeof data.skills === 'string' ? data.skills.split(',').map(s => s.trim()).filter(Boolean) : (data.skills || localParsed?.skills || []),
103
+ projects: typeof data.projects === 'string' ? data.projects.split(',').map(s => s.trim()).filter(Boolean) : (data.projects || localParsed?.projects || []),
104
+ summary: data.summary || localParsed?.summary || '',
105
+ experience: data.experience || localParsed?.experience || '',
106
+ education: data.education || localParsed?.education || { school: '', major: '', degree: '', startYear: '', endYear: '' },
107
+ }
108
+ onConfirm(confirmed)
109
+ }
110
+ }
111
+
112
+ const handleReEdit = () => {
113
+ const source = localParsed || resumeData
114
+ if (!source) {
115
+ setFormData({
116
+ skillInput: '',
117
+ skills: [],
118
+ projects: [{ name: '', description: '', techStack: '' }],
119
+ experience: '',
120
+ education: { school: '', major: '', degree: '', startYear: '', endYear: '' }
121
+ })
122
+ } else {
123
+ const mapProject = (p) => {
124
+ const pName = typeof p === 'string' ? p : (p.name || '')
125
+ const pDesc = typeof p === 'string' ? p : (p.desc || p.name || '')
126
+ return { name: pName, description: pDesc, techStack: '' }
127
+ }
128
+ setFormData({
129
+ skillInput: (source.skills || []).join(', '),
130
+ skills: (source.skills || []).map(name => ({ name, level: '熟悉' })),
131
+ projects: (source.projects || []).map(mapProject),
132
+ experience: source.experience || '',
133
+ education: {
134
+ school: source.education?.school || '',
135
+ major: source.education?.major || '',
136
+ degree: source.education?.degree || '',
137
+ startYear: source.education?.startYear || '',
138
+ endYear: source.education?.endYear || ''
139
+ }
140
+ })
141
+ }
142
+ setManualMode(true)
143
+ }
144
+
145
+ const parseSkillInput = (text) => {
146
+ const names = text.split(',').map(s => s.trim()).filter(Boolean)
147
+ return names.map(name => {
148
+ const existing = formData.skills.find(s => s.name === name)
149
+ return { name, level: existing ? existing.level : '熟悉' }
150
+ })
151
+ }
152
+
153
+ const handleSkillInputChange = (text) => {
154
+ setFormData(p => ({ ...p, skillInput: text, skills: parseSkillInput(text) }))
155
+ }
156
+
157
+ const handleSkillLevelChange = (skillName, level) => {
158
+ setFormData(p => ({
159
+ ...p,
160
+ skills: p.skills.map(s => s.name === skillName ? { ...s, level } : s)
161
+ }))
162
+ }
163
+
164
+ const handleProjectAdd = () => {
165
+ setFormData(p => ({ ...p, projects: [...p.projects, { name: '', description: '', techStack: '' }] }))
166
+ }
167
+
168
+ const handleProjectRemove = (index) => {
169
+ setFormData(p => ({ ...p, projects: p.projects.filter((_, i) => i !== index) }))
170
+ }
171
+
172
+ const handleProjectChange = (index, field, value) => {
173
+ setFormData(p => {
174
+ const projects = [...p.projects]
175
+ projects[index] = { ...projects[index], [field]: value }
176
+ return { ...p, projects }
177
+ })
178
+ }
179
+
180
+ const handleEducationChange = (field, value) => {
181
+ setFormData(p => ({ ...p, education: { ...p.education, [field]: value } }))
182
+ }
183
+
184
+ const handleManualSubmit = useCallback(() => {
185
+ const hasAny = formData.skillInput.trim() || formData.projects.some(p => p.name.trim()) || formData.experience.trim() || formData.education.school.trim()
186
+ if (!hasAny) { setErrorMsg('请至少填写一个字段'); return }
187
+ const data = {
188
+ name: '',
189
+ school: formData.education.school || '',
190
+ major: formData.education.major || '',
191
+ grade: formData.education.degree || '',
192
+ skills: formData.skills.map(s => s.name),
193
+ projects: formData.projects.filter(p => p.name.trim()).map(p => p.name),
194
+ projectDetails: formData.projects.filter(p => p.name.trim()),
195
+ summary: '',
196
+ experience: formData.experience,
197
+ education: formData.education.school
198
+ ? `${formData.education.school} ${formData.education.major} ${formData.education.degree} ${formData.education.startYear}-${formData.education.endYear}`
199
+ : ''
200
+ }
201
+ setLocalParsed(data)
202
+ setStatus('preview')
203
+ setManualMode(false)
204
+ setAutoTriggered(false)
205
+ }, [formData])
206
+
207
+ if (manualMode) {
208
+ return (
209
+ <div className="page-container">
210
+ <div className="card mx-auto max-w-640">
211
+ <h2 className="font-bold text-xl mb-24">手工填写简历</h2>
212
+ {autoTriggered && (
213
+ <div className="msg-warning text-sm mb-16">
214
+ 已连续3次上传失败,已自动切换为手工填写模式
215
+ </div>
216
+ )}
217
+ {errorMsg && status === 'error' && (
218
+ <div className="msg-error text-sm mb-16">
219
+ {errorMsg}
220
+ </div>
221
+ )}
222
+ <div className="flex flex-col gap-16">
223
+ <div>
224
+ <label className="text-sm font-bold">技能(逗号分隔)</label>
225
+ <input
226
+ value={formData.skillInput}
227
+ onChange={e => handleSkillInputChange(e.target.value)}
228
+ className="input"
229
+ placeholder="如: React, Python, SQL"
230
+ />
231
+ {formData.skills.length > 0 && (
232
+ <div className="flex flex-col gap-8 mt-8">
233
+ {formData.skills.map((skill, i) => (
234
+ <div key={i} className="flex items-center gap-8">
235
+ <span className="mw-80 text-sm flex-shrink-0">{skill.name}</span>
236
+ <select
237
+ value={skill.level}
238
+ onChange={e => handleSkillLevelChange(skill.name, e.target.value)}
239
+ className="input w-120"
240
+ >
241
+ {SKILL_LEVELS.map(level => (
242
+ <option key={level} value={level}>{level}</option>
243
+ ))}
244
+ </select>
245
+ </div>
246
+ ))}
247
+ </div>
248
+ )}
249
+ </div>
250
+
251
+ <div>
252
+ <div className="flex-between mb-8 flex-wrap gap-8">
253
+ <label className="text-sm font-bold">项目经历</label>
254
+ <button className="btn btn-sm btn-secondary" onClick={handleProjectAdd}>+ 添加项目</button>
255
+ </div>
256
+ {formData.projects.map((project, i) => (
257
+ <div key={i} className="card mb-8 p-12">
258
+ <div className="flex-between mb-8 flex-wrap gap-8">
259
+ <span className="text-sm font-bold">项目 #{i + 1}</span>
260
+ {formData.projects.length > 1 && (
261
+ <button className="btn btn-sm btn-secondary text-error" onClick={() => handleProjectRemove(i)}>删除</button>
262
+ )}
263
+ </div>
264
+ <input
265
+ className="input mb-8"
266
+ placeholder="项目名称"
267
+ value={project.name}
268
+ onChange={e => handleProjectChange(i, 'name', e.target.value)}
269
+ />
270
+ <textarea
271
+ className="input mb-8"
272
+ rows={2}
273
+ placeholder="项目描述"
274
+ value={project.description}
275
+ onChange={e => handleProjectChange(i, 'description', e.target.value)}
276
+ />
277
+ <input
278
+ className="input"
279
+ placeholder="技术栈(逗号分隔)"
280
+ value={project.techStack}
281
+ onChange={e => handleProjectChange(i, 'techStack', e.target.value)}
282
+ />
283
+ </div>
284
+ ))}
285
+ </div>
286
+
287
+ <div>
288
+ <label className="text-sm font-bold">实习经历</label>
289
+ <textarea
290
+ className="input"
291
+ rows={3}
292
+ value={formData.experience}
293
+ onChange={e => setFormData(p => ({ ...p, experience: e.target.value }))}
294
+ placeholder="简要描述实习经历"
295
+ />
296
+ </div>
297
+
298
+ <div>
299
+ <label className="text-sm font-bold">教育背景</label>
300
+ <div className="grid-auto-fit mt-8">
301
+ <input className="input" placeholder="学校" value={formData.education.school} onChange={e => handleEducationChange('school', e.target.value)} />
302
+ <input className="input" placeholder="专业" value={formData.education.major} onChange={e => handleEducationChange('major', e.target.value)} />
303
+ <input className="input" placeholder="学位(本科/硕士/博士)" value={formData.education.degree} onChange={e => handleEducationChange('degree', e.target.value)} />
304
+ <div className="flex gap-8">
305
+ <input className="input" placeholder="开始年份" value={formData.education.startYear} onChange={e => handleEducationChange('startYear', e.target.value)} />
306
+ <input className="input" placeholder="结束年份" value={formData.education.endYear} onChange={e => handleEducationChange('endYear', e.target.value)} />
307
+ </div>
308
+ </div>
309
+ </div>
310
+
311
+ <button className="btn btn-primary" onClick={handleManualSubmit}>提交预览</button>
312
+ <button className="btn btn-secondary" onClick={() => { setManualMode(false); setStatus('idle'); setAutoTriggered(false) }}>返回</button>
313
+ </div>
314
+ </div>
315
+ </div>
316
+ )
317
+ }
318
+
319
+ if (status === 'uploading' || status === 'loading') {
320
+ return (
321
+ <div className="loading-state h-320">
322
+ <div className="loading-spinner loading-spinner-lg" />
323
+ <p className="mt-16 text-secondary">{status === 'uploading' ? '上传中...' : '解析中...'}</p>
324
+ </div>
325
+ )
326
+ }
327
+
328
+ if (status === 'error') {
329
+ return (
330
+ <div className="error-state">
331
+ <p className="error-state-text">{errorMsg}</p>
332
+ <div className="flex gap-12 flex-wrap">
333
+ <button className="btn btn-primary" onClick={() => setStatus('idle')}>重新上传</button>
334
+ <button className="btn btn-secondary" onClick={() => { setManualMode(true); setAutoTriggered(true) }}>手工填写</button>
335
+ </div>
336
+ </div>
337
+ )
338
+ }
339
+
340
+ if (status === 'preview' && localParsed) {
341
+ return (
342
+ <div className="page-container">
343
+ <div className="card mx-auto max-w-640">
344
+ <h2 className="font-bold text-xl mb-16">简历解析结果</h2>
345
+ <p className="text-sm text-secondary mb-16">请核对并修改解析结果,确认后进入推荐</p>
346
+ <div className="flex flex-col gap-12">
347
+ <div>
348
+ <label className="text-sm font-bold">姓名</label>
349
+ <input className="input mt-4" value={editValues.name} onChange={e => setEditValues(f => ({ ...f, name: e.target.value }))} />
350
+ </div>
351
+ <div>
352
+ <label className="text-sm font-bold">学校</label>
353
+ <input className="input mt-4" value={editValues.school} onChange={e => setEditValues(f => ({ ...f, school: e.target.value }))} />
354
+ </div>
355
+ <div>
356
+ <label className="text-sm font-bold">专业</label>
357
+ <input className="input mt-4" value={editValues.major} onChange={e => setEditValues(f => ({ ...f, major: e.target.value }))} />
358
+ </div>
359
+ <div>
360
+ <label className="text-sm font-bold">年级</label>
361
+ <input className="input mt-4" value={editValues.grade} onChange={e => setEditValues(f => ({ ...f, grade: e.target.value }))} />
362
+ </div>
363
+ <div>
364
+ <label className="text-sm font-bold">技能(逗号分隔)</label>
365
+ <input className="input mt-4" value={editValues.skills} onChange={e => setEditValues(f => ({ ...f, skills: e.target.value }))} placeholder="如: Python, Java, SQL" />
366
+ </div>
367
+ <div>
368
+ <label className="text-sm font-bold">项目经历(逗号分隔)</label>
369
+ <input className="input mt-4" value={editValues.projects} onChange={e => setEditValues(f => ({ ...f, projects: e.target.value }))} placeholder="如: 推荐系统, 电商后端" />
370
+ </div>
371
+ <div>
372
+ <label className="text-sm font-bold">实习经历</label>
373
+ <textarea className="input mt-4" rows={3} value={editValues.experience} onChange={e => setEditValues(f => ({ ...f, experience: e.target.value }))} placeholder="描述实习经历" />
374
+ </div>
375
+ <div>
376
+ <label className="text-sm font-bold">自我评价</label>
377
+ <textarea className="input mt-4" rows={3} value={editValues.summary} onChange={e => setEditValues(f => ({ ...f, summary: e.target.value }))} />
378
+ </div>
379
+ </div>
380
+ <div className="flex gap-12 mt-24 flex-wrap">
381
+ <button className="btn btn-primary flex-1" onClick={() => handleConfirm(editValues)}>确认并继续</button>
382
+ <button className="btn btn-secondary flex-1" onClick={handleReEdit}>重新编辑</button>
383
+ </div>
384
+ </div>
385
+ </div>
386
+ )
387
+ }
388
+
389
+ if (status === 'dashboard' && resumeData) {
390
+ const skillNames = (resumeData.skills || []).map(s => typeof s === 'string' ? s : s.name).join(', ')
391
+
392
+ const filledFields = [
393
+ resumeData.name,
394
+ resumeData.school,
395
+ resumeData.major,
396
+ resumeData.grade,
397
+ resumeData.education && (resumeData.education.school || resumeData.education.major || resumeData.education.degree),
398
+ resumeData.skills && resumeData.skills.length > 0,
399
+ resumeData.projects && resumeData.projects.length > 0,
400
+ resumeData.summary,
401
+ resumeData.experience
402
+ ].filter(Boolean).length
403
+ const completionRate = Math.round((filledFields / 9) * 100)
404
+ const weakCount = (resumeData.scores || []).filter(s => s < 70).length
405
+
406
+ const metrics = [
407
+ { label: '画像完成度', value: `${completionRate}%`, cls: 'text-success' },
408
+ { label: '已匹配岗位', value: `${previewJobs.length}`, cls: 'text-primary' },
409
+ { label: '待改进维度', value: `${weakCount}`, cls: 'text-warning' },
410
+ ]
411
+ return (
412
+ <div className="page-container">
413
+ <div className="flex-between mb-24 items-start flex-wrap gap-12">
414
+ <div>
415
+ <h2 className="font-bold text-xl">个人中心</h2>
416
+ <p className="text-sm text-secondary mt-4">
417
+ {resumeData.name || '求职者'} | {resumeData.school || '未设置'}
418
+ </p>
419
+ </div>
420
+ <div className="flex gap-8 flex-wrap">
421
+ <button className="btn btn-sm btn-secondary" onClick={() => inputRef.current?.click()}>上传简历</button>
422
+ <input ref={inputRef} type="file" accept=".pdf" className="hidden" onChange={e => { const f = e.target.files[0]; if (f) handleFile(f); e.target.value = '' }} />
423
+ <button className="btn btn-sm btn-secondary" onClick={() => {
424
+ setFormData({
425
+ skillInput: skillNames,
426
+ skills: (resumeData.skills || []).map(s => ({ name: typeof s === 'string' ? s : s.name, level: '熟悉' })),
427
+ projects: [{ name: '', description: '', techStack: '' }],
428
+ experience: resumeData.experience || '',
429
+ education: { school: '', major: '', degree: '', startYear: '', endYear: '' }
430
+ })
431
+ setManualMode(true)
432
+ }}>编辑简历</button>
433
+ </div>
434
+ </div>
435
+
436
+ <div className="flex flex-wrap gap-12 mb-24">
437
+ {metrics.map((m, i) => (
438
+ <div key={i} className="card text-center flex-1 mw-140">
439
+ <p className={`text-2xl font-bold ${m.cls}`}>{m.value}</p>
440
+ <p className="text-sm text-secondary mt-4">{m.label}</p>
441
+ </div>
442
+ ))}
443
+ </div>
444
+
445
+ <div className="card mb-24 text-center">
446
+ <h3 className="font-bold mb-16">能力画像</h3>
447
+ <RadarChart dimensions={resumeData.dimensions || []} scores={resumeData.scores || []} />
448
+ <p className="text-sm text-secondary mt-16">{resumeData.summary || ''}</p>
449
+ </div>
450
+
451
+ {previewJobs.length > 0 && (
452
+ <div className="card mb-24">
453
+ <div className="flex-between mb-16">
454
+ <h3 className="font-bold">推荐岗位 Top 3</h3>
455
+ </div>
456
+ <div className="flex flex-col gap-12">
457
+ {previewJobs.map(job => (
458
+ <div className="py-8 px-12 bg-light rounded-sm flex flex-between items-center flex-wrap gap-8">
459
+ <div>
460
+ <span className="font-bold text-sm">{job.name}</span>
461
+ <span className="text-sm text-secondary ml-8">{job.company}</span>
462
+ </div>
463
+ <span className="font-bold text-sm" style={{
464
+ color: job.match_rate >= 80 ? 'var(--color-success)' : job.match_rate >= 60 ? 'var(--color-warning)' : 'var(--color-error)'
465
+ }}>
466
+ {job.match_rate}%
467
+ </span>
468
+ </div>
469
+ ))}
470
+ </div>
471
+ </div>
472
+ )}
473
+
474
+ {previewJobs.length > 0 && (
475
+ <div className="card mb-24">
476
+ <div className="flex-between mb-16">
477
+ <h3 className="font-bold">HR 视角速览</h3>
478
+ </div>
479
+ <p className="text-sm mb-16 leading-relaxed text-secondary">
480
+ HR 初筛一份简历平均只花 <strong>10~15 秒</strong>⏱️,他们最先扫一眼你的学校、实习经历和技能关键词。下面是你 Top 3 岗位的 HR 关注点,帮你理解他们筛选时在想什么👇
481
+ </p>
482
+ <div className="flex flex-col gap-12">
483
+ {previewJobs.map(job => (
484
+ <div key={job.job_id} className="card py-8 px-12 bg-light">
485
+ <div className="flex-between mb-8">
486
+ <span className="font-bold text-sm">{job.name}<span className="text-secondary ml-8">{job.company}</span></span>
487
+ </div>
488
+ <div className="flex flex-wrap gap-4">
489
+ {(job.expectation_signals || []).map((signal, i) => (
490
+ <span key={i} className="signal-chip">
491
+ {signal.tag}
492
+ <span className="signal-evidence">— {signal.evidence}</span>
493
+ </span>
494
+ ))}
495
+ </div>
496
+ </div>
497
+ ))}
498
+ </div>
499
+ <p className="tip-box tip-box-text mt-16">
500
+ ✨ <strong>小提醒:</strong>针对每个岗位的 HR 关注点,在简历中有针对性地突出相关关键词和经历,能大幅提高初筛通过率!
501
+ </p>
502
+ </div>
503
+ )}
504
+
505
+ <div className="card mb-24">
506
+ <h3 className="font-bold mb-16">开始匹配</h3>
507
+ <div className="flex gap-12 flex-wrap">
508
+ <button className="btn btn-primary" onClick={() => onConfirm(resumeData)}>确认并继续</button>
509
+ <button className="btn btn-secondary" onClick={handleReEdit}>编辑简历</button>
510
+ <button className="btn btn-secondary" onClick={onGoRecommend}>浏览推荐岗位</button>
511
+ </div>
512
+ </div>
513
+ </div>
514
+ )
515
+ }
516
+
517
+ return (
518
+ <div className="page-container">
519
+ <div className="card text-center p-24">
520
+ <h2 className="font-bold text-xl mb-8">我的简历</h2>
521
+ <p className="text-secondary mb-24">上传简历,AI 帮你匹配合适岗位、诊断简历匹配度、提供改进建议</p>
522
+ <div
523
+ className="drop-zone"
524
+ onClick={() => inputRef.current?.click()}
525
+ onDrop={e => { e.preventDefault(); const f = e.dataTransfer.files[0]; if (f) handleFile(f) }}
526
+ onDragOver={e => e.preventDefault()}
527
+ >
528
+ <p className="text-secondary">拖拽 PDF 到此处,或点击上传</p>
529
+ <p className="text-sm text-light mt-8">支持 PDF 格式</p>
530
+ </div>
531
+ <input ref={inputRef} type="file" accept=".pdf" className="hidden" onChange={e => { const f = e.target.files[0]; if (f) handleFile(f); e.target.value = '' }} />
532
+ <button className="btn btn-secondary mt-16" onClick={handleReEdit}>没有简历?手工填写</button>
533
+ <div className="mt-16">
534
+ <button className="btn btn-primary" onClick={onGoRecommend}>浏览推荐岗位</button>
535
+ </div>
536
+ </div>
537
+ </div>
538
+ )
539
+ }
540
+
541
+ export default HomePage
src/pages/RecommendPage.jsx ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useState, useEffect } from 'react'
2
+ import { getRecommendJobs } from '../api'
3
+ import JobCard from '../components/JobCard'
4
+
5
+ const PAGE_SIZE = 10
6
+
7
+ function RecommendPage({ resumeData, onSelectJob, onGoHome }) {
8
+ const [status, setStatus] = useState('loading')
9
+ const [jobs, setJobs] = useState([])
10
+ const [page, setPage] = useState(0)
11
+ const [errorMsg, setErrorMsg] = useState('')
12
+
13
+ const isBrowsing = !resumeData
14
+
15
+ const fetchJobs = async () => {
16
+ setStatus('loading')
17
+ try {
18
+ const resumeId = resumeData?.id || 1
19
+ const res = await getRecommendJobs(resumeId)
20
+ const list = res.data?.jobs || []
21
+ setJobs(list)
22
+ setPage(0)
23
+ setStatus(list.length === 0 ? 'empty' : 'success')
24
+ } catch {
25
+ setStatus('error')
26
+ setErrorMsg('加载失败,请重试')
27
+ }
28
+ }
29
+
30
+ useEffect(() => {
31
+ fetchJobs()
32
+ }, [])
33
+
34
+ const totalPages = Math.ceil(jobs.length / PAGE_SIZE)
35
+ const pageJobs = jobs.slice(page * PAGE_SIZE, (page + 1) * PAGE_SIZE)
36
+
37
+ if (status === 'loading') {
38
+ return (
39
+ <div className="loading-state">
40
+ <div className="loading-spinner loading-spinner-lg" />
41
+ <p className="mt-16 text-secondary">加载推荐岗位中...</p>
42
+ </div>
43
+ )
44
+ }
45
+
46
+ if (status === 'error') {
47
+ return (
48
+ <div className="error-state">
49
+ <p className="error-state-text">{errorMsg}</p>
50
+ <div className="flex gap-12">
51
+ <button className="btn btn-primary" onClick={fetchJobs}>重试</button>
52
+ <button className="btn btn-secondary" onClick={onGoHome}>返回首页</button>
53
+ </div>
54
+ </div>
55
+ )
56
+ }
57
+
58
+ if (status === 'empty') {
59
+ return (
60
+ <div className="empty-state">
61
+ <p className="empty-state-text">暂无可推荐岗位,请完善简历后重试</p>
62
+ <button className="btn btn-primary" onClick={onGoHome}>返回首页</button>
63
+ </div>
64
+ )
65
+ }
66
+
67
+ return (
68
+ <div>
69
+ <div className="flex-between flex-wrap mb-24">
70
+ <h2 className="font-bold text-xl">推荐岗位</h2>
71
+ <span className="text-sm text-light">共 {jobs.length} 个岗位</span>
72
+ </div>
73
+ <div className="flex flex-col gap-16">
74
+ {pageJobs.map((job) => (
75
+ <JobCard
76
+ key={job.job_id}
77
+ job={job}
78
+ onClick={(jobId, jobData) => onSelectJob(jobId, jobData || job)}
79
+ lowMatchWarning={(job.match_rate || 0) < 40}
80
+ showMatch={!isBrowsing}
81
+ onUploadClick={isBrowsing ? onGoHome : undefined}
82
+ />
83
+ ))}
84
+ </div>
85
+ {totalPages > 1 && (
86
+ <div className="flex-center gap-12 mt-24 flex-wrap">
87
+ <button
88
+ className="btn btn-sm btn-secondary"
89
+ disabled={page === 0}
90
+ onClick={() => setPage(p => Math.max(0, p - 1))}
91
+ >
92
+ 上一页
93
+ </button>
94
+ <span className="text-sm text-secondary">
95
+ {page + 1} / {totalPages}
96
+ </span>
97
+ <button
98
+ className="btn btn-sm btn-secondary"
99
+ disabled={page >= totalPages - 1}
100
+ onClick={() => setPage(p => Math.min(totalPages - 1, p + 1))}
101
+ >
102
+ 下一页
103
+ </button>
104
+ </div>
105
+ )}
106
+ <div className="flex-center mt-24">
107
+ <button className="btn btn-secondary" onClick={onGoHome}>返回首页</button>
108
+ </div>
109
+ </div>
110
+ )
111
+ }
112
+
113
+ export default RecommendPage
src/pages/SuggestPage.jsx ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useState, useCallback } from 'react'
2
+ import { rerankReport } from '../api'
3
+
4
+ function SuggestPage({ jobId, resumeData, advice, onBack }) {
5
+ const initData = resumeData || {}
6
+ const projToString = (p) => typeof p === 'string' ? p : (p.name || p.title || '')
7
+
8
+ const [editedResume, setEditedResume] = useState({
9
+ skills: (initData.skills || []).join(', '),
10
+ projects: (initData.projects || []).map(projToString).join(', '),
11
+ experience: initData.experience || ''
12
+ })
13
+ const [rerankResult, setRerankResult] = useState(null)
14
+ const [reranking, setReranking] = useState(false)
15
+
16
+ const handleRerank = useCallback(async () => {
17
+ const hasContent = editedResume.skills.trim() || editedResume.projects.trim() || editedResume.experience.trim()
18
+ if (!hasContent) return
19
+ setReranking(true)
20
+ try {
21
+ const text = `技能: ${editedResume.skills}\n项目: ${editedResume.projects}\n经历: ${editedResume.experience}`
22
+ const res = await rerankReport(jobId, text)
23
+ setRerankResult(res.data)
24
+ } catch {
25
+ setRerankResult({ error: '重评估失败' })
26
+ }
27
+ setReranking(false)
28
+ }, [jobId, editedResume])
29
+
30
+ const hasAdvice = !!(advice && (
31
+ (advice.rewrite_suggestions && advice.rewrite_suggestions.length > 0) ||
32
+ (advice.interview_tips && advice.interview_tips.length > 0) ||
33
+ advice.encouragement
34
+ ))
35
+
36
+ if (!hasAdvice && !resumeData) {
37
+ return (
38
+ <div className="page-container">
39
+ <div className="empty-state">
40
+ <p className="empty-state-text">暂无简历修改建议</p>
41
+ <button className="btn btn-primary" onClick={onBack}>返回</button>
42
+ </div>
43
+ </div>
44
+ )
45
+ }
46
+
47
+ const suggestions = advice?.rewrite_suggestions || []
48
+ const tips = advice?.interview_tips || []
49
+
50
+ return (
51
+ <div className="page-container">
52
+ <h2 className="font-bold text-xl mb-24">简历修改建议</h2>
53
+
54
+ {hasAdvice && (
55
+ <>
56
+ {suggestions.length > 0 && (
57
+ <div className="mb-24">
58
+ <h3 className="font-bold mb-16">简历修改建议</h3>
59
+ <div className="flex flex-col gap-16">
60
+ {suggestions.map((item, i) => (
61
+ <div key={i} className="card">
62
+ <div className="flex-between mb-8 flex-wrap gap-4">
63
+ <span className="font-bold">{item.dimension}</span>
64
+ <span className="text-sm text-warning">{item.issue}</span>
65
+ </div>
66
+ <div className="mb-8">
67
+ <span className="text-sm text-secondary">原文: </span>
68
+ <s className="text-sm text-error">{item.original}</s>
69
+ </div>
70
+ <div className="mb-8">
71
+ <span className="text-sm text-secondary">建议: </span>
72
+ <span className="text-sm font-bold text-success">{item.suggestion}</span>
73
+ </div>
74
+ <div>
75
+ <span className="text-sm text-light">{item.reason}</span>
76
+ </div>
77
+ </div>
78
+ ))}
79
+ </div>
80
+ </div>
81
+ )}
82
+
83
+ {tips.length > 0 && (
84
+ <div className="mb-24">
85
+ <h3 className="font-bold mb-16">面试准备方向</h3>
86
+ <div className="flex flex-col gap-16">
87
+ {tips.map((item, i) => (
88
+ <div key={i} className="card">
89
+ <div className="flex-between mb-8 flex-wrap gap-4">
90
+ <span className="font-bold">{item.topic}</span>
91
+ <span className="text-sm text-secondary">{item.reason}</span>
92
+ </div>
93
+ <p className="text-sm text-primary">{item.tip}</p>
94
+ </div>
95
+ ))}
96
+ </div>
97
+ </div>
98
+ )}
99
+
100
+ {advice.encouragement && (
101
+ <div className="card mb-24">
102
+ <h3 className="font-bold mb-8">鼓励</h3>
103
+ <p className="text-secondary">{advice.encouragement}</p>
104
+ </div>
105
+ )}
106
+
107
+ <hr className="divider mb-24" />
108
+ </>
109
+ )}
110
+
111
+ <div className="card mb-24">
112
+ <h3 className="font-bold mb-16">编辑简历</h3>
113
+ <div className="flex flex-col gap-12">
114
+ <div>
115
+ <label className="text-sm font-bold">技能(逗号分隔)</label>
116
+ <input
117
+ className="input"
118
+ value={editedResume.skills}
119
+ onChange={e => setEditedResume(p => ({ ...p, skills: e.target.value }))}
120
+ placeholder="如: React, Python, SQL"
121
+ />
122
+ </div>
123
+ <div>
124
+ <label className="text-sm font-bold">项目经历</label>
125
+ <textarea
126
+ className="input"
127
+ rows={3}
128
+ value={editedResume.projects}
129
+ onChange={e => setEditedResume(p => ({ ...p, projects: e.target.value }))}
130
+ placeholder="描述你的项目经历"
131
+ />
132
+ </div>
133
+ <div>
134
+ <label className="text-sm font-bold">实习经历</label>
135
+ <textarea
136
+ className="input"
137
+ rows={3}
138
+ value={editedResume.experience}
139
+ onChange={e => setEditedResume(p => ({ ...p, experience: e.target.value }))}
140
+ placeholder="描述你的实习经历"
141
+ />
142
+ </div>
143
+ </div>
144
+ <button
145
+ className="btn btn-primary mt-16"
146
+ onClick={handleRerank}
147
+ disabled={reranking || !(editedResume.skills.trim() || editedResume.projects.trim() || editedResume.experience.trim())}
148
+ >
149
+ {reranking ? '重新评估中...' : '重新评估匹配度'}
150
+ </button>
151
+ </div>
152
+
153
+ {rerankResult && !rerankResult.error && (
154
+ <div className="card mb-24">
155
+ <h3 className="font-bold mb-16">修改后匹配度</h3>
156
+ <p>
157
+ 匹配度:<span className="font-bold text-lg">{rerankResult.match_rate}%</span>
158
+ </p>
159
+ <p className="text-secondary mt-8">修改前:{rerankResult.previous_rate}%</p>
160
+ {rerankResult.match_rate > rerankResult.previous_rate && (
161
+ <p className="text-success mt-8">
162
+ 修改有效,匹配度提升了 {rerankResult.match_rate - rerankResult.previous_rate}%
163
+ </p>
164
+ )}
165
+ </div>
166
+ )}
167
+
168
+ {rerankResult?.error && (
169
+ <div className="card mb-24">
170
+ <p className="text-error">{rerankResult.error}</p>
171
+ </div>
172
+ )}
173
+
174
+ <div className="text-center">
175
+ <button className="btn btn-secondary" onClick={onBack}>返回诊断</button>
176
+ </div>
177
+ </div>
178
+ )
179
+ }
180
+
181
+ export default SuggestPage