mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2026-03-23 05:52:25 +00:00
fix(core,data-source): 多个页面片容器引用同一个页面片时,其他有未渲染的页面片容器时会导致数据源编译后数据无法更新
This commit is contained in:
parent
f6bd647958
commit
0bbafa153d
@ -16,6 +16,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { cloneDeep } from 'lodash-es';
|
||||||
|
|
||||||
import type { Id, MComponent, MContainer, MPage, MPageFragment } from '@tmagic/schema';
|
import type { Id, MComponent, MContainer, MPage, MPageFragment } from '@tmagic/schema';
|
||||||
|
|
||||||
import App from './App';
|
import App from './App';
|
||||||
@ -70,7 +72,7 @@ class Page extends Node {
|
|||||||
this.app.pageFragments.set(
|
this.app.pageFragments.set(
|
||||||
config.id,
|
config.id,
|
||||||
new Page({
|
new Page({
|
||||||
config: pageFragment,
|
config: cloneDeep(pageFragment),
|
||||||
app: this.app,
|
app: this.app,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import { union } from 'lodash-es';
|
import { cloneDeep, union } from 'lodash-es';
|
||||||
|
|
||||||
import type { default as TMagicApp } from '@tmagic/core';
|
import type { default as TMagicApp } from '@tmagic/core';
|
||||||
import { getDepNodeIds, getNodes, isPage, isPageFragment, replaceChildNode } from '@tmagic/core';
|
import { getDepNodeIds, getNodes, isPage, isPageFragment, replaceChildNode } from '@tmagic/core';
|
||||||
@ -82,11 +82,11 @@ export const createDataSourceManager = (app: TMagicApp, useMock?: boolean, initi
|
|||||||
|
|
||||||
for (const [, pageFragment] of app.pageFragments) {
|
for (const [, pageFragment] of app.pageFragments) {
|
||||||
if (pageFragment.data.id === newNode.id) {
|
if (pageFragment.data.id === newNode.id) {
|
||||||
pageFragment.setData(newNode);
|
pageFragment.setData(cloneDeep(newNode));
|
||||||
} else if (pageFragment.data.id === page.id) {
|
} else if (pageFragment.data.id === page.id) {
|
||||||
pageFragment.getNode(newNode.id, { strict: true })?.setData(newNode);
|
pageFragment.getNode(newNode.id, { strict: true })?.setData(cloneDeep(newNode));
|
||||||
if (!pageFragment.instance) {
|
if (!pageFragment.instance) {
|
||||||
replaceChildNode(newNode, [pageFragment.data]);
|
replaceChildNode(cloneDeep(newNode), [pageFragment.data]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user