Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
嗨向前出发
form-render
提交
9cc591f0
F
form-render
项目概览
嗨向前出发
/
form-render
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
form-render
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
9cc591f0
编写于
5月 27, 2021
作者:
F
F-loat
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(generator): baseSettings for array
上级
0773790e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
50 addition
and
19 deletion
+50
-19
docs/tools/generator/demo/settings.jsx
docs/tools/generator/demo/settings.jsx
+20
-7
tools/schema-generator/src/Right/ItemSettings.js
tools/schema-generator/src/Right/ItemSettings.js
+23
-11
tools/schema-generator/src/Settings/index.js
tools/schema-generator/src/Settings/index.js
+1
-1
tools/schema-generator/src/utils.js
tools/schema-generator/src/utils.js
+6
-0
未找到文件。
docs/tools/generator/demo/settings.jsx
浏览文件 @
9cc591f0
...
...
@@ -32,6 +32,17 @@ const Demo = () => {
api
:
{
title
:
'
api
'
,
type
:
'
string
'
},
},
},
{
text
:
'
姓名
'
,
name
:
'
name
'
,
schema
:
{
title
:
'
输入框
'
,
type
:
'
string
'
,
},
setting
:
{
maxLength
:
{
title
:
'
最长字数
'
,
type
:
'
number
'
},
},
},
{
text
:
'
object
'
,
name
:
'
object
'
,
...
...
@@ -43,15 +54,17 @@ const Demo = () => {
setting
:
{},
},
{
text
:
'
姓名
'
,
name
:
'
name
'
,
text
:
'
array
'
,
name
:
'
array
'
,
schema
:
{
title
:
'
输入框
'
,
type
:
'
string
'
,
},
setting
:
{
maxLength
:
{
title
:
'
最长字数
'
,
type
:
'
number
'
},
title
:
'
数组
'
,
type
:
'
array
'
,
items
:
{
type
:
'
object
'
,
properties
:
{},
},
},
setting
:
{},
},
],
},
...
...
tools/schema-generator/src/Right/ItemSettings.js
浏览文件 @
9cc591f0
...
...
@@ -39,14 +39,28 @@ export default function ItemSettings() {
const
getWidgetList
=
(
settings
,
commonSettings
)
=>
{
return
settings
.
reduce
((
widgetList
,
setting
)
=>
{
if
(
!
Array
.
isArray
(
setting
.
widgets
))
return
widgetList
;
const
basicWidgets
=
setting
.
widgets
.
map
(
item
=>
({
...
item
,
widget
:
item
.
widget
||
item
.
schema
.
widget
||
getWidgetName
(
item
.
schema
,
defaultMapping
),
setting
:
{
...
commonSettings
,
...
item
.
setting
},
}));
const
basicWidgets
=
setting
.
widgets
.
map
(
item
=>
{
const
baseItemSettings
=
{};
if
(
item
.
schema
.
type
===
'
array
'
)
{
baseItemSettings
.
items
=
{
type
:
'
object
'
,
hidden
:
'
{{true}}
'
,
};
}
return
{
...
item
,
widget
:
item
.
widget
||
item
.
schema
.
widget
||
getWidgetName
(
item
.
schema
,
defaultMapping
),
setting
:
{
...
baseCommonSettings
,
...
commonSettings
,
...
baseItemSettings
,
...
item
.
setting
,
},
};
});
return
[...
widgetList
,
...
basicWidgets
];
},
[]);
};
...
...
@@ -82,9 +96,7 @@ export default function ItemSettings() {
const
_commonSettings
=
isObject
(
commonSettings
)
?
commonSettings
:
defaultCommonSettings
;
// 补全基础属性
const
_fixedCommonSettings
=
{
...
baseCommonSettings
,
...
_commonSettings
};
const
widgetList
=
getWidgetList
(
_settings
,
_fixedCommonSettings
);
const
widgetList
=
getWidgetList
(
_settings
,
_commonSettings
);
const
widgetName
=
getWidgetName
(
item
.
schema
,
defaultMapping
);
const
element
=
widgetList
.
find
(
e
=>
e
.
widget
===
widgetName
)
||
{};
// 有可能会没有找到
const
properties
=
{
...
element
.
setting
};
...
...
tools/schema-generator/src/Settings/index.js
浏览文件 @
9cc591f0
...
...
@@ -445,7 +445,7 @@ export const advancedElements = [
export
const
layouts
=
[
{
text
:
'
object
'
,
text
:
'
对象
'
,
name
:
'
object
'
,
schema
:
{
title
:
'
对象
'
,
...
...
tools/schema-generator/src/utils.js
浏览文件 @
9cc591f0
...
...
@@ -228,6 +228,12 @@ export function idToSchema(flatten, id = '#', final = false) {
if
(
final
)
{
schema
.
$id
&&
delete
schema
.
$id
;
}
if
(
schema
.
type
===
'
array
'
)
{
if
(
!
schema
.
items
)
schema
.
items
=
{}
if
(
!
schema
.
items
.
type
)
{
schema
.
items
.
type
=
'
object
'
}
}
if
(
item
.
children
.
length
>
0
)
{
item
.
children
.
forEach
(
child
=>
{
let
childId
=
child
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录