Initial commit

This commit is contained in:
2025-10-14 14:17:21 +08:00
commit ac715a8b88
35011 changed files with 3834178 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
'use client'
import React from 'react'
import ChatWithHistoryWrap from '@/app/components/base/chat/chat-with-history'
const Chat = () => {
return (
<ChatWithHistoryWrap />
)
}
export default React.memo(Chat)

View File

@@ -0,0 +1,11 @@
'use client'
import React from 'react'
import EmbeddedChatbot from '@/app/components/base/chat/embedded-chatbot'
const Chatbot = () => {
return (
<EmbeddedChatbot />
)
}
export default React.memo(Chatbot)

View File

@@ -0,0 +1,10 @@
import React from 'react'
import Main from '@/app/components/share/text-generation'
const Completion = () => {
return (
<Main />
)
}
export default React.memo(Completion)

View File

@@ -0,0 +1,19 @@
import React from 'react'
import type { FC } from 'react'
import type { Metadata } from 'next'
export const metadata: Metadata = {
icons: 'data:,', // prevent browser from using default favicon
}
const Layout: FC<{
children: React.ReactNode
}> = ({ children }) => {
return (
<div className="min-w-[300px] h-full pb-[env(safe-area-inset-bottom)]">
{children}
</div>
)
}
export default Layout

View File

@@ -0,0 +1,103 @@
'use client'
import { useRouter, useSearchParams } from 'next/navigation'
import type { FC } from 'react'
import React, { useEffect } from 'react'
import cn from '@/utils/classnames'
import Toast from '@/app/components/base/toast'
import { fetchSystemFeatures, fetchWebOAuth2SSOUrl, fetchWebOIDCSSOUrl, fetchWebSAMLSSOUrl } from '@/service/share'
import { setAccessToken } from '@/app/components/share/utils'
import Loading from '@/app/components/base/loading'
const WebSSOForm: FC = () => {
const searchParams = useSearchParams()
const router = useRouter()
const redirectUrl = searchParams.get('redirect_url')
const tokenFromUrl = searchParams.get('web_sso_token')
const message = searchParams.get('message')
const showErrorToast = (message: string) => {
Toast.notify({
type: 'error',
message,
})
}
const getAppCodeFromRedirectUrl = () => {
const appCode = redirectUrl?.split('/').pop()
if (!appCode)
return null
return appCode
}
const processTokenAndRedirect = async () => {
const appCode = getAppCodeFromRedirectUrl()
if (!appCode || !tokenFromUrl || !redirectUrl) {
showErrorToast('redirect url or app code or token is invalid.')
return
}
await setAccessToken(appCode, tokenFromUrl)
router.push(redirectUrl)
}
const handleSSOLogin = async (protocol: string) => {
const appCode = getAppCodeFromRedirectUrl()
if (!appCode || !redirectUrl) {
showErrorToast('redirect url or app code is invalid.')
return
}
switch (protocol) {
case 'saml': {
const samlRes = await fetchWebSAMLSSOUrl(appCode, redirectUrl)
router.push(samlRes.url)
break
}
case 'oidc': {
const oidcRes = await fetchWebOIDCSSOUrl(appCode, redirectUrl)
router.push(oidcRes.url)
break
}
case 'oauth2': {
const oauth2Res = await fetchWebOAuth2SSOUrl(appCode, redirectUrl)
router.push(oauth2Res.url)
break
}
default:
showErrorToast('SSO protocol is not supported.')
}
}
useEffect(() => {
const init = async () => {
const res = await fetchSystemFeatures()
const protocol = res.sso_enforced_for_web_protocol
if (message) {
showErrorToast(message)
return
}
if (!tokenFromUrl) {
await handleSSOLogin(protocol)
return
}
await processTokenAndRedirect()
}
init()
}, [message, tokenFromUrl]) // Added dependencies to useEffect
return (
<div className="flex items-center justify-center h-full">
<div className={cn('flex flex-col items-center w-full grow justify-center', 'px-6', 'md:px-[108px]')}>
<Loading type='area' />
</div>
</div>
)
}
export default React.memo(WebSSOForm)

View File

@@ -0,0 +1,11 @@
import React from 'react'
import Main from '@/app/components/share/text-generation'
const Workflow = () => {
return (
<Main isWorkflow />
)
}
export default React.memo(Workflow)