Skip to content

Commit

Permalink
fix: 删除无用代码
Browse files Browse the repository at this point in the history
  • Loading branch information
yy-wow committed Jan 13, 2025
1 parent 1942594 commit 8c36268
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 35 deletions.
19 changes: 2 additions & 17 deletions packages/canvas/common/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ const dynamicImportComponentLib = async ({ pkg, script }) => {

try {
// 优先从importmap导入,兼容npm.script字段定义的cdn地址
if (getImportMapKeys().includes(pkg)) {
const importMapKeys = getImportMapKeys()
if (importMapKeys.includes(pkg)) {
modules = await import(/* @vite-ignore */ pkg)
} else if (script) {
modules = await import(/* @vite-ignore */ script)
Expand Down Expand Up @@ -121,19 +122,3 @@ export const getComponents = async ({ package: pkg, script, components }) => {
}
})
}

/**
* 更新区块/组件依赖
* @param {object} param0 依赖的CDN信息
*/
export const updateDependencies = ({ detail }) => {
const { scripts = [], styles = [] } = detail || {}
const { styles: canvasStyles } = window.componentsDepsMap
const newStyles = [...styles].filter((item) => !canvasStyles.has(item))

newStyles.forEach((item) => canvasStyles.add(item))

const promises = [...newStyles].map((src) => addStyle(src)).concat(scripts.map(getComponents))

Promise.allSettled(promises)
}
4 changes: 1 addition & 3 deletions packages/canvas/render/src/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/

import { createApp } from 'vue'
import { addScript, addStyle, getComponents, updateDependencies } from '../../common'
import { addScript, addStyle, getComponents } from '../../common'
import TinyI18nHost, { I18nInjectionKey } from '@opentiny/tiny-engine-common/js/i18n'
import Main, { api } from './RenderMain'
import lowcode from './lowcode'
Expand All @@ -27,8 +27,6 @@ const initRenderContext = () => {

window.TinyLowcodeComponent = {}
window.TinyComponentLibs = {}

document.addEventListener('updateDependencies', updateDependencies)
}

let App = null
Expand Down
15 changes: 0 additions & 15 deletions packages/plugins/materials/src/composable/useMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,20 +478,6 @@ const getBlockDeps = (dependencies = {}) => {
styles?.forEach((item) => materialState.componentsDepsMap.styles.add(item))
}

/**
* 获取新增区块的依赖,更新画布中的组件依赖
* @param {array} blocks 新增的区块列表
*/
const updateCanvasDependencies = (blocks) => {
blocks.forEach((block) => {
if (!block.content.dependencies) return

getBlockDeps(block.content.dependencies)
})

useCanvas().canvasApi.value?.canvasDispatch('updateDependencies', { detail: materialState.componentsDepsMap })
}

const initBuiltinMaterial = () => {
const { Builtin } = useCanvas().canvasApi.value
// 添加画布物料
Expand Down Expand Up @@ -535,7 +521,6 @@ export default function () {
setMaterial, // 设置单个物料 (property) setMaterial: (name: string, data: Material) => void
addMaterials, // 添加多个物料
registerBlock, // 注册新的区块
updateCanvasDependencies, //传入新的区块,获取新增区块的依赖,更新画布中的组件依赖
getCanvasDeps, // 组装画布依赖,包含物料和工具类的依赖。
updateCanvasDeps, // 通知画布更新依赖
getConfigureMap, // 获取物料组件的配置信息
Expand Down

0 comments on commit 8c36268

Please sign in to comment.