Nicksxs's Blog

What hurts more, the pain of hard work or the pain of regret?

首先是生成plan

完整生成完后还是无法运行,多次把问题提给kimi也没有解决

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Compiled with warnings.

[eslint]
src/components/TodoItem.tsx
Line 4:19: 'FiX' is defined but never used @typescript-eslint/no-unused-vars
Line 4:108: 'FiClock' is defined but never used @typescript-eslint/no-unused-vars
Line 213:7: 'ActionBar' is assigned a value but never used @typescript-eslint/no-unused-vars
Line 222:7: 'ActionButtons' is assigned a value but never used @typescript-eslint/no-unused-vars
Line 334:7: 'Timestamp' is assigned a value but never used @typescript-eslint/no-unused-vars

Search for the keywords to learn more about each warning.
To ignore, add // eslint-disable-next-line to the line before.

WARNING in [eslint]
src/components/TodoItem.tsx
Line 4:19: 'FiX' is defined but never used @typescript-eslint/no-unused-vars
Line 4:108: 'FiClock' is defined but never used @typescript-eslint/no-unused-vars
Line 213:7: 'ActionBar' is assigned a value but never used @typescript-eslint/no-unused-vars
Line 222:7: 'ActionButtons' is assigned a value but never used @typescript-eslint/no-unused-vars
Line 334:7: 'Timestamp' is assigned a value but never used @typescript-eslint/no-unused-vars

webpack compiled with 1 warning
Files successfully emitted, waiting for typecheck results...
Issues checking in progress...
ERROR in src/components/Header.tsx:270:16
TS2786: 'FiSearch' cannot be used as a JSX component.
Its return type 'ReactNode' is not a valid JSX element.
Type 'undefined' is not assignable to type 'Element | null'.
268 | <SearchContainer>
269 | <SearchIcon>
> 270 | <FiSearch {...({ size: 16 } as any)} />
| ^^^^^^^^
271 | </SearchIcon>
272 | <SearchInput
273 | type="text"

ERROR in src/components/Header.tsx:300:18
TS2786: 'FiHome' cannot be used as a JSX component.
Its return type 'ReactNode' is not a valid JSX element.
298 | <NavIcons>
299 | <NavIcon>
> 300 | <FiHome {...({ size: 24 } as any)} />
| ^^^^^^
301 | </NavIcon>
302 | <NavIcon>
303 | <FiCompass {...({ size: 24 } as any)} />


