df07b16c7a
1. 飞书客户端内:静默自动登录
- 检测飞书环境 (userAgent + ttjsBridge)
- 调用 ttjsBridge.getAuthCode() 获取授权码
- 自动登录到后台
2. 飞书客户端外:扫码登录
- 后端新增三个接口:
* POST /api/v1/auth/qrcode-login - 生成登录会话和二维码
* GET /api/v1/auth/qrcode-login/status - 轮询登录状态
* GET /login/qrcode/{id} - 飞书授权回调
- 前端新增 QRCodeLogin 组件:
* 使用 qrcode.react 生成二维码
* 每 2 秒轮询登录状态
* 状态:loading → pending → scanning → success/expired
3. 数据库表:feishu_login_session
- 存储 session_id, auth_url, status, user_id
- 状态:pending, scanning, success, expired
- 2 分钟过期机制
4. 其他优化
- 移除审批详情页的 header
- 更新 PROJECT_ISSUES.md 文档
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
31 lines
1.3 KiB
PHP
31 lines
1.3 KiB
PHP
<?php
|
|
|
|
use support\Db;
|
|
|
|
return new class
|
|
{
|
|
public function up(): void
|
|
{
|
|
Db::statement('
|
|
CREATE TABLE IF NOT EXISTS `feishu_login_session` (
|
|
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
|
|
`company_id` bigint unsigned NOT NULL COMMENT '公司ID',
|
|
`tenant_key` varchar(64) NOT NULL COMMENT '租户密钥',
|
|
`status` varchar(20) NOT NULL DEFAULT \'pending\' COMMENT \'pending: 待扫码, scanning: 已扫码待授权, success: 登录成功, expired: 已过期\'',
|
|
`user_id` bigint unsigned DEFAULT NULL COMMENT \'用户ID(登录成功后填充)\'',
|
|
`expires_at` datetime NOT NULL COMMENT \'过期时间\'',
|
|
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
|
|
`updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
PRIMARY KEY (`id`),
|
|
KEY `idx_company_status` (`company_id`, `status`),
|
|
KEY `idx_expires_at` (`expires_at`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT=\'飞书扫码登录会话表\'
|
|
');
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
Db::statement('DROP TABLE IF EXISTS `feishu_login_session`');
|
|
}
|
|
};
|