@easyv/screen-cli 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -6
- package/bin/postinstall.js +9 -0
- package/dist/commands/component.js +37 -8
- package/dist/commands/skills.js +10 -41
- package/dist/commands/update.js +17 -0
- package/dist/config.js +5 -0
- package/dist/index.js +10 -4
- package/dist/package-info.js +17 -0
- package/dist/postinstall.js +15 -0
- package/dist/skills-install.js +68 -0
- package/dist/update-check.js +167 -0
- package/package.json +2 -1
- package/skills/easyv-component-dev/SKILL.md +7 -9
- package/skills/easyv-component-dev/references/assets.md +81 -0
- package/skills/easyv-component-dev/references/component-spec.md +23 -17
- package/skills/easyv-component-dev/references/configuration.md +655 -0
- package/skills/easyv-screen-build/SKILL.md +23 -9
- package/skills/easyv-screen-build/references/component-selection.md +182 -0
- package/skills/easyv-screen-edit/SKILL.md +4 -1
- package/skills/easyv-screen-shared/SKILL.md +1 -0
- package/skills/figma-asset-slice/SKILL.md +194 -0
- package/skills/figma-asset-slice/scripts/build_preview.py +446 -0
- package/spec/openapi.v1.yaml +151 -8
|
@@ -0,0 +1,655 @@
|
|
|
1
|
+
# configuration 配置规范
|
|
2
|
+
|
|
3
|
+
`main.json` 的 `configuration` 是配置项数组。平台用它渲染右侧配置面板,再按每一层的 `name` 把数组归约成对象。组件从 `props.configuration` 读取归约后的值。
|
|
4
|
+
|
|
5
|
+
本文只写配置项本身:公共字段、分组、显隐和控件类型。`base`、`triggers`、`actions` 见 [component-spec.md](component-spec.md)。
|
|
6
|
+
|
|
7
|
+
依据的官方说明:
|
|
8
|
+
|
|
9
|
+
- [配置文件属性](https://easyv.cloud/help/docs/gnh3m8u15o026yzi.html)
|
|
10
|
+
- [配置控件类型](https://easyv.cloud/help/docs/cxwhndpnchlappb9.html)
|
|
11
|
+
- [配置项分组](https://easyv.cloud/help/docs/xkbd8qe1u6qagsq4.html)
|
|
12
|
+
- [Rule 配置规则](https://easyv.cloud/help/docs/zb4gtzgozxh21sof.html)
|
|
13
|
+
- [Rule 跨 Tab 配置规则](https://easyv.cloud/help/docs/sgrfad2p7tldgy51.html)
|
|
14
|
+
|
|
15
|
+
## 公共字段
|
|
16
|
+
|
|
17
|
+
同一层的 `name` 不能重复。不写 `type` 时按 `number` 处理。
|
|
18
|
+
|
|
19
|
+
| 字段 | 必填 | 说明 |
|
|
20
|
+
| --- | --- | --- |
|
|
21
|
+
| `name` | 是 | 这一层的键。运行时用它取 `value` |
|
|
22
|
+
| `displayName` | 是 | 面板上的标题 |
|
|
23
|
+
| `type` | 否 | 控件类型,默认 `number` |
|
|
24
|
+
| `value` | 是 | 当前值。类型决定它是标量、对象还是数组 |
|
|
25
|
+
| `config` | 视类型 | 该控件的额外选项,例如 `options`、`min`、`span` |
|
|
26
|
+
| `tip` | 否 | 标题旁的补充说明 |
|
|
27
|
+
| `rule` | 否 | 显隐条件,见下文 |
|
|
28
|
+
| `ruleType` | 否 | 多条 `rule` 的关系,默认 `$and` |
|
|
29
|
+
|
|
30
|
+
当前平台的字段名不带下划线。独立部署版本低于 3.15 才使用 `_name`、`_displayName`、`_value` 这类字段,并且没有 `config`,扩展属性直接写在外层。新组件按本文写法。
|
|
31
|
+
|
|
32
|
+
## 运行时取值
|
|
33
|
+
|
|
34
|
+
面板保存的是声明里的 `value`。分组会被收成嵌套对象,叶子节点就是该控件的 `value`。
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"name": "style",
|
|
39
|
+
"displayName": "样式",
|
|
40
|
+
"value": [
|
|
41
|
+
{ "name": "color", "displayName": "颜色", "type": "color", "value": "#3ba0ff" },
|
|
42
|
+
{ "name": "fontSize", "displayName": "字号", "value": 32 }
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
```jsx
|
|
48
|
+
configuration.style.color // "#3ba0ff"
|
|
49
|
+
configuration.style.fontSize // 32
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`type: "array"` 的系列在运行时仍是列表,每一项再按模板里的子项 `name` 取值。
|
|
53
|
+
|
|
54
|
+
## 分组
|
|
55
|
+
|
|
56
|
+
没有 `type`、且 `value` 是配置项数组的对象,是一个分组。`type: "group"` 是另一回事,表示同一行里并排几个原子控件,见后文「同行成组」。
|
|
57
|
+
|
|
58
|
+
### 纵向折叠
|
|
59
|
+
|
|
60
|
+
分组要放进另一个配置项的 `value` 数组里,才会画成折叠面板。直接写在 `configuration` 第一层、自身又不带 `type` 的对象只是容器,面板不把它画成一组。
|
|
61
|
+
|
|
62
|
+
第一层要用纵向分组时,外面再包一层容器:
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"name": "chart",
|
|
67
|
+
"displayName": "组件",
|
|
68
|
+
"value": [
|
|
69
|
+
{
|
|
70
|
+
"name": "titleStyle",
|
|
71
|
+
"displayName": "标题",
|
|
72
|
+
"value": [
|
|
73
|
+
{ "name": "fontFamily", "displayName": "字体", "type": "font", "value": "Microsoft Yahei" },
|
|
74
|
+
{ "name": "fontSize", "displayName": "字号", "value": 32 },
|
|
75
|
+
{ "name": "color", "displayName": "颜色", "type": "color", "value": "#ddd" }
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
运行时:`configuration.chart.titleStyle.fontSize`。
|
|
83
|
+
|
|
84
|
+
纵向分组可以继续嵌套纵向分组,父级是纵向或横向都可以。
|
|
85
|
+
|
|
86
|
+
### 横向 Tab
|
|
87
|
+
|
|
88
|
+
横向分组写在 `configuration` 第一层,不要再包容器。第一个分组(它本身必须是分组)设置 `config.layout` 为 `"horizontal"`,它和后面的同级分组都变成 Tab。
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
[
|
|
92
|
+
{
|
|
93
|
+
"name": "chart",
|
|
94
|
+
"displayName": "全局",
|
|
95
|
+
"config": { "layout": "horizontal" },
|
|
96
|
+
"value": []
|
|
97
|
+
},
|
|
98
|
+
{ "name": "axis", "displayName": "坐标轴", "value": [] },
|
|
99
|
+
{ "name": "series", "displayName": "系列", "value": [] }
|
|
100
|
+
]
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
横向分组不能再作为别的分组的子分组。需要在一个 Tab 里横向切换几组配置时,用下面的按钮组。
|
|
104
|
+
|
|
105
|
+
### 按钮组
|
|
106
|
+
|
|
107
|
+
只在横向布局的第一层分组上有效。给该分组加上 `"type": "menu"`,它的子分组以按钮切换,而不是再开一层 Tab。
|
|
108
|
+
|
|
109
|
+
```json
|
|
110
|
+
{
|
|
111
|
+
"name": "chart",
|
|
112
|
+
"displayName": "全局",
|
|
113
|
+
"type": "menu",
|
|
114
|
+
"config": { "layout": "horizontal" },
|
|
115
|
+
"value": [
|
|
116
|
+
{ "name": "prefix", "displayName": "前缀", "value": [] },
|
|
117
|
+
{ "name": "number", "displayName": "数字", "value": [] },
|
|
118
|
+
{ "name": "suffix", "displayName": "后缀", "value": [] }
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### 整组开关
|
|
124
|
+
|
|
125
|
+
某一组想让用户整体关掉时,在这组的 `value` 数组里放一个 `name` 固定为 `show` 的布尔项。它只对所在的这一组有效。
|
|
126
|
+
|
|
127
|
+
```json
|
|
128
|
+
{
|
|
129
|
+
"name": "shadow",
|
|
130
|
+
"displayName": "阴影",
|
|
131
|
+
"value": [
|
|
132
|
+
{ "name": "show", "displayName": "", "type": "boolean", "value": true },
|
|
133
|
+
{ "name": "blur", "displayName": "模糊", "value": 8 }
|
|
134
|
+
]
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
面板上的开关只改变 `show` 的布尔值。组件要自己判断,例如 `configuration.chart.shadow.show` 为真才画阴影。
|
|
139
|
+
|
|
140
|
+
### 标签占位
|
|
141
|
+
|
|
142
|
+
官方跨 Tab 示例里,配置项上还出现了 `labelLayout`(数字)和 `labelPosition`(`"bottom"`),用来调整标题占位。控件类型文档没有单独定义取值范围。需要把标题放到输入框下方时,按该示例填写;普通配置可以不写。
|
|
143
|
+
|
|
144
|
+
## 显隐 rule
|
|
145
|
+
|
|
146
|
+
`rule` 决定这项在配置面板里出不出现。条件成立才显示。它不代替组件里的绘制判断。
|
|
147
|
+
|
|
148
|
+
```json
|
|
149
|
+
"rule": [
|
|
150
|
+
["依赖项的 name", "操作符", "比较值"]
|
|
151
|
+
]
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
同一层的依赖只写对方的 `name`:
|
|
155
|
+
|
|
156
|
+
```json
|
|
157
|
+
{
|
|
158
|
+
"name": "action",
|
|
159
|
+
"displayName": "方向",
|
|
160
|
+
"type": "select",
|
|
161
|
+
"value": "left",
|
|
162
|
+
"config": {
|
|
163
|
+
"options": [
|
|
164
|
+
{ "name": "左", "value": "left" },
|
|
165
|
+
{ "name": "右", "value": "right" }
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
"name": "left",
|
|
171
|
+
"displayName": "左",
|
|
172
|
+
"type": "number",
|
|
173
|
+
"value": 0,
|
|
174
|
+
"rule": [["action", "$eq", "left"]]
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
依赖项不在同一层时,从配置根上的 `name` 写到目标 `name`,中间用 `/` 连接。动画 Tab 依赖基础配置 Tab(`name` 为 `chart`)里的 `testRule` 时,写成 `chart/testRule`。这种跨层路径需要 `@easyv/react-gui` v1.20.0 及以上。
|
|
179
|
+
|
|
180
|
+
```json
|
|
181
|
+
{
|
|
182
|
+
"name": "textVertical",
|
|
183
|
+
"displayName": "跨 Tab 显隐",
|
|
184
|
+
"type": "radio",
|
|
185
|
+
"value": "center",
|
|
186
|
+
"rule": [["chart/testRule", "$eq", true]],
|
|
187
|
+
"config": {
|
|
188
|
+
"options": [
|
|
189
|
+
{ "name": "上", "value": "top" },
|
|
190
|
+
{ "name": "居中", "value": "center" },
|
|
191
|
+
{ "name": "下", "value": "bottom" }
|
|
192
|
+
]
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
多条规则默认同时成立才显示。`ruleType` 改为 `"$or"` 时,成立一条即可。
|
|
198
|
+
|
|
199
|
+
```json
|
|
200
|
+
{
|
|
201
|
+
"name": "stayTime",
|
|
202
|
+
"displayName": "结束停留时间",
|
|
203
|
+
"type": "number",
|
|
204
|
+
"value": 3,
|
|
205
|
+
"rule": [
|
|
206
|
+
["open", "$eq", true],
|
|
207
|
+
["type", "$eq", "normal"]
|
|
208
|
+
]
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
| 操作符 | 含义 |
|
|
213
|
+
| --- | --- |
|
|
214
|
+
| `$eq` | 等于 |
|
|
215
|
+
| `$neq` | 不等于 |
|
|
216
|
+
| `$gt` | 大于 |
|
|
217
|
+
| `$lt` | 小于 |
|
|
218
|
+
| `$gte` | 大于等于 |
|
|
219
|
+
| `$lte` | 小于等于 |
|
|
220
|
+
| `$in` | 包含 |
|
|
221
|
+
| `$nin` | 不包含 |
|
|
222
|
+
|
|
223
|
+
`$eq`、`$neq` 之外的操作符,以及 `ruleType`,需要平台 v4.7.0 及以上。
|
|
224
|
+
|
|
225
|
+
## 控件类型
|
|
226
|
+
|
|
227
|
+
下表的「值」是 `value` 的类型。版本列为空表示文档没有额外版本要求。
|
|
228
|
+
|
|
229
|
+
| type | 面板 | 值 | 版本 |
|
|
230
|
+
| --- | --- | --- | --- |
|
|
231
|
+
| `text` | 静态文本 | `string` | |
|
|
232
|
+
| `input` | 输入框 | `string` | |
|
|
233
|
+
| `number` | 数值 | `number` | |
|
|
234
|
+
| `select` | 下拉 | `string` | |
|
|
235
|
+
| `selectCard` | 带封面的下拉 | `string` | |
|
|
236
|
+
| `radio` | 单选 | `string` | |
|
|
237
|
+
| `checkbox` | 多选 | `string[]` | |
|
|
238
|
+
| `boolean` | 开关 | `boolean` | |
|
|
239
|
+
| `color` | 颜色 | `string` | |
|
|
240
|
+
| `multicolor` | 纯色或线性渐变 | `object` | 平台 ≥ 3.15 |
|
|
241
|
+
| `rangeColor` | 颜色区间 | `{ offset, color }[]` | 平台 ≥ 4.5.0 |
|
|
242
|
+
| `range` | 滑块,值为数组时是双滑块 | `number` 或 `[number, number]` | |
|
|
243
|
+
| `font` | 平台字体列表 | `string` | |
|
|
244
|
+
| `area` | 行政区选择 | `string`,行政区划代码 | |
|
|
245
|
+
| `grid` | 九宫格锚点 | `string`,如 `"center center"` | 平台 ≥ 3.15 |
|
|
246
|
+
| `position` | 位置 | `[x, y]`,x、y 为 0 到 1 | 平台 ≥ 3.15 |
|
|
247
|
+
| `shadow` | 阴影 | `object` | 平台 ≥ 3.15 |
|
|
248
|
+
| `textStyle` | 一段文本样式 | `object` | 平台 ≥ 3.15 |
|
|
249
|
+
| `image` | 图片 | `string`,上传后的相对路径 | |
|
|
250
|
+
| `video` | 视频 | `string`,上传后的相对路径 | |
|
|
251
|
+
| `audio` | 音频 | `string`,上传后的相对路径 | |
|
|
252
|
+
| `uploadModel` | 模型 | `string` | |
|
|
253
|
+
| `model` | 任意文件 | `string` | |
|
|
254
|
+
| `json` | JSON 编辑器 | JSON 字符串 | 平台 ≥ 4.13 |
|
|
255
|
+
| `jscode` | JavaScript 编辑器 | 代码字符串 | 平台 ≥ 4.13 |
|
|
256
|
+
| `array` | 可增删的系列 | `object[]` | |
|
|
257
|
+
| `group` | 同一行并排的原子控件 | 配置项数组 | |
|
|
258
|
+
| `imgSize` | 宽高,可锁定比例 | 两个 `number` 配置项 | |
|
|
259
|
+
| `remoteOptions` | 远程控制其他大屏 | JSON 字符串 | |
|
|
260
|
+
|
|
261
|
+
选项类的 `config.options` 每一项是 `{ "name": "显示名", "value": "值" }`。`name` 给面板看,`value` 进运行时。
|
|
262
|
+
|
|
263
|
+
### input
|
|
264
|
+
|
|
265
|
+
`config`:`prefix`、`suffix`、`placeholder`、`disabled`。
|
|
266
|
+
|
|
267
|
+
```json
|
|
268
|
+
{
|
|
269
|
+
"name": "title",
|
|
270
|
+
"displayName": "标题",
|
|
271
|
+
"type": "input",
|
|
272
|
+
"value": "今日销售额",
|
|
273
|
+
"config": { "placeholder": "请输入标题", "prefix": "", "suffix": "" }
|
|
274
|
+
}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### number
|
|
278
|
+
|
|
279
|
+
`config`:`min`、`max`、`step`(默认 1)、`prefix`、`suffix`、`placeholder`、`disabled`、`showStep`、`precision`、`validataFun`。
|
|
280
|
+
|
|
281
|
+
`showStep` 控制是否画出步进按钮。不写时,有 `suffix` 就不显示步进,没有后缀则显示。`precision` 是保留的小数位数,取非负整数。
|
|
282
|
+
|
|
283
|
+
`validataFun` 是每次改值时执行的函数体,参数名是 `oldVal`、`newVal`,字段名就是这个拼写。`"return newVal/2"` 等价于把新值减半后再写回。
|
|
284
|
+
|
|
285
|
+
```json
|
|
286
|
+
{
|
|
287
|
+
"name": "fontSize",
|
|
288
|
+
"displayName": "字号",
|
|
289
|
+
"type": "number",
|
|
290
|
+
"value": 32,
|
|
291
|
+
"config": { "min": 12, "max": 96, "step": 1, "suffix": "px", "precision": 0 }
|
|
292
|
+
}
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### select 与 selectCard
|
|
296
|
+
|
|
297
|
+
两者都要 `config.options`。还可以写 `allowInput`(允许直接输入)和 `placeholder`。
|
|
298
|
+
|
|
299
|
+
`selectCard` 的选项多一个 `cover`,可以是图片绝对地址,也可以是平台上的相对地址,下拉项会带封面。
|
|
300
|
+
|
|
301
|
+
```json
|
|
302
|
+
{
|
|
303
|
+
"name": "shape",
|
|
304
|
+
"displayName": "形状",
|
|
305
|
+
"type": "select",
|
|
306
|
+
"value": "rect",
|
|
307
|
+
"config": {
|
|
308
|
+
"options": [
|
|
309
|
+
{ "name": "矩形", "value": "rect" },
|
|
310
|
+
{ "name": "圆形", "value": "circle" }
|
|
311
|
+
]
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
```json
|
|
317
|
+
{
|
|
318
|
+
"name": "cover",
|
|
319
|
+
"displayName": "封面",
|
|
320
|
+
"type": "selectCard",
|
|
321
|
+
"value": "option1",
|
|
322
|
+
"config": {
|
|
323
|
+
"options": [
|
|
324
|
+
{ "name": "选项一", "value": "option1", "cover": "https://example.com/a.jpg" },
|
|
325
|
+
{ "name": "选项二", "value": "option2", "cover": "template/a.jpg" }
|
|
326
|
+
]
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### radio
|
|
332
|
+
|
|
333
|
+
`config.options` 必填。项上可以带 `icon`,取值是图标库里的图标名或图片地址。`config.mode`:
|
|
334
|
+
|
|
335
|
+
| mode | 面板 |
|
|
336
|
+
| --- | --- |
|
|
337
|
+
| `normal` | 普通单选,默认 |
|
|
338
|
+
| `button` | 按钮 |
|
|
339
|
+
| `icon` | 只显示图标 |
|
|
340
|
+
|
|
341
|
+
对齐方式这类短选项适合 `icon`:`align-left`、`align-center`、`align-right`、`toward-top`、`toward-bottom`。
|
|
342
|
+
|
|
343
|
+
```json
|
|
344
|
+
{
|
|
345
|
+
"name": "textAlign",
|
|
346
|
+
"displayName": "水平对齐",
|
|
347
|
+
"type": "radio",
|
|
348
|
+
"value": "left",
|
|
349
|
+
"config": {
|
|
350
|
+
"mode": "icon",
|
|
351
|
+
"options": [
|
|
352
|
+
{ "name": "左对齐", "value": "left", "icon": "align-left" },
|
|
353
|
+
{ "name": "居中", "value": "center", "icon": "align-center" },
|
|
354
|
+
{ "name": "右对齐", "value": "right", "icon": "align-right" }
|
|
355
|
+
]
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
### checkbox
|
|
361
|
+
|
|
362
|
+
`value` 是选中值的数组。官方字段表写的是 `string[]`,示例却给了一个字符串。按字段表写成数组。
|
|
363
|
+
|
|
364
|
+
```json
|
|
365
|
+
{
|
|
366
|
+
"name": "position",
|
|
367
|
+
"displayName": "位置",
|
|
368
|
+
"type": "checkbox",
|
|
369
|
+
"value": ["bottom"],
|
|
370
|
+
"config": {
|
|
371
|
+
"options": [
|
|
372
|
+
{ "name": "右", "value": "right" },
|
|
373
|
+
{ "name": "上", "value": "top" },
|
|
374
|
+
{ "name": "下", "value": "bottom" }
|
|
375
|
+
]
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
### boolean
|
|
381
|
+
|
|
382
|
+
`config.mode`:`normal`(默认)、`switch`、`icon`。`icon` 模式用 `config.icon` 指定图标名,例如 `bold`、`italic`。
|
|
383
|
+
|
|
384
|
+
```json
|
|
385
|
+
{
|
|
386
|
+
"name": "bold",
|
|
387
|
+
"displayName": "",
|
|
388
|
+
"type": "boolean",
|
|
389
|
+
"value": false,
|
|
390
|
+
"config": { "mode": "icon", "icon": "bold" }
|
|
391
|
+
}
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
### color、multicolor、rangeColor
|
|
395
|
+
|
|
396
|
+
`color` 的值是颜色字符串。`config.simple` 为真时只保留取色器。
|
|
397
|
+
|
|
398
|
+
`multicolor` 同时备着纯色和渐变,用 `value.type` 标明当前用哪一种。`linear.stops[].offset` 是色标位置,`angle` 是角度,`opacity` 是透明度。
|
|
399
|
+
|
|
400
|
+
```json
|
|
401
|
+
{
|
|
402
|
+
"name": "color",
|
|
403
|
+
"displayName": "颜色",
|
|
404
|
+
"type": "multicolor",
|
|
405
|
+
"value": {
|
|
406
|
+
"type": "pure",
|
|
407
|
+
"pure": "#ffffff",
|
|
408
|
+
"linear": {
|
|
409
|
+
"stops": [
|
|
410
|
+
{ "offset": 0, "color": "#ffffff" },
|
|
411
|
+
{ "offset": 100, "color": "#ff00ff" }
|
|
412
|
+
],
|
|
413
|
+
"angle": 0,
|
|
414
|
+
"opacity": 1
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
`rangeColor` 的值是 `{ "offset": number, "color": string }[]`,用来做从最小值到最大值的颜色映射。官方示例把它放进 `type: "group"`。
|
|
421
|
+
|
|
422
|
+
```json
|
|
423
|
+
{
|
|
424
|
+
"name": "rangeColor",
|
|
425
|
+
"displayName": "最小值 -> 最大值",
|
|
426
|
+
"type": "rangeColor",
|
|
427
|
+
"value": [
|
|
428
|
+
{ "offset": 0, "color": "#ffffff" },
|
|
429
|
+
{ "offset": 100, "color": "#000000" }
|
|
430
|
+
]
|
|
431
|
+
}
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
### range
|
|
435
|
+
|
|
436
|
+
`config.min` 和 `config.max` 必填。`step` 默认 1,还可以写 `prefix`、`suffix`。`value` 是一个数时为单滑块,是 `[number, number]` 时为区间。
|
|
437
|
+
|
|
438
|
+
```json
|
|
439
|
+
{
|
|
440
|
+
"name": "opacity",
|
|
441
|
+
"displayName": "透明度",
|
|
442
|
+
"type": "range",
|
|
443
|
+
"value": 10,
|
|
444
|
+
"config": { "min": 0, "max": 100, "step": 1, "suffix": "%" }
|
|
445
|
+
}
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
### font、area、grid、position
|
|
449
|
+
|
|
450
|
+
`font` 的值是字体名,列表由平台给出,例如 `"Microsoft Yahei"`。
|
|
451
|
+
|
|
452
|
+
`area` 的值是行政区划代码。官方示例是 `"100000"`。
|
|
453
|
+
|
|
454
|
+
`grid` 的 `config.options` 是长度为 9 的字符串数组,按行从左到右、从上到下对应九个锚点。某一项写成 `""` 时,该格不显示点。`value` 取当前选中的那一项,例如 `"center center"`。
|
|
455
|
+
|
|
456
|
+
```json
|
|
457
|
+
{
|
|
458
|
+
"name": "anchor",
|
|
459
|
+
"displayName": "锚点",
|
|
460
|
+
"type": "grid",
|
|
461
|
+
"value": "center center",
|
|
462
|
+
"config": {
|
|
463
|
+
"options": [
|
|
464
|
+
"left top", "center top", "right top",
|
|
465
|
+
"left center", "center center", "right center",
|
|
466
|
+
"left bottom", "center bottom", "right bottom"
|
|
467
|
+
]
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
`position` 的值是 `[x, y]`,两个数都在 0 到 1 之间。
|
|
473
|
+
|
|
474
|
+
```json
|
|
475
|
+
{
|
|
476
|
+
"name": "origin",
|
|
477
|
+
"displayName": "位置",
|
|
478
|
+
"type": "position",
|
|
479
|
+
"value": [0.5, 0.5]
|
|
480
|
+
}
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
### shadow 与 textStyle
|
|
484
|
+
|
|
485
|
+
文字阴影不写 `spread`。形状阴影需要扩散时加上 `spread`。
|
|
486
|
+
|
|
487
|
+
```json
|
|
488
|
+
{
|
|
489
|
+
"name": "shadow",
|
|
490
|
+
"displayName": "文本阴影",
|
|
491
|
+
"type": "shadow",
|
|
492
|
+
"value": { "color": "#ffffff", "hShadow": -10, "vShadow": 8, "blur": 8 }
|
|
493
|
+
}
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
```json
|
|
497
|
+
{
|
|
498
|
+
"name": "textStyle",
|
|
499
|
+
"displayName": "文本样式",
|
|
500
|
+
"type": "textStyle",
|
|
501
|
+
"value": {
|
|
502
|
+
"fontFamily": "Microsoft Yahei",
|
|
503
|
+
"fontSize": 24,
|
|
504
|
+
"color": "#ffffff",
|
|
505
|
+
"bold": true,
|
|
506
|
+
"italic": false,
|
|
507
|
+
"letterSpacing": 0,
|
|
508
|
+
"lineHeight": 32
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
同一组样式如果要拆开控制间距,也可以不用 `textStyle`,改用 `type: "group"` 把 `font`、`number`、`multicolor`、`boolean` 排在一行。见下文。
|
|
514
|
+
|
|
515
|
+
### 上传
|
|
516
|
+
|
|
517
|
+
`image`、`video`、`audio` 的 `value` 是 OpenAPI `uploadAsset`(`POST /api/easyv/open/v1/assets`)返回的相对路径 `path`。组件内用 `window.appConfig.ASSETS_URL` 拼接,见 [assets.md](assets.md)。`config.accept` 是字符串数组,写法与 HTML 文件输入的 `accept` 相同,用来收窄类型。不写时分别对应 `image/*`、`video/*`、`audio/*`。
|
|
518
|
+
|
|
519
|
+
```json
|
|
520
|
+
{
|
|
521
|
+
"name": "background",
|
|
522
|
+
"displayName": "背景图",
|
|
523
|
+
"type": "image",
|
|
524
|
+
"value": "spaces/10/openapi-assets/202611/Ab3xYz9kQ2LmNoPq.png",
|
|
525
|
+
"config": { "accept": ["image/png", "image/jpeg"] }
|
|
526
|
+
}
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
`uploadModel` 用于模型。文档列出的扩展名:`glb`、`gltf`、`fbx`、`obj`、`stl`、`dae`、`3dm`、`3ds`、`3mf`、`amf`、`pmd`、`vmd`、`vpd`、`ply`、`vrm`、`wrl`、`b3dm`、`osgb`。
|
|
530
|
+
|
|
531
|
+
`model` 不限制文件类型,适合 `json`、`mtl` 以及其他资源。
|
|
532
|
+
|
|
533
|
+
```json
|
|
534
|
+
{ "name": "modelFile", "displayName": "模型", "type": "uploadModel", "value": "" }
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
### json 与 jscode
|
|
538
|
+
|
|
539
|
+
值都是字符串。`json` 存一份 JSON 文本,`jscode` 存 JavaScript 源码。`config.showGutter` 为真时编辑器显示行号,默认不显示。两种控件都支持全屏编辑。
|
|
540
|
+
|
|
541
|
+
```json
|
|
542
|
+
{
|
|
543
|
+
"name": "formatter",
|
|
544
|
+
"displayName": "格式化",
|
|
545
|
+
"type": "jscode",
|
|
546
|
+
"value": "return value",
|
|
547
|
+
"config": { "showGutter": true }
|
|
548
|
+
}
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
### array 系列
|
|
552
|
+
|
|
553
|
+
用户可以按模板新增多份配置,每份的值互不影响。`config.template` 是新增一项时复制的那份配置。`config.defaultCollapsed` 默认 `true`,系列项默认折叠。
|
|
554
|
+
|
|
555
|
+
```json
|
|
556
|
+
{
|
|
557
|
+
"name": "series",
|
|
558
|
+
"displayName": "数据系列",
|
|
559
|
+
"type": "array",
|
|
560
|
+
"value": [
|
|
561
|
+
{
|
|
562
|
+
"name": "series1",
|
|
563
|
+
"displayName": "系列",
|
|
564
|
+
"value": [
|
|
565
|
+
{ "name": "name", "displayName": "名称", "type": "input", "value": "系列一" },
|
|
566
|
+
{ "name": "color", "displayName": "颜色", "type": "color", "value": "#3ba0ff" }
|
|
567
|
+
]
|
|
568
|
+
}
|
|
569
|
+
],
|
|
570
|
+
"config": {
|
|
571
|
+
"template": {
|
|
572
|
+
"name": "seriesItem",
|
|
573
|
+
"displayName": "系列",
|
|
574
|
+
"value": [
|
|
575
|
+
{ "name": "name", "displayName": "名称", "type": "input", "value": "系列" },
|
|
576
|
+
{ "name": "color", "displayName": "颜色", "type": "color", "value": "#3ba0ff" }
|
|
577
|
+
]
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
### 同行成组 group
|
|
584
|
+
|
|
585
|
+
外层 `type` 设为 `"group"` 后,`value` 里的子项排在同一行。子项只能是原子控件,不能再套分组或系列。子项的 `config.span` 是它在这一行里的占比,官方示例按 24 栅格分配,两项各一半就各写 `12`。
|
|
586
|
+
|
|
587
|
+
在成组配置上设置 `config.lock` 后,组内的两个 `number` 可以按比例锁定。
|
|
588
|
+
|
|
589
|
+
```json
|
|
590
|
+
{
|
|
591
|
+
"name": "padding",
|
|
592
|
+
"displayName": "边距",
|
|
593
|
+
"type": "group",
|
|
594
|
+
"value": [
|
|
595
|
+
{ "name": "x", "displayName": "水平", "type": "number", "value": 12, "config": { "span": 12, "suffix": "px" } },
|
|
596
|
+
{ "name": "y", "displayName": "垂直", "type": "number", "value": 8, "config": { "span": 12, "suffix": "px" } }
|
|
597
|
+
]
|
|
598
|
+
}
|
|
599
|
+
```
|
|
600
|
+
|
|
601
|
+
`imgSize` 是专门的宽高控件。`value` 固定两项 `number`,外层 `config.lock` 锁定宽高比。子项的 `config` 与 `number` 相同。
|
|
602
|
+
|
|
603
|
+
```json
|
|
604
|
+
{
|
|
605
|
+
"name": "imgSize",
|
|
606
|
+
"displayName": "图片尺寸",
|
|
607
|
+
"type": "imgSize",
|
|
608
|
+
"config": { "lock": true },
|
|
609
|
+
"value": [
|
|
610
|
+
{ "name": "width", "displayName": "宽度", "type": "number", "value": 45, "config": { "suffix": "px" } },
|
|
611
|
+
{ "name": "height", "displayName": "高度", "type": "number", "value": 45, "config": { "suffix": "px" } }
|
|
612
|
+
]
|
|
613
|
+
}
|
|
614
|
+
```
|
|
615
|
+
|
|
616
|
+
### remoteOptions
|
|
617
|
+
|
|
618
|
+
平台控件,用来遥控另一块大屏上已经配好的自定义事件,或把回调值送进那块大屏。普通样式配置不要用它。`value` 是 JSON 字符串,结构为:
|
|
619
|
+
|
|
620
|
+
| 字段 | 说明 |
|
|
621
|
+
| --- | --- |
|
|
622
|
+
| `type` | `"event"` 或 `"callback"` |
|
|
623
|
+
| `screen` | 目标大屏,如 `"$screen(1)"` |
|
|
624
|
+
| `component` | 事件类型下选中的组件,如 `"$component(1)"` |
|
|
625
|
+
| `event` | 事件类型下,目标组件上已有的自定义事件 |
|
|
626
|
+
|
|
627
|
+
事件对象里常见字段:`type`(触发类型,如 `click`)、`action`(如 `show`、`hide`)、`component`(受控组件)、`panel`(动态面板或引用面板,含 `panelId`、`stateId`)。
|
|
628
|
+
|
|
629
|
+
组件在配置里的引用形式:
|
|
630
|
+
|
|
631
|
+
| 对象 | 形式 |
|
|
632
|
+
| --- | --- |
|
|
633
|
+
| 组件 | `$component(1)` |
|
|
634
|
+
| 分组 | `$group(group_1)` |
|
|
635
|
+
| 动态面板 | `$panel(panel_341)` |
|
|
636
|
+
| 引用面板 | `$panel(ref_1)` |
|
|
637
|
+
| 面板状态 | `$state(1)` |
|
|
638
|
+
|
|
639
|
+
```json
|
|
640
|
+
{
|
|
641
|
+
"name": "remote",
|
|
642
|
+
"displayName": "远程控制",
|
|
643
|
+
"type": "remoteOptions",
|
|
644
|
+
"value": "{\"type\":\"callback\",\"screen\":\"$screen(1)\"}"
|
|
645
|
+
}
|
|
646
|
+
```
|
|
647
|
+
|
|
648
|
+
## 怎么选
|
|
649
|
+
|
|
650
|
+
- 给用户改的短文本用 `input`,只在面板里展示的用 `text`。
|
|
651
|
+
- 互斥选项用 `radio` 或 `select`。选项多,或允许直接输入时,用 `select`。选项需要预览图时用 `selectCard`。可以同时选多个用 `checkbox`。
|
|
652
|
+
- 开或关用 `boolean`。某项只在别的配置取特定值时才有意义,用 `rule` 控制它在面板里的显隐。
|
|
653
|
+
- 纯色用 `color`。纯色和渐变都要支持时用 `multicolor`。数值到颜色的映射用 `rangeColor`。
|
|
654
|
+
- 同一类样式要重复多份,并且允许用户新增、删除时,用 `array`。
|
|
655
|
+
- 面板上要分成几大块时用纵向分组。块很多、需要顶部分类时用横向 Tab。
|