package com.yidian.shenghuoquan.broot.service

import com.yidian.xarc.xrouter.ResultResolver
import com.yidian.xpage.XPageManager
import com.yidian.yac.core.zap.ZapService

/**
 * XPageService服务
 * ⚠️ 注意：架构需要使用，请勿随意修改
 **/

class XPageService : ZapService() {
  companion object {
    const val SERVICE_NAME: String = "xpage"
  }

  override fun onAction(
    path: String,
    action: String,
    params: Any,
    options: Any,
    resolver: ResultResolver
  ) {
    params as Map<String, Any>
    val name = params["pageName"] as String
    val pageParams = params["pageParams"] as Map<String, Any>
    when (action) {
      "push" -> {
        XPageManager.push(name, pageParams)
      }
      "pop" -> {
        XPageManager.pop(pageParams)
      }
      "popTo" -> {
        XPageManager.popTo(name, pageParams)
      }
      "popToRoot" -> {
        XPageManager.popToRoot(pageParams)
      }
    }
  }

  override fun onInit() {
  }

  override fun onExit() {
  }


}
