mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-08-28 20:10:36 +08:00
chore(editor): ts type error
This commit is contained in:
parent
765c0a227d
commit
00cd237f61
@ -45,11 +45,12 @@
|
||||
<template #header>
|
||||
<div class="code-name-wrapper">
|
||||
<div class="code-name-label">代码块名称</div>
|
||||
<el-input class="code-name-input" v-model="codeConfig.name" :disabled="!editable" />
|
||||
<el-input v-if="codeConfig" class="code-name-input" v-model="codeConfig.name" :disabled="!editable" />
|
||||
</div>
|
||||
</template>
|
||||
<div class="m-editor-wrapper">
|
||||
<magic-code-editor
|
||||
v-if="codeConfig"
|
||||
ref="codeEditor"
|
||||
class="m-editor-container"
|
||||
:init-values="`${codeConfig.content}`"
|
||||
@ -80,6 +81,7 @@
|
||||
import { computed, inject, reactive, ref, watchEffect } from 'vue';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import { forIn, isEmpty } from 'lodash-es';
|
||||
import type * as monaco from 'monaco-editor';
|
||||
|
||||
import type { CodeBlockContent, CodeDslList, ListState, Services } from '../../../type';
|
||||
import { CodeEditorMode } from '../../../type';
|
||||
@ -132,7 +134,7 @@ const saveCode = async (): Promise<boolean> => {
|
||||
|
||||
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) {
|
||||
|
@ -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) {
|
||||
|
3
pnpm-lock.yaml
generated
3
pnpm-lock.yaml
generated
@ -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==}
|
||||
|
Loading…
x
Reference in New Issue
Block a user