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