mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-06-18 03:05:11 +08:00
feat(editor): 修改代码块参数结构,以对象形式暴露app,params
This commit is contained in:
parent
a55c6eb8b0
commit
8195a600f5
@ -94,7 +94,7 @@ class Node extends EventEmitter {
|
|||||||
for (const item of this.data[hook].hookData) {
|
for (const item of this.data[hook].hookData) {
|
||||||
const { codeId, params = {} } = item;
|
const { codeId, params = {} } = item;
|
||||||
if (this.app.codeDsl[codeId] && typeof this.app?.codeDsl[codeId]?.content === 'function') {
|
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 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ const createCodeBlock = async () => {
|
|||||||
}
|
}
|
||||||
const codeConfig: CodeBlockContent = {
|
const codeConfig: CodeBlockContent = {
|
||||||
name: '代码块',
|
name: '代码块',
|
||||||
content: `() => {\n // place your code here\n}`,
|
content: `({app, params}) => {\n // place your code here\n}`,
|
||||||
params: [],
|
params: [],
|
||||||
};
|
};
|
||||||
await codeBlockService.setMode(CodeEditorMode.EDITOR);
|
await codeBlockService.setMode(CodeEditorMode.EDITOR);
|
||||||
|
@ -24,7 +24,7 @@ export default {
|
|||||||
code_5336: {
|
code_5336: {
|
||||||
name: 'getData',
|
name: 'getData',
|
||||||
// eslint-disable-next-line no-eval
|
// 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: [
|
params: [
|
||||||
{
|
{
|
||||||
name: 'age',
|
name: 'age',
|
||||||
@ -37,7 +37,7 @@ export default {
|
|||||||
code_5316: {
|
code_5316: {
|
||||||
name: 'getList',
|
name: 'getList',
|
||||||
// eslint-disable-next-line no-eval
|
// 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: [],
|
params: [],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user