ERROR in src/components/TodoItem.tsx:453:43
TS2786: 'FiTag' cannot be used as a JSX component.
Its return type 'ReactNode' is not a valid JSX element.
451 | {todo.priority === 'high' ? '🔴 高' : todo.priority === 'medium' ? '🟡 中' : '🟢 低'}
452 | </PriorityBadge>
> 453 | {todo.category && <CategoryTag><FiTag size={10} /> #{todo.category}</CategoryTag>}
| ^^^^^
454 |
455 | <div style={{ position: 'relative' }}>
456 | <MoreButton onClick={() => setShowDropdown(!showDropdown)}>


没办法,后面我好好思考了下,前面因为响应一直很慢,我退出了几次又继续使用同一个prompt,但是实际的模型是需要读取原先写到一半的代码,这样其实每次的生成上下文就被搞混乱了,所以重新清理了代码,再给kimi一次机会,这次就慢慢等了
首先也是列出了todo list

完成后主体的代码也不多

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
import React, { useState, useEffect } from 'react';
import styled from '@emotion/styled';
import { motion, AnimatePresence } from 'framer-motion';
import { Plus } from 'lucide-react';
import TodoItem from './TodoItem';
import TodoForm from './TodoForm';

export interface Todo {
id: string;
text: string;
completed: boolean;
createdAt: Date;
priority: 'low' | 'medium' | 'high';
}

const Container = styled(motion.div)`
background: rgba(255, 255, 255, 0.95);
backdrop-filter: blur(20px);
border-radius: 24px;
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
width: 100%;
max-width: 500px;
min-height: 600px;
padding: 30px;
position: relative;
overflow: hidden;
`;

const Header = styled.div`
text-align: center;
margin-bottom: 30px;
`;

const Title = styled.h1`
font-size: 2.5rem;
font-weight: 700;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
margin: 0;
letter-spacing: -0.02em;
`;

const Subtitle = styled.p`
color: #6b7280;
font-size: 1rem;
margin: 8px 0 0 0;
font-weight: 500;
`;

const TodoList = styled.div`
margin-top: 30px;
max-height: 400px;
overflow-y: auto;
padding-right: 10px;

&::-webkit-scrollbar {
width: 6px;
}

&::-webkit-scrollbar-track {
background: #f1f5f9;
border-radius: 3px;
}

&::-webkit-scrollbar-thumb {
background: #cbd5e1;
border-radius: 3px;
}

&::-webkit-scrollbar-thumb:hover {
background: #94a3b8;
}
`;

const EmptyState = styled(motion.div)`
text-align: center;
padding: 60px 20px;
color: #9ca3af;
`;

const EmptyIcon = styled.div`
font-size: 4rem;
margin-bottom: 16px;
opacity: 0.5;
`;

const EmptyText = styled.p`
font-size: 1.1rem;
margin: 0;
font-weight: 500;
`;

const Stats = styled.div`
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 20px;
padding-top: 20px;
border-top: 1px solid #e5e7eb;
`;

const StatItem = styled.div`
text-align: center;
`;

const StatNumber = styled.div`
font-size: 1.5rem;
font-weight: 700;
color: #667eea;
`;

const StatLabel = styled.div`
font-size: 0.875rem;
color: #6b7280;
margin-top: 4px;
`;

const TodoApp: React.FC = () => {
const [todos, setTodos] = useState<Todo[]>([]);
const [showForm, setShowForm] = useState(false);
const [editingTodo, setEditingTodo] = useState<Todo | null>(null);

useEffect(() => {
const savedTodos = localStorage.getItem('todos');
if (savedTodos) {
setTodos(JSON.parse(savedTodos).map((todo: any) => ({
...todo,
createdAt: new Date(todo.createdAt)
})));
}
}, []);

useEffect(() => {
localStorage.setItem('todos', JSON.stringify(todos));
}, [todos]);

const addTodo = (text: string, priority: 'low' | 'medium' | 'high') => {
const newTodo: Todo = {
id: Date.now().toString(),
text,
completed: false,
createdAt: new Date(),
priority
};
setTodos([newTodo, ...todos]);
setShowForm(false);
};

const toggleTodo = (id: string) => {
setTodos(todos.map(todo =>
todo.id === id ? { ...todo, completed: !todo.completed } : todo
));
};

const deleteTodo = (id: string) => {
setTodos(todos.filter(todo => todo.id !== id));
};

const editTodo = (id: string, newText: string, newPriority: 'low' | 'medium' | 'high') => {
setTodos(todos.map(todo =>
todo.id === id ? { ...todo, text: newText, priority: newPriority } : todo
));
setEditingTodo(null);
};

const completedCount = todos.filter(todo => todo.completed).length;
const totalCount = todos.length;

return (
<Container
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.6, ease: "easeOut" }}
>
<Header>
<Title>My Tasks</Title>
<Subtitle>Stay organized and productive</Subtitle>
</Header>

{showForm && (
<TodoForm
onSubmit={addTodo}
onCancel={() => setShowForm(false)}
/>
)}

{editingTodo && (
<TodoForm
todo={editingTodo}
onSubmit={(text, priority) => editTodo(editingTodo.id, text, priority)}
onCancel={() => setEditingTodo(null)}
/>
)}

<TodoList>
<AnimatePresence>
{todos.length === 0 ? (
<EmptyState
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
>
<EmptyIcon>📝</EmptyIcon>
<EmptyText>No tasks yet. Add one to get started!</EmptyText>
</EmptyState>
) : (
todos.map((todo) => (
<TodoItem
key={todo.id}
todo={todo}
onToggle={toggleTodo}
onDelete={deleteTodo}
onEdit={setEditingTodo}
/>
))
)}
</AnimatePresence>
</TodoList>

{todos.length > 0 && (
<Stats>
<StatItem>
<StatNumber>{totalCount}</StatNumber>
<StatLabel>Total</StatLabel>
</StatItem>
<StatItem>
<StatNumber>{completedCount}</StatNumber>
<StatLabel>Completed</StatLabel>
</StatItem>
<StatItem>
<StatNumber>{totalCount - completedCount}</StatNumber>
<StatLabel>Remaining</StatLabel>
</StatItem>
</Stats>
)}

{!showForm && !editingTodo && (
<motion.button
style={{
position: 'absolute',
bottom: '30px',
right: '30px',
width: '60px',
height: '60px',
borderRadius: '50%',
background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
border: 'none',
color: 'white',
fontSize: '24px',
cursor: 'pointer',
boxShadow: '0 10px 25px rgba(102, 126, 234, 0.4)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center'
}}
whileHover={{ scale: 1.1 }}
whileTap={{ scale: 0.95 }}
onClick={() => setShowForm(true)}
>
<Plus size={24} />
</motion.button>
)}
</Container>
);
};

