feat(editor): 修改代码块参数结构,以对象形式暴露app,params

This commit is contained in:
parisma 2022-11-21 17:14:26 +08:00 committed by roymondchen
parent a55c6eb8b0
commit 8195a600f5
3 changed files with 4 additions and 4 deletions

View File

@ -94,7 +94,7 @@ class Node extends EventEmitter {
for (const item of this.data[hook].hookData) {
const { codeId, params = {} } = item;
if (this.app.codeDsl[codeId] && typeof this.app?.codeDsl[codeId]?.content === 'function') {
await this.app.codeDsl[codeId].content(this, params);
await this.app.codeDsl[codeId].content({ app: this.app, params });
}
}
}

View File

@ -164,7 +164,7 @@ const createCodeBlock = async () => {
}
const codeConfig: CodeBlockContent = {
name: '代码块',
content: `() => {\n // place your code here\n}`,
content: `({app, params}) => {\n // place your code here\n}`,
params: [],
};
await codeBlockService.setMode(CodeEditorMode.EDITOR);

View File

@ -24,7 +24,7 @@ export default {
code_5336: {
name: 'getData',
// eslint-disable-next-line no-eval
content: eval(`(vm, params) => {\n console.log("this is getData function",params)\n}`),
content: eval(`({app, params}) => {\n console.log("this is getData function",params,app)\n}`),
params: [
{
name: 'age',
@ -37,7 +37,7 @@ export default {
code_5316: {
name: 'getList',
// eslint-disable-next-line no-eval
content: eval(`(vm) => {\n console.log("this is getList function")\n}`),
content: eval(`() => {\n console.log("this is getList function")\n}`),
params: [],
},
},