Files
qiming/qiming-mobile/subpackages/pages/chat-conversation-component/layers/AgentDetailData.uts

144 lines
5.0 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { ref } from "vue";
import type {
AgentDetailDto,
AgentManualComponentInfo,
GuidQuestionDto,
FileNode,
} from "@/types/interfaces/agent";
import { BindConfigWithSub } from "@/types/interfaces/common";
import {
MessageInfo,
ConversationInfo,
ProcessingInfo,
OpenAppParams,
} from "@/types/interfaces/conversationInfo";
import { SandboxInfo } from "@/types/interfaces/sandbox";
/**
* 数据层:负责状态管理和数据存储
*/
export default class AgentDetailData {
// 基础信息
agentId = ref<number | null>(null);
agentName = ref<string>("");
agentInfo = ref<AgentDetailDto | null>(null);
conversationId = ref<number | null>(null);
// 是否是临时会话
isTempChat = ref<boolean>(false);
// 首页页面URL
pageHomeUrl = ref<string>("");
// 首页页面弹窗
popupPage = ref<any>(null);
// 消息相关
messageList = ref<MessageInfo[]>([]);
// 引导问题建议
chatSuggestList = ref<string[] | GuidQuestionDto[]>([]);
requestId = ref<string>("");
messageIdRef = ref<string>("");
// 当前会话消息请求ID
currentConversationRequestId = ref<string>("");
// 停止操作是否正在进行中
isStoppingConversation = ref<boolean>(false);
// 会话状态
conversationInfo = ref<ConversationInfo | null>(null);
// 是否用户问题建议
isSuggest = ref<boolean>(false);
// 是否需要更新主题
needUpdateTopicRef = ref<boolean>(true);
// 是否正在加载会话
isLoadingConversation = ref<boolean>(false);
// 会话是否正在进行中(有消息正在处理)
isConversationActive = ref<boolean>(false);
// 是否发送过消息,如果是,则禁用变量参数
isSendMessageRef = ref<boolean>(false);
// 是否禁用发送按钮
wholeDisabled = ref<boolean>(false);
// ==================== 临时会话相关 ====================
// 链接Key
chatKey = ref<string>("");
// 验证码参数
captchaVerifyParam = ref<string>("");
// 会话唯一标识
// 会话唯一标识
conversationUid = ref<string>("");
// ==================== 沙盒相关 ====================
// 沙盒列表
sandboxList = ref<SandboxInfo[]>([]);
// 智能体选中的沙盒映射
agentSelectedSandbox = ref<{ [key: string]: string }>({});
// 当前选中的沙盒ID
currentSandboxId = ref<string>("");
// 是否允许切换沙盒 (当ID固定时为true)
isSandboxSwitchDisabled = ref<boolean>(false);
// 沙盒是否不可用 (当显示"电脑不可用"时为true)
isSandboxUnavailable = ref<boolean>(false);
// 沙盒不可用时的提示文案
sandboxDisabledText = ref<string>("");
// ==================== 模型选择相关 ====================
// 当前选中的模型ID
currentModelId = ref<number>(0);
// 当前选中的模型名称
currentModelName = ref<string>("");
// 模型选择弹窗是否可见
modelSelectVisible = ref<boolean>(false);
// 组件和功能
manualComponents = ref<AgentManualComponentInfo[]>([]);
// 已选组件列表
selectedComponents = ref<AgentSelectedComponentInfo[]>([]);
// 变量参数
variables = ref<BindConfigWithSub[]>([]);
// 用户填充变量
userFillVariables = ref<{ [key: string]: string | number }>({});
processingList = ref<ProcessingInfo[]>([]);
messageRefs = ref<{ [key: string]: any }>({});
// 滚动相关
scrollIntoView = ref<string>("");
scrollInBottom = ref<boolean>(true);
scrollWithAnimation = ref<boolean>(false);
scrollTouch = ref<boolean>(false);
scrolling = ref<boolean>(false);
keyboardHeight = ref<number>(0);
// 弹窗引用
refMorePopup = ref<any>(null);
refSubscriptionModal = ref<any>(null);
sseProcessor: any = null;
autoToLastMsg = ref<boolean>(false);
scrollingT = ref<number>(0);
mouseScroll = ref<boolean>(false);
needSetLockAutoToLastMsg = ref<boolean>(true);
// ==================== 任务型智能体文件列表相关 ====================
// 文件列表
fileList = ref<FileNode[]>([]);
// 是否正在加载文件列表
isLoadingFiles = ref<boolean>(false);
// ==================== 加载更多历史消息相关 ====================
// 是否正在加载更多消息
isLoadingMoreMessages = ref<boolean>(false);
// 是否还有更多历史消息
hasMoreMessages = ref<boolean>(false);
// ==================== 开放应用参数, 来自用户自定义url地址传入的参数params ====================
appParams = ref<OpenAppParams | null>(null);
// 如果没有携带message参数则将其他参数(files、attachments、selectedComponents、skillIds、modelId等)保存到urlOtherParams中用于后续首次发送消息时使用
urlOtherParams = ref<{ [key: string]: string }>({});
// ==================== 订阅和付费限制相关 ====================
// 是否需要付费/订阅锁定
subscriptionRequired = ref<boolean>(false);
// 付费/订阅弹窗可见性
subscriptionModalVisible = ref<boolean>(false);
// 是否允许开启订阅限制(根据租户配置中的 enableSubscription 是否等于 1 来决定)
enableSubscription = ref<number>(0);
}