export default TodoApp;

一开始运行出现了个问题,
新增的时候报错 Component selectors can only be used in conjunction with @emotion/babel-plugin, the swc Emotion plugin, or another Emotion-aware compiler transform.
就继续让kimi来解决这个问题,结果一次就改好了,

整体看起来也还行,可能的确是我一开始中断了几次导致上下文太复杂,只是不确定是模型消耗资源比较多还是什么原因响应有时候会很慢,可能免费的资源池是共用的,高峰期就比较慢了

这里我们用iflow的默认Qwen3-Coder-Plus模型来生成一个todo应用
本次的prompt稍微调整了下

1
帮我生成一个todo应用,基于react实现,需要具有非常精美的UI,媲美Instagram那样的网站

生成的复杂度比之前roocode小很多
主要就是在App.tsx里

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
import React, { useState, useEffect } from 'react';
import styled, { createGlobalStyle, keyframes } from 'styled-components';
import { FiCheck, FiTrash2, FiEdit2 } from 'react-icons/fi';

// 淡入动画
const fadeIn = keyframes`
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
`;

// 淡入缩放动画
const fadeInScale = keyframes`
from {
opacity: 0;
transform: scale(0.95);
}
to {
opacity: 1;
transform: scale(1);
}
`;

// 按钮点击动画
const buttonClick = keyframes`
0% {
transform: scale(1);
}
50% {
transform: scale(0.95);
}
100% {
transform: scale(1);
}
`;

// 按钮悬停脉冲动画
const pulse = keyframes`
0% {
box-shadow: 0 0 0 0 rgba(56, 151, 240, 0.4);
}
70% {
box-shadow: 0 0 0 10px rgba(56, 151, 240, 0);
}
100% {
box-shadow: 0 0 0 0 rgba(56, 151, 240, 0);
}
`;

// 任务项滑动动画
const slideIn = keyframes`
from {
opacity: 0;
transform: translateX(30px);
}
to {
opacity: 1;
transform: translateX(0);
}
`;

// 全局样式
const GlobalStyle = createGlobalStyle`
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

body {
background: linear-gradient(135deg, #f5f7fa 0%, #e4edf5 100%);
min-height: 100vh;
padding: 20px;
}
`;

// 主容器
const AppContainer = styled.div`
max-width: 600px;
margin: 0 auto;
background: rgba(255, 255, 255, 0.95);
border-radius: 20px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
overflow: hidden;
border: 1px solid rgba(255, 255, 255, 0.2);
backdrop-filter: blur(10px);
animation: ${fadeIn} 0.5s ease-out;
`;

