// src/router/index.ts
import { createRouter, createWebHashHistory, RouteRecordRaw,useRouter } from 'vue-router';
import { staticRouter, errorRouter } from './staticRouter';

/**
 * 创建路由
 */
const router = createRouter({
  history: createWebHashHistory(),
  routes: [ ...staticRouter, ...errorRouter] as RouteRecordRaw[],
  // 刷新时，滚动条位置还原
  scrollBehavior: () => ({ left: 0, top: 0 })
});

/**
 * 重置路由
 */
export function resetRouter() {
  router.replace({ path: '/login' });
  location.reload();
}

/**
 * 获取当前路由
 */
export function currentRouter() {
  return router.currentRoute
}

export default router;
