再谈效率 @ Mon, Feb 20, 2023 6:33 PM
再谈效率 @ Tue, Feb 21, 2023 11:13 AM
Expand 16 lines ...
17
17
18
## 定义一些有用的变量
18
## 定义一些有用的变量
19
19
20
-
+ `$TM_FILENAME_BASE$`: 按文件名生成大驼峰变量名  
20
+
+ [`$TM_FILENAME_BASE$`](https://github.com/powerfulyang/live-templates/blob/master/variables/%24TM_FILENAME_BASE%24): 按文件名生成大驼峰变量名    
21
-
    表达式如下: `capitalize(camelCase(fileNameWithoutExtension()))`  
22
    example: `hello-world.js` => `HelloWorld`  
21
    example: `hello-world.js` => `HelloWorld`  
23
    example: `HelloWorld.js` => `HelloWorld`
22
    example: `HelloWorld.js` => `HelloWorld`
24
-
+ `$COLUMNS$`: 读取剪切板内容,并按空格分割,生成 ProTable 的 columns  
23
+
+ [`$COLUMNS$`](https://github.com/powerfulyang/live-templates/blob/master/variables/%24COLUMNS%24): 读取剪切板内容,并按空格分割,生成 ProTable 的 columns  
25
-
    表达式如下: `groovyScript("def str = _1;def labels = str.split(' ').findAll { it != ''};def mappedLabels = labels.collect { it -> \"{\\ntitle: '${it}',\\ndataIndex: ''\\n}\\n\" };def joinedLabels = mappedLabels.join(',\\n');def columns = \"[\\n${joinedLabels}\\n]\";def result = \"const columns: ProColumnDetectType<any>[] = ${columns};\";return result;", clipboard())`
24
+
    example: `id name age` =>
25
+
    ```tsx
26
+
    const columns: ProColumnDetectType<any>[] = [
27
+
    {
28
+
        title: 'id',
29
+
        dataIndex: '',
30
+
    },
31
+
    {
32
+
        title: 'name',
33
+
        dataIndex: '',
34
+
    },
35
+
    {
36
+
        title: 'age',
37
+
        dataIndex: '',
38
+
    },
39
+
    ];
40
+
    ```