// 顶部导航栏
const Header = styled.header`
background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
padding: 25px;
text-align: center;
position: relative;
overflow: hidden;

&::before {
content: '';
position: absolute;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 70%);
transform: rotate(30deg);
}

&::after {
content: '';
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 2px;
background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
}
`;

const AppTitle = styled.h1`
color: white;
font-size: 2rem;
font-weight: 700;
letter-spacing: 0.5px;
margin: 0;
position: relative;
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
background: linear-gradient(90deg, white, #e0f7fa);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
`;

// 主内容区域
const MainContent = styled.main`
padding: 30px;
`;

// 添加任务表单
const AddTodoForm = styled.div`
display: flex;
margin-bottom: 25px;
gap: 12px;
animation: ${fadeIn} 0.5s ease-out;
`;

const TodoInput = styled.input`
flex: 1;
padding: 16px 20px;
border: 1px solid rgba(134, 142, 150, 0.2);
border-radius: 12px;
font-size: 1rem;
outline: none;
transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
background: rgba(255, 255, 255, 0.8);
box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);

&:focus {
border-color: #3897f0;
background: white;
box-shadow: 0 0 0 3px rgba(56, 151, 240, 0.2), inset 0 2px 4px rgba(0, 0, 0, 0.05);
transform: translateY(-2px);
}

&::placeholder {
color: #a0aec0;
}
`;

const AddButton = styled.button`
background: linear-gradient(135deg, #3897f0 0%, #833ab4 100%);
color: white;
border: none;
border-radius: 12px;
padding: 0 24px;
font-size: 1rem;
font-weight: 600;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
position: relative;
overflow: hidden;
box-shadow: 0 4px 15px rgba(56, 151, 240, 0.3);

&:hover {
background: linear-gradient(135deg, #2d7bc4 0%, #6a11cb 100%);
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(56, 151, 240, 0.4);
}

&:active {
animation: ${buttonClick} 0.2s ease;
transform: translateY(0);
}

&:focus {
animation: ${pulse} 1.5s infinite;
}

&::before {
content: '';
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
transition: 0.5s;
}

&:hover::before {
left: 100%;
}
`;

// 任务列表
const TodoList = styled.div`
display: flex;
flex-direction: column;
gap: 15px;
`;

// 单个任务项
const TodoItem = styled.div<{ completed: boolean }>`
display: flex;
align-items: center;
padding: 18px;
background: rgba(255, 255, 255, 0.8);
border-radius: 12px;
border: 1px solid rgba(134, 142, 150, 0.15);
transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
animation: ${slideIn} 0.3s ease-out;

${props => props.completed && `
opacity: 0.8;
background: rgba(240, 240, 240, 0.6);
`}

&:hover {
border-color: rgba(134, 142, 150, 0.3);
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
}
`;

const Checkbox = styled.input.attrs({ type: 'checkbox' })`
width: 22px;
height: 22px;
cursor: pointer;
accent-color: #4CAF50;
border-radius: 6px;
border: 2px solid #cbd5e0;
transition: all 0.2s ease;

&:checked {
border-color: #4CAF50;
background: #4CAF50;
}

&:hover {
transform: scale(1.1);
}
`;

const TodoText = styled.span<{ completed: boolean }>`
flex: 1;
font-size: 1.1rem;
margin: 0 15px;
transition: all 0.3s ease;
color: #2d3748;
${props => props.completed && `
text-decoration: line-through;
color: #a0aec0;
`}
`;

const TodoActions = styled.div`
display: flex;
gap: 12px;
`;

