import { AppLayoutService } from '../../../app-service';
import { IndexViewBase } from '../../../view/indexview-base';

/**
 * 应用首页视图基类
 *
 * @export
 * @class AppIndexViewBase
 * @extends {IndexViewBase}
 */
export class AppIndexViewBase extends IndexViewBase {
  /**
   * 应用首页视图渲染
   *
   * @memberof AppIndexViewBase
   */
  render(h: any) {
    if (!this.viewIsLoaded) {
      return null;
    }
    const targetViewLayoutComponent: any = AppLayoutService.getLayoutComponent(`${this.viewInstance?.viewType}-${this.viewInstance?.viewStyle}`);
    return h(
      targetViewLayoutComponent,
      {
        props: { viewInstance: this.viewInstance, model: this.model, modelService: this.modelService, viewparams: this.viewparams, context: this.context },
        on: {
          onCollapseChange: (collapseChange: any) => {
            this.collapseChange = collapseChange;
          },
        },
      },
      [this.renderMainContent()],
    );
  }
}
