mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-12-15 03:26:57 +08:00
fix(tmagic-form): runtime刷新导致root丢失
This commit is contained in:
parent
83664cd440
commit
d039cee913
@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "1.1.3",
|
||||
"version": "1.1.4",
|
||||
"name": "@tmagic/tmagic-form-runtime",
|
||||
"type": "module",
|
||||
"main": "dist/tmagic-form-runtime.umd.cjs",
|
||||
|
||||
@ -12,7 +12,7 @@ import { useFormConfig } from './useFormConfig';
|
||||
|
||||
const props = defineProps<AppProps>();
|
||||
|
||||
const { mForm, formConfig, config, values } = useFormConfig(props);
|
||||
const { formConfig, config, values } = useFormConfig(props);
|
||||
|
||||
watch(formConfig, async () => {
|
||||
setTimeout(() => {
|
||||
|
||||
@ -73,8 +73,15 @@ export const useFormConfig = (props: AppProps) => {
|
||||
return nextTick().then(() => getElById()(document, `${id}`) as HTMLElement);
|
||||
},
|
||||
|
||||
add({ config, parentId }: UpdateData) {
|
||||
if (!root.value) throw new Error('error');
|
||||
add({ config, parentId, root: appConfig }: UpdateData) {
|
||||
if (!root.value) {
|
||||
if (appConfig) {
|
||||
root.value = appConfig;
|
||||
resetValues();
|
||||
return;
|
||||
}
|
||||
throw new Error('error');
|
||||
}
|
||||
if (!selectedId.value) throw new Error('error');
|
||||
if (!parentId) throw new Error('error');
|
||||
|
||||
@ -97,8 +104,17 @@ export const useFormConfig = (props: AppProps) => {
|
||||
resetValues();
|
||||
},
|
||||
|
||||
update({ config, parentId }: UpdateData) {
|
||||
if (!root.value || !app) throw new Error('error');
|
||||
update({ config, parentId, root: appConfig }: UpdateData) {
|
||||
if (!root.value) {
|
||||
if (appConfig) {
|
||||
root.value = appConfig;
|
||||
resetValues();
|
||||
return;
|
||||
}
|
||||
throw new Error('error');
|
||||
}
|
||||
|
||||
if (!app) throw new Error('error');
|
||||
|
||||
const newNode = app.dataSourceManager?.compiledNode(config) || config;
|
||||
replaceChildNode(reactive(newNode), [root.value], parentId);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user