diff --git a/packages/editor/src/layouts/sidebar/code-block/CodeBlockEditor.vue b/packages/editor/src/layouts/sidebar/code-block/CodeBlockEditor.vue
index f4f70dac..271d5fd3 100644
--- a/packages/editor/src/layouts/sidebar/code-block/CodeBlockEditor.vue
+++ b/packages/editor/src/layouts/sidebar/code-block/CodeBlockEditor.vue
@@ -45,11 +45,12 @@
=> {
try {
// 代码内容
- const codeContent = codeEditor.value.getEditor()?.getValue();
+ const codeContent = (codeEditor.value.getEditor() as monaco.editor.IStandaloneCodeEditor)?.getValue();
/* eslint no-eval: "off" */
codeConfig.value.content = eval(codeContent);
} catch (e: any) {
diff --git a/packages/editor/src/services/codeBlock.ts b/packages/editor/src/services/codeBlock.ts
index 3ea5a17e..fba9d7f8 100644
--- a/packages/editor/src/services/codeBlock.ts
+++ b/packages/editor/src/services/codeBlock.ts
@@ -243,9 +243,9 @@ class CodeBlock extends BaseService {
try {
diffCodeIds.forEach((codeId) => {
const compsContent = codeDsl[codeId].comps;
- const index = compsContent[compId].findIndex((item) => item === hook);
- if (index !== -1) {
- compsContent[compId].splice(index, 1);
+ const index = compsContent?.[compId].findIndex((item) => item === hook);
+ if (typeof index !== 'undefined' && index !== -1) {
+ compsContent?.[compId].splice(index, 1);
}
});
} catch (e) {
@@ -265,7 +265,7 @@ class CodeBlock extends BaseService {
};
} else {
// 往已有的关系中添加hook
- existHooks.push(hook);
+ existHooks?.push(hook);
}
});
} catch (e) {
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index fcca687e..de78a461 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -146,11 +146,11 @@ importers:
dependencies:
'@tmagic/schema': link:../schema
events: 3.3.0
+ lodash-es: 4.17.21
devDependencies:
'@types/events': 3.0.0
'@types/lodash-es': 4.17.6
'@types/node': 15.14.9
- lodash-es: 4.17.21
rimraf: 3.0.2
typescript: 4.7.4
vite: 3.1.3
@@ -5563,6 +5563,7 @@ packages:
/lodash-es/4.17.21:
resolution: {integrity: sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==}
+ dev: false
/lodash-unified/1.0.2_3ib2ivapxullxkx3xftsimdk7u:
resolution: {integrity: sha512-OGbEy+1P+UT26CYi4opY4gebD8cWRDxAT6MAObIVQMiqYdxZr1g3QHWCToVsm31x2NkLS4K3+MC2qInaRMa39g==}