import { createWebHistory, createRouter } from "vue-router"; import Main from "../pages/main/Main.vue"; import Login from "../pages/login/Login.vue"; import store from './AppStore' import axios from 'axios'; // 기준정보 BaselinInformation import Bi001 from "./AccountingManagement/BaselineInformation/Bi001.vue"; import Bi002 from "./AccountingManagement/BaselineInformation/Bi002.vue"; import Bi003 from "./AccountingManagement/BaselineInformation/Bi003.vue"; import Bi004 from "./AccountingManagement/BaselineInformation/Bi004.vue"; import Bi005 from "./AccountingManagement/BaselineInformation/Bi005.vue"; import Bi006 from "./AccountingManagement/BaselineInformation/Bi006.vue"; import Bi007 from "./AccountingManagement/BaselineInformation/Bi007.vue"; import Cm001 from "./AccountingManagement/ChitManagement/Cm001.vue"; import Cm002 from "./AccountingManagement/ChitManagement/Cm002.vue"; const routes = [ /* 메인화면 */ { path: "/", name: "/", component: Main }, { path: "/Login.page", name: "Login", component: Login },//로그인 // 기준정보 BaselinInformation { path: "/Bi001.page", name: "Bi001", component: Bi001 }, //(회계)공동코드 등록 { path: "/Bi002.page", name: "Bi002", component: Bi002 }, //거래처정보 등록 { path: "/Bi003.page", name: "Bi003", component: Bi003 }, //계정과목 등록 { path: "/Bi004.page", name: "Bi004", component: Bi004 }, //재무제표 양식 등록 { path: "/Bi005.page", name: "Bi005", component: Bi005 }, //재무제표 계정설정등록 { path: "/Bi006.page", name: "Bi006", component: Bi006 }, //은행계좌 등록 { path: "/Bi007.page", name: "Bi007", component: Bi007 }, //거래처대장 // 전표관리 { path: "/Cm001.page", name: "Cm001", component: Cm001 }, //잔액 이월 전표등록 { path: "/Cm002.page", name: "Cm002", component: Cm002 }, //전표작성(일반) ]; const AppRouter = createRouter({ history: createWebHistory(), routes, }); AppRouter.beforeEach(async (to, from, next)=>{ const userId = store.state.loginUser; if(userId == null && to.path != '/login.page'){ var vm = this; axios({ url: '/getLoginInfo.json', method: 'post', headers: { 'Content-Type': 'application/json; charset=UTF-8' } }).then(function (response) { // 로그인 정보 있음 if(response.data.checkMessage.status > 0){ store.commit('setLoginUser',response.data.resultData.LoginUserInfo); next() }else{ next('/login.page') } }).catch(function (error) { console.log(error); }); }else{ if(to.path == '/login.page' && userId != null ){ next('/Cm001.page') }else if(to.path == '/login.page' && userId == null){ next() }else if(to.path != '/login.page' && userId == null){ next('/login.page') }else{ next() } } }) export default AppRouter;