From 191eb7cd8eaa21b67527cd717253bdbc9daed00b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=90=E9=98=B3?= <2260837959@qq.com> Date: Tue, 2 Dec 2025 08:21:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/proxy.ts | 6 +++--- mock/user.ts | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/config/proxy.ts b/config/proxy.ts index e44f0f72..aaae8f07 100644 --- a/config/proxy.ts +++ b/config/proxy.ts @@ -12,10 +12,10 @@ export default { // 如果需要自定义本地开发服务器 请取消注释按需调整 dev: { - // localhost:8000/api/** -> https://preview.pro.ant.design/api/** + // localhost:8003/api/** -> http://localhost:8003/api/ '/api/': { - // 要代理的地址 - 使用本地mock服务 - target: 'http://localhost:8000', + // 要代理的地址 - 指向开发服务器自身 + target: 'http://localhost:8003', // 配置了这个可以从 http 代理到 https // 依赖 origin 的功能可能需要这个,比如 cookie changeOrigin: true, diff --git a/mock/user.ts b/mock/user.ts index 06125bf5..cfb92877 100644 --- a/mock/user.ts +++ b/mock/user.ts @@ -157,6 +157,27 @@ export default { }); access = 'guest'; }, + // 支持GET请求的登录接口 + 'GET /api/login/account': async (req: Request, res: Response) => { + const { token, username, type } = req.query; + await waitTime(1000); + if (token === '123' || username === 'admin') { + res.send({ + status: 'ok', + type: type || 'account', + currentAuthority: 'admin', + token: '123', + }); + access = 'admin'; + return; + } + res.send({ + status: 'error', + type: type || 'account', + currentAuthority: 'guest', + }); + access = 'guest'; + }, 'POST /api/login/outLogin': (_req: Request, res: Response) => { access = ''; res.send({ data: {}, success: true });