/*
 * @Author: your name
 * @Date: 2022-02-22 14:22:47
 * @LastEditTime: 2022-03-01 17:36:22
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \lowcode-ui\src\router\index.js
 */
import Vue from 'vue'
import Router from 'vue-router'
import { constantRouterMap } from '../config/router.config.js'

// hack router push callback
const originalPush = Router.prototype.push
Router.prototype.push = function push (location, onResolve, onReject) {
  if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
  return originalPush.call(this, location).catch(err => err)
}

Vue.use(Router)

export default new Router({

  mode: process.env.NODE_ENV !== 'dev' ? 'history' : 'hash',
  base: process.env.BASE_URL,
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
