File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
import { createWebHistory, createRouter } from 'vue-router';
// import App from "../App.vue";
import login from '../Login.vue';
import Join from '../Join.vue';
import MyPage from './main/MyPage.vue';
import MyPlan from './main/MyPlan.vue';
import MyPlan2 from './main/MyPlan2.vue';
import PhotoBook from './main/PhotoBook.vue';
import Dashboard from './main/Dashboard.vue';
import AIDashboard from './main/AIDashboard.vue';
import Camera from './main/Camera.vue';
import PhotoDesign from './main/PhotoDesign.vue';
import PhotoEdit from './main/PhotoEdit.vue';
import PreviewNote from './main/PreviewNote.vue';
import Main from './main/Main.vue';
import Main_c from './main/Main_c.vue';
import Chapter1 from './main/Chapter/Chapter1.vue';
import Chapter1_1 from './main/Chapter/Chapter1_1.vue';
import Chapter1_2 from './main/Chapter/Chapter1_2.vue';
import Chapter1_3 from './main/Chapter/Chapter1_3.vue';
import Chapter2 from './main/Chapter/Chapter2.vue';
import Chapter2_1 from './main/Chapter/Chapter2_1.vue';
import Chapter2_2 from './main/Chapter/Chapter2_2.vue';
import Chapter2_3 from './main/Chapter/Chapter2_3.vue';
import Chapter2_4 from './main/Chapter/Chapter2_4.vue';
import Chapter2_5 from './main/Chapter/Chapter2_5.vue';
import Chapter2_6 from './main/Chapter/Chapter2_6.vue';
import Chapter2_7 from './main/Chapter/Chapter2_7.vue';
import Chapter2_8 from './main/Chapter/Chapter2_8.vue';
import Chapter2_9 from './main/Chapter/Chapter2_9.vue';
import Chapter2_10 from './main/Chapter/Chapter2_10.vue';
import Chapter2_11 from './main/Chapter/Chapter2_11.vue';
import Chapter2_12 from './main/Chapter/Chapter2_12.vue';
import Chapter2_13 from './main/Chapter/Chapter2_13.vue';
import Chapter3 from './main/Chapter/Chapter3.vue';
import Chapter3_1 from './main/Chapter/Chapter3_1.vue';
import Chapter3_2 from './main/Chapter/Chapter3_2.vue';
import Chapter3_3 from './main/Chapter/Chapter3_3.vue';
import Chapter3_3_1 from './main/Chapter/Chapter3_3_1.vue';
import Chapter3_4 from './main/Chapter/Chapter3_4.vue';
import Chapter3_5 from './main/Chapter/Chapter3_5.vue';
import Chapter3_6 from './main/Chapter/Chapter3_6.vue';
import Chapter3_7 from './main/Chapter/Chapter3_7.vue';
import Chapter3_8 from './main/Chapter/Chapter3_8.vue';
import Chapter3_9 from './main/Chapter/Chapter3_9.vue';
import Chapter3_10 from './main/Chapter/Chapter3_10.vue';
import Chapter3_11 from './main/Chapter/Chapter3_11.vue';
import Chapter3_12 from './main/Chapter/Chapter3_12.vue';
import Chapter3_13 from './main/Chapter/Chapter3_13.vue';
import Chapter3_14 from './main/Chapter/Chapter3_14.vue';
import Chapter3_15 from './main/Chapter/Chapter3_15.vue';
import Chapter3_16 from './main/Chapter/Chapter3_16.vue';
import Chapter4 from './main/Chapter/Chapter4.vue';
import Chapter5 from './main/Chapter/Chapter5.vue';
import Chapter6 from './main/Chapter/Chapter6.vue';
import Chapter7 from './main/Chapter/Chapter7.vue';
import Chapter8 from './main/Chapter/Chapter8.vue';
import Chapter9 from './main/Chapter/Chapter9.vue';
import Chapter10 from './main/Chapter/Chapter10.vue';
import Chapter11 from './main/Chapter/Chapter11.vue';
import Main_p from './parents/Main_p.vue';
import PhotoBook_p from './parents/PhotoBook_p.vue';
import Main_t from './teacher/Main_t.vue';
import Board from './teacher/Board.vue';
import noticeInsert from './teacher/noticeInsert.vue';
import noticeDetail from './teacher/noticeDetail.vue';
import StudentList from './teacher/StudentList.vue';
import StudentDetail from './teacher/StudentDetail.vue';
import textbook from './teacher/textbook.vue';
import C_Textbook from './teacher/C_Textbook.vue';
import C_TextBookDetail from './teacher/C_TextBookDetail.vue';
import C_TextList from './teacher/C_TextList .vue';
import C_TextInsert from './teacher/C_TextInsert.vue';
import C_QuestionList from './teacher/C_QuestionList.vue';
import C_QuestionInsert from './teacher/C_QuestionInsert.vue';
import C_Voca_List from './teacher/C_Voca_List.vue';
import C_ExamList from './teacher/C_ExamList.vue';
import C_ExamDetail from './teacher/C_ExamDetail.vue';
import C_ExamInsert from './teacher/C_ExamInsert.vue';
import TextBookDetail from './teacher/TextBookDetail.vue';
import Home from './teacher/Home.vue';
import ClassDetail from './teacher/ClassDetail.vue';
import TextList from './teacher/TextList.vue';
import TextInsert from './teacher/TextInsert.vue';
import TextDetail from './teacher/TextDetail.vue';
import QuestionList from './teacher/QuestionList.vue';
import QuestionInsert from './teacher/QuestionInsert.vue';
import QuestionDetail from './teacher/QuestionDetail.vue';
import VocaList from './teacher/VocaList.vue';
import VocaInsert from './teacher/VocaInsert.vue';
import VocaDetail from './teacher/VocaDetail.vue';
import ExamList from './teacher/ExamList.vue';
import ExamDetail from './teacher/ExamDetail.vue';
import ExamInsert from './teacher/ExamInsert.vue';
import RoadMap from './teacher/RoadMap.vue';
import store from './AppStore';
import axios from 'axios';
const routes = [
{ path: '/login.page', name: 'login', component: login },
{ path: '/Join.page', name: 'Join', component: Join },
// { path: '/App.page', name: 'App', component: App,
// children:[
// ]
// },
// { path: '/Main.page', name: 'Main', component: Main},
/* 학생 */
{
path: '/',
name: 'Main',
component: Main,
children: [
{
path: '/Dashboard.page',
name: 'Dashboard',
component: Dashboard,
},
{
path: '/AIDashboard.page',
name: 'AIDashboard',
component: AIDashboard,
},
{ path: '/MyPage.page', name: 'MyPage', component: MyPage },
{ path: '/MyPlan.page', name: 'MyPlan', component: MyPlan },
{ path: '/MyPlan2.page', name: 'MyPlan2', component: MyPlan2 },
{
path: '/PhotoBook.page',
name: 'PhotoBook',
component: PhotoBook,
},
{
path: '/PreviewNote.page',
name: 'PreviewNote',
component: PreviewNote,
},
],
},
{ path: '/Camera.page', name: 'Camera', component: Camera },
{ path: '/PhotoDesign.page', name: 'PhotoDesign', component: PhotoDesign },
{ path: '/PhotoEdit.page', name: 'PhotoEdit', component: PhotoEdit },
/* 지문 */
{ path: '/Chapter1.page', name: 'Chapter1', component: Chapter1 },
{ path: '/Chapter1_1.page', name: 'Chapter1_1', component: Chapter1_1 },
{ path: '/Chapter1_2.page', name: 'Chapter1_2', component: Chapter1_2 },
{ path: '/Chapter1_3.page', name: 'Chapter1_3', component: Chapter1_3 },
/* 단어장 및 지문 문제 */
{ path: '/Chapter2.page', name: 'Chapter2', component: Chapter2 },
{ path: '/Chapter2_1.page', name: 'Chapter2_1', component: Chapter2_1 },
{ path: '/Chapter2_2.page', name: 'Chapter2_2', component: Chapter2_2 },
{ path: '/Chapter2_3.page', name: 'Chapter2_3', component: Chapter2_3 },
{ path: '/Chapter2_4.page', name: 'Chapter2_4', component: Chapter2_4 },
{ path: '/Chapter2_5.page', name: 'Chapter2_5', component: Chapter2_5 },
{ path: '/Chapter2_6.page', name: 'Chapter2_6', component: Chapter2_6 },
{ path: '/Chapter2_7.page', name: 'Chapter2_7', component: Chapter2_7 },
{ path: '/Chapter2_8.page', name: 'Chapter2_8', component: Chapter2_8 },
{ path: '/Chapter2_9.page', name: 'Chapter2_9', component: Chapter2_9 },
{ path: '/Chapter2_10.page', name: 'Chapter2_10', component: Chapter2_10 },
{ path: '/Chapter2_11.page', name: 'Chapter2_11', component: Chapter2_11 },
{ path: '/Chapter2_12.page', name: 'Chapter2_12', component: Chapter2_12 },
{ path: '/Chapter2_13.page', name: 'Chapter2_13', component: Chapter2_13 },
/* 평가 문제 */
{
path: '/Main_c.page',
name: 'Main_c',
component: Main_c,
children: [
{ path: '/Chapter3.page', name: 'Chapter3', component: Chapter3 },
{
path: '/Chapter3_1.page',
name: 'Chapter3_1',
component: Chapter3_1,
},
{
path: '/Chapter3_2.page',
name: 'Chapter3_2',
component: Chapter3_2,
},
{
path: '/Chapter3_3.page',
name: 'Chapter3_3',
component: Chapter3_3,
},
{
path: '/Chapter3_3_1.page',
name: 'Chapter3_3_1',
component: Chapter3_3_1,
},
{
path: '/Chapter3_4.page',
name: 'Chapter3_4',
component: Chapter3_4,
},
{
path: '/Chapter3_5.page',
name: 'Chapter3_5',
component: Chapter3_5,
},
{
path: '/Chapter3_6.page',
name: 'Chapter3_6',
component: Chapter3_6,
},
{
path: '/Chapter3_7.page',
name: 'Chapter3_7',
component: Chapter3_7,
},
{
path: '/Chapter3_8.page',
name: 'Chapter3_8',
component: Chapter3_8,
},
{
path: '/Chapter3_9.page',
name: 'Chapter3_9',
component: Chapter3_9,
},
{
path: '/Chapter3_10.page',
name: 'Chapter3_10',
component: Chapter3_10,
},
{
path: '/Chapter3_11.page',
name: 'Chapter3_11',
component: Chapter3_11,
},
{
path: '/Chapter3_12.page',
name: 'Chapter3_12',
component: Chapter3_12,
},
{
path: '/Chapter3_13.page',
name: 'Chapter3_13',
component: Chapter3_13,
},
{
path: '/Chapter3_14.page',
name: 'Chapter3_14',
component: Chapter3_14,
},
{
path: '/Chapter3_15.page',
name: 'Chapter3_15',
component: Chapter3_15,
},
],
},
/* 설문 조사 페이지*/
{ path: '/Chapter3_16.page', name: 'Chapter3_16', component: Chapter3_16 },
/* 평가 결과 페이지*/
{ path: '/Chapter4.page', name: 'Chapter4', component: Chapter4 },
{ path: '/Chapter5.page', name: 'Chapter5', component: Chapter5 },
{ path: '/Chapter6.page', name: 'Chapter6', component: Chapter6 },
{ path: '/Chapter7.page', name: 'Chapter7', component: Chapter7 },
{ path: '/Chapter8.page', name: 'Chapter8', component: Chapter8 },
{ path: '/Chapter9.page', name: 'Chapter9', component: Chapter9 },
{ path: '/Chapter10.page', name: 'Chapter10', component: Chapter10 },
{ path: '/Chapter11.page', name: 'Chapter11', component: Chapter11 },
/* 부모님 */
{ path: '/Main_p.page', name: 'Main_p', component: Main_p },
{ path: '/PhotoBook_p.page', name: 'PhotoBook_p', component: PhotoBook_p },
/* 선생님 */
{
path: '/Main_t.page',
name: 'Main_t',
component: Main_t,
children: [
{ path: '/Board.page', name: 'Board', component: Board },
{
path: '/noticeInsert.page',
name: 'noticeInsert',
component: noticeInsert,
},
{
path: '/noticeDetail.page',
name: 'noticeDetail',
component: noticeDetail,
},
{ path: '/Home.page', name: 'Home', component: Home },
{
path: '/ClassDetail.page',
name: 'ClassDetail',
component: ClassDetail,
},
{
path: '/StudentList.page',
name: 'StudentList',
component: StudentList,
},
{
path: '/StudentDetail.page',
name: 'StudentDetail',
component: StudentDetail,
},
{
path: '/C_Textbook.page',
name: 'C_Textbook',
component: C_Textbook,
},
{ path: '/textbook.page', name: 'textbook', component: textbook },
{
path: '/TextBookDetail.page',
name: 'TextBookDetail',
component: TextBookDetail,
},
{
path: '/C_TextBookDetail.page',
name: 'C_TextBookDetail',
component: C_TextBookDetail,
},
{ path: '/TextList.page', name: 'TextList', component: TextList },
{
path: '/TextInsert.page',
name: 'TextInsert',
component: TextInsert,
},
{
path: '/TextDetail.page',
name: 'TextDetail',
component: TextDetail,
},
{
path: '/QuestionList.page',
name: 'QuestionList',
component: QuestionList,
},
{
path: '/QuestionInsert.page',
name: 'QuestionInsert',
component: QuestionInsert,
},
{
path: '/QuestionDetail.page',
name: 'QuestionDetail',
component: QuestionDetail,
},
{ path: '/VocaList.page', name: 'VocaList', component: VocaList },
{
path: '/VocaInsert.page',
name: 'VocaInsert',
component: VocaInsert,
},
{
path: '/VocaDetail.page',
name: 'VocaDetail',
component: VocaDetail,
},
{ path: '/ExamList.page', name: 'ExamList', component: ExamList },
{
path: '/ExamDetail.page',
name: 'ExamDetail',
component: ExamDetail,
},
{
path: '/ExamInsert.page',
name: 'ExamInsert',
component: ExamInsert,
},
{
path: '/C_TextList.page',
name: 'C_TextList',
component: C_TextList,
},
{
path: '/C_TextInsert.page',
name: 'C_TextInsert',
component: C_TextInsert,
},
{
path: '/C_QuestionList.page',
name: 'C_QuestionList',
component: C_QuestionList,
},
{
path: '/C_QuestionInsert.page',
name: 'C_QuestionInsert',
component: C_QuestionInsert,
},
{
path: '/C_Voca_List.page',
name: 'C_Voca_List',
component: C_Voca_List,
},
{
path: '/C_ExamList.page',
name: 'C_ExamList',
component: C_ExamList,
},
{
path: '/C_ExamDetail.page',
name: 'C_ExamDetail',
component: C_ExamDetail,
},
{
path: '/C_ExamInsert.page',
name: 'C_ExamInsert',
component: C_ExamInsert,
},
{ path: '/RoadMap.page', name: 'RoadMap', component: RoadMap },
{
path: '/TextDetail.page',
name: 'TextDetail',
component: TextDetail,
},
],
},
];
const AppRouter = createRouter({
history: createWebHistory(),
routes,
});
AppRouter.beforeEach((to, from, next) => {
const token = localStorage.getItem('token');
if (!token && to.name !== 'login' && to.name !== 'Join') {
// 토큰이 없고 로그인 페이지가 아닐 경우 로그인 페이지로 리다이렉트
next({ name: 'login' });
} else if (token) {
// 토큰이 있을 경우 역할에 따른 접근 제어
const tokenParts = token.split('.');
const payload = tokenParts[1];
const base64 = payload.replace(/-/g, '+').replace(/_/g, '/');
const jsonPayload = decodeURIComponent(
Array.prototype.map
.call(atob(base64), (c) => {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
})
.join('')
);
const userInfo = JSON.parse(jsonPayload);
const teacherRoutes = routes[36].children.map((route) => route.path);
if (userInfo.author[0].authority === 'STUDENT') {
if (teacherRoutes.includes(to.path) || to.name === 'Main_p') {
next({ name: 'MyPlan' });
} else {
next(); // 다른 페이지로 접근 허용
}
} else if (userInfo.author[0].authority === 'TEACHER') {
if (!teacherRoutes.includes(to.path)) {
next({ name: 'Home' });
} else {
next();
}
} else if (userInfo.author[0].authority === 'PARENT') {
if (to.name === 'PhotoBook_p') {
next();
}
if (to.name !== 'Main_p') {
next({ name: 'Main_p' });
} else {
next();
}
} else {
next();
}
} else {
next();
}
});
export default AppRouter;