mirror of
				https://github.com/Tencent/tmagic-editor.git
				synced 2025-11-04 10:49:51 +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) {
 | 
			
		||||
      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 });
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -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);
 | 
			
		||||
 | 
			
		||||
@ -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: [],
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user