diff --git a/frontend/portal/src/router/index.js b/frontend/portal/src/router/index.js index 301dfee..bf3bafa 100644 --- a/frontend/portal/src/router/index.js +++ b/frontend/portal/src/router/index.js @@ -61,7 +61,7 @@ const router = createRouter({ ] }, - { path: '/auth/login', name: 'login', component: TitlePage, meta: { title: '登录' } }, + { path: '/auth/login', name: 'login', component: () => import('@/views/pages/auth/Login.vue'), meta: { title: '登录' } }, { path: '/auth/register', name: 'register', component: () => import('@/views/pages/auth/Register.vue'), meta: { title: '注册' } }, { path: '/auth/forgot-password', name: 'forgotPassword', component: TitlePage, meta: { title: '忘记密码' } }, { path: '/auth/verify', name: 'verify', component: TitlePage, meta: { title: '验证(邮箱/手机)' } }, diff --git a/frontend/portal/src/service/auth.js b/frontend/portal/src/service/auth.js index f354462..baca259 100644 --- a/frontend/portal/src/service/auth.js +++ b/frontend/portal/src/service/auth.js @@ -1,6 +1,16 @@ import { requestJson } from './apiClient'; import { setTokenAndLoadMe } from './session'; +export async function login({ username, password }) { + const data = await requestJson('/v1/auth/login', { + method: 'POST', + body: { username, password } + }); + const token = data?.token ?? ''; + if (token) await setTokenAndLoadMe(token); + return token; +} + export async function register({ username, password, confirmPassword, verifyCode }) { const data = await requestJson('/v1/auth/register', { method: 'POST', diff --git a/frontend/portal/src/views/pages/auth/Login.vue b/frontend/portal/src/views/pages/auth/Login.vue index 48da712..15268bd 100644 --- a/frontend/portal/src/views/pages/auth/Login.vue +++ b/frontend/portal/src/views/pages/auth/Login.vue @@ -1,10 +1,78 @@ @@ -31,25 +99,50 @@ const checked = ref(false); /> - Welcome to PrimeLand! - Sign in to continue + 登录 + 欢迎回来 - Email - + 用户名 + - Password - + 密码 + - - Remember me + + 记住用户名 - Forgot password? + 忘记密码? + + + + + 还没有账号? + 去注册 -