const ActionButton = styled.button`
background: rgba(255, 255, 255, 0.7);
border: 1px solid rgba(134, 142, 150, 0.2);
cursor: pointer;
font-size: 1.2rem;
width: 40px;
height: 40px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
color: #718096;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);

&:hover {
background: white;
color: #4a5568;
border-color: rgba(134, 142, 150, 0.4);
transform: translateY(-2px) scale(1.1);
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

&:active {
transform: scale(0.95);
}
`;

const CheckButton = styled(ActionButton)`
&:hover {
color: #4CAF50;
border-color: rgba(76, 175, 80, 0.4);
background: rgba(76, 175, 80, 0.1);
}
`;

const EditButton = styled(ActionButton)`
&:hover {
color: #2b6cb0;
border-color: rgba(43, 108, 176, 0.4);
background: rgba(43, 108, 176, 0.1);
}
`;

const DeleteButton = styled(ActionButton)`
&:hover {
color: #e53e3e;
border-color: rgba(229, 62, 62, 0.4);
background: rgba(229, 62, 62, 0.1);
}
`;

// 统计信息
const StatsContainer = styled.div`
display: flex;
justify-content: space-between;
margin-top: 25px;
padding: 20px;
background: rgba(255, 255, 255, 0.7);
border-radius: 12px;
font-weight: 500;
color: #718096;
border: 1px solid rgba(134, 142, 150, 0.15);
animation: ${fadeInScale} 0.5s ease-out;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
`;

const StatItem = styled.div`
text-align: center;
padding: 10px 15px;
border-radius: 8px;
transition: all 0.3s ease;

&:hover {
background: rgba(255, 255, 255, 0.5);
transform: translateY(-2px);
}
`;

const StatNumber = styled.div`
font-size: 1.5rem;
font-weight: 700;
color: #2d3748;
background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
`;

const StatLabel = styled.div`
font-size: 0.85rem;
color: #a0aec0;
margin-top: 3px;
`;

// 空状态
const EmptyState = styled.div`
text-align: center;
padding: 60px 20px;
color: #a0aec0;
animation: ${fadeIn} 0.5s ease-out;
background: rgba(255, 255, 255, 0.5);
border-radius: 12px;
margin-top: 10px;
backdrop-filter: blur(5px);
`;

const EmptyIcon = styled.div`
font-size: 3.5rem;
margin-bottom: 20px;
opacity: 0.6;
filter: grayscale(100%);
animation: ${fadeIn} 1s ease-in-out infinite alternate;
`;

interface Todo {
id: string;
text: string;
completed: boolean;
createdAt: Date;
}

