mirror of https://github.com/halo-dev/halo
fix: default value of formkit schema is not initialize in annotation form (halo-dev/console#880)
#### What type of PR is this? /kind bug /milestone 2.3.x /area console #### What this PR does / why we need it: #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/3357 #### Special notes for your reviewer: 测试使用主题/插件自定义的元数据信息,是否能够在 console 中显示默认值。 #### Does this PR introduce a user-facing change? ```release-note 使用主题/插件配置的元数据将能够展示默认值 ```pull/3445/head
parent
fbcd6bf037
commit
2dba8d0dbb
|
@ -100,22 +100,23 @@ const handleProcessCustomAnnotations = () => {
|
||||||
})
|
})
|
||||||
.filter((item) => item) as { key: string; value: string }[];
|
.filter((item) => item) as { key: string; value: string }[];
|
||||||
|
|
||||||
annotations.value = Object.entries(props.value || {})
|
annotations.value = formSchemas
|
||||||
.map(([key, value]) => {
|
.map((item) => {
|
||||||
const fromThemeSpec = formSchemas.some((item) => {
|
|
||||||
if (typeof item === "object" && "$formkit" in item) {
|
if (typeof item === "object" && "$formkit" in item) {
|
||||||
return item.name === key;
|
if (props.value && item.name in props.value) {
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
if (fromThemeSpec) {
|
|
||||||
return {
|
return {
|
||||||
key,
|
key: item.name,
|
||||||
value,
|
value: props.value[item.name],
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
key: item.name,
|
||||||
|
value: item.value,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.filter((item) => item)
|
.filter(Boolean)
|
||||||
.reduce((acc, cur) => {
|
.reduce((acc, cur) => {
|
||||||
if (cur) {
|
if (cur) {
|
||||||
acc[cur.key] = cur.value;
|
acc[cur.key] = cur.value;
|
||||||
|
|
Loading…
Reference in New Issue