diff --git a/public/background1.jpg b/public/background1.jpg new file mode 100644 index 0000000..ac3a6e2 Binary files /dev/null and b/public/background1.jpg differ diff --git a/public/background2.jpg b/public/background2.jpg new file mode 100644 index 0000000..1a756c2 Binary files /dev/null and b/public/background2.jpg differ diff --git a/src/assets/avatar.jpg b/src/assets/avatar.jpg new file mode 100644 index 0000000..cf7c939 Binary files /dev/null and b/src/assets/avatar.jpg differ diff --git a/src/components/HelloWorld.vue b/src/components/HelloWorld.vue index ae9327e..6e484f8 100644 --- a/src/components/HelloWorld.vue +++ b/src/components/HelloWorld.vue @@ -1,7 +1,7 @@ + \ No newline at end of file diff --git a/src/router/authentication.js b/src/router/authentication.js index 7c0f2e7..b04a1e6 100644 --- a/src/router/authentication.js +++ b/src/router/authentication.js @@ -1,10 +1,23 @@ -// !!!这是一个示例,请根据实际情况修改!!! -// import Login from '../views/authentication/Login.vue' -// import Register from '../views/authentication/Register.vue' -// import Profile from '../views/authentication/Profile.vue' +// authentication.js +import Login from '../views/authentication/Login.vue'; +import Register from '../views/authentication/Register.vue'; +import Profile from '../views/authentication/Profile.vue'; export default [ - // { path: '/login', component: Login }, - // { path: '/register', component: Register }, - // { path: '/profile', component: Profile } -] + { + path: '/login', + name: 'Login', + component: Login + }, + { + path: '/register', + name: 'Register', + component: Register + }, + { + path: '/profile', + // path: '/profile/:userId', + name: 'Profile', + component: Profile + } +]; \ No newline at end of file diff --git a/src/services/authenticationService.js b/src/services/authenticationService.js index e69de29..001fae7 100644 --- a/src/services/authenticationService.js +++ b/src/services/authenticationService.js @@ -0,0 +1,34 @@ +// authenticationService.js +import axios from 'axios'; + +const API_URL = '/api'; + +class AuthenticationService { + login(credentials) { + return axios.post(`${API_URL}/login`, credentials); + } + + register(user) { + return axios.post(`${API_URL}/register`, user); + } + + updateUserInfo(user) { + return axios.post(`${API_URL}/update`, user); + } + + changePassword(data) { + return axios.post(`${API_URL}/changePassword`, null, { + params: { + username: data.username, + oldPassword: data.oldPassword, + newPassword: data.newPassword + } + }); + } + + getUserInfo(token) { + return axios.get(`${API_URL}/profile?token=${token}`); + } +} + +export default new AuthenticationService(); \ No newline at end of file diff --git a/src/store/authentication.js b/src/store/authentication.js index 77ff04e..7e79daf 100644 --- a/src/store/authentication.js +++ b/src/store/authentication.js @@ -1,24 +1,25 @@ const state = { - user: null + token: null } const mutations = { - setUser(state, user) { - state.user = user + setUser(state, {token}) { + state.token = token } } const actions = { - login({ commit }, user) { - commit('setUser', user) + login({commit}, token) { + commit('setUser', token) }, - logout({ commit }) { + logout({commit}) { commit('setUser', null) } } const getters = { - isAuthenticated: state => !!state.user + isAuthenticated: state => !!state.token, + token: state => state.token } export default { diff --git a/src/views/authentication/Login.vue b/src/views/authentication/Login.vue new file mode 100644 index 0000000..3868819 --- /dev/null +++ b/src/views/authentication/Login.vue @@ -0,0 +1,73 @@ + + + + + \ No newline at end of file diff --git a/src/views/authentication/Profile.vue b/src/views/authentication/Profile.vue new file mode 100644 index 0000000..77350b3 --- /dev/null +++ b/src/views/authentication/Profile.vue @@ -0,0 +1,189 @@ + + + + + \ No newline at end of file diff --git a/src/views/authentication/Register.vue b/src/views/authentication/Register.vue new file mode 100644 index 0000000..2487f46 --- /dev/null +++ b/src/views/authentication/Register.vue @@ -0,0 +1,84 @@ + + + \ No newline at end of file diff --git a/src/views/user-management/Profile.vue b/src/views/user-management/Profile.vue new file mode 100644 index 0000000..2fb1d7b --- /dev/null +++ b/src/views/user-management/Profile.vue @@ -0,0 +1,56 @@ + + + \ No newline at end of file