From 361287b098f3d28d4d35f2e7bfecb2c7dc685353 Mon Sep 17 00:00:00 2001 From: leejunghyeok Date: Mon, 20 May 2024 08:44:37 +0900 Subject: [PATCH] feat : page upload --- package-lock.json | 18 ++++ package.json | 2 + src/api/article.js | 4 +- src/api/member.js | 27 +++++ src/components/AppHeader.vue | 40 ++++++- src/components/article/ArticleList.vue | 36 ++++++- src/components/users/UserLogin.vue | 82 +++++++++++++++ src/components/users/UserMyPage.vue | 40 +++++++ src/components/users/UserRegister.vue | 82 +++++++++++++++ src/main.js | 9 +- src/router/index.js | 49 +++++++++ src/stores/member.js | 139 +++++++++++++++++++++++++ src/stores/menu.js | 19 ++++ src/utils/http-status.js | 11 ++ src/views/TheUserView.vue | 14 +++ 15 files changed, 565 insertions(+), 7 deletions(-) create mode 100644 src/api/member.js create mode 100644 src/components/users/UserLogin.vue create mode 100644 src/components/users/UserMyPage.vue create mode 100644 src/components/users/UserRegister.vue create mode 100644 src/stores/member.js create mode 100644 src/stores/menu.js create mode 100644 src/utils/http-status.js create mode 100644 src/views/TheUserView.vue diff --git a/package-lock.json b/package-lock.json index 1bc147c..ea5c53c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,9 @@ "version": "0.0.0", "dependencies": { "axios": "^1.6.8", + "jwt-decode": "^4.0.0", "pinia": "^2.1.7", + "pinia-plugin-persistedstate": "^3.2.1", "vue": "^3.4.21", "vue-router": "^4.3.0" }, @@ -2847,6 +2849,14 @@ "graceful-fs": "^4.1.6" } }, + "node_modules/jwt-decode": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jwt-decode/-/jwt-decode-4.0.0.tgz", + "integrity": "sha512-+KJGIyHgkGuIq3IEBNftfhW/LfWhXUIY6OmyVWjliu5KH1y0fw7VQ8YndE2O4qZdMSd9SqbnC8GOcZEy0Om7sA==", + "engines": { + "node": ">=18" + } + }, "node_modules/keyv": { "version": "4.5.4", "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", @@ -3239,6 +3249,14 @@ } } }, + "node_modules/pinia-plugin-persistedstate": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/pinia-plugin-persistedstate/-/pinia-plugin-persistedstate-3.2.1.tgz", + "integrity": "sha512-MK++8LRUsGF7r45PjBFES82ISnPzyO6IZx3CH5vyPseFLZCk1g2kgx6l/nW8pEBKxxd4do0P6bJw+mUSZIEZUQ==", + "peerDependencies": { + "pinia": "^2.0.0" + } + }, "node_modules/pinia/node_modules/vue-demi": { "version": "0.14.7", "resolved": "https://registry.npmjs.org/vue-demi/-/vue-demi-0.14.7.tgz", diff --git a/package.json b/package.json index e726799..3d73068 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,9 @@ }, "dependencies": { "axios": "^1.6.8", + "jwt-decode": "^4.0.0", "pinia": "^2.1.7", + "pinia-plugin-persistedstate": "^3.2.1", "vue": "^3.4.21", "vue-router": "^4.3.0" }, diff --git a/src/api/article.js b/src/api/article.js index a566dfa..a876094 100644 --- a/src/api/article.js +++ b/src/api/article.js @@ -2,9 +2,9 @@ import { localAxios } from '@/utils/http-commons'; const local = localAxios; -function getArticles(success, fail) { +function getArticles(params,success, fail) { //list - local.get('/article/list').then(success).catch(fail); + local.get('/article/list',{ params }).then(success).catch(fail); } function searchArticle(keyword, success, fail) { diff --git a/src/api/member.js b/src/api/member.js new file mode 100644 index 0000000..a58531a --- /dev/null +++ b/src/api/member.js @@ -0,0 +1,27 @@ +import { localAxios } from "@/utils/http-commons"; + +const local = localAxios; + +async function userConfirm(param, success, fail) { + await local.post(`/member/login`, param).then(success).catch(fail); +} + +async function findById(userid, success, fail) { + local.defaults.headers["Authorization"] = sessionStorage.getItem("accessToken"); + await local.get(`/member/info/${userid}`).then(success).catch(fail); +} + +async function tokenRegeneration(user, success, fail) { + local.defaults.headers["refreshToken"] = sessionStorage.getItem("refreshToken"); //axios header에 refresh-token 셋팅 + await local.post(`/member/refresh`, user).then(success).catch(fail); +} + +async function logout(userid, success, fail) { + await local.get(`/member/logout/${userid}`).then(success).catch(fail); +} + +function registMember(member, success, fail) { + local.post('/member/join',JSON.stringify(member)).then(success).catch(fail); +} + +export { userConfirm, findById, tokenRegeneration, logout, registMember }; diff --git a/src/components/AppHeader.vue b/src/components/AppHeader.vue index 9cb2404..142119c 100644 --- a/src/components/AppHeader.vue +++ b/src/components/AppHeader.vue @@ -1,5 +1,21 @@