Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ui/src/api/admin/auth/external-login.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/** 提供 Admin 第三方认证、扫码登录及客户端授权回调接口。 */

import { get } from '../core/request'
import type { ExternalAuthSetting, LoginResponse, QrCodeSource } from './types'
import type { ExternalAuthSetting, QrCodeSource } from '@/api/types'
import type { LoginResponse } from './types'

/** 获取外部认证方式的跳转配置。 */
const getExternalAuthSetting = (authType: string) => {
Expand Down
20 changes: 1 addition & 19 deletions ui/src/api/admin/auth/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** Admin 认证 API 及其 Store 消费方共同使用的类型。 */

import type { LoginMethod, QrCodeConfig, WorkspaceItem } from '@/api/types'
import type { WorkspaceItem } from '@/api/types'

export interface CurrentUserInfo {
email: string
Expand Down Expand Up @@ -32,24 +32,6 @@ export interface CaptchaResponse {
captcha: string
}

export interface ExternalAuthConfig {
authEndpoint?: string
clientId?: string
ldpUri?: string
redirectUrl: string
scope?: string
state?: string
}

export interface ExternalAuthSetting {
config?: ExternalAuthConfig
}

export interface QrCodeSource {
auth_type: Extract<LoginMethod, 'dingtalk' | 'lark' | 'wecom'>
config: QrCodeConfig
}

export interface BaseProfile {
edition: 'CE' | 'EE' | 'PE'
license_is_valid: boolean
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { del, get, getExportFile, put } from '@/api/admin/core/request'
import type { ParamsPage, ResponsePage } from '@/api/admin/core/types'
import type { ApplicationAccessToken, ApplicationAccessTokenPayload, ApplicationDetail, ApplicationFormPayload, Dict } from '@/api/types'
import type {
ApplicationAccessToken,
ApplicationAccessTokenPayload,
ApplicationDetail,
ApplicationDisplaySetting,
ApplicationFormPayload,
Dict,
} from '@/api/types'

const prefix = '/system/resource/application'

Expand Down Expand Up @@ -45,6 +52,9 @@ const getAccessToken = (applicationId: string) => get<ApplicationAccessToken>(`$
const putAccessToken = (applicationId: string, payload: ApplicationAccessTokenPayload) =>
put<ApplicationAccessTokenPayload, ApplicationAccessToken>(`${prefix}/${applicationId}/access_token`, payload)

/** 获取智能体展示设置,仅许可证有效的专业版、企业版提供;未保存过的字段可能缺失。 */
const getDisplaySetting = (applicationId: string) => get<Partial<ApplicationDisplaySetting>>(`${prefix}/${applicationId}/setting`)

/** 保存智能体展示设置,沿用 V2 图片与配置的 multipart 协议。 */
const putDisplaySetting = (applicationId: string, payload: FormData) => put<FormData>(`${prefix}/${applicationId}/setting`, payload)

Expand All @@ -63,6 +73,7 @@ export default {
getApplicationDetail,
getAccessToken,
putAccessToken,
getDisplaySetting,
putDisplaySetting,
putApplication,
putApplicationPublish,
Expand Down
13 changes: 12 additions & 1 deletion ui/src/api/admin/workspace/application/application.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { del, get, getExportFile, post, put } from '../../core/request'
import type { ParamsPage, ResponsePage } from '../../core/types'
import type { ApplicationAccessToken, ApplicationAccessTokenPayload, ApplicationDetail, ApplicationFormPayload, Dict } from '@/api/types'
import type {
ApplicationAccessToken,
ApplicationAccessTokenPayload,
ApplicationDetail,
ApplicationDisplaySetting,
ApplicationFormPayload,
Dict,
} from '@/api/types'
import { getWorkspaceId } from '@/utils/resource-context'

const getPrefix = () => {
Expand Down Expand Up @@ -34,6 +41,9 @@ const getAccessToken = (applicationId: string) => get<ApplicationAccessToken>(`$
const putAccessToken = (applicationId: string, payload: ApplicationAccessTokenPayload) =>
put<ApplicationAccessTokenPayload, ApplicationAccessToken>(`${getPrefix()}/${applicationId}/access_token`, payload)

/** 获取智能体展示设置,仅许可证有效的专业版、企业版提供;未保存过的字段可能缺失。 */
const getDisplaySetting = (applicationId: string) => get<Partial<ApplicationDisplaySetting>>(`${getPrefix()}/${applicationId}/setting`)

/** 保存智能体展示设置,沿用 V2 图片与配置的 multipart 协议。 */
const putDisplaySetting = (applicationId: string, payload: FormData) => put<FormData>(`${getPrefix()}/${applicationId}/setting`, payload)

Expand Down Expand Up @@ -103,6 +113,7 @@ export default {
getApplicationDetail,
getAccessToken,
putAccessToken,
getDisplaySetting,
putDisplaySetting,
deleteApplication,
exportApplication,
Expand Down
41 changes: 38 additions & 3 deletions ui/src/api/chat/auth.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/** 提供单应用对话与门户的认证前置配置、匿名认证、登录和登出接口。 */
/** 提供单应用对话与门户的认证前置配置、匿名认证、账号/第三方/扫码登录和登出接口。 */

import { get, post, promise, request } from './core/request'
import type { ApiResponse } from './core/types'
import type { ApplicationAuthProfile, ChatLoginRequest, ChatLoginResponse, PortalAuthProfile } from '@/api/types'
import type { ApplicationAuthProfile, ChatLoginRequest, ChatLoginResponse, ExternalAuthSetting, PortalAuthProfile, QrCodeSource } from '@/api/types'

interface ChatCaptchaResponse {
captcha: string
Expand Down Expand Up @@ -43,6 +43,30 @@ const postLogin = (loginRequest: ChatLoginRequest, accessToken?: string, savedTo
)
}

/** 使用 LDAP 账号登录;传入 accessToken 时登录到对应应用,否则登录门户。携带本地保存的 token。 */
const postLdapLogin = (loginRequest: ChatLoginRequest, accessToken?: string, savedToken?: string) => {
return promise<ChatLoginResponse>(
request.post<ApiResponse<ChatLoginResponse>>(accessToken ? `/auth/ldap/login/${accessToken}` : '/auth/ldap/login', loginRequest, {
headers: getSavedTokenHeaders(savedToken),
}),
)
}

/** 获取 CAS、OIDC、OAuth2 等对话用户第三方认证的跳转配置。 */
const getExternalAuthSetting = (authType: string) => {
return get<ExternalAuthSetting>(`/chat_user/${authType}/detail`)
}

/** 获取对话用户扫码登录提供商配置。 */
const getQrCodeSources = () => {
return get<QrCodeSource[]>('/auth/qr_type/source')
}

/** 使用钉钉扫码授权码登录;传入 accessToken 时登录到对应应用。 */
const getDingTalkCallback = (code: string, accessToken?: string) => {
return get<ChatLoginResponse>('/auth/dingtalk', accessToken ? { code, accessToken } : { code })
}

/**
* 获取应用登录验证码;无需验证码时返回空字符串。
* 后端当前以 `application_id` 查询参数接收 accessToken,且仅支持应用场景。
Expand All @@ -56,4 +80,15 @@ const postLogout = () => {
return post<undefined, boolean>('/v3/auth/logout')
}

export default { getApplicationAuthProfile, getPortalAuthProfile, postAnonymousAuth, postLogin, getCaptcha, postLogout }
export default {
getApplicationAuthProfile,
getPortalAuthProfile,
postAnonymousAuth,
postLogin,
postLdapLogin,
getExternalAuthSetting,
getQrCodeSources,
getDingTalkCallback,
getCaptcha,
postLogout,
}
2 changes: 2 additions & 0 deletions ui/src/api/types/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ export interface ApplicationFormPayload {
tts_type?: string
tts_autoplay?: boolean
stt_autosend?: boolean
file_upload_enable?: boolean
file_upload_setting?: Record<string, unknown>
folder_id?: string
workspace_id?: string
mcp_enable?: boolean
Expand Down
42 changes: 40 additions & 2 deletions ui/src/api/types/chat-application.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,50 @@
/** 对话端智能体信息类型。 */

/** 对话端可见的智能体基础信息,仅声明当前使用的字段。 */
import type LogicFlow from '@logicflow/core'
import type { ApplicationType } from './application'
import type { Dict } from './common'

/**
* 对话端可见的智能体信息。门户智能体列表只返回基础字段;
* profile 接口额外返回对话配置(已发布版本)与访问设置,访问设置中的展示项需许可证有效才返回。
*/
export interface ChatApplicationProfile {
id: string
name: string
icon: string
desc?: string
desc?: string | null
prologue?: string
type?: ApplicationType
dialogue_number?: number
problem_optimization?: boolean
stt_model_id?: string | null
tts_model_id?: string | null
stt_model_enable?: boolean
tts_model_enable?: boolean
tts_type?: string
tts_autoplay?: boolean
stt_autosend?: boolean
file_upload_enable?: boolean
file_upload_setting?: Dict<unknown>
/** 仅包含开始节点(base-node),非工作流智能体为 null。 */
work_flow?: LogicFlow.GraphConfigData | null
show_source?: boolean
show_exec?: boolean
show_share?: boolean
language?: string | null
show_history?: boolean
draggable?: boolean
show_guide?: boolean
avatar?: string
show_avatar?: boolean
float_icon?: string
disclaimer?: boolean
disclaimer_value?: string
custom_theme?: { theme_color?: string; header_font_color?: string }
user_avatar?: string
show_user_avatar?: boolean
float_location?: Dict<unknown>
chat_background?: string
}

/** 门户历史对话中单条会话的摘要。 */
Expand Down
19 changes: 19 additions & 0 deletions ui/src/api/types/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,25 @@ export interface QrCodeConfig {
qr_url?: string
}

export interface QrCodeSource {
auth_type: QrCodeProvider
config: QrCodeConfig
}

/** CAS、OIDC、OAuth2 等第三方认证的跳转配置。 */
export interface ExternalAuthConfig {
authEndpoint?: string
clientId?: string
ldpUri?: string
redirectUrl: string
scope?: string
state?: string
}

export interface ExternalAuthSetting {
config?: ExternalAuthConfig
}

export interface UpdatePasswordForm {
password: string
re_password: string
Expand Down
Binary file added ui/src/assets/conversation/load_error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions ui/src/constants/CONSTANT_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@ API 枚举值。例如角色类型和登录方式以 `src/api/enums` 为唯一

`file-type.ts` 维护图片、文档、视频和音频的文件扩展名常量,扩展名统一使用大写。
使用方判断文件类型时先将后缀转换为大写,再与对应常量匹配。

`application.ts` 的 `APPLICATION_DISPLAY_SETTING_DEFAULT` 维护智能体显示设置默认值,专业版显示设置弹窗的
初始与恢复默认、调试面板(社区版或接口未返回的字段)共用;常量只读,使用方修改前先深拷贝。
24 changes: 24 additions & 0 deletions ui/src/constants/application.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/** 智能体共享常量。 */

import type { ApplicationDisplaySetting } from '@/api/types'

/** 显示设置默认值:专业版显示设置弹窗的初始与恢复默认,社区版调试面板也以此展示。使用方按需深拷贝。 */
export const APPLICATION_DISPLAY_SETTING_DEFAULT: Readonly<ApplicationDisplaySetting> = {
show_source: false,
show_exec: false,
language: '',
show_history: true,
draggable: true,
show_share: true,
icon: '',
chat_background: '',
avatar: './favicon.ico',
float_icon: '',
user_avatar: './favicon.ico',
disclaimer: false,
disclaimer_value: '「以上内容均由 AI 生成,仅供参考和借鉴」',
custom_theme: { theme_color: '', header_font_color: '#1f2329' },
float_location: { x: { type: 'right', value: 0 }, y: { type: 'bottom', value: 30 } },
show_avatar: true,
show_user_avatar: true,
}
7 changes: 3 additions & 4 deletions ui/src/conversation-panel/components/content/items/text.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
<script setup lang="ts">
import { useId } from 'vue'
import MarkdownRenderer from '../../markdown-renderer/index.vue'

defineOptions({ name: 'ConversationTextContent' })

defineProps<{
content: { content?: string | null }
}>()

const editorId = `conversation-text-${useId()}`
</script>

<template>
<!-- 正文兼容 v2 标签(快捷问题、HTML、图表等),其余按 Markdown 渲染 -->
<div class="mk-conversation-text-content">
<MdPreview :editor-id="editorId" :model-value="content.content ?? ''" />
<MarkdownRenderer :source="content.content ?? ''" />
</div>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const debug = useDebugHeaderStore()
</MkTooltip>
</template>
<ApplicationIcon :icon="appInfo?.icon" :size="24" class="shrink-0 mr-2" />
<!-- // TODO 没拿到appInfo -->
<h4 class="min-w-0 flex-1 truncate font-semibold" :title="appInfo?.name">
{{ appInfo?.name }}
</h4>
Expand Down
Loading
Loading