Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support chagne the ui form to yaml editor #172

Merged
merged 1 commit into from
Oct 11, 2024
Merged

Conversation

MrWindlike
Copy link
Collaborator

@MrWindlike MrWindlike commented Sep 23, 2024

支持表单模式转换为 YAML 编辑模式。

表单 -> YAML

将表单当前值作为初始值赋给 YAML 编辑器,并在提交时进行 YAML 格式、Schema 和自定义逻辑校验。

YAML -> 表单

会提示转换为表单后 YAML 编辑器所填内容会丢失,转换后会回到之前表单所填写的值。

主要代码在 useYamlForm。

image

image

image

image

@MrWindlike MrWindlike marked this pull request as ready for review October 10, 2024 09:00
const slug = slugify(cssText);

const cssFilename = path
.normalize(`${id.replace(/\.[jt]sx?$/, '')}_${slug}.${extension}`)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

修改 linaria vite 插件以支持使用 scss 变量

@MrWindlike MrWindlike requested a review from tanbowensg October 10, 2024 09:02
}, [schema, editorOptions?.isGenerateAnnotations, initialValues, schemas, useResourceResult.resource?.name, editorErrors, action, fold]);
}, [schema, editorOptions?.isGenerateAnnotations, initialValues, schemas, useResourceResult.resource?.name, editorErrors, action, finalErrors, fold]);

React.useEffect(() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这段逻辑或许可以放在onMutationError里?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

const action = useMemo(
() => actionFromProps || useResourceResult.action,
[actionFromProps, useResourceResult.action]
);
const initialValues = useMemo(() => {
const initialValues =
(queryResult?.data?.data
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的逻辑是不是应该改成通过action判断?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已加上 action 的判断

@tanbowensg tanbowensg merged commit 4d87ed9 into main Oct 11, 2024
1 check passed
@tanbowensg tanbowensg deleted the feat/form-switch branch October 11, 2024 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants