From 2a3e951acb1abe90293ff449746b054ea26d4634 Mon Sep 17 00:00:00 2001 From: Rogee Date: Wed, 24 Dec 2025 23:09:14 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=9E=E7=8E=B0=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=8C=85=E6=8B=AC=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=90=8D=E5=92=8C=E5=AF=86=E7=A0=81=E8=BE=93=E5=85=A5=E3=80=81?= =?UTF-8?q?=E8=A1=A8=E5=8D=95=E9=AA=8C=E8=AF=81=E5=8F=8A=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/portal/src/router/index.js | 2 +- frontend/portal/src/service/auth.js | 10 ++ .../portal/src/views/pages/auth/Login.vue | 119 ++++++++++++++++-- 3 files changed, 117 insertions(+), 14 deletions(-) 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 @@