import { createRouter, createWebHistory, RouteRecordRaw, createWebHashHistory, RouterScrollBehavior } from 'vue-router';
import { useStore } from 'vuex';
import appSetting from '@/app-setting';
import HomeView from '../views/index.vue';

const constantRouterMap: RouteRecordRaw[] = [
    /* platformLogin */
    { path: '/login', component: () => import('@/views/auth/boxed-signin.vue'), meta: { layout: 'auth' } },
    { path: '/platformLogin', component: () => import('@/views/auth/platformLogin.vue'), meta: { layout: 'auth' } },
    { path: '/lockscreen', component: () => import('@/views/auth/boxed-lockscreen.vue'), meta: { layout: 'auth' } },
    { path: '/boxed-signup', component: () => import('@/views/auth/boxed-signup.vue'), meta: { layout: 'auth' } },
];

const router = createRouter({
    history: createWebHashHistory(),
    scrollBehavior: RouterScrollBehavior => {
        return { left: 0, top: 0 };
    },
    routes: constantRouterMap
});

const asyncRouterMap: RouteRecordRaw[] = [
    {
        path: '/',
        component: () => import('@/views/index.vue'),
        redirect: '/dashboard',
        children: [
            { 
                path: 'dashboard', 
                component: () => import('@/views/index.vue'), 
                name: 'dashboard', 
                meta: { title: 'home', icon: 'dashboard', layout: 'app' } 
            }
        ]
    },
   /*  {
        path: '/',
        redirect: '/dashboard',
        name: 'dashboard',
        children: [
            { path: 'dashboard', component: () => import('@/views/index.vue'), name: 'dashboard', meta: { title: 'home', icon: 'dashboard', layout: 'app' } }
        ]
    }, */
    {
        path: '/stock',
        redirect: '/stock',
        name: 'stock',
        children: [
            { path: 'warehouseList', component: () => import('@/views/stock/warehouseList.vue'), name: 'warehouseList', meta: { title: 'warehouseList', layout: 'app' } },
            { path: 'goodsLend', component: () => import('@/views/stock/goodsLend.vue'), name: 'goodsLend', meta: { title: 'goodsLend', layout: 'app' } },
            { path: 'goodsTransfer', component: () => import('@/views/stock/goodsTransfer.vue'), name: 'goodsTransfer', meta: { title: 'goodsTransfer', layout: 'app' } },
            { path: 'goodsExchange', component: () => import('@/views/stock/warehousing.vue'), name: 'goodsExchange', meta: { title: 'goodsExchange' } },
            { path: 'goodsOutBound', component: () => import('@/views/stock/outbound.vue'), name: 'goodsOutBound', meta: { title: 'goodsOutBound' } },
            { path: 'warehouseLocation', component: () => import('@/views/stock/warehouseLocation.vue'), name: 'warehouseLocation', meta: { title: 'warehouseLocation', layout: 'app' } },
            { path: 'addInventory', component: () => import('@/views/stock/addInventory.vue'), name: 'addInventory', meta: { title: 'addInventory', layout: 'app' } },
            { path: 'addOutbound', component: () => import('@/views/stock/addOutbound.vue'), name: 'addOutbound', meta: { title: 'addOutbound', layout: 'app' } },
            { path: 'goodsInventory', component: () => import('@/views/stock/goodsInventory.vue'), name: 'goodsInventory', meta: { title: 'goodsInventory', layout: 'app' } },
            { path: 'goodsInventoryAdd', component: () => import('@/views/stock/goodsInventoryAdd.vue'), name: 'goodsInventoryAdd', meta: { title: 'goodsInventoryAdd', layout: 'app' } },
            { path: 'goodsInventoryLoss', component: () => import('@/views/stock/goodsInventoryLoss.vue'), name: 'goodsInventoryLoss', meta: { title: 'goodsInventoryLoss', layout: 'app' } },
            { path: 'goodsInventoryLossAdd', component: () => import('@/views/stock/goodsInventoryLossAdd.vue'), name: 'goodsInventoryLossAdd', meta: { title: 'goodsInventoryLossAdd', layout: 'app' } },
            { path: 'goodsUnderstock', component: () => import('@/views/stock/goodsUnderstock.vue'), name: 'goodsUnderstock', meta: { title: 'goodsUnderstock', layout: 'app' } },
            { path: 'goodsUnderstockAdd', component: () => import('@/views/stock/goodsUnderstockAdd.vue'), name: 'goodsUnderstockAdd', meta: { title: 'goodsUnderstockAdd', layout: 'app' } },
            { path: 'overseasWarehouseAuth', component: () => import('@/views/stock/overseasWarehouseAuth.vue'), name: 'overseasWarehouseAuth', meta: { title: 'overseasWarehouseAuth', layout: 'app' } },
            { path: 'overseasList', component: () => import('@/views/stock/overseasList.vue'), name: 'overseasList', meta: { title: 'overseasList', layout: 'app' } },
        ]
    },
    {
        path: '/package',
        redirect: '/package',
        name: 'package',
        children: [
            { path: 'packageList', component: () => import('@/views/package/packageList.vue'), name: 'packageList', meta: { title: 'packageList', layout: 'app' } },
            { path: 'packagePermissions', component: () => import('@/views/package/packagePermissions.vue'), name: 'packagePermissions', meta: { title: 'packagePermissions', layout: 'app' } },
            { path: 'packageAdd', component: () => import('@/views/package/packageAdd.vue'), name: 'packageAdd', meta: { title: 'packageAdd', layout: 'app' } },
        ]
    },
    {
        path: '/templateManage',
        redirect: '/templateManage',
        name: 'templateManage',
        children: [
            { path: 'smsTemplate', component: () => import('@/views/templateManage/smsTemplate.vue'), name: 'smsTemplate', meta: { title: 'smsTemplate', layout: 'app' } },
            { path: 'systemMessage', component: () => import('@/views/templateManage/systemMessage.vue'), name: 'systemMessage', meta: { title: 'systemMessage', layout: 'app' } },
            { path: 'emailtemplate', component: () => import('@/views/templateManage/emailtemplate.vue'), name: 'emailtemplate', meta: { title: 'emailtemplate', layout: 'app' } },
            { path: 'accountTemplate', component: () => import('@/views/templateManage/accountTemplate.vue'), name: 'accountTemplate', meta: { title: 'accountTemplate', layout: 'app' } },
            /*{ path: 'goodsOutBound', component: () => import('@/views/templateManage/outbound.vue'), name: 'goodsOutBound', meta: { title: 'goodsOutBound' } }, */
        ]
    },
    {
        path: '/setting',
        redirect: '/setting',
        name: 'setting',
        meta: {
            title: 'setting',
            icon: 'setting-manage'
        },
        children: [
            { path: 'companyList', component: () => import('@/views/setting/companyList.vue'), name: 'companyList', meta: { title: 'companyList', layout: 'app' } },
            { path: 'roleManage', component: () => import('@/views/setting/roleManage.vue'), name: 'roleManage', meta: { title: 'roleManage', layout: 'app' } },
            { path: 'roleManageAdd', component: () => import('@/views/setting/roleManageAdd.vue'), name: 'roleManageAdd', meta: { title: 'roleManageAdd', layout: 'app' } },
            { path: 'dicData', component: () => import('@/views/setting/dicData.vue'), name: 'dicData', meta: { title: 'dicData', layout: 'app' } },
            { path: 'menuManage', component: () => import('@/views/setting/menuManage.vue'), name: 'menuManage', meta: { title: 'menuManage', layout: 'app' } },
            { path: 'systemLog', component: () => import('@/views/setting/systemLog.vue'), name: 'systemLog', meta: { title: 'systemLog', layout: 'app' } },
            { path: 'express', component: () => import('@/views/setting/express.vue'), name: 'express', meta: { title: 'express', layout: 'app' } },
        ]
    },
    {
        path: '/companyMent',
        redirect: '/companyMent',
        name: 'companyMent',
        children: [
            { path: 'administratorManage', component: () => import('@/views/companyMent/administratorManage.vue'), name: 'administratorManage', meta: { title: 'administratorManage', layout: 'app' } },
            { path: 'branch', component: () => import('@/views/companyMent/branch.vue'), name: 'branch', meta: { title: 'branch', layout: 'app' } },
            { path: 'companyInfo', component: () => import('@/views/companyMent/companyInfo.vue'), name: 'companyInfo', meta: { title: 'companyInfo', layout: 'app' } },
            { path: 'configMsg', component: () => import('@/views/companyMent/configMsg.vue'), name: 'configMsg', meta: { title: 'configMsg', layout: 'app' } },
            /* Notify */
            { path: 'Notify', component: () => import('@/views/companyMent/Notify.vue'), name: 'Notify', meta: { title: 'Notify', layout: 'app' } },
        ]
    },
    {
        path: '/goods',
        redirect: '/goods',
        name: 'goods',
        children: [
            { path: 'SKUList', component: () => import('@/views/goods/SKUList.vue'), name: 'SKUList', meta: { title: 'SKUList', layout: 'app' } },
            /*  { path: 'branch', component: () => import('@/views/companyMent/branch.vue'), name: 'branch', meta: { title: 'branch', layout: 'app' } },
            { path: 'companyInfo', component: () => import('@/views/companyMent/companyInfo.vue'), name: 'companyInfo', meta: { title: 'companyInfo', layout: 'app' } }, */
        ]
    },
    {
        path: '/order',
        redirect: '/order',
        name: 'order',
        children: [
            { path: 'orderList', component: () => import('@/views/order/orderList.vue'), name: 'orderList', meta: { title: 'orderList', layout: 'app' } },
            /*  { path: 'branch', component: () => import('@/views/companyMent/branch.vue'), name: 'branch', meta: { title: 'branch', layout: 'app' } },
            { path: 'companyInfo', component: () => import('@/views/companyMent/companyInfo.vue'), name: 'companyInfo', meta: { title: 'companyInfo', layout: 'app' } }, */
        ]
    },
];

asyncRouterMap.forEach(route => {
    router.addRoute(route);
});

export { constantRouterMap, asyncRouterMap };
export default router;