const App: React.FC = () => {
const [todos, setTodos] = useState<Todo[]>([]);
const [newTodo, setNewTodo] = useState<string>('');

// 从localStorage加载数据
useEffect(() => {
const savedTodos = localStorage.getItem('todos');
if (savedTodos) {
try {
const parsedTodos = JSON.parse(savedTodos);
// 将日期字符串转换回Date对象
const todosWithDates = parsedTodos.map((todo: any) => ({
...todo,
createdAt: new Date(todo.createdAt)
}));
setTodos(todosWithDates);
} catch (e) {
console.error('Error parsing todos from localStorage', e);
}
}
}, []);

// 保存数据到localStorage
useEffect(() => {
localStorage.setItem('todos', JSON.stringify(todos));
}, [todos]);

const addTodo = () => {
if (newTodo.trim() !== '') {
const newTodoItem: Todo = {
id: Date.now().toString(),
text: newTodo,
completed: false,
createdAt: new Date()
};
setTodos([newTodoItem, ...todos]); // 将新任务添加到列表顶部
setNewTodo('');
}
};

const toggleTodo = (id: string) => {
setTodos(todos.map(todo =>
todo.id === id ? { ...todo, completed: !todo.completed } : todo
));
};

const deleteTodo = (id: string) => {
setTodos(todos.filter(todo => todo.id !== id));
};

const editTodo = (id: string, newText: string) => {
if (newText.trim() !== '') {
setTodos(todos.map(todo =>
todo.id === id ? { ...todo, text: newText } : todo
));
}
};

const handleKeyPress = (e: React.KeyboardEvent<HTMLInputElement>) => {
if (e.key === 'Enter') {
addTodo();
}
};

const completedCount = todos.filter(todo => todo.completed).length;
const totalCount = todos.length;

return (
<>
<GlobalStyle />
<AppContainer>
<Header>
<AppTitle>Instagram风格Todo</AppTitle>
</Header>

<MainContent>
<AddTodoForm>
<TodoInput
type="text"
value={newTodo}
onChange={(e) => setNewTodo(e.target.value)}
onKeyPress={handleKeyPress}
placeholder="添加新任务..."
/>
<AddButton onClick={addTodo}>
添加
</AddButton>
</AddTodoForm>

{todos.length > 0 ? (
<>
<TodoList>
{todos.map(todo => (
<TodoItem key={todo.id} completed={todo.completed}>
<Checkbox
checked={todo.completed}
onChange={() => toggleTodo(todo.id)}
/>
<TodoText completed={todo.completed}>{todo.text}</TodoText>
<TodoActions>
<CheckButton
onClick={() => toggleTodo(todo.id)}
title={todo.completed ? "标记为未完成" : "标记为完成"}
>
{React.createElement(FiCheck as any)}
</CheckButton>
<EditButton
onClick={() => {
const newText = prompt('编辑任务:', todo.text);
if (newText !== null) {
editTodo(todo.id, newText);
}
}}
title="编辑"
>
{React.createElement(FiEdit2 as any)}
</EditButton>
<DeleteButton
onClick={() => deleteTodo(todo.id)}
title="删除"
>
{React.createElement(FiTrash2 as any)}
</DeleteButton>
</TodoActions>
</TodoItem>
))}
</TodoList>

<StatsContainer>
<StatItem>
<StatNumber>{totalCount}</StatNumber>
<StatLabel>总任务</StatLabel>
</StatItem>
<StatItem>
<StatNumber>{completedCount}</StatNumber>
<StatLabel>已完成</StatLabel>
</StatItem>
<StatItem>
<StatNumber>{totalCount - completedCount}</StatNumber>
<StatLabel>待完成</StatLabel>
</StatItem>
</StatsContainer>
</>
) : (
<EmptyState>
<EmptyIcon>📝</EmptyIcon>
<h2>还没有任务</h2>
<p>添加你的第一个任务开始吧!</p>
</EmptyState>
)}
</MainContent>
</AppContainer>
</>
);
};

export default App;

包括了主体代码和样式,但是颜色样式我还不太满意,希望是之前Instagram那种比较素的颜色,又很精致的那种,但是最近又登录看了下,发现他们家也倒退很多,又通过一些修改,感觉好了一些

另外在运行过程中把之前说的问题截到图了,这就是我说的广告,也做的太快了

好像是我碰到的第一个带有广告的,不过其他家都是需要为api用量付费的,免费的有点代价也正常
另外在调整UI的过程中我们需要让iflow在每一步变更前先把当前代码提交,这样方便我们在多次ui调整中选择最佳的版本

最近一直在找这些AI编程助手,想找个cc的八分平替,刚好前阵子在朋友圈看到iflow-cli,据说是可以免费用GLM4.6这些模型,
首先安装也很简单
使用这行命令就行

1
bash -c "$(curl -fsSL https://gitee.com/iflow-ai/iflow-cli/raw/main/install.sh)"

但是这里他会判断nodejs的版本,需要22及以上版本
这个可以用nvm切换,不过这里比较好奇,应该是nodejs的普及率太高了所以都用它做来会更方便
切换以后运行上面的命令,首次运行直接回进去类似于claude code的交互界面,
当然我还是让它给我修复下roo代码

第一个错误是启动npm run dev 的时候就报的,后面是在chrome控制台的

