tmagic-editor/docs/guide/runtime.html
2025-03-31 12:39:00 +00:00

26 lines
35 KiB
HTML
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en-US" dir="ltr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>RUNTIME | tmagic-editor</title>
<meta name="description" content="页面可视化平台">
<meta name="generator" content="VitePress v1.6.3">
<link rel="preload stylesheet" href="/tmagic-editor/docs/assets/style.D3lBSx2e.css" as="style">
<link rel="preload stylesheet" href="/tmagic-editor/docs/vp-icons.css" as="style">
<script type="module" src="/tmagic-editor/docs/assets/app.CTxZuwPV.js"></script>
<link rel="preload" href="/tmagic-editor/docs/assets/inter-roman-latin.Di8DUHzh.woff2" as="font" type="font/woff2" crossorigin="">
<link rel="modulepreload" href="/tmagic-editor/docs/assets/chunks/theme.CgftMYhc.js">
<link rel="modulepreload" href="/tmagic-editor/docs/assets/chunks/framework.BCBheFgR.js">
<link rel="modulepreload" href="/tmagic-editor/docs/assets/guide_runtime.md.DXMc06eN.lean.js">
<meta name="theme-color" content="#646cff">
<script id="check-dark-mode">(()=>{const e=localStorage.getItem("vitepress-theme-appearance")||"auto",a=window.matchMedia("(prefers-color-scheme: dark)").matches;(!e||e==="auto"?a:e==="dark")&&document.documentElement.classList.add("dark")})();</script>
<script id="check-mac-os">document.documentElement.classList.toggle("mac",/Mac|iPhone|iPod|iPad/i.test(navigator.platform));</script>
</head>
<body>
<div id="app"><div class="Layout" data-v-6dfe06bb><!--[--><!--]--><!--[--><span tabindex="-1" data-v-ae2ac445></span><a href="#VPContent" class="VPSkipLink visually-hidden" data-v-ae2ac445>Skip to content</a><!--]--><!----><header class="VPNav" data-v-6dfe06bb data-v-77ceb46e><div class="VPNavBar" data-v-77ceb46e data-v-90d7d232><div class="wrapper" data-v-90d7d232><div class="container" data-v-90d7d232><div class="title" data-v-90d7d232><div class="VPNavBarTitle has-sidebar" data-v-90d7d232 data-v-53247a16><a class="title" href="/tmagic-editor/docs/" data-v-53247a16><!--[--><!--]--><!--[--><img class="VPImage logo" src="./favicon.png" alt data-v-d81a7e16><!--]--><span data-v-53247a16>tmagic-editor</span><!--[--><!--]--></a></div></div><div class="content" data-v-90d7d232><div class="content-body" data-v-90d7d232><!--[--><!--]--><div class="VPNavBarSearch search" data-v-90d7d232><!--[--><!----><div id="local-search"><button type="button" class="DocSearch DocSearch-Button" aria-label="Search"><span class="DocSearch-Button-Container"><span class="vp-icon DocSearch-Search-Icon"></span><span class="DocSearch-Button-Placeholder">Search</span></span><span class="DocSearch-Button-Keys"><kbd class="DocSearch-Button-Key"></kbd><kbd class="DocSearch-Button-Key">K</kbd></span></button></div><!--]--></div><nav aria-labelledby="main-nav-aria-label" class="VPNavBarMenu menu" data-v-90d7d232 data-v-3bf1ab04><span id="main-nav-aria-label" class="visually-hidden" data-v-3bf1ab04> Main Navigation </span><!--[--><!--[--><a class="VPLink link VPNavBarMenuLink active" href="/tmagic-editor/docs/guide/" tabindex="0" data-v-3bf1ab04 data-v-3536d535><!--[--><span data-v-3536d535>文档</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/tmagic-editor/docs/api/editor/props.html" tabindex="0" data-v-3bf1ab04 data-v-3536d535><!--[--><span data-v-3536d535>API</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/tmagic-editor/docs/form-config/fields/text.html" tabindex="0" data-v-3bf1ab04 data-v-3536d535><!--[--><span data-v-3536d535>表单配置</span><!--]--></a><!--]--><!--[--><a class="VPLink link vp-external-link-icon VPNavBarMenuLink" href="https://github.com/Tencent/tmagic-editor/releases" target="_blank" rel="noreferrer" tabindex="0" data-v-3bf1ab04 data-v-3536d535><!--[--><span data-v-3536d535>更新日志</span><!--]--></a><!--]--><!--[--><a class="VPLink link vp-external-link-icon VPNavBarMenuLink" href="https://tencent.github.io/tmagic-editor/playground/index.html" target="_blank" rel="noreferrer" tabindex="0" data-v-3bf1ab04 data-v-3536d535><!--[--><span data-v-3536d535>Playground</span><!--]--></a><!--]--><!--]--></nav><!----><div class="VPNavBarAppearance appearance" data-v-90d7d232 data-v-c02c67ee><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title aria-checked="false" data-v-c02c67ee data-v-1920dc4a data-v-9de62149><span class="check" data-v-9de62149><span class="icon" data-v-9de62149><!--[--><span class="vpi-sun sun" data-v-1920dc4a></span><span class="vpi-moon moon" data-v-1920dc4a></span><!--]--></span></span></button></div><div class="VPSocialLinks VPNavBarSocialLinks social-links" data-v-90d7d232 data-v-8c084606 data-v-9ea5b2de><!--[--><a class="VPSocialLink no-icon" href="https://github.com/Tencent/tmagic-editor" aria-label="github" target="_blank" rel="noopener" data-v-9ea5b2de data-v-fbc8ca05><span class="vpi-social-github"></span></a><!--]--></div><div class="VPFlyout VPNavBarExtra extra" data-v-90d7d232 data-v-600d423b data-v-09c9f8b4><button type="button" class="button" aria-haspopup="true" aria-expanded="false" aria-label="extra navigation" data-v-09c9f8b4><span class="vpi-more-horizontal icon" data-v-09c9f8b4></span></button><div class="menu" data-v-09c9f8b4><div class="VPMenu" data-v-09c9f8b4 data-v-813f2462><!----><!--[--><!--[--><!----><div class="group" data-v-600d423b><div class="item appearance" data-v-600d423b><p class="label" data-v-600d423b>Appearance</p><div class="appearance-action" data-v-600d423b><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title aria-checked="false" data-v-600d423b data-v-1920dc4a data-v-9de62149><span class="check" data-v-9de62149><span class="icon" data-v-9de62149><!--[--><span class="vpi-sun sun" data-v-1920dc4a></span><span class="vpi-moon moon" data-v-1920dc4a></span><!--]--></span></span></button></div></div></div><div class="group" data-v-600d423b><div class="item social-links" data-v-600d423b><div class="VPSocialLinks social-links-list" data-v-600d423b data-v-9ea5b2de><!--[--><a class="VPSocialLink no-icon" href="https://github.com/Tencent/tmagic-editor" aria-label="github" target="_blank" rel="noopener" data-v-9ea5b2de data-v-fbc8ca05><span class="vpi-social-github"></span></a><!--]--></div></div></div><!--]--><!--]--></div></div></div><!--[--><!--]--><button type="button" class="VPNavBarHamburger hamburger" aria-label="mobile navigation" aria-expanded="false" aria-controls="VPNavScreen" data-v-90d7d232 data-v-fe1766e7><span class="container" data-v-fe1766e7><span class="top" data-v-fe1766e7></span><span class="middle" data-v-fe1766e7></span><span class="bottom" data-v-fe1766e7></span></span></button></div></div></div></div><div class="divider" data-v-90d7d232><div class="divider-line" data-v-90d7d232></div></div></div><!----></header><div class="VPLocalNav has-sidebar empty" data-v-6dfe06bb data-v-38fd278f><div class="container" data-v-38fd278f><button class="menu" aria-expanded="false" aria-controls="VPSidebarNav" data-v-38fd278f><span class="vpi-align-left menu-icon" data-v-38fd278f></span><span class="menu-text" data-v-38fd278f>Menu</span></button><div class="VPLocalNavOutlineDropdown" style="--vp-vh:0px;" data-v-38fd278f data-v-0096f25c><button data-v-0096f25c>Return to top</button><!----></div></div></div><aside class="VPSidebar" data-v-6dfe06bb data-v-99b3c27c><div class="curtain" data-v-99b3c27c></div><nav class="nav" id="VPSidebarNav" aria-labelledby="sidebar-aria-label" tabindex="-1" data-v-99b3c27c><span class="visually-hidden" id="sidebar-aria-label" data-v-99b3c27c> Sidebar Navigation </span><!--[--><!--]--><!--[--><div class="no-transition group" data-v-30ef2553><section class="VPSidebarItem level-0 has-active" data-v-30ef2553 data-v-ca1de9d4><div class="item" role="button" tabindex="0" data-v-ca1de9d4><div class="indicator" data-v-ca1de9d4></div><h2 class="text" data-v-ca1de9d4>文档</h2><!----></div><div class="items" data-v-ca1de9d4><!--[--><div class="VPSidebarItem level-1 is-link" data-v-ca1de9d4 data-v-ca1de9d4><div class="item" data-v-ca1de9d4><div class="indicator" data-v-ca1de9d4></div><a class="VPLink link link" href="/tmagic-editor/docs/guide/introduction.html" data-v-ca1de9d4><!--[--><p class="text" data-v-ca1de9d4>介绍</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-ca1de9d4 data-v-ca1de9d4><div class="item" data-v-ca1de9d4><div class="indicator" data-v-ca1de9d4></div><a class="VPLink link link" href="/tmagic-editor/docs/guide/" data-v-ca1de9d4><!--[--><p class="text" data-v-ca1de9d4>快速开始</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-ca1de9d4 data-v-ca1de9d4><div class="item" data-v-ca1de9d4><div class="indicator" data-v-ca1de9d4></div><a class="VPLink link link" href="/tmagic-editor/docs/guide/conception.html" data-v-ca1de9d4><!--[--><p class="text" data-v-ca1de9d4>基础概念</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-ca1de9d4 data-v-ca1de9d4><div class="item" data-v-ca1de9d4><div class="indicator" data-v-ca1de9d4></div><a class="VPLink link link" href="/tmagic-editor/docs/guide/publish.html" data-v-ca1de9d4><!--[--><p class="text" data-v-ca1de9d4>页面发布</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-ca1de9d4 data-v-ca1de9d4><div class="item" data-v-ca1de9d4><div class="indicator" data-v-ca1de9d4></div><a class="VPLink link link" href="/tmagic-editor/docs/guide/runtime.html" data-v-ca1de9d4><!--[--><p class="text" data-v-ca1de9d4>RUNTIME</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-ca1de9d4 data-v-ca1de9d4><div class="item" data-v-ca1de9d4><div class="indicator" data-v-ca1de9d4></div><a class="VPLink link link" href="/tmagic-editor/docs/guide/component.html" data-v-ca1de9d4><!--[--><p class="text" data-v-ca1de9d4>组件开发</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-ca1de9d4 data-v-ca1de9d4><div class="item" data-v-ca1de9d4><div class="indicator" data-v-ca1de9d4></div><a class="VPLink link link" href="/tmagic-editor/docs/guide/editor-expand.html" data-v-ca1de9d4><!--[--><p class="text" data-v-ca1de9d4>编辑器扩展</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-ca1de9d4 data-v-ca1de9d4><div class="item" data-v-ca1de9d4><div class="indicator" data-v-ca1de9d4></div><a class="VPLink link link" href="/tmagic-editor/docs/guide/migration.html" data-v-ca1de9d4><!--[--><p class="text" data-v-ca1de9d4>升级到1.5.x</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="no-transition group" data-v-30ef2553><section class="VPSidebarItem level-0" data-v-30ef2553 data-v-ca1de9d4><div class="item" role="button" tabindex="0" data-v-ca1de9d4><div class="indicator" data-v-ca1de9d4></div><h2 class="text" data-v-ca1de9d4>进阶指南</h2><!----></div><div class="items" data-v-ca1de9d4><!--[--><div class="VPSidebarItem level-1 is-link" data-v-ca1de9d4 data-v-ca1de9d4><div class="item" data-v-ca1de9d4><div class="indicator" data-v-ca1de9d4></div><a class="VPLink link link" href="/tmagic-editor/docs/guide/advanced/js-schema.html" data-v-ca1de9d4><!--[--><p class="text" data-v-ca1de9d4>JS Schema</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-ca1de9d4 data-v-ca1de9d4><div class="item" data-v-ca1de9d4><div class="indicator" data-v-ca1de9d4></div><a class="VPLink link link" href="/tmagic-editor/docs/guide/advanced/layout.html" data-v-ca1de9d4><!--[--><p class="text" data-v-ca1de9d4>布局原理</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-ca1de9d4 data-v-ca1de9d4><div class="item" data-v-ca1de9d4><div class="indicator" data-v-ca1de9d4></div><a class="VPLink link link" href="/tmagic-editor/docs/guide/advanced/page.html" data-v-ca1de9d4><!--[--><p class="text" data-v-ca1de9d4>页面渲染</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-ca1de9d4 data-v-ca1de9d4><div class="item" data-v-ca1de9d4><div class="indicator" data-v-ca1de9d4></div><a class="VPLink link link" href="/tmagic-editor/docs/guide/advanced/coupling.html" data-v-ca1de9d4><!--[--><p class="text" data-v-ca1de9d4>联动原理</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-ca1de9d4 data-v-ca1de9d4><div class="item" data-v-ca1de9d4><div class="indicator" data-v-ca1de9d4></div><a class="VPLink link link" href="/tmagic-editor/docs/guide/advanced/code-block.html" data-v-ca1de9d4><!--[--><p class="text" data-v-ca1de9d4>代码块</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-ca1de9d4 data-v-ca1de9d4><div class="item" data-v-ca1de9d4><div class="indicator" data-v-ca1de9d4></div><a class="VPLink link link" href="/tmagic-editor/docs/guide/advanced/data-source.html" data-v-ca1de9d4><!--[--><p class="text" data-v-ca1de9d4>数据源</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-ca1de9d4 data-v-ca1de9d4><div class="item" data-v-ca1de9d4><div class="indicator" data-v-ca1de9d4></div><a class="VPLink link link" href="/tmagic-editor/docs/guide/advanced/tmagic-ui.html" data-v-ca1de9d4><!--[--><p class="text" data-v-ca1de9d4>@tmagic/ui</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-ca1de9d4 data-v-ca1de9d4><div class="item" data-v-ca1de9d4><div class="indicator" data-v-ca1de9d4></div><a class="VPLink link link" href="/tmagic-editor/docs/guide/advanced/tmagic-form.html" data-v-ca1de9d4><!--[--><p class="text" data-v-ca1de9d4>@tmagic/form</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="no-transition group" data-v-30ef2553><section class="VPSidebarItem level-0" data-v-30ef2553 data-v-ca1de9d4><div class="item" role="button" tabindex="0" data-v-ca1de9d4><div class="indicator" data-v-ca1de9d4></div><h2 class="text" data-v-ca1de9d4>教程</h2><!----></div><div class="items" data-v-ca1de9d4><!--[--><div class="VPSidebarItem level-1 is-link" data-v-ca1de9d4 data-v-ca1de9d4><div class="item" data-v-ca1de9d4><div class="indicator" data-v-ca1de9d4></div><a class="VPLink link link" href="/tmagic-editor/docs/guide/tutorial/" data-v-ca1de9d4><!--[--><p class="text" data-v-ca1de9d4>写在前面</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-ca1de9d4 data-v-ca1de9d4><div class="item" data-v-ca1de9d4><div class="indicator" data-v-ca1de9d4></div><a class="VPLink link link" href="/tmagic-editor/docs/guide/tutorial/hello-world.html" data-v-ca1de9d4><!--[--><p class="text" data-v-ca1de9d4>1.Hello World</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-ca1de9d4 data-v-ca1de9d4><div class="item" data-v-ca1de9d4><div class="indicator" data-v-ca1de9d4></div><a class="VPLink link link" href="/tmagic-editor/docs/guide/tutorial/runtime.html" data-v-ca1de9d4><!--[--><p class="text" data-v-ca1de9d4>2.Runtime</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-ca1de9d4 data-v-ca1de9d4><div class="item" data-v-ca1de9d4><div class="indicator" data-v-ca1de9d4></div><a class="VPLink link link" href="/tmagic-editor/docs/guide/tutorial/render.html" data-v-ca1de9d4><!--[--><p class="text" data-v-ca1de9d4>3.DSL解析渲染</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><!--]--><!--[--><!--]--></nav></aside><div class="VPContent has-sidebar" id="VPContent" data-v-6dfe06bb data-v-1b3f546a><div class="VPDoc has-sidebar has-aside" data-v-1b3f546a data-v-a5165e9c><!--[--><!--]--><div class="container" data-v-a5165e9c><div class="aside" data-v-a5165e9c><div class="aside-curtain" data-v-a5165e9c></div><div class="aside-container" data-v-a5165e9c><div class="aside-content" data-v-a5165e9c><div class="VPDocAside" data-v-a5165e9c data-v-302fb326><!--[--><!--]--><!--[--><!--]--><nav aria-labelledby="doc-outline-aria-label" class="VPDocAsideOutline" data-v-302fb326 data-v-1e498253><div class="content" data-v-1e498253><div class="outline-marker" data-v-1e498253></div><div aria-level="2" class="outline-title" id="doc-outline-aria-label" role="heading" data-v-1e498253>On this page</div><ul class="VPDocOutlineItem root" data-v-1e498253 data-v-1bc86f42><!--[--><!--]--></ul></div></nav><!--[--><!--]--><div class="spacer" data-v-302fb326></div><!--[--><!--]--><!----><!--[--><!--]--><!--[--><!--]--></div></div></div></div><div class="content" data-v-a5165e9c><div class="content-container" data-v-a5165e9c><!--[--><!--]--><main class="main" data-v-a5165e9c><div style="position:relative;" class="vp-doc _tmagic-editor_docs_guide_runtime" data-v-a5165e9c><div><h1 id="runtime" tabindex="-1">RUNTIME <a class="header-anchor" href="#runtime" aria-label="Permalink to &quot;RUNTIME&quot;"></a></h1><p>本章详细介绍如何深入理解tmagic-editor的打包以及如何根据需求定制修改tmagic-editor的页面打包发布方案。页面发布、打包相关的定制化开发需要使用tmagic-editor的业务方搭建好基于开源tmagic-editor的管理平台、存储服务等配套设施。</p><h2 id="实现一个-runtime" tabindex="-1">实现一个 runtime <a class="header-anchor" href="#实现一个-runtime" aria-label="Permalink to &quot;实现一个 runtime&quot;"></a></h2><p><a href="./advanced/tmagic-ui.html">@tmagic/ui</a> 部分我们已经说过runtime 和 UI 是配套实现的。每个版本的 runtime 都需要一个对应的 UI 来作为渲染器,实现渲染 DSL 呈现页面的功能。</p><h3 id="ui" tabindex="-1">UI <a class="header-anchor" href="#ui" aria-label="Permalink to &quot;UI&quot;"></a></h3><p>一个 UI 应该至少包含一个渲染器,来实现<a href="./advanced/page.html">页面渲染</a>。同时可以提供一些基础组件。具体实现可以参考<a href="./advanced/tmagic-ui.html">@tmagic/ui</a></p><h3 id="page" tabindex="-1">page <a class="header-anchor" href="#page" aria-label="Permalink to &quot;page&quot;"></a></h3><p>runtime 的 <code>page</code> 部分,就是真实项目页面的渲染环境。发布出去的项目页都需要基于该部分来实现渲染功能。而 <code>page</code> 的主要逻辑,就是需要加载 UI同时实现业务方需要的业务逻辑比如</p><ul><li>提供页面需要的全局 api</li><li>业务需要的特殊实现逻辑</li><li>加载第三方全局组件/插件等</li></ul><p>具体的 page 实现示例,可以参考</p><ul><li><a href="https://github.com/Tencent/tmagic-editor/blob/master/runtime/vue3/page" target="_blank" rel="noreferrer">vue3 runtime</a></li><li><a href="https://github.com/Tencent/tmagic-editor/blob/master/runtime/vue2/page" target="_blank" rel="noreferrer">vue2 runtime</a></li><li><a href="https://github.com/Tencent/tmagic-editor/blob/master/runtime/react/page" target="_blank" rel="noreferrer">react runtime</a></li></ul><h3 id="playground" tabindex="-1">playground <a class="header-anchor" href="#playground" aria-label="Permalink to &quot;playground&quot;"></a></h3><p>runtime 的 <code>playground</code> 部分,和 <code>page</code> 做的事情几乎一致,业务方可以包含上述 <code>page</code> 所拥有的全部能力。但是,因为 playground 需要被编辑器加载,作为编辑器中页面模拟器的渲染容器,和编辑器通信,接受编辑器中组件的增删改查。所以,除了保持和 <code>page</code> 一样的渲染逻辑之外,<code>playground</code> 还要额外实现一套既定通信内容和 api才能实现和编辑器的通信功能。</p><h4 id="onruntimeready" tabindex="-1">onRuntimeReady <a class="header-anchor" href="#onruntimeready" aria-label="Permalink to &quot;onRuntimeReady&quot;"></a></h4><p><strong>在 playground 页面渲染后</strong>,需要调用接口通知编辑器完成加载。该调用需要传入一个参数 API即挂载了增删改查功能的对象示例提供给编辑器。</p><div class="language-javascript vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">javascript</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">window.magic?.</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">onRuntimeReady</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">API</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div><h4 id="onpageelupdate" tabindex="-1">onPageElUpdate <a class="header-anchor" href="#onpageelupdate" aria-label="Permalink to &quot;onPageElUpdate&quot;"></a></h4><p><strong>playground 在每次更新了页面配置后</strong>,调用一次 onPageElUpdate 并传入一个 DOM 节点,该方法作用是传入一个页面渲染组件的根节点,用来告知编辑器的模拟器遮罩如何作出反应。</p><div class="language-javascript vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">javascript</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">window.magic.</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">onPageElUpdate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(document.</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">querySelector</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;.magic-ui-page&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">));</span></span></code></pre></div><h4 id="提供-api" tabindex="-1">提供 API <a class="header-anchor" href="#提供-api" aria-label="Permalink to &quot;提供 API&quot;"></a></h4><table tabindex="0"><thead><tr><th>API</th><th>说明</th><th>参数</th></tr></thead><tbody><tr><td>updateRootConfig</td><td>根节点更新</td><td><code>root: MApp</code></td></tr><tr><td>updatePageId</td><td>更新当前页面 id</td><td><code>id: string</code></td></tr><tr><td>select</td><td>选中组件</td><td><code>id: string</code></td></tr><tr><td>add</td><td>增加组件</td><td>{ <code>config</code> , <code>root</code> }: <code>UpdateData</code></td></tr><tr><td>update</td><td>更新组件</td><td>{ <code>config</code> , <code>root</code> }: <code>UpdateData</code></td></tr><tr><td>remove</td><td>删除组件</td><td>{ <code>config</code> , <code>root</code> }: <code>UpdateData</code></td></tr><tr><td>sortNode</td><td>组件在容器间排序</td><td>{ <code>src</code> , <code>dist</code>, <code>root</code> }: <code>SortEventData</code></td></tr></tbody></table><p>runtime 的实现示例可以参考tmagic-editor提供的</p><ul><li><a href="https://github.com/Tencent/tmagic-editor/blob/master/runtime/vue3" target="_blank" rel="noreferrer">vue3 runtime</a></li><li><a href="https://github.com/Tencent/tmagic-editor/blob/master/runtime/vue2" target="_blank" rel="noreferrer">vue2 runtime</a></li><li><a href="https://github.com/Tencent/tmagic-editor/blob/master/runtime/react" target="_blank" rel="noreferrer">react runtime</a></li></ul><h3 id="页面发布" tabindex="-1">页面发布 <a class="header-anchor" href="#页面发布" aria-label="Permalink to &quot;页面发布&quot;"></a></h3><p>如介绍中提到的tmagic-editor页面发布方案是对构建产物 <code>page/index.html</code> 进行项目信息注入。项目信息就是搭建平台存储的页面配置。发布时,将注入项目信息的 <code>page/index.html</code> 发布出去即可。</p><h2 id="版本管理" tabindex="-1">版本管理 <a class="header-anchor" href="#版本管理" aria-label="Permalink to &quot;版本管理&quot;"></a></h2><p>基于上一步提到的打包原理,每次构建后,得到的产物都可以进行归档编号,存为版本。涉及到的组件改动和新增修改,体现在各个版本中。</p><img src="https://image.video.qpic.cn/oa_88b7d-32_1233288257_1633783105283986" width="40%" alt="版本选择"><p>版本管理具体如何实现这取决于使用tmagic-editor的业务方。版本管理具有如下优点</p><ol><li>对于已经配置好发布的项目,使用固定版本,不会被新版本的特性影响,保证项目线上稳定运行</li><li>发布的新版本如果出现问题,可以及时回退选择使用旧版本</li></ol><h2 id="结合业务定制" tabindex="-1">结合业务定制 <a class="header-anchor" href="#结合业务定制" aria-label="Permalink to &quot;结合业务定制&quot;"></a></h2><p>tmagic-editor的静态资源构建项目配置保存页面发布在tmagic-editor的提供的示例方案中流程是</p><ol><li>触发构建,执行流水线,基于 runtime 执行 build</li><li>将构建产物归档推送至 cdn存为一个ui版本</li><li>项目配保存后,项目发布时,将项目配置发布至 CDN 存储为 DSL.js同时根据当前项目使用的ui版本获取到 page/index.html将 DSL.js 引用方式以 script 标签形式写入。</li><li>将注入信息的 page/index.html 发布为项目静态资源 act.html</li><li>线上可加载 act.html 访问项目</li></ol><p>其中各个步骤的定制可以交由业务方根据tmagic-editor提供的示例进行自定义修改。</p></div></div></main><footer class="VPDocFooter" data-v-a5165e9c data-v-f8258240><!--[--><!--]--><!----><nav class="prev-next" aria-labelledby="doc-footer-aria-label" data-v-f8258240><span class="visually-hidden" id="doc-footer-aria-label" data-v-f8258240>Pager</span><div class="pager" data-v-f8258240><a class="VPLink link pager-link prev" href="/tmagic-editor/docs/guide/publish.html" data-v-f8258240><!--[--><span class="desc" data-v-f8258240>Previous page</span><span class="title" data-v-f8258240>页面发布</span><!--]--></a></div><div class="pager" data-v-f8258240><a class="VPLink link pager-link next" href="/tmagic-editor/docs/guide/component.html" data-v-f8258240><!--[--><span class="desc" data-v-f8258240>Next page</span><span class="title" data-v-f8258240>组件开发</span><!--]--></a></div></nav></footer><!--[--><!--]--></div></div></div><!--[--><!--]--></div></div><footer class="VPFooter has-sidebar" data-v-6dfe06bb data-v-89c31066><div class="container" data-v-89c31066><p class="message" data-v-89c31066>Powered by 腾讯视频会员平台技术中心</p><p class="copyright" data-v-89c31066>Copyright (C) 2023 THL A29 Limited, a Tencent company.</p></div></footer><!--[--><!--]--></div></div>
<script>window.__VP_HASH_MAP__=JSON.parse("{\"api_editor_codeblockservicemethods.md\":\"ByEWNde9\",\"api_editor_componentlistservicemethods.md\":\"BlIpybO4\",\"api_editor_datasourceservicemethods.md\":\"dOFTimur\",\"api_editor_editorserviceevents.md\":\"NWnbRW-u\",\"api_editor_editorservicemethods.md\":\"BkDhL-Jz\",\"api_editor_events.md\":\"D-n7YlOa\",\"api_editor_eventsservicemethods.md\":\"B7XiPAU9\",\"api_editor_historyserviceevents.md\":\"Ch4EzexV\",\"api_editor_historyservicemethods.md\":\"BGNz7JVb\",\"api_editor_props.md\":\"C6nXtNoN\",\"api_editor_propsserviceevents.md\":\"Bi16r2I6\",\"api_editor_propsservicemethods.md\":\"CtS4AyA6\",\"api_editor_slots.md\":\"DJc0kZyD\",\"api_editor_storageservicemethods.md\":\"B8JZCP8b\",\"api_editor_uiservicemethods.md\":\"BhNAYUwK\",\"api_form_form-dialog-events.md\":\"B1Tvd5mR\",\"api_form_form-dialog-methods.md\":\"BHbhKE0E\",\"api_form_form-dialog-props.md\":\"DGgPNL4j\",\"api_form_form-events.md\":\"DjtkQ04g\",\"api_form_form-methods.md\":\"D8KfiSNh\",\"api_form_form-props.md\":\"BuujGPjG\",\"api_stage_coreevents.md\":\"DWLYMszB\",\"api_stage_coremethods.md\":\"DiiD7c0X\",\"api_table_events.md\":\"CfFQQmdb\",\"api_table_methods.md\":\"DK7PIkqn\",\"api_table_props.md\":\"DO3IJxZ9\",\"form-config_compare.md\":\"CzwGEwJZ\",\"form-config_fields_cascader.md\":\"DVdum0nR\",\"form-config_fields_checkbox.md\":\"DE6q5Ibr\",\"form-config_fields_color-picker.md\":\"DXoJjSov\",\"form-config_fields_date-picker.md\":\"D2VhlcjQ\",\"form-config_fields_datetime-picker.md\":\"LJjuzKo6\",\"form-config_fields_display.md\":\"B7Bf4Lpm\",\"form-config_fields_hidden.md\":\"3tLOI4Ku\",\"form-config_fields_link.md\":\"XRLOekQP\",\"form-config_fields_number.md\":\"CFsP0NKf\",\"form-config_fields_radio.md\":\"CNVjIAaP\",\"form-config_fields_select.md\":\"y8DvtD5s\",\"form-config_fields_switch.md\":\"CoIuX0Sf\",\"form-config_fields_text.md\":\"TX1l0lwW\",\"form-config_fields_textarea.md\":\"BBSDxUFe\",\"form-config_fields_time-picker.md\":\"C9wRi_IB\",\"form-config_layout.md\":\"fUDi4ZGv\",\"form-config_relate.md\":\"Dw-kLwJI\",\"guide_advanced_code-block.md\":\"1m2EdpET\",\"guide_advanced_coupling.md\":\"XSIQCzCw\",\"guide_advanced_data-source.md\":\"Q6P421HC\",\"guide_advanced_js-schema.md\":\"XQRodkeW\",\"guide_advanced_layout.md\":\"PE5_6dEb\",\"guide_advanced_page.md\":\"BeH6A7ti\",\"guide_advanced_tmagic-form.md\":\"BAl3iNDg\",\"guide_advanced_tmagic-ui.md\":\"D6lHMeDC\",\"guide_component.md\":\"C3ln72FC\",\"guide_conception.md\":\"DLxZBuUJ\",\"guide_editor-expand.md\":\"C0W8uGZG\",\"guide_index.md\":\"BM-Tluo7\",\"guide_introduction.md\":\"Ch_-Uv4O\",\"guide_migration.md\":\"Cgzwa-8h\",\"guide_publish.md\":\"DuQIDRyD\",\"guide_runtime.md\":\"DXMc06eN\",\"guide_tutorial_hello-world.md\":\"BrEh5Nq7\",\"guide_tutorial_index.md\":\"CbM8aiXv\",\"guide_tutorial_render.md\":\"D_6uyszN\",\"guide_tutorial_runtime.md\":\"BQ9hcU3d\",\"index.md\":\"CFu6CvwY\"}");window.__VP_SITE_DATA__=JSON.parse("{\"lang\":\"en-US\",\"dir\":\"ltr\",\"title\":\"tmagic-editor\",\"description\":\"页面可视化平台\",\"base\":\"/tmagic-editor/docs/\",\"head\":[],\"router\":{\"prefetchLinks\":true},\"appearance\":true,\"themeConfig\":{\"logo\":\"./favicon.png\",\"search\":{\"provider\":\"local\"},\"socialLinks\":[{\"icon\":\"github\",\"link\":\"https://github.com/Tencent/tmagic-editor\"}],\"footer\":{\"message\":\"Powered by 腾讯视频会员平台技术中心\",\"copyright\":\"Copyright (C) 2023 THL A29 Limited, a Tencent company.\"},\"nav\":[{\"text\":\"文档\",\"link\":\"/guide/\",\"activeMatch\":\"/guide/\"},{\"text\":\"API\",\"link\":\"/api/editor/props\",\"activeMatch\":\"/api/\"},{\"text\":\"表单配置\",\"link\":\"/form-config/fields/text\",\"activeMatch\":\"/form-config/\"},{\"text\":\"更新日志\",\"link\":\"https://github.com/Tencent/tmagic-editor/releases\"},{\"text\":\"Playground\",\"link\":\"https://tencent.github.io/tmagic-editor/playground/index.html\"}],\"sidebar\":{\"/guide/\":[{\"text\":\"文档\",\"items\":[{\"text\":\"介绍\",\"link\":\"/guide/introduction.md\"},{\"text\":\"快速开始\",\"link\":\"/guide/\"},{\"text\":\"基础概念\",\"link\":\"/guide/conception.md\"},{\"text\":\"页面发布\",\"link\":\"/guide/publish.md\"},{\"text\":\"RUNTIME\",\"link\":\"/guide/runtime.md\"},{\"text\":\"组件开发\",\"link\":\"/guide/component.md\"},{\"text\":\"编辑器扩展\",\"link\":\"/guide/editor-expand.md\"},{\"text\":\"升级到1.5.x\",\"link\":\"/guide/migration.md\"}]},{\"text\":\"进阶指南\",\"items\":[{\"text\":\"JS Schema\",\"link\":\"/guide/advanced/js-schema.md\"},{\"text\":\"布局原理\",\"link\":\"/guide/advanced/layout.md\"},{\"text\":\"页面渲染\",\"link\":\"/guide/advanced/page.md\"},{\"text\":\"联动原理\",\"link\":\"/guide/advanced/coupling.md\"},{\"text\":\"代码块\",\"link\":\"/guide/advanced/code-block.md\"},{\"text\":\"数据源\",\"link\":\"/guide/advanced/data-source.md\"},{\"text\":\"@tmagic/ui\",\"link\":\"/guide/advanced/tmagic-ui.md\"},{\"text\":\"@tmagic/form\",\"link\":\"/guide/advanced/tmagic-form.md\"}]},{\"text\":\"教程\",\"items\":[{\"text\":\"写在前面\",\"link\":\"/guide/tutorial/\"},{\"text\":\"1.Hello World\",\"link\":\"/guide/tutorial/hello-world.md\"},{\"text\":\"2.Runtime\",\"link\":\"/guide/tutorial/runtime.md\"},{\"text\":\"3.DSL解析渲染\",\"link\":\"/guide/tutorial/render.md\"}]}],\"/api/\":[{\"text\":\"编辑器\",\"items\":[{\"text\":\"Editor组件\",\"items\":[{\"text\":\"props\",\"link\":\"/api/editor/props.md\"},{\"text\":\"slots\",\"link\":\"/api/editor/slots.md\"},{\"text\":\"events\",\"link\":\"/api/editor/events.md\"}]},{\"text\":\"editorService\",\"items\":[{\"text\":\"方法\",\"link\":\"/api/editor/editorServiceMethods.md\"},{\"text\":\"事件\",\"link\":\"/api/editor/editorServiceEvents.md\"}]},{\"text\":\"propsService\",\"items\":[{\"text\":\"方法\",\"link\":\"/api/editor/propsServiceMethods.md\"},{\"text\":\"事件\",\"link\":\"/api/editor/propsServiceEvents.md\"}]},{\"text\":\"historyService\",\"items\":[{\"text\":\"方法\",\"link\":\"/api/editor/historyServiceMethods.md\"},{\"text\":\"事件\",\"link\":\"/api/editor/historyServiceEvents.md\"}]},{\"text\":\"eventsService\",\"link\":\"/api/editor/eventsServiceMethods.md\"},{\"text\":\"uiService\",\"link\":\"/api/editor/uiServiceMethods.md\"},{\"text\":\"codeBlockService\",\"link\":\"/api/editor/codeBlockServiceMethods.md\"},{\"text\":\"componentListService\",\"link\":\"/api/editor/componentListServiceMethods.md\"},{\"text\":\"storageService\",\"link\":\"/api/editor/storageServiceMethods.md\"}]},{\"text\":\"表单\",\"items\":[{\"text\":\"Form组件\",\"items\":[{\"text\":\"props\",\"link\":\"/api/form/form-props\"},{\"text\":\"methods\",\"link\":\"/api/form/form-methods\"},{\"text\":\"events\",\"link\":\"/api/form/form-events\"}]},{\"text\":\"FormDialog组件\",\"items\":[{\"text\":\"props\",\"link\":\"/api/form/form-dialog-props\"},{\"text\":\"methods\",\"link\":\"/api/form/form-dialog-methods\"},{\"text\":\"events\",\"link\":\"/api/form/form-dialog-events\"}]}]},{\"text\":\"表格\",\"items\":[{\"text\":\"Table组件\",\"items\":[{\"text\":\"props\",\"link\":\"/api/table/props\"},{\"text\":\"methods\",\"link\":\"/api/table/methods\"},{\"text\":\"events\",\"link\":\"/api/table/events\"}]}]},{\"text\":\"stage\",\"items\":[{\"text\":\"StageCore\",\"items\":[{\"text\":\"方法\",\"link\":\"/api/stage/coreMethods\"},{\"text\":\"事件\",\"link\":\"/api/stage/coreEvents\"}]}]}],\"/form-config/\":[{\"text\":\"基础配置\",\"items\":[{\"text\":\"Input输入框\",\"link\":\"/form-config/fields/text.md\"},{\"text\":\"Textarea文本域\",\"link\":\"/form-config/fields/textarea.md\"},{\"text\":\"InputNumber计数器\",\"link\":\"/form-config/fields/number.md\"},{\"text\":\"Display只读文本\",\"link\":\"/form-config/fields/display.md\"},{\"text\":\"Hidden隐藏域\",\"link\":\"/form-config/fields/hidden.md\"},{\"text\":\"Link链接\",\"link\":\"/form-config/fields/link.md\"},{\"text\":\"Checkbox多选框\",\"link\":\"/form-config/fields/checkbox.md\"},{\"text\":\"Radio单选框\",\"link\":\"/form-config/fields/radio.md\"},{\"text\":\"Switch开关\",\"link\":\"/form-config/fields/switch.md\"},{\"text\":\"Select选择器\",\"link\":\"/form-config/fields/select.md\"},{\"text\":\"Cascader级联选择器\",\"link\":\"/form-config/fields/cascader.md\"},{\"text\":\"ColorPicker颜色选择器\",\"link\":\"/form-config/fields/color-picker.md\"},{\"text\":\"DatePick日期选择器\",\"link\":\"/form-config/fields/date-picker.md\"},{\"text\":\"DatetimePick日期时间选择器\",\"link\":\"/form-config/fields/datetime-picker.md\"},{\"text\":\"TimePick时间选择器\",\"link\":\"/form-config/fields/time-picker.md\"}]},{\"text\":\"布局配置\",\"items\":[{\"text\":\"布局\",\"link\":\"/form-config/layout.md\"}]},{\"text\":\"联动配置\",\"items\":[{\"text\":\"联动\",\"link\":\"/form-config/relate.md\"}]},{\"text\":\"表单对比\",\"items\":[{\"text\":\"表单对比\",\"link\":\"/form-config/compare.md\"}]}]}},\"locales\":{},\"scrollOffset\":134,\"cleanUrls\":false}");</script>
</body>
</html>