File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change 11- 不要直接用 fetch 获取资源,而是使用 ui/src/api/v1.ts 来获取数据。
22- 使用 2 spaces 缩进。使用单引号。
33- 在完成任务前验证是否有 Linter 或者 TypeScript 错误
4+ - 对于动态的 className,优先使用 clsx 来生成。只有遇到可能覆盖的情况下才使用 ` import { cn } from '@/lib/utils' ` 。cn 底层用的是 twMerge,性能上会比 clsx 差一些。
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import { useState } from 'react';
1111import { isSelectNet , SelectNet } from '@/api/rdp' ;
1212import { useInstance } from '@/contexts/instance' ;
1313import { cn } from '@/lib/utils' ;
14+ import { clsx } from 'clsx' ;
1415import pLimit from 'p-limit' ;
1516import { useLocalStorage } from '@/hooks/use-local-storage' ;
1617
@@ -69,10 +70,14 @@ const SelectNetItem: React.FC<SelectNetItemProps> = ({
6970 }
7071 } }
7172 >
72- < Timer className = { `h-4 w-4 ${ net . list ?. some ( item => testingStates [ item ] ) ? 'animate-spin' : '' } ` } />
73+ < Timer className = { clsx ( "h-4 w-4" , {
74+ "animate-spin" : net . list ?. some ( item => testingStates [ item ] )
75+ } ) } />
7376 </ Button >
7477 < ChevronDown
75- className = { `h-4 w-4 transition-transform duration-200 ${ isOpen ? 'transform rotate-180' : '' } ` }
78+ className = { clsx ( "h-4 w-4 transition-transform duration-200" , {
79+ "transform rotate-180" : isOpen
80+ } ) }
7681 />
7782 </ div >
7883 </ CollapsibleTrigger >
@@ -90,7 +95,7 @@ const SelectNetItem: React.FC<SelectNetItemProps> = ({
9095 >
9196 { item }
9297 { item in latencyResults && (
93- < span className = { cn ( ' ml-2 text-xs' , colorClass ) } >
98+ < span className = { cn ( " ml-2 text-xs" , colorClass ) } >
9499 { latencyText }
95100 </ span >
96101 ) }
You can’t perform that action at this time.
0 commit comments