From bd809479e64477a473526a51609f905dbbea91f3 Mon Sep 17 00:00:00 2001 From: JiaoTianBo Date: Fri, 27 Mar 2026 17:49:32 +0800 Subject: [PATCH] =?UTF-8?q?feat(login):=20=E9=9B=86=E6=88=90=E9=A3=9E?= =?UTF-8?q?=E4=B9=A6=E7=99=BB=E5=BD=95=E5=8A=9F=E8=83=BD=E5=8F=8A=E5=85=B6?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E7=95=8C=E9=9D=A2=E5=92=8C=E8=B7=AF=E7=94=B1?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增飞书登录API接口定义及请求方法 - 添加飞书登录相关的类型声明 - 本地多语言文件增加飞书登录文案(中英文) - 登录页面新增飞书登录视图和样式,支持扫码或授权登录 - 添加飞书登录状态控制、回调处理逻辑,支持token和用户信息存储 - 路由白名单增加飞书登录回调路径,避免权限拦截 - 登录页新增切换账号密码登录和飞书登录的切换按钮 - Vite配置新增本地api代理规则,便于接口联调测试 --- locales/en.yaml | 1 + locales/zh-CN.yaml | 1 + src/api/feishu.ts | 33 +++++ src/api/默认模块.openapi.json | 81 +++++++++++++ src/router/index.ts | 2 +- src/views/login/index.vue | 215 ++++++++++++++++++++++++++++++++- src/views/login/utils/enums.ts | 4 + vite.config.ts | 8 +- 8 files changed, 340 insertions(+), 5 deletions(-) create mode 100644 src/api/feishu.ts create mode 100644 src/api/默认模块.openapi.json diff --git a/locales/en.yaml b/locales/en.yaml index 651ff31..7ff11b5 100644 --- a/locales/en.yaml +++ b/locales/en.yaml @@ -220,6 +220,7 @@ login: pureAlipayLogin: Alipay Login pureQQLogin: QQ Login pureWeiBoLogin: Weibo Login + pureFeishuLogin: Feishu Login purePhone: Phone pureSmsVerifyCode: SMS VerifyCode pureBack: Back diff --git a/locales/zh-CN.yaml b/locales/zh-CN.yaml index f89dcf8..c6b318b 100644 --- a/locales/zh-CN.yaml +++ b/locales/zh-CN.yaml @@ -220,6 +220,7 @@ login: pureAlipayLogin: 支付宝登录 pureQQLogin: QQ登录 pureWeiBoLogin: 微博登录 + pureFeishuLogin: 飞书登录 purePhone: 手机号码 pureSmsVerifyCode: 短信验证码 pureBack: 返回 diff --git a/src/api/feishu.ts b/src/api/feishu.ts new file mode 100644 index 0000000..2456620 --- /dev/null +++ b/src/api/feishu.ts @@ -0,0 +1,33 @@ +import { http } from "@/utils/http"; + +export type FeishuLoginResult = { + code: number; + message: string; + data: { + /** 是否登录成功 */ + isLogin: boolean; + /** 用户ID */ + userId: string | number; + /** 用户名 */ + username: string; + /** 真实姓名 */ + realName: string; + /** 头像 */ + avatar: string; + /** 手机号 */ + phone: string; + /** 邮箱 */ + email: string; + /** token */ + token: string; + /** token名称 */ + tokenName: string; + }; +}; + +/** 飞书OAuth登录接口(前端回调后调用) */ +export const getFeishuLogin = (code: string) => { + return http.request("post", "/api/v1/auth/feishu/login", { + params: { code } + }); +}; diff --git a/src/api/默认模块.openapi.json b/src/api/默认模块.openapi.json new file mode 100644 index 0000000..2084c28 --- /dev/null +++ b/src/api/默认模块.openapi.json @@ -0,0 +1,81 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "默认模块", + "description": "", + "version": "1.0.0" + }, + "tags": [], + "paths": { + "/api/v1/auth/feishu/login": { + "post": { + "summary": "飞书OAuth登录接口(前端回调后调用)", + "deprecated": false, + "description": "前端从飞书回调中获取code,然后调用此接口完成登录", + "tags": [], + "parameters": [ + { + "name": "code", + "in": "query", + "description": "飞书授权码", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BaseResponseMapObject", + "description": "登录结果(包含token和用户信息)" + } + } + } + } + }, + "security": [] + } + } + }, + "components": { + "schemas": { + "BaseResponseMapObject": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "" + }, + "data": { + "type": "object", + "properties": { + "isLogin": { + "type": "boolean" + }, + "userId": { + "$ref": "#/components/schemas/userId" + } + }, + "description": "" + }, + "message": { + "description": "", + "type": "null" + } + } + }, + "userId": { + "type": "object", + "properties": {} + } + }, + "responses": {}, + "securitySchemes": {} + }, + "servers": [], + "security": [] +} diff --git a/src/router/index.ts b/src/router/index.ts index b92a529..290d74d 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -116,7 +116,7 @@ export function resetRouter() { } /** 路由白名单 */ -const whiteList = ["/login"]; +const whiteList = ["/login", "/auth/callback"]; const { VITE_HIDE_HOME } = import.meta.env; diff --git a/src/views/login/index.vue b/src/views/login/index.vue index f6c0d64..8fc7575 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -1,7 +1,7 @@