/*
 * @Description:: 请补充填写
 * @Version: 请配置版本号
 * @Author: 舟舟
 * @Date: 2022-06-25 22:54:40
 * @LastEditors: 舟舟
 * @LastEditTime: 2022-07-28 14:34:34
 * @FilePath: /ouicai_web_framework_vite_ep_nolang/src/router/index.ts
 */
import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
import { staticRoutes } from '/@/router/static'
import { loading } from '/@/utils/loading'

const router = createRouter({
    history: createWebHistory(),
    routes: staticRoutes,
})

router.beforeEach((to, from, next) => {
    if(to.name!=='documentview' && to.name!=='goodview' && to.name!=='helpcenter' && to.name!=='helpdetail'){
        NProgress.configure({ showSpinner: false })
        NProgress.start()
        if (!window.existLoading) {
            loading.show()
            window.existLoading = true
        }

    }

    next()

})

// 路由加载后
router.afterEach((to, from) => {

    if (window.existLoading) {
        loading.hide()
    }

    NProgress.done()
})

export default router
