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 @@