parent
034020d5f9
commit
b9ff01e056
@ -1,304 +1,689 @@ |
||||
import { defineStore } from 'pinia' |
||||
import { computed, ref } from 'vue' |
||||
import { ref } from 'vue' |
||||
|
||||
import { Toast, Dialog } from 'vant' |
||||
import { fetchPost, upLoadImgHttp } from '@/utils/https' |
||||
import wsConnection from '@/utils/socket' |
||||
import FormatDate from '@/utils/filters' |
||||
import utils from '@/utils/utils' |
||||
import { Decryption, DecryptionECB, Encrypt } from '@/utils' |
||||
import _ from 'lodash' |
||||
|
||||
// 幂等键统一采用用户消息前缀,便于和后端日志对齐排查。
|
||||
const createIdempotentKey = () => `user_msg_${Date.now()}` |
||||
export const UPDATE_DIRECTION = 'UPDATE_DIRECTION' |
||||
|
||||
// —— 模块级初始值(加 initial 前缀,避免与 setup 内同名 ref 产生 TDZ/遮蔽问题)——
|
||||
const initialToken = sessionStorage.token ? sessionStorage.token : '' |
||||
const initialUserId = localStorage.userId ? localStorage.userId : '' |
||||
const initialSource = localStorage.source ? localStorage.source : '' |
||||
const initialPlanCode = localStorage.planCode ? localStorage.planCode : '' |
||||
const initialEntrance = localStorage.entrance ? localStorage.entrance : '' |
||||
// 取到身份证后解密
|
||||
const initialUserInfo = localStorage.userInfo ? JSON.parse(localStorage.userInfo) : {} |
||||
// try {
|
||||
// if(!!userInfo.versionNo1){
|
||||
// const year = new Date().getFullYear()
|
||||
// const versionNo1 = DecryptionECB(`${year}${year}${year}${year}`,userInfo.versionNo1)
|
||||
// const key = versionNo1.substring(0, 16)
|
||||
// const iv = versionNo1.substring(16, 32)
|
||||
// if (!!userInfo.encryptPhone) {
|
||||
// userInfo.decryptPhone = Decryption(key,iv,userInfo.encryptPhone)
|
||||
// }
|
||||
// if (!!userInfo.idnum) {
|
||||
// userInfo.idnum = Decryption(key,iv,userInfo.idnum)
|
||||
// console.log("取到后解密====", userInfo.idnum)
|
||||
// }
|
||||
// }
|
||||
// } catch (error) { }
|
||||
const initialConfigId = localStorage.configId ? localStorage.configId : '' |
||||
const initialSessionId = localStorage.sessionId ? localStorage.sessionId : '' |
||||
|
||||
const initialHtmlExtParams = localStorage.htmlExtParams ? localStorage.htmlExtParams : '' |
||||
const initialComplaint = localStorage.complaint ? localStorage.complaint : '' |
||||
const initialNavigationCorpus = localStorage.navigationCorpus ? localStorage.navigationCorpus : '' |
||||
|
||||
const initialHeaderAvatar = localStorage.headerAvatar ? JSON.parse(localStorage.headerAvatar) : {} |
||||
const initialSysConfig = localStorage.sysConfig ? localStorage.sysConfig : '' |
||||
const initialIsLeaveMessageSuccess = sessionStorage.isLeaveMessageSuccess |
||||
? sessionStorage.isLeaveMessageSuccess |
||||
: false //留言是否成功
|
||||
|
||||
// 聊天消息 数据
|
||||
const initialChatList = localStorage.chatList ? JSON.parse(localStorage.chatList) : [] |
||||
|
||||
const initialSendMessageList = localStorage.sendMessageList |
||||
? JSON.parse(localStorage.sendMessageList) |
||||
: [] |
||||
|
||||
const initialReceiveMessageList = localStorage.receiveMessageList |
||||
? JSON.parse(localStorage.receiveMessageList) |
||||
: [] |
||||
|
||||
export const useAppStore = defineStore('app', () => { |
||||
// Session 相关状态(原 apiState)
|
||||
const sessionId = ref('') |
||||
const messageId = ref('') |
||||
const serverLastMessageId = ref('') |
||||
const currentNode = ref('') |
||||
const currentStage = ref('') |
||||
const channel = ref('') |
||||
const code = ref('') |
||||
const cardType = ref('') |
||||
const idempotentKey = ref(createIdempotentKey()) |
||||
const userId = ref('debug-user') |
||||
const token = ref(initialToken) |
||||
const userId = ref(initialUserId) |
||||
const configId = ref(initialConfigId) |
||||
const sessionId = ref(initialSessionId) |
||||
const source = ref(initialSource) |
||||
const planCode = ref(initialPlanCode) |
||||
const entrance = ref(initialEntrance) |
||||
const elder = ref(true) |
||||
const notitle = ref('') |
||||
const userInfo = ref(initialUserInfo) |
||||
const sysConfig = ref(initialSysConfig) |
||||
const headerAvatar = ref(initialHeaderAvatar) |
||||
const htmlExtParams = ref(initialHtmlExtParams) |
||||
const complaint = ref(initialComplaint) |
||||
const navigationCorpus = ref(initialNavigationCorpus) |
||||
const routeAction = ref('push') |
||||
const direction = ref('forward') |
||||
const mescrollContent = ref('') |
||||
const isLeaveMessage = ref(false) |
||||
const isLeaveMessageSuccess = ref(initialIsLeaveMessageSuccess) |
||||
const manualService = ref(1) |
||||
const queuedTimeout = ref(false) |
||||
const sendLoading = ref(false) |
||||
const isSendSuccess = ref(false) |
||||
const timestamp = ref(0) |
||||
const sendParmas = ref({}) |
||||
const chatList = ref(initialChatList) |
||||
const sendMessageList = ref(initialSendMessageList) |
||||
const receiveMessageList = ref(initialReceiveMessageList) |
||||
const chatId = ref('') |
||||
const currentItemId = ref('') |
||||
const issubmit = ref(true) |
||||
const otherTips = ref('') |
||||
const lastMessage = ref({}) |
||||
const asrConfig = ref({}) |
||||
const sendFailList = ref([]) |
||||
const isLostMessage = ref('') |
||||
const hxSessionId = ref('') |
||||
const qaId = ref('') |
||||
const problemFeedback = ref(false) |
||||
const isBackstage = ref(false) |
||||
const sdkLoaded = ref(false) |
||||
const chatArr = ref([]) |
||||
const isChatLoading = ref(false) |
||||
const bpErrorInfo = ref([]) |
||||
const voiceDataList = ref([]) |
||||
const hxOpenSucceseds = ref([]) |
||||
const pcaData = ref([]) |
||||
const appentry = ref('') |
||||
const tts = ref('') |
||||
const flagType = ref('') |
||||
const msgStatus = ref('') |
||||
const channelReform = ref(false) |
||||
const isHumanChat = ref(false) |
||||
const gaokeUser = ref(false) |
||||
const hotUser = ref(false) |
||||
const reviewRestricted = ref(false) |
||||
const integratedUser = ref(false) |
||||
const showHumanAppraise = ref(false) |
||||
const mydFlag = ref(false) |
||||
const isBqCalcClaim = ref(false) |
||||
const msgReply = ref(true) |
||||
const hotUserData = ref(null) |
||||
const branchCompany = ref('') |
||||
|
||||
// —— Session ——
|
||||
function setIsBqCalcClaim(payload) { |
||||
isBqCalcClaim.value = payload |
||||
} |
||||
|
||||
// 应用相关状态
|
||||
const appName = ref('xiaolan-chat') |
||||
const loading = ref(false) |
||||
// 保单是否基金类型,默认为非基金 N
|
||||
const jjxFlag = ref('N') |
||||
// 保单是否保障类型,默认为非基金 N
|
||||
const bzxFlag = ref('N') |
||||
//
|
||||
const sfFlag = ref('N') |
||||
const isUserSelctLoading = ref(false) |
||||
const buttonLoading = ref(false) |
||||
function setToken(payload) { |
||||
token.value = payload |
||||
try { |
||||
sessionStorage.token = payload |
||||
} catch (e) { |
||||
console.log(e) |
||||
} |
||||
} |
||||
|
||||
// Getters
|
||||
const hasSession = computed(() => !!sessionId.value) |
||||
const isLoading = computed(() => loading.value) |
||||
const userInfo = computed(() => ({ |
||||
userId: userId.value, |
||||
code: code.value, |
||||
channel: channel.value, |
||||
})) |
||||
function setSessionId(payload) { |
||||
sessionId.value = payload |
||||
try { |
||||
localStorage.sessionId = payload |
||||
} catch (e) { |
||||
console.log(e) |
||||
} |
||||
} |
||||
|
||||
// Actions - Session 管理
|
||||
function setSessionId(id) { |
||||
sessionId.value = id |
||||
function setConfigId(payload) { |
||||
configId.value = payload |
||||
try { |
||||
localStorage.configId = payload |
||||
} catch (e) { |
||||
console.log(e) |
||||
} |
||||
} |
||||
|
||||
function setMessageId(id) { |
||||
messageId.value = id || '' |
||||
console.log('MessageId-------->', messageId.value) |
||||
console.log('SessionId-------->', sessionId.value) |
||||
function setAppentry(payload) { |
||||
appentry.value = payload |
||||
} |
||||
function setServerLastMessageId(id) { |
||||
serverLastMessageId.value = id || '' |
||||
|
||||
function setBpErrorInfo(payload) { |
||||
bpErrorInfo.value = payload |
||||
} |
||||
|
||||
function clearMessageId() { |
||||
messageId.value = '' |
||||
function delToken() { |
||||
token.value = '' |
||||
} |
||||
|
||||
function setUserInfo(info) { |
||||
if (info.userId !== undefined) userId.value = info.userId |
||||
if (info.channel !== undefined) channel.value = info.channel |
||||
if (info.code !== undefined) code.value = info.code |
||||
function setUserId(payload) { |
||||
userId.value = payload |
||||
try { |
||||
localStorage.userId = payload |
||||
} catch (e) { |
||||
console.log(e) |
||||
} |
||||
} |
||||
|
||||
function setFlowPosition({ node, stage }) { |
||||
if (node !== undefined) currentNode.value = node |
||||
if (stage !== undefined) currentStage.value = stage |
||||
function setSource(payload) { |
||||
source.value = payload |
||||
try { |
||||
localStorage.source = payload |
||||
} catch (e) { |
||||
console.log(e) |
||||
} |
||||
} |
||||
|
||||
function setCardType(type) { |
||||
cardType.value = type |
||||
function setNotitle(payload) { |
||||
notitle.value = payload |
||||
try { |
||||
localStorage.notitle = payload |
||||
} catch (e) { |
||||
console.log(e) |
||||
} |
||||
} |
||||
|
||||
// 允许外部在特殊场景下直接覆盖幂等键。
|
||||
function setIdempotentKey(key) { |
||||
idempotentKey.value = key || '' |
||||
function setElder(payload) { |
||||
elder.value = payload |
||||
try { |
||||
localStorage.elder = payload |
||||
} catch (e) { |
||||
console.log(e) |
||||
} |
||||
} |
||||
|
||||
// 请求成功后刷新出下一次交互要使用的幂等键。
|
||||
function refreshIdempotentKey() { |
||||
const nextKey = createIdempotentKey() |
||||
idempotentKey.value = nextKey |
||||
return nextKey |
||||
function setPlanCode(payload) { |
||||
planCode.value = payload |
||||
try { |
||||
localStorage.planCode = payload |
||||
} catch (e) { |
||||
console.log(e) |
||||
} |
||||
} |
||||
|
||||
// 兼容现有调用方按方法读取幂等键。
|
||||
function getIdempotentKey() { |
||||
return idempotentKey.value |
||||
function setEntrance(payload) { |
||||
entrance.value = payload |
||||
try { |
||||
localStorage.entrance = payload |
||||
} catch (e) { |
||||
console.log(e) |
||||
} |
||||
} |
||||
|
||||
// 清理时不置空,直接生成新键,避免后续请求误拿空值。
|
||||
function clearIdempotentKey() { |
||||
idempotentKey.value = createIdempotentKey() |
||||
function setUserInfo(payload) { |
||||
userInfo.value = payload |
||||
try { |
||||
localStorage.userInfo = JSON.stringify(payload) |
||||
} catch (e) { |
||||
console.log(e) |
||||
} |
||||
} |
||||
|
||||
// 统一替换整段聊天记录,适合会话恢复或回放场景。
|
||||
function setChatArr(list) { |
||||
chatArr.value = Array.isArray(list) ? list : [] |
||||
function setHtmlExtParams(payload) { |
||||
htmlExtParams.value = payload |
||||
try { |
||||
localStorage.htmlExtParams = payload |
||||
} catch (e) { |
||||
console.log(e) |
||||
} |
||||
} |
||||
|
||||
// 新消息统一从 store 入口追加,便于后续集中扩展。
|
||||
function pushChatMessage(message) { |
||||
if (message) { |
||||
chatArr.value.push(message) |
||||
function setComplaint(payload) { |
||||
complaint.value = payload |
||||
try { |
||||
localStorage.complaint = payload |
||||
} catch (e) { |
||||
console.log(e) |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 创建并推送用户消息到聊天列表 |
||||
* @param {String} content - 消息内容 |
||||
* @param {String} messageType - 消息类型,默认为 'user' |
||||
* @param {String} systemType - 系统类型,默认为 'CARD' |
||||
* @returns {Object|null} 创建的消息对象,失败返回 null |
||||
*/ |
||||
function pushUserMessage(content, messageType = 'user', systemType = 'CARD') { |
||||
if (!content) { |
||||
console.warn('pushUserMessage: 消息内容不能为空') |
||||
return null |
||||
function setNavigationCorpus(payload) { |
||||
navigationCorpus.value = payload |
||||
try { |
||||
localStorage.navigationCorpus = payload |
||||
} catch (e) { |
||||
console.log(e) |
||||
} |
||||
} |
||||
|
||||
const model = JSON.parse( |
||||
JSON.stringify([ |
||||
{ |
||||
value: '', |
||||
param: '', |
||||
type: 'text', |
||||
options: { |
||||
label: '', |
||||
readOnly: false, |
||||
placeholder: '', |
||||
}, |
||||
}, |
||||
]), |
||||
) |
||||
|
||||
model[0].options.label = content |
||||
|
||||
const messageObj = { |
||||
type: messageType, |
||||
system: systemType, |
||||
isSendSuccess: true, |
||||
message: model, |
||||
function setManualService(payload) { |
||||
manualService.value = payload |
||||
try { |
||||
localStorage.manualService = JSON.stringify(payload) |
||||
} catch (e) { |
||||
console.log(e) |
||||
} |
||||
} |
||||
|
||||
if (messageType === 'user') { |
||||
messageObj.idempotentKey = idempotentKey.value |
||||
isChatLoading.value = true |
||||
function setSysConfig(payload) { |
||||
sysConfig.value = payload |
||||
try { |
||||
localStorage.sysConfig = payload |
||||
} catch (e) { |
||||
console.log(e) |
||||
} |
||||
} |
||||
|
||||
function setHeaderAvatar(payload) { |
||||
headerAvatar.value = payload |
||||
try { |
||||
localStorage.headerAvatar = JSON.stringify(payload) |
||||
} catch (e) { |
||||
console.log(e) |
||||
} |
||||
} |
||||
|
||||
chatArr.value.push(messageObj) |
||||
// —— 消息发送状态 ——
|
||||
function setSendLoading(payload) { |
||||
sendLoading.value = payload |
||||
} |
||||
|
||||
function setIsSendSuccess(payload) { |
||||
isSendSuccess.value = payload |
||||
} |
||||
|
||||
function setQaId(payload) { |
||||
qaId.value = payload |
||||
} |
||||
|
||||
function setProblemFeedback(payload) { |
||||
problemFeedback.value = payload |
||||
} |
||||
|
||||
return messageObj |
||||
function setOtherTips(payload) { |
||||
otherTips.value = payload |
||||
} |
||||
|
||||
// 根据幂等键回写指定消息的发送状态,必要时同步记录失败请求参数。
|
||||
function updateChatMessageSendStatus(idempotentKeyValue, isSendSuccess, requestParams = null) { |
||||
if (!idempotentKeyValue) { |
||||
return false |
||||
function setLastMessage(payload) { |
||||
lastMessage.value = payload |
||||
} |
||||
|
||||
function setSendFailList(payload) { |
||||
sendFailList.value.push(payload) |
||||
} |
||||
|
||||
function setIsLostMessage(payload) { |
||||
isLostMessage.value = payload |
||||
} |
||||
|
||||
function delSendFailList(payload) { |
||||
sendFailList.value = payload |
||||
} |
||||
|
||||
function setLeaveMessage(payload) { |
||||
isLeaveMessage.value = payload |
||||
} |
||||
|
||||
function setIsLeaveMessageSuccess(payload) { |
||||
isLeaveMessageSuccess.value = payload |
||||
try { |
||||
sessionStorage.isLeaveMessageSuccess = payload |
||||
} catch (e) { |
||||
console.log(e) |
||||
} |
||||
} |
||||
|
||||
function setMescrollContent(payload) { |
||||
mescrollContent.value = payload |
||||
} |
||||
|
||||
function setSendMessageList(payload) { |
||||
sendMessageList.value = payload |
||||
} |
||||
|
||||
function setReceiveMessageList(payload) { |
||||
receiveMessageList.value = payload |
||||
} |
||||
|
||||
function setTts(payload) { |
||||
tts.value = payload |
||||
} |
||||
|
||||
function setHxOpenSuccesed(payload) { |
||||
hxOpenSucceseds.value = payload |
||||
} |
||||
|
||||
for (let index = chatArr.value.length - 1; index >= 0; index -= 1) { |
||||
const item = chatArr.value[index] |
||||
if (item?.idempotentKey === idempotentKeyValue) { |
||||
item.isSendSuccess = isSendSuccess |
||||
if (requestParams) { |
||||
item.requestParams = requestParams |
||||
function setTimestamp(payload) { |
||||
timestamp.value = payload |
||||
} |
||||
|
||||
function setSendParmas(payload) { |
||||
sendParmas.value = payload |
||||
} |
||||
|
||||
function setQueuedTimeout(payload) { |
||||
queuedTimeout.value = payload |
||||
} |
||||
|
||||
// 存储发送的消息到 chatList
|
||||
function addSendMessageList(payload = {}) { |
||||
console.log('接收发送的消息===', payload) |
||||
|
||||
sendParmas.value = { |
||||
token: token.value, |
||||
fromFlag: payload.fromFlag || 1, // 1为自己 2为其他 other提示消息
|
||||
userId: userId.value, |
||||
sessionId: sessionId.value, |
||||
reqAndResType: payload.reqAndResType, // 1文本 2图片 3问提评价
|
||||
msgType: payload.msgType || '', |
||||
msgText: payload.msgText, |
||||
file: payload.file || '', |
||||
filename: payload.filename || '', |
||||
formData: payload.formData || '', |
||||
source: source.value, |
||||
timestamp: payload.timestamp || new Date().valueOf(), |
||||
msgSource: manualService.value, // 1机器人 2人工
|
||||
cmd: payload.cmd || '', |
||||
sendLoading: payload.sendLoading, |
||||
isSendSuccess: payload.isSendSuccess, |
||||
voiceNo: payload.voiceNo, |
||||
quoteData: payload.quoteData || null, |
||||
bpErrorContent: payload.bpErrorContent || '', // 电子回访断点服务
|
||||
} |
||||
console.log('发送消息==', sendParmas.value) |
||||
|
||||
timestamp.value = sendParmas.value.timestamp |
||||
|
||||
// 存储正在发送的那条数据
|
||||
setCurrentItemId(sendParmas.value.timestamp) |
||||
|
||||
chatList.value.push(sendParmas.value) |
||||
} |
||||
|
||||
// 消息列表
|
||||
function setChatList(payload) { |
||||
const normalizedItem = utils.normalizeMessage(payload) |
||||
chatList.value.push(normalizedItem) |
||||
} |
||||
|
||||
function delChatList(index) { |
||||
chatList.value.splice(index, 1) |
||||
} |
||||
|
||||
function delAllChatList() { |
||||
chatList.value.splice(0, chatList.value.length) |
||||
} |
||||
|
||||
function delSendFailListById(delId) { |
||||
if (sendFailList.value && sendFailList.value.length > 0) { |
||||
sendFailList.value.forEach((item, index) => { |
||||
if (delId === item.timestamp) { |
||||
sendFailList.value.splice(index, 1) |
||||
} |
||||
return true |
||||
} |
||||
}) |
||||
} |
||||
} |
||||
|
||||
// 存储到消息队列中
|
||||
function setChatId(payload) { |
||||
chatId.value.push(payload) |
||||
} |
||||
|
||||
function setCurrentItemId(payload) { |
||||
currentItemId.value = payload |
||||
} |
||||
|
||||
function setFindActiveItem(findActiveItem) { |
||||
if (chatList.value && chatList.value.length > 0) { |
||||
chatList.value.forEach((item) => { |
||||
if (currentItemId.value == item.timestamp) { |
||||
item.isSendSuccess = findActiveItem |
||||
item.sendLoading = false |
||||
} |
||||
}) |
||||
} |
||||
} |
||||
|
||||
function setActiveItemExtra(data) { |
||||
if (chatList.value && chatList.value.length > 0) { |
||||
chatList.value.forEach((item) => { |
||||
if (currentItemId.value == item.timestamp) { |
||||
if (data && data.imgKey) { |
||||
item.imgKey = data.imgKey |
||||
} |
||||
if (data && data.imgUrl) { |
||||
item.imgUrl = data.imgUrl |
||||
} |
||||
} |
||||
}) |
||||
} |
||||
} |
||||
|
||||
function setReSendMessage(reSendMessageId) { |
||||
if (chatList.value && chatList.value.length > 0) { |
||||
chatList.value.forEach((item, index) => { |
||||
if (reSendMessageId === item.timestamp) { |
||||
chatList.value.splice(index, 1) |
||||
} |
||||
}) |
||||
} |
||||
delSendFailListById(reSendMessageId) |
||||
} |
||||
|
||||
function scrollBottom() { |
||||
setTimeout(() => { |
||||
try { |
||||
mescrollContent.value.scrollTop = mescrollContent.value.scrollHeight || 0 |
||||
} catch (error) { |
||||
console.log(error.message) |
||||
} |
||||
}, 500) |
||||
} |
||||
|
||||
// —— 其他状态 ——
|
||||
function setIsBackstage(payload) { |
||||
isBackstage.value = payload |
||||
} |
||||
|
||||
// 存储语音
|
||||
function setVoiceData(payload) { |
||||
voiceDataList.value.push(payload) |
||||
} |
||||
|
||||
// sdk是否已加载好
|
||||
function setSdkLoaded(payload) { |
||||
sdkLoaded.value = payload |
||||
} |
||||
|
||||
function setPcaData(payload) { |
||||
pcaData.value = payload |
||||
} |
||||
|
||||
function setChannelReform(payload) { |
||||
channelReform.value = payload |
||||
} |
||||
|
||||
return false |
||||
function setMsgStatus(payload) { |
||||
msgStatus.value = payload |
||||
} |
||||
|
||||
function clearChatArr() { |
||||
chatArr.value = [] |
||||
function setMsgReply(payload) { |
||||
msgReply.value = payload |
||||
} |
||||
|
||||
// 会话级状态统一回收,并重置一份新的幂等键给下一轮会话使用。
|
||||
function clearSession() { |
||||
sessionId.value = '' |
||||
messageId.value = '' |
||||
currentNode.value = '' |
||||
currentStage.value = '' |
||||
channel.value = '' |
||||
cardType.value = '' |
||||
idempotentKey.value = createIdempotentKey() |
||||
userId.value = 'debug-user' |
||||
chatArr.value = [] |
||||
function setIsHumanChat(payload) { |
||||
isHumanChat.value = payload |
||||
} |
||||
|
||||
// Actions - 应用管理
|
||||
function setLoading(value) { |
||||
loading.value = Boolean(value) |
||||
function setGaokeUser(payload) { |
||||
gaokeUser.value = payload |
||||
} |
||||
|
||||
function setAppName(name) { |
||||
appName.value = name || appName.value |
||||
function setBranchCompany(payload) { |
||||
branchCompany.value = payload |
||||
} |
||||
//
|
||||
function setJjxFlag(name) { |
||||
jjxFlag.value = name || appName.value |
||||
|
||||
function setHotUser(payload) { |
||||
hotUser.value = payload |
||||
} |
||||
|
||||
function setHotUserData(payload) { |
||||
hotUserData.value = payload |
||||
} |
||||
|
||||
function setReviewRestricted(payload) { |
||||
reviewRestricted.value = payload |
||||
} |
||||
|
||||
function setIntegratedUser(payload) { |
||||
integratedUser.value = payload |
||||
} |
||||
function setBzxFLag(name) { |
||||
bzxFlag.value = name || appName.value |
||||
|
||||
function setHxSessionId(payload) { |
||||
hxSessionId.value = payload |
||||
} |
||||
|
||||
function setSfFlag(name) { |
||||
sfFlag.value = name || appName.value |
||||
function setShowHumanAppraise(payload) { |
||||
showHumanAppraise.value = payload |
||||
} |
||||
|
||||
return { |
||||
// Session State - 会话ID,用于标识当前用户会话
|
||||
sessionId, |
||||
// Session State - 当前消息ID
|
||||
messageId, |
||||
serverLastMessageId, |
||||
// Session State - 当前工作流节点编码
|
||||
currentNode, |
||||
// Session State - 当前工作流阶段编码
|
||||
currentStage, |
||||
// Session State - 渠道标识(如微信、APP等)
|
||||
channel, |
||||
code, |
||||
// Session State - 卡片类型,用于标识当前交互的卡片模版类型
|
||||
cardType, |
||||
// Session State - 幂等键
|
||||
idempotentKey, |
||||
// Session State - 用户ID,默认为 debug-user
|
||||
// State
|
||||
token, |
||||
userId, |
||||
// Session State - 聊天渲染数组
|
||||
chatArr, |
||||
|
||||
// App State - 应用名称
|
||||
appName, |
||||
// App State - 全局加载状态标识
|
||||
loading, |
||||
// App State - 保单是否基金类型,默认为非基金
|
||||
jjxFlag, |
||||
// App State - 保单是否保障类型,默认为非保障
|
||||
bzxFlag, |
||||
// App State -
|
||||
sfFlag, |
||||
|
||||
// Getters - 判断是否存在有效会话
|
||||
hasSession, |
||||
// Getters - 获取当前加载状态
|
||||
isLoading, |
||||
// Getters - 获取用户信息对象(包含 userId 和 channel)
|
||||
configId, |
||||
sessionId, |
||||
source, |
||||
planCode, |
||||
entrance, |
||||
elder, |
||||
notitle, |
||||
userInfo, |
||||
|
||||
// Actions - Session - 设置会话ID
|
||||
sysConfig, |
||||
headerAvatar, |
||||
htmlExtParams, |
||||
complaint, |
||||
navigationCorpus, |
||||
routeAction, |
||||
direction, |
||||
mescrollContent, |
||||
isLeaveMessage, |
||||
isLeaveMessageSuccess, |
||||
manualService, |
||||
queuedTimeout, |
||||
sendLoading, |
||||
isSendSuccess, |
||||
timestamp, |
||||
sendParmas, |
||||
chatList, |
||||
sendMessageList, |
||||
receiveMessageList, |
||||
chatId, |
||||
currentItemId, |
||||
issubmit, |
||||
otherTips, |
||||
lastMessage, |
||||
asrConfig, |
||||
sendFailList, |
||||
isLostMessage, |
||||
hxSessionId, |
||||
qaId, |
||||
problemFeedback, |
||||
isBackstage, |
||||
sdkLoaded, |
||||
chatArr, |
||||
bpErrorInfo, |
||||
voiceDataList, |
||||
hxOpenSucceseds, |
||||
pcaData, |
||||
appentry, |
||||
tts, |
||||
flagType, |
||||
msgStatus, |
||||
channelReform, |
||||
isHumanChat, |
||||
gaokeUser, |
||||
hotUser, |
||||
reviewRestricted, |
||||
integratedUser, |
||||
showHumanAppraise, |
||||
mydFlag, |
||||
isBqCalcClaim, |
||||
msgReply, |
||||
hotUserData, |
||||
branchCompany, |
||||
|
||||
// Actions
|
||||
setIsBqCalcClaim, |
||||
setToken, |
||||
setSessionId, |
||||
// Actions - Session - 设置消息ID
|
||||
setMessageId, |
||||
// Actions - setServerLastMessageId - 设置消息ID
|
||||
setServerLastMessageId, |
||||
// Actions - Session - 清空消息ID
|
||||
clearMessageId, |
||||
// Actions - Session - 设置用户信息(userId 和 channel)
|
||||
setConfigId, |
||||
setAppentry, |
||||
setBpErrorInfo, |
||||
delToken, |
||||
setUserId, |
||||
setSource, |
||||
setNotitle, |
||||
setElder, |
||||
setPlanCode, |
||||
setEntrance, |
||||
setUserInfo, |
||||
// Actions - Session - 设置工作流位置(节点和阶段)
|
||||
setFlowPosition, |
||||
// Actions - Session - 设置卡片类型
|
||||
setCardType, |
||||
// Actions - Session - 设置幂等键
|
||||
setIdempotentKey, |
||||
// Actions - Session - 刷新幂等键
|
||||
refreshIdempotentKey, |
||||
// Actions - Session - 获取幂等键
|
||||
getIdempotentKey, |
||||
// Actions - Session - 清空幂等键
|
||||
clearIdempotentKey, |
||||
// Actions - Session - 覆盖聊天数组
|
||||
setChatArr, |
||||
// Actions - Session - 追加聊天消息
|
||||
pushChatMessage, |
||||
// Actions - Session - 创建并推送用户消息到聊天列表
|
||||
pushUserMessage, |
||||
// Actions - Session - 根据幂等键更新消息发送状态
|
||||
updateChatMessageSendStatus, |
||||
// Actions - Session - 清空聊天数组
|
||||
clearChatArr, |
||||
// Actions - Session - 清空会话状态,重置为初始值
|
||||
clearSession, |
||||
|
||||
// Actions - App - 设置全局加载状态
|
||||
setLoading, |
||||
// Actions - App - 设置应用名称
|
||||
setAppName, |
||||
// Actions - App - 设置保单是否基金类型
|
||||
setJjxFlag, |
||||
// Actions - App - 设置保单是否保障类型
|
||||
setBzxFLag, |
||||
|
||||
// Actions - App - 设置获取医院需要类型
|
||||
setSfFlag, |
||||
isUserSelctLoading, |
||||
isChatLoading, |
||||
buttonLoading, |
||||
setHtmlExtParams, |
||||
setComplaint, |
||||
setNavigationCorpus, |
||||
setManualService, |
||||
setSysConfig, |
||||
setHeaderAvatar, |
||||
setSendLoading, |
||||
setIsSendSuccess, |
||||
setQaId, |
||||
setProblemFeedback, |
||||
setOtherTips, |
||||
setLastMessage, |
||||
setSendFailList, |
||||
setIsLostMessage, |
||||
delSendFailList, |
||||
delSendFailListById, |
||||
setLeaveMessage, |
||||
setIsLeaveMessageSuccess, |
||||
setMescrollContent, |
||||
setSendMessageList, |
||||
setReceiveMessageList, |
||||
setTts, |
||||
setHxOpenSuccesed, |
||||
setTimestamp, |
||||
setSendParmas, |
||||
setQueuedTimeout, |
||||
addSendMessageList, |
||||
setChatList, |
||||
delChatList, |
||||
delAllChatList, |
||||
setChatId, |
||||
setCurrentItemId, |
||||
setFindActiveItem, |
||||
setActiveItemExtra, |
||||
setReSendMessage, |
||||
scrollBottom, |
||||
setIsBackstage, |
||||
setVoiceData, |
||||
setSdkLoaded, |
||||
setPcaData, |
||||
setChannelReform, |
||||
setMsgStatus, |
||||
setMsgReply, |
||||
setIsHumanChat, |
||||
setGaokeUser, |
||||
setBranchCompany, |
||||
setHotUser, |
||||
setHotUserData, |
||||
setReviewRestricted, |
||||
setIntegratedUser, |
||||
setHxSessionId, |
||||
setShowHumanAppraise, |
||||
} |
||||
}) |
||||
export default useAppStore |
||||
|
||||
@ -1,689 +1,5 @@ |
||||
import { defineStore } from 'pinia' |
||||
import { ref } from 'vue' |
||||
import { createPinia } from 'pinia' |
||||
|
||||
import { Toast, Dialog } from 'vant' |
||||
import { fetchPost, upLoadImgHttp } from '@/utils/https' |
||||
import wsConnection from '@/utils/socket' |
||||
import FormatDate from '@/utils/filters' |
||||
import utils from '@/utils/utils' |
||||
import { Decryption, DecryptionECB, Encrypt } from '@/utils' |
||||
import _ from 'lodash' |
||||
const pinia = createPinia() |
||||
|
||||
// 幂等键统一采用用户消息前缀,便于和后端日志对齐排查。
|
||||
const createIdempotentKey = () => `user_msg_${Date.now()}` |
||||
export const UPDATE_DIRECTION = 'UPDATE_DIRECTION' |
||||
|
||||
// —— 模块级初始值(加 initial 前缀,避免与 setup 内同名 ref 产生 TDZ/遮蔽问题)——
|
||||
const initialToken = sessionStorage.token ? sessionStorage.token : '' |
||||
const initialUserId = localStorage.userId ? localStorage.userId : '' |
||||
const initialSource = localStorage.source ? localStorage.source : '' |
||||
const initialPlanCode = localStorage.planCode ? localStorage.planCode : '' |
||||
const initialEntrance = localStorage.entrance ? localStorage.entrance : '' |
||||
// 取到身份证后解密
|
||||
const initialUserInfo = localStorage.userInfo ? JSON.parse(localStorage.userInfo) : {} |
||||
// try {
|
||||
// if(!!userInfo.versionNo1){
|
||||
// const year = new Date().getFullYear()
|
||||
// const versionNo1 = DecryptionECB(`${year}${year}${year}${year}`,userInfo.versionNo1)
|
||||
// const key = versionNo1.substring(0, 16)
|
||||
// const iv = versionNo1.substring(16, 32)
|
||||
// if (!!userInfo.encryptPhone) {
|
||||
// userInfo.decryptPhone = Decryption(key,iv,userInfo.encryptPhone)
|
||||
// }
|
||||
// if (!!userInfo.idnum) {
|
||||
// userInfo.idnum = Decryption(key,iv,userInfo.idnum)
|
||||
// console.log("取到后解密====", userInfo.idnum)
|
||||
// }
|
||||
// }
|
||||
// } catch (error) { }
|
||||
const initialConfigId = localStorage.configId ? localStorage.configId : '' |
||||
const initialSessionId = localStorage.sessionId ? localStorage.sessionId : '' |
||||
|
||||
const initialHtmlExtParams = localStorage.htmlExtParams ? localStorage.htmlExtParams : '' |
||||
const initialComplaint = localStorage.complaint ? localStorage.complaint : '' |
||||
const initialNavigationCorpus = localStorage.navigationCorpus ? localStorage.navigationCorpus : '' |
||||
|
||||
const initialHeaderAvatar = localStorage.headerAvatar ? JSON.parse(localStorage.headerAvatar) : {} |
||||
const initialSysConfig = localStorage.sysConfig ? localStorage.sysConfig : '' |
||||
const initialIsLeaveMessageSuccess = sessionStorage.isLeaveMessageSuccess |
||||
? sessionStorage.isLeaveMessageSuccess |
||||
: false //留言是否成功
|
||||
|
||||
// 聊天消息 数据
|
||||
const initialChatList = localStorage.chatList ? JSON.parse(localStorage.chatList) : [] |
||||
|
||||
const initialSendMessageList = localStorage.sendMessageList |
||||
? JSON.parse(localStorage.sendMessageList) |
||||
: [] |
||||
|
||||
const initialReceiveMessageList = localStorage.receiveMessageList |
||||
? JSON.parse(localStorage.receiveMessageList) |
||||
: [] |
||||
|
||||
export const useAppStore = defineStore('app', () => { |
||||
// Session 相关状态(原 apiState)
|
||||
const token = ref(initialToken) |
||||
const userId = ref(initialUserId) |
||||
const configId = ref(initialConfigId) |
||||
const sessionId = ref(initialSessionId) |
||||
const source = ref(initialSource) |
||||
const planCode = ref(initialPlanCode) |
||||
const entrance = ref(initialEntrance) |
||||
const elder = ref(true) |
||||
const notitle = ref('') |
||||
const userInfo = ref(initialUserInfo) |
||||
const sysConfig = ref(initialSysConfig) |
||||
const headerAvatar = ref(initialHeaderAvatar) |
||||
const htmlExtParams = ref(initialHtmlExtParams) |
||||
const complaint = ref(initialComplaint) |
||||
const navigationCorpus = ref(initialNavigationCorpus) |
||||
const routeAction = ref('push') |
||||
const direction = ref('forward') |
||||
const mescrollContent = ref('') |
||||
const isLeaveMessage = ref(false) |
||||
const isLeaveMessageSuccess = ref(initialIsLeaveMessageSuccess) |
||||
const manualService = ref(1) |
||||
const queuedTimeout = ref(false) |
||||
const sendLoading = ref(false) |
||||
const isSendSuccess = ref(false) |
||||
const timestamp = ref(0) |
||||
const sendParmas = ref({}) |
||||
const chatList = ref(initialChatList) |
||||
const sendMessageList = ref(initialSendMessageList) |
||||
const receiveMessageList = ref(initialReceiveMessageList) |
||||
const chatId = ref('') |
||||
const currentItemId = ref('') |
||||
const issubmit = ref(true) |
||||
const otherTips = ref('') |
||||
const lastMessage = ref({}) |
||||
const asrConfig = ref({}) |
||||
const sendFailList = ref([]) |
||||
const isLostMessage = ref('') |
||||
const hxSessionId = ref('') |
||||
const qaId = ref('') |
||||
const problemFeedback = ref(false) |
||||
const isBackstage = ref(false) |
||||
const sdkLoaded = ref(false) |
||||
const chatArr = ref([]) |
||||
const bpErrorInfo = ref([]) |
||||
const voiceDataList = ref([]) |
||||
const hxOpenSucceseds = ref([]) |
||||
const pcaData = ref([]) |
||||
const appentry = ref('') |
||||
const tts = ref('') |
||||
const flagType = ref('') |
||||
const msgStatus = ref('') |
||||
const channelReform = ref(false) |
||||
const isHumanChat = ref(false) |
||||
const gaokeUser = ref(false) |
||||
const hotUser = ref(false) |
||||
const reviewRestricted = ref(false) |
||||
const integratedUser = ref(false) |
||||
const showHumanAppraise = ref(false) |
||||
const mydFlag = ref(false) |
||||
const isBqCalcClaim = ref(false) |
||||
const msgReply = ref(true) |
||||
const hotUserData = ref(null) |
||||
const branchCompany = ref('') |
||||
|
||||
// —— Session ——
|
||||
function setIsBqCalcClaim(payload) { |
||||
isBqCalcClaim.value = payload |
||||
} |
||||
|
||||
function setToken(payload) { |
||||
token.value = payload |
||||
try { |
||||
sessionStorage.token = payload |
||||
} catch (e) { |
||||
console.log(e) |
||||
} |
||||
} |
||||
|
||||
function setSessionId(payload) { |
||||
sessionId.value = payload |
||||
try { |
||||
localStorage.sessionId = payload |
||||
} catch (e) { |
||||
console.log(e) |
||||
} |
||||
} |
||||
|
||||
function setConfigId(payload) { |
||||
configId.value = payload |
||||
try { |
||||
localStorage.configId = payload |
||||
} catch (e) { |
||||
console.log(e) |
||||
} |
||||
} |
||||
|
||||
function setAppentry(payload) { |
||||
appentry.value = payload |
||||
} |
||||
|
||||
function setBpErrorInfo(payload) { |
||||
bpErrorInfo.value = payload |
||||
} |
||||
|
||||
function delToken() { |
||||
token.value = '' |
||||
} |
||||
|
||||
function setUserId(payload) { |
||||
userId.value = payload |
||||
try { |
||||
localStorage.userId = payload |
||||
} catch (e) { |
||||
console.log(e) |
||||
} |
||||
} |
||||
|
||||
function setSource(payload) { |
||||
source.value = payload |
||||
try { |
||||
localStorage.source = payload |
||||
} catch (e) { |
||||
console.log(e) |
||||
} |
||||
} |
||||
|
||||
function setNotitle(payload) { |
||||
notitle.value = payload |
||||
try { |
||||
localStorage.notitle = payload |
||||
} catch (e) { |
||||
console.log(e) |
||||
} |
||||
} |
||||
|
||||
function setElder(payload) { |
||||
elder.value = payload |
||||
try { |
||||
localStorage.elder = payload |
||||
} catch (e) { |
||||
console.log(e) |
||||
} |
||||
} |
||||
|
||||
function setPlanCode(payload) { |
||||
planCode.value = payload |
||||
try { |
||||
localStorage.planCode = payload |
||||
} catch (e) { |
||||
console.log(e) |
||||
} |
||||
} |
||||
|
||||
function setEntrance(payload) { |
||||
entrance.value = payload |
||||
try { |
||||
localStorage.entrance = payload |
||||
} catch (e) { |
||||
console.log(e) |
||||
} |
||||
} |
||||
|
||||
function setUserInfo(payload) { |
||||
userInfo.value = payload |
||||
try { |
||||
localStorage.userInfo = JSON.stringify(payload) |
||||
} catch (e) { |
||||
console.log(e) |
||||
} |
||||
} |
||||
|
||||
function setHtmlExtParams(payload) { |
||||
htmlExtParams.value = payload |
||||
try { |
||||
localStorage.htmlExtParams = payload |
||||
} catch (e) { |
||||
console.log(e) |
||||
} |
||||
} |
||||
|
||||
function setComplaint(payload) { |
||||
complaint.value = payload |
||||
try { |
||||
localStorage.complaint = payload |
||||
} catch (e) { |
||||
console.log(e) |
||||
} |
||||
} |
||||
|
||||
function setNavigationCorpus(payload) { |
||||
navigationCorpus.value = payload |
||||
try { |
||||
localStorage.navigationCorpus = payload |
||||
} catch (e) { |
||||
console.log(e) |
||||
} |
||||
} |
||||
|
||||
function setManualService(payload) { |
||||
manualService.value = payload |
||||
try { |
||||
localStorage.manualService = JSON.stringify(payload) |
||||
} catch (e) { |
||||
console.log(e) |
||||
} |
||||
} |
||||
|
||||
function setSysConfig(payload) { |
||||
sysConfig.value = payload |
||||
try { |
||||
localStorage.sysConfig = payload |
||||
} catch (e) { |
||||
console.log(e) |
||||
} |
||||
} |
||||
|
||||
function setHeaderAvatar(payload) { |
||||
headerAvatar.value = payload |
||||
try { |
||||
localStorage.headerAvatar = JSON.stringify(payload) |
||||
} catch (e) { |
||||
console.log(e) |
||||
} |
||||
} |
||||
|
||||
// —— 消息发送状态 ——
|
||||
function setSendLoading(payload) { |
||||
sendLoading.value = payload |
||||
} |
||||
|
||||
function setIsSendSuccess(payload) { |
||||
isSendSuccess.value = payload |
||||
} |
||||
|
||||
function setQaId(payload) { |
||||
qaId.value = payload |
||||
} |
||||
|
||||
function setProblemFeedback(payload) { |
||||
problemFeedback.value = payload |
||||
} |
||||
|
||||
function setOtherTips(payload) { |
||||
otherTips.value = payload |
||||
} |
||||
|
||||
function setLastMessage(payload) { |
||||
lastMessage.value = payload |
||||
} |
||||
|
||||
function setSendFailList(payload) { |
||||
sendFailList.value.push(payload) |
||||
} |
||||
|
||||
function setIsLostMessage(payload) { |
||||
isLostMessage.value = payload |
||||
} |
||||
|
||||
function delSendFailList(payload) { |
||||
sendFailList.value = payload |
||||
} |
||||
|
||||
function setLeaveMessage(payload) { |
||||
isLeaveMessage.value = payload |
||||
} |
||||
|
||||
function setIsLeaveMessageSuccess(payload) { |
||||
isLeaveMessageSuccess.value = payload |
||||
try { |
||||
sessionStorage.isLeaveMessageSuccess = payload |
||||
} catch (e) { |
||||
console.log(e) |
||||
} |
||||
} |
||||
|
||||
function setMescrollContent(payload) { |
||||
mescrollContent.value = payload |
||||
} |
||||
|
||||
function setSendMessageList(payload) { |
||||
sendMessageList.value = payload |
||||
} |
||||
|
||||
function setReceiveMessageList(payload) { |
||||
receiveMessageList.value = payload |
||||
} |
||||
|
||||
function setTts(payload) { |
||||
tts.value = payload |
||||
} |
||||
|
||||
function setHxOpenSuccesed(payload) { |
||||
hxOpenSucceseds.value = payload |
||||
} |
||||
|
||||
function setTimestamp(payload) { |
||||
timestamp.value = payload |
||||
} |
||||
|
||||
function setSendParmas(payload) { |
||||
sendParmas.value = payload |
||||
} |
||||
|
||||
function setQueuedTimeout(payload) { |
||||
queuedTimeout.value = payload |
||||
} |
||||
|
||||
// 存储发送的消息到 chatList
|
||||
function addSendMessageList(payload = {}) { |
||||
console.log('接收发送的消息===', payload) |
||||
|
||||
sendParmas.value = { |
||||
token: token.value, |
||||
fromFlag: payload.fromFlag || 1, // 1为自己 2为其他 other提示消息
|
||||
userId: userId.value, |
||||
sessionId: sessionId.value, |
||||
reqAndResType: payload.reqAndResType, // 1文本 2图片 3问提评价
|
||||
msgType: payload.msgType || '', |
||||
msgText: payload.msgText, |
||||
file: payload.file || '', |
||||
filename: payload.filename || '', |
||||
formData: payload.formData || '', |
||||
source: source.value, |
||||
timestamp: payload.timestamp || new Date().valueOf(), |
||||
msgSource: manualService.value, // 1机器人 2人工
|
||||
cmd: payload.cmd || '', |
||||
sendLoading: payload.sendLoading, |
||||
isSendSuccess: payload.isSendSuccess, |
||||
voiceNo: payload.voiceNo, |
||||
quoteData: payload.quoteData || null, |
||||
bpErrorContent: payload.bpErrorContent || '', // 电子回访断点服务
|
||||
} |
||||
console.log('发送消息==', sendParmas.value) |
||||
|
||||
timestamp.value = sendParmas.value.timestamp |
||||
|
||||
// 存储正在发送的那条数据
|
||||
setCurrentItemId(sendParmas.value.timestamp) |
||||
|
||||
chatList.value.push(sendParmas.value) |
||||
} |
||||
|
||||
// 消息列表
|
||||
function setChatList(payload) { |
||||
const normalizedItem = utils.normalizeMessage(payload) |
||||
chatList.value.push(normalizedItem) |
||||
} |
||||
|
||||
function delChatList(index) { |
||||
chatList.value.splice(index, 1) |
||||
} |
||||
|
||||
function delAllChatList() { |
||||
chatList.value.splice(0, chatList.value.length) |
||||
} |
||||
|
||||
function delSendFailListById(delId) { |
||||
if (sendFailList.value && sendFailList.value.length > 0) { |
||||
sendFailList.value.forEach((item, index) => { |
||||
if (delId === item.timestamp) { |
||||
sendFailList.value.splice(index, 1) |
||||
} |
||||
}) |
||||
} |
||||
} |
||||
|
||||
// 存储到消息队列中
|
||||
function setChatId(payload) { |
||||
chatId.value.push(payload) |
||||
} |
||||
|
||||
function setCurrentItemId(payload) { |
||||
currentItemId.value = payload |
||||
} |
||||
|
||||
function setFindActiveItem(findActiveItem) { |
||||
if (chatList.value && chatList.value.length > 0) { |
||||
chatList.value.forEach((item) => { |
||||
if (currentItemId.value == item.timestamp) { |
||||
item.isSendSuccess = findActiveItem |
||||
item.sendLoading = false |
||||
} |
||||
}) |
||||
} |
||||
} |
||||
|
||||
function setActiveItemExtra(data) { |
||||
if (chatList.value && chatList.value.length > 0) { |
||||
chatList.value.forEach((item) => { |
||||
if (currentItemId.value == item.timestamp) { |
||||
if (data && data.imgKey) { |
||||
item.imgKey = data.imgKey |
||||
} |
||||
if (data && data.imgUrl) { |
||||
item.imgUrl = data.imgUrl |
||||
} |
||||
} |
||||
}) |
||||
} |
||||
} |
||||
|
||||
function setReSendMessage(reSendMessageId) { |
||||
if (chatList.value && chatList.value.length > 0) { |
||||
chatList.value.forEach((item, index) => { |
||||
if (reSendMessageId === item.timestamp) { |
||||
chatList.value.splice(index, 1) |
||||
} |
||||
}) |
||||
} |
||||
delSendFailListById(reSendMessageId) |
||||
} |
||||
|
||||
function scrollBottom() { |
||||
setTimeout(() => { |
||||
try { |
||||
mescrollContent.value.scrollTop = mescrollContent.value.scrollHeight || 0 |
||||
} catch (error) { |
||||
console.log(error.message) |
||||
} |
||||
}, 500) |
||||
} |
||||
|
||||
// —— 其他状态 ——
|
||||
function setIsBackstage(payload) { |
||||
isBackstage.value = payload |
||||
} |
||||
|
||||
// 存储语音
|
||||
function setVoiceData(payload) { |
||||
voiceDataList.value.push(payload) |
||||
} |
||||
|
||||
// sdk是否已加载好
|
||||
function setSdkLoaded(payload) { |
||||
sdkLoaded.value = payload |
||||
} |
||||
|
||||
function setPcaData(payload) { |
||||
pcaData.value = payload |
||||
} |
||||
|
||||
function setChannelReform(payload) { |
||||
channelReform.value = payload |
||||
} |
||||
|
||||
function setMsgStatus(payload) { |
||||
msgStatus.value = payload |
||||
} |
||||
|
||||
function setMsgReply(payload) { |
||||
msgReply.value = payload |
||||
} |
||||
|
||||
function setIsHumanChat(payload) { |
||||
isHumanChat.value = payload |
||||
} |
||||
|
||||
function setGaokeUser(payload) { |
||||
gaokeUser.value = payload |
||||
} |
||||
|
||||
function setBranchCompany(payload) { |
||||
branchCompany.value = payload |
||||
} |
||||
|
||||
function setHotUser(payload) { |
||||
hotUser.value = payload |
||||
} |
||||
|
||||
function setHotUserData(payload) { |
||||
hotUserData.value = payload |
||||
} |
||||
|
||||
function setReviewRestricted(payload) { |
||||
reviewRestricted.value = payload |
||||
} |
||||
|
||||
function setIntegratedUser(payload) { |
||||
integratedUser.value = payload |
||||
} |
||||
|
||||
function setHxSessionId(payload) { |
||||
hxSessionId.value = payload |
||||
} |
||||
|
||||
function setShowHumanAppraise(payload) { |
||||
showHumanAppraise.value = payload |
||||
} |
||||
|
||||
return { |
||||
// State
|
||||
token, |
||||
userId, |
||||
configId, |
||||
sessionId, |
||||
source, |
||||
planCode, |
||||
entrance, |
||||
elder, |
||||
notitle, |
||||
userInfo, |
||||
sysConfig, |
||||
headerAvatar, |
||||
htmlExtParams, |
||||
complaint, |
||||
navigationCorpus, |
||||
routeAction, |
||||
direction, |
||||
mescrollContent, |
||||
isLeaveMessage, |
||||
isLeaveMessageSuccess, |
||||
manualService, |
||||
queuedTimeout, |
||||
sendLoading, |
||||
isSendSuccess, |
||||
timestamp, |
||||
sendParmas, |
||||
chatList, |
||||
sendMessageList, |
||||
receiveMessageList, |
||||
chatId, |
||||
currentItemId, |
||||
issubmit, |
||||
otherTips, |
||||
lastMessage, |
||||
asrConfig, |
||||
sendFailList, |
||||
isLostMessage, |
||||
hxSessionId, |
||||
qaId, |
||||
problemFeedback, |
||||
isBackstage, |
||||
sdkLoaded, |
||||
chatArr, |
||||
bpErrorInfo, |
||||
voiceDataList, |
||||
hxOpenSucceseds, |
||||
pcaData, |
||||
appentry, |
||||
tts, |
||||
flagType, |
||||
msgStatus, |
||||
channelReform, |
||||
isHumanChat, |
||||
gaokeUser, |
||||
hotUser, |
||||
reviewRestricted, |
||||
integratedUser, |
||||
showHumanAppraise, |
||||
mydFlag, |
||||
isBqCalcClaim, |
||||
msgReply, |
||||
hotUserData, |
||||
branchCompany, |
||||
|
||||
// Actions
|
||||
setIsBqCalcClaim, |
||||
setToken, |
||||
setSessionId, |
||||
setConfigId, |
||||
setAppentry, |
||||
setBpErrorInfo, |
||||
delToken, |
||||
setUserId, |
||||
setSource, |
||||
setNotitle, |
||||
setElder, |
||||
setPlanCode, |
||||
setEntrance, |
||||
setUserInfo, |
||||
setHtmlExtParams, |
||||
setComplaint, |
||||
setNavigationCorpus, |
||||
setManualService, |
||||
setSysConfig, |
||||
setHeaderAvatar, |
||||
setSendLoading, |
||||
setIsSendSuccess, |
||||
setQaId, |
||||
setProblemFeedback, |
||||
setOtherTips, |
||||
setLastMessage, |
||||
setSendFailList, |
||||
setIsLostMessage, |
||||
delSendFailList, |
||||
delSendFailListById, |
||||
setLeaveMessage, |
||||
setIsLeaveMessageSuccess, |
||||
setMescrollContent, |
||||
setSendMessageList, |
||||
setReceiveMessageList, |
||||
setTts, |
||||
setHxOpenSuccesed, |
||||
setTimestamp, |
||||
setSendParmas, |
||||
setQueuedTimeout, |
||||
addSendMessageList, |
||||
setChatList, |
||||
delChatList, |
||||
delAllChatList, |
||||
setChatId, |
||||
setCurrentItemId, |
||||
setFindActiveItem, |
||||
setActiveItemExtra, |
||||
setReSendMessage, |
||||
scrollBottom, |
||||
setIsBackstage, |
||||
setVoiceData, |
||||
setSdkLoaded, |
||||
setPcaData, |
||||
setChannelReform, |
||||
setMsgStatus, |
||||
setMsgReply, |
||||
setIsHumanChat, |
||||
setGaokeUser, |
||||
setBranchCompany, |
||||
setHotUser, |
||||
setHotUserData, |
||||
setReviewRestricted, |
||||
setIntegratedUser, |
||||
setHxSessionId, |
||||
setShowHumanAppraise, |
||||
} |
||||
}) |
||||
export default useAppStore |
||||
export default pinia |
||||
|
||||
Loading…
Reference in new issue