/*
 * @Author: your name
 * @Date: 2021-11-18 17:30:38
 * @LastEditTime: 2021-11-29 09:52:34
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: /ansu-business/src/router/index.js
 */
import Vue from 'vue'
import Router from "vue-router"
const originalPush = Router.prototype.push

Router.prototype.push = function push(location) {
	return originalPush.call(this, location).catch(err => err)
}
Vue.use(Router);

import Layout from "@/views/Layout"
import basic from "./basic" // 基础功能
import manage from "./manage" // 管理平台
const router = [
	{
		path: "/",
		name: "Layout",
		title: "外框",
		component: Layout,
		redirect: '/Basic/home',
		meta: {title: '首页'},
		children: [
			...basic,
			...manage
		]
	},
	{
		path: "/login",
		name: "Login",
		title: "登录", 
		component: resolve => require(['@/views/Login'], resolve)
	}
]

export default new Router({
	mode: 'history',
	routes: router,
	scrollBehavior(to, from, savedPosition) {
		// console.log(savedPosition);
		if (savedPosition) {
			return new Promise((resolve) => {
				setTimeout(() => {
					console.log('savedPosition', savedPosition)
					resolve(savedPosition)
				}, 500);
			})
		} else {
			return { x: 0, y: 0 }
		}
	}
})