import BaseMgr from '@/core/base/baseMgr'
import UiConfig from './uiConfig'
import { RawLocation } from 'vue-router/types'
import { ErrorHandler } from 'vue-router/types/router'

export type PageParams = {
  onComplete?: Function
  onAbort?: ErrorHandler
  web?: {}
  wx?: {
    events: {
      [eventName: string]: Function
    }
    success: Function
    fail: Function
    complete: Function
  }
  zfb?: {}
}

export default abstract class UiMgr extends BaseMgr {
  config!: UiConfig
  constructor(config: UiConfig) {
    super()
    this.config = config
  }

  get router() {
    return this.config.router
  }

  get routerConfig() {
    return this.config.routerConfig
  }

  /**
   * 初始化函数
   */
  protected abstract init(): any

  /**
   * 推入一个页面
   */
  abstract pushPage(location: RawLocation, pageParams: PageParams): any
  /**
   * 返回一个页面
   */
  abstract popPage(): any
  /**
   * 跳到相应页面
   */
  abstract gotoPage(n: number): any
  /**
   * 替换当前页面
   */
  abstract redirectPage(location: RawLocation, pageParams: PageParams): any
  /**
   * 去首页
   */
  abstract goHomePage(tabIndex: number): any
}
