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",
|
"name": "@tmagic/tmagic-form-runtime",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/tmagic-form-runtime.umd.cjs",
|
"main": "dist/tmagic-form-runtime.umd.cjs",
|
||||||
|
|||||||
@ -12,7 +12,7 @@ import { useFormConfig } from './useFormConfig';
|
|||||||
|
|
||||||
const props = defineProps<AppProps>();
|
const props = defineProps<AppProps>();
|
||||||
|
|
||||||
const { mForm, formConfig, config, values } = useFormConfig(props);
|
const { formConfig, config, values } = useFormConfig(props);
|
||||||
|
|
||||||
watch(formConfig, async () => {
|
watch(formConfig, async () => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|||||||
@ -73,8 +73,15 @@ export const useFormConfig = (props: AppProps) => {
|
|||||||
return nextTick().then(() => getElById()(document, `${id}`) as HTMLElement);
|
return nextTick().then(() => getElById()(document, `${id}`) as HTMLElement);
|
||||||
},
|
},
|
||||||
|
|
||||||
add({ config, parentId }: UpdateData) {
|
add({ config, parentId, root: appConfig }: UpdateData) {
|
||||||
if (!root.value) throw new Error('error');
|
if (!root.value) {
|
||||||
|
if (appConfig) {
|
||||||
|
root.value = appConfig;
|
||||||
|
resetValues();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw new Error('error');
|
||||||
|
}
|
||||||
if (!selectedId.value) throw new Error('error');
|
if (!selectedId.value) throw new Error('error');
|
||||||
if (!parentId) throw new Error('error');
|
if (!parentId) throw new Error('error');
|
||||||
|
|
||||||
@ -97,8 +104,17 @@ export const useFormConfig = (props: AppProps) => {
|
|||||||
resetValues();
|
resetValues();
|
||||||
},
|
},
|
||||||
|
|
||||||
update({ config, parentId }: UpdateData) {
|
update({ config, parentId, root: appConfig }: UpdateData) {
|
||||||
if (!root.value || !app) throw new Error('error');
|
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;
|
const newNode = app.dataSourceManager?.compiledNode(config) || config;
|
||||||
replaceChildNode(reactive(newNode), [root.value], parentId);
|
replaceChildNode(reactive(newNode), [root.value], parentId);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user