diff --git a/app/api/dingtalk/callback/route.ts b/app/api/dingtalk/callback/route.ts
index 3b2904e8..94daf667 100644
--- a/app/api/dingtalk/callback/route.ts
+++ b/app/api/dingtalk/callback/route.ts
@@ -1,5 +1,5 @@
import { NextResponse, type NextRequest } from 'next/server'
-import { parseDingtalkOAuthState } from '@/lib/dingtalk-oauth'
+import { DINGTALK_DIRECT_LOGIN_SOURCE, parseDingtalkOAuthState } from '@/lib/dingtalk-oauth'
import { getPublicAppOrigin } from '@/lib/public-app-url'
import { buildDingtalkAutoLoginPath } from '@/lib/safe-redirect'
@@ -32,9 +32,48 @@ function getInternalLoginUrl() {
return `http://127.0.0.1:${port}/api/dingtalk/login`
}
+function createCookieLandingResponse(redirectPath: string, loginResponse: Response) {
+ const escapedPath = JSON.stringify(redirectPath).replace(/
+
+
+
+
+ 正在进入素材库
+
+
+
+
+
+ 登录成功
+ 正在进入考核调研...
+
+
+
+`,
+ {
+ status: 200,
+ headers: {
+ 'Content-Type': 'text/html; charset=utf-8',
+ 'Cache-Control': 'no-store, no-cache, must-revalidate, max-age=0',
+ },
+ },
+ )
+
+ appendLoginSetCookie(response, loginResponse)
+ return response
+}
+
export async function GET(request: NextRequest) {
const code = request.nextUrl.searchParams.get('code') || request.nextUrl.searchParams.get('authCode')
- const { redirectPath } = parseDingtalkOAuthState(request.nextUrl.searchParams.get('state'))
+ const { redirectPath, source } = parseDingtalkOAuthState(request.nextUrl.searchParams.get('state'))
const publicOrigin = getPublicAppOrigin()
if (!code) {
@@ -62,6 +101,10 @@ export async function GET(request: NextRequest) {
return NextResponse.redirect(url)
}
+ if (source === DINGTALK_DIRECT_LOGIN_SOURCE) {
+ return createCookieLandingResponse(redirectPath, loginResponse)
+ }
+
const redirectResponse = NextResponse.redirect(new URL(redirectPath, publicOrigin))
appendLoginSetCookie(redirectResponse, loginResponse)
redirectResponse.headers.set('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0')