/*
 * @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)
	},
	{
		path: "/admin",
		name: "Admin",
		title: "小蜜蜂管家端隐私政策", 
		component: resolve => require(['@/views/Rule/admin.vue'], resolve)
	},
	{
		path: "/adminApp",
		name: "AdminApp",
		title: "小蜜蜂管家端用户协议", 
		component: resolve => require(['@/views/Rule/adminApp.vue'], resolve)
	},
	{
		path: "/user",
		name: "User",
		title: "小蜜蜂隐私政策", 
		component: resolve => require(['@/views/Rule/user.vue'], resolve)
	},
	{
		path: "/userApp",
		name: "UserApp",
		title: "住户端APP用户协议", 
		component: resolve => require(['@/views/Rule/userApp.vue'], 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 }
		}
	}
})