这两个问题改完之后终于这个“庞大的”工程终于起来了,原因只是为了做roocode测试,并且我的prompt加了“精美的”这种关键词,结果用copilot改了半天index.css中依赖tailwind的问题,
这次总算用iflow-cli给修好了,但也是能跑起来

可以看到页面是比之前的都精美了,但是样式还有点不对,有点偏右,而且经过copilot的修改,可能配色也已经不太一样了
iflow总结用下来有两个问题,第一个是有时候会莫名其妙超时,非常久,有一次我放着没管,一晚上都没结果
第二个是广告,在等待prompt结果的时候,会有一行文字的广告,这个体验非常差,当然如果是为了免费也没办法,希望能有一定的控制,后续可以看看它支持的模型里哪个生成的比较好

之前在GLM网站看到他们家有适配各种代码生成插件,就先来体验下这个Roo Code
这是个在vscode插件市场里可以安装的插件,

安装完在这就有个图标了

然后在API Provider里选择 Z AI
Z AI Entrypoint 选择 China Coding Plan
Z AI API KEY 就是他们家的API KEY
然后选择Model,可以选择最新的glm-4.6
这样就配置好了

还是以相同任务来做下测验
他会先逐个求问,来帮忙细化我前面比较粗略的prompt
然后会生成这样的架构计划

这让我觉得有点惊喜,在开发前已经在做系分和架构设计了

但是在N步之后,还是有出了问题
12:23:12 AM [vite] (client) Pre-transform error: [postcss] It looks like you're trying to usetailwindcssdirectly as a PostCSS plugin. The PostCSS plugin has moved to a separate package, so to continue using Tailwind CSS with PostCSS you'll need to install@tailwindcss/postcssand update your PostCSS configuration. Plugin: vite:css

不过它识别到了这个错误

但是其实这个修复还是有问题,后续又因为token超限了,这样的一个简单应用,它用了83K的token,虽然可能设想很好,实现的还是问题比较多
整体看下来Roo Code应该是想解决比较大型的项目的架构设计和代码实现,但是可能因为模型能力不够,也可能是在prompt的设计中出现了问题,比如这里看下来跟tailwind的版本和具体的使用方式有关系,这一点可能跟glm模型的训练有关
即使我用了copilot基于claude-sonnet-4.5模型调试了挺久还是没有解决问题
倒不是特别悲观,只是可能很多项目都有复杂的历史包袱,要在非常核心的项目(特别是历史悠久)中使用,目前来看还需要一些时间来进步

在很久之前最开始体验国产模型的时候就体验了ChatGLM,那个时候属于国内基本没几家有出大语言模型,但是说实话体验效果的确比较一般
但是目前GLM也是国内比较头部的大语言模型了,特别是最新出的GLM4.6,看大佬的评测好像比Deepseek V3.2还好一些
我们就基于claude code来做一下体验,还是老规矩,用最简单的prompt让它实现个todo应用
前置工作我们先去 bigmodel 申请下apikey
申请完了就在我们体验的项目目录下

1
2
export ANTHROPIC_BASE_URL=``https://open.bigmodel.cn/api/anthropic
export ANTHROPIC_AUTH_TOKEN="刚才复制的 API Key"

一开始运行还发现模型是不对的,用的是claude的模型
需要手动指定

1
export ANTHROPIC_DEFAULT_SONNET_MODEL=GLM-4.5

这里为什么用4.5呢,因为没付费,不给用4.6
所以我们先测一下4.5,待会再看下4.6
4.5模型的测了好几次都是中途卡住
生成的效果也比较一般

接下来我充了值,再试下4.6模型,果然动用了钞能力就是不一样,一遍完成,并且样式也美化了很多

过程中的任务编排也是比较合理,并且逐条完成了,4.5感觉还是完成度不高,4.6给我的感觉可能跟deepseek r1接近,
没有特别明显的优势,可能需要更加复杂的任务才能测出来差别,总之国产模型还是有在进步的

0%