mirror of
				https://github.com/Tencent/tmagic-editor.git
				synced 2025-11-04 02:28:04 +08:00 
			
		
		
		
	refactor(editor): 修改代码块描述内容在dsl中的键名为codeBlock字段
This commit is contained in:
		
							parent
							
								
									92f3696e44
								
							
						
					
					
						commit
						415ecad24c
					
				@ -61,7 +61,8 @@ class App extends EventEmitter {
 | 
				
			|||||||
    super();
 | 
					    super();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    this.env = new Env(options.ua);
 | 
					    this.env = new Env(options.ua);
 | 
				
			||||||
    this.codeDsl = options.config?.methods;
 | 
					    // 代码块描述内容在dsl codeBlock字段
 | 
				
			||||||
 | 
					    this.codeDsl = options.config?.codeBlock;
 | 
				
			||||||
    options.platform && (this.platform = options.platform);
 | 
					    options.platform && (this.platform = options.platform);
 | 
				
			||||||
    options.jsEngine && (this.jsEngine = options.jsEngine);
 | 
					    options.jsEngine && (this.jsEngine = options.jsEngine);
 | 
				
			||||||
    options.designWidth && (this.designWidth = options.designWidth);
 | 
					    options.designWidth && (this.designWidth = options.designWidth);
 | 
				
			||||||
@ -141,7 +142,7 @@ class App extends EventEmitter {
 | 
				
			|||||||
   * @param curPage 当前页面id
 | 
					   * @param curPage 当前页面id
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  public setConfig(config: MApp, curPage?: Id) {
 | 
					  public setConfig(config: MApp, curPage?: Id) {
 | 
				
			||||||
    this.codeDsl = config.methods;
 | 
					    this.codeDsl = config.codeBlock;
 | 
				
			||||||
    this.pages = new Map();
 | 
					    this.pages = new Map();
 | 
				
			||||||
    config.items?.forEach((page) => {
 | 
					    config.items?.forEach((page) => {
 | 
				
			||||||
      this.pages.set(
 | 
					      this.pages.set(
 | 
				
			||||||
 | 
				
			|||||||
@ -69,7 +69,7 @@ class CodeBlock extends BaseService {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * 获取活动的代码块dsl数据源(默认从dsl中的methods字段读取)
 | 
					   * 获取活动的代码块dsl数据源(默认从dsl中的codeBlock字段读取)
 | 
				
			||||||
   * @param {boolean} forceRefresh 是否强制从活动dsl拉取刷新
 | 
					   * @param {boolean} forceRefresh 是否强制从活动dsl拉取刷新
 | 
				
			||||||
   * @returns {CodeBlockDSL | null}
 | 
					   * @returns {CodeBlockDSL | null}
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
 | 
				
			|||||||
@ -767,23 +767,23 @@ class Editor extends BaseService {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * 从dsl中的methods字段读取活动的代码块
 | 
					   * 从dsl中的codeBlock字段读取活动的代码块
 | 
				
			||||||
   * @returns {CodeBlockDSL | null}
 | 
					   * @returns {CodeBlockDSL | null}
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  public async getCodeDsl(): Promise<CodeBlockDSL | null> {
 | 
					  public async getCodeDsl(): Promise<CodeBlockDSL | null> {
 | 
				
			||||||
    const root = this.get<MApp | null>('root');
 | 
					    const root = this.get<MApp | null>('root');
 | 
				
			||||||
    if (!root) return null;
 | 
					    if (!root) return null;
 | 
				
			||||||
    return root.methods || null;
 | 
					    return root.codeBlock || null;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * 设置代码块到dsl的methods字段
 | 
					   * 设置代码块到dsl的codeBlock字段
 | 
				
			||||||
   * @param {CodeBlockDSL} codeDsl 代码DSL
 | 
					   * @param {CodeBlockDSL} codeDsl 代码DSL
 | 
				
			||||||
   * @returns {void}
 | 
					   * @returns {void}
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  public async setCodeDsl(codeDsl: CodeBlockDSL): Promise<void> {
 | 
					  public async setCodeDsl(codeDsl: CodeBlockDSL): Promise<void> {
 | 
				
			||||||
    if (!this.state.root) return;
 | 
					    if (!this.state.root) return;
 | 
				
			||||||
    this.state.root.methods = codeDsl;
 | 
					    this.state.root.codeBlock = codeDsl;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private addModifiedNodeId(id: Id) {
 | 
					  private addModifiedNodeId(id: Id) {
 | 
				
			||||||
 | 
				
			|||||||
@ -20,7 +20,7 @@ export default {
 | 
				
			|||||||
  id: '75f0extui9d7yksklx27hff8xg',
 | 
					  id: '75f0extui9d7yksklx27hff8xg',
 | 
				
			||||||
  name: 'test',
 | 
					  name: 'test',
 | 
				
			||||||
  type: 'app',
 | 
					  type: 'app',
 | 
				
			||||||
  methods: {
 | 
					  codeBlock: {
 | 
				
			||||||
    code_5336: {
 | 
					    code_5336: {
 | 
				
			||||||
      name: 'getData',
 | 
					      name: 'getData',
 | 
				
			||||||
      // eslint-disable-next-line no-eval
 | 
					      // eslint-disable-next-line no-eval
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user