zj-plugin-intelligent 1.2.5-beta.12 → 1.2.5-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -975,7 +975,7 @@ eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n
|
|
|
975
975
|
/***/ (function(module, exports, __webpack_require__) {
|
|
976
976
|
|
|
977
977
|
"use strict";
|
|
978
|
-
eval("\n\nvar _interopRequireDefault = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.28.4@@babel/runtime/helpers/interopRequireDefault.js */ \"./node_modules/_@babel_runtime@7.28.4@@babel/runtime/helpers/interopRequireDefault.js\").default;\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n__webpack_require__(/*! core-js/modules/es.iterator.constructor.js */ \"./node_modules/_core-js@3.45.1@core-js/modules/es.iterator.constructor.js\");\n__webpack_require__(/*! core-js/modules/es.iterator.find.js */ \"./node_modules/_core-js@3.45.1@core-js/modules/es.iterator.find.js\");\n__webpack_require__(/*! core-js/modules/es.iterator.map.js */ \"./node_modules/_core-js@3.45.1@core-js/modules/es.iterator.map.js\");\nvar _apichat = __webpack_require__(/*! @lib/api/apichat */ \"./src/lib/api/apichat.js\");\nvar _cookie = __webpack_require__(/*! @lib/utils/cookie.js */ \"./src/lib/utils/cookie.js\");\nvar _ChatSidebar = _interopRequireDefault(__webpack_require__(/*! ./ChatSidebar.vue */ \"./src/lib/components/chatMain/ChatSidebar.vue\"));\nvar _AgentSelector = _interopRequireDefault(__webpack_require__(/*! ./AgentSelector.vue */ \"./src/lib/components/chatMain/AgentSelector.vue\"));\nvar _ChatDetail = _interopRequireDefault(__webpack_require__(/*! ./ChatDetail.vue */ \"./src/lib/components/chatMain/ChatDetail.vue\"));\nvar _default = exports.default = {\n name: 'ChatMain',\n components: {\n ChatSidebar: _ChatSidebar.default,\n AgentSelector: _AgentSelector.default,\n ChatDetail: _ChatDetail.default\n },\n props: {\n Ak: {\n type: String,\n default: ''\n },\n Sk: {\n type: String,\n default: ''\n },\n imAccount: {\n type: String,\n default: ''\n },\n companyNo: {\n type: String,\n default: ''\n },\n isIntelShow: {\n default: false,\n type: Boolean\n },\n chatImToken: {\n default: '',\n type: String\n }\n },\n data() {\n // 首次渲染前检测窗口宽度,避免 H5 端先显示 PC 布局再切换导致闪烁\n const _isMobile = typeof window !== 'undefined' && window.innerWidth <= 768;\n return {\n agentList: [],\n currentAgent: '',\n currentAgentDesc: '',\n sessionsLoaded: false,\n sessionList: [],\n activeSessionId: '',\n loadingMore: false,\n showAgentSelect: !_isMobile,\n isMobile: _isMobile,\n showSidebar: false,\n showH5List: _isMobile,\n agentInfo: {},\n _swipeStartX: 0,\n _swipeStartY: 0,\n _swipeHandled: false\n };\n },\n created() {\n if (this.Ak || this.Sk) {\n (0, _apichat.setApiAuth)(this.Ak, this.Sk, this.imAccount, this.companyNo, this.chatImToken);\n }\n this.loadAgents();\n this.loadSessions();\n },\n mounted() {\n this.updateViewportState();\n window.addEventListener('resize', this.updateViewportState, {\n passive: true\n });\n // Android WebView 兼容:在 document 级别监听 touchmove/touchend\n // 避免可滚动子元素消费事件后不冒泡到父级\n document.addEventListener('touchmove', this._onSwipeMove, {\n passive: true\n });\n document.addEventListener('touchend', this._onSwipeEnd, {\n passive: true\n });\n },\n watch: {},\n methods: {\n // ── H5 侧滑手势 ──\n onSwipeTouchStart(e) {\n if (!this.isMobile) return;\n this._swipeStartX = e.touches[0].clientX;\n this._swipeStartY = e.touches[0].clientY;\n this._swipeHandled = false;\n },\n // 在 touchmove 中实时检测(绕过 Android 可滚动区域冒泡问题)\n _onSwipeMove(e) {\n if (!this.isMobile || this._swipeHandled) return;\n const moveX = e.touches[0].clientX;\n const moveY = e.touches[0].clientY;\n const diffX = moveX - this._swipeStartX;\n const diffY = moveY - this._swipeStartY;\n if (this._swipeStartX > 30) return;\n if (diffX < 60) return;\n if (Math.abs(diffX) < Math.abs(diffY) * 2) return;\n this._swipeHandled = true;\n this._triggerSwipeAction();\n },\n // touchend 检测(兜底,兼容不支持 touchmove 的场景)\n _onSwipeEnd(e) {\n if (!this.isMobile || this._swipeHandled) return;\n const endX = e.changedTouches[0].clientX;\n const endY = e.changedTouches[0].clientY;\n const diffX = endX - this._swipeStartX;\n const diffY = endY - this._swipeStartY;\n\n // 从左侧边缘开始滑动(30px 内),向右滑动超过 60px,且水平距离明显大于垂直距离\n if (this._swipeStartX > 30) return;\n if (diffX < 60) return;\n if (Math.abs(diffX) < Math.abs(diffY) * 2) return;\n this._swipeHandled = true;\n this._triggerSwipeAction();\n },\n _triggerSwipeAction() {\n if (this.showH5List) {\n // 列表页 → 原生返回\n this.handleNativeBack();\n } else if (!this.showAgentSelect) {\n // 详情页/欢迎页 → 返回列表\n this.goBackToList();\n }\n },\n handleNewSessionInternal() {\n if (!this.currentAgent) return;\n if (this.activeSessionId) this.closeOldSession();\n (0, _apichat.startSession)(this.currentAgent).then(res => {\n this.activeSessionId = res.sessionId || '';\n this.loadSessions();\n const agent = this.agentList.find(a => a.agentCode === this.currentAgent);\n if (agent) this.addWelcomeMessage(agent);\n }).catch(() => {});\n },\n updateViewportState() {\n if (typeof window === 'undefined') return;\n const nextIsMobile = window.innerWidth <= 768;\n const wasMobile = this.isMobile;\n this.isMobile = nextIsMobile;\n if (!nextIsMobile) {\n this.showSidebar = false;\n this.showH5List = false;\n } else if (!wasMobile && nextIsMobile) {\n if (this.sessionList.length > 0 && !this.activeSessionId) {\n this.showH5List = true;\n this.showAgentSelect = false;\n }\n }\n },\n toggleSidebar() {\n if (!this.isMobile) return;\n this.showSidebar = !this.showSidebar;\n },\n closeSidebar() {\n this.showSidebar = false;\n },\n handleNativeBack() {\n if (this.$hybrid && typeof this.$hybrid.closePage === 'function') {\n this.$hybrid.closePage();\n } else if (window.history.length > 1) {\n window.history.back();\n }\n },\n handleSidebarBack() {\n this.handleNativeBack();\n },\n agentjumpclick() {\n const cd = this.$refs.chatDetail;\n if (cd && cd.sending) {\n this.$message.warning('AI正在生成内容,暂时请不要切换对话');\n return;\n }\n this.currentAgent = '';\n this.currentAgentDesc = '';\n this.activeSessionId = '';\n this.showAgentSelect = true;\n this.showH5List = false;\n this.closeSidebar();\n },\n goBackToList() {\n const cd = this.$refs.chatDetail;\n if (cd && cd.sending) {\n this.$message.warning('AI正在生成内容,暂时请不要切换对话');\n return;\n }\n if (cd) {\n if (cd.eventSource) {\n cd.eventSource.close();\n cd.eventSource = null;\n }\n cd.sending = false;\n cd.clearWaitTimer();\n cd.messages = [];\n cd.contentCache = {};\n }\n this.activeSessionId = '';\n this.currentAgent = '';\n this.currentAgentDesc = '';\n this.agentInfo = {};\n this.showH5List = true;\n this.showAgentSelect = false;\n this.closeSidebar();\n },\n loadAgents() {\n (0, _apichat.getChatAgents)().then(list => {\n this.agentList = list || [];\n }).catch(() => {});\n },\n loadSessions() {\n (0, _apichat.getSessionList)().then(list => {\n if (!this.activeSessionId) {\n this.sessionList = list || [];\n if (this.sessionList.length > 0) {\n if (this.isMobile) {\n this.showAgentSelect = false;\n this.showH5List = true;\n this.showSidebar = false;\n } else {\n this.switchSession(this.sessionList[0]);\n }\n }\n if (this.sessionList.length === 0) {\n this.showAgentSelect = true;\n this.showH5List = false;\n }\n } else {\n this.sessionList = list || [];\n let _item = list.find(res => res.sessionId == this.activeSessionId);\n try {\n if (_item && _item.suggestedQuestions) {\n _item.suggestedQuestions = JSON.parse(_item.suggestedQuestions);\n }\n _item && (this.agentInfo = _item);\n } catch (err) {\n this.agentInfo.questionArr = [];\n console.warn('快捷提问解析失败', err);\n }\n }\n }).catch(() => {});\n },\n startChatWithAgent(agent) {\n console.log('选择了助手', agent.agentCode, this.currentAgent);\n if (agent.agentCode == this.currentAgent) {\n return;\n }\n this.currentAgent = agent.agentCode;\n this.currentAgentDesc = agent.description || '';\n this.agentInfo = {};\n this.showAgentSelect = false;\n this.closeSidebar();\n if (this.isMobile) {\n this.showH5List = false;\n }\n const existing = this.sessionList.find(s => s.agentCode === agent.agentCode);\n if (existing) {\n this.switchSession(existing);\n } else {\n this.handleNewSession();\n }\n },\n handleNewSession() {\n if (!this.currentAgent) return;\n if (this.activeSessionId) this.closeOldSession();\n (0, _apichat.startSession)(this.currentAgent).then(res => {\n this.activeSessionId = res.sessionId || '';\n this.loadSessions();\n const agent = this.agentList.find(a => a.agentCode === this.currentAgent);\n if (agent) this.addWelcomeMessage(agent);\n }).catch(() => {});\n },\n addWelcomeMessage(agent) {\n const cd = this.$refs.chatDetail;\n if (cd) {\n const _agent = this.agentList.find(x => x.agentCode === this.currentAgent);\n cd.greeting = _agent ? _agent.greeting || '很高兴为您服务,请问有什么可以帮到您?' : '';\n }\n },\n async switchSession(s) {\n let cd = this.$refs.chatDetail;\n if (cd && cd.sending) {\n this.$message.warning('AI正在生成内容,暂时请不要切换对话');\n return;\n }\n this.showAgentSelect = false;\n this.closeSidebar();\n if (this.isMobile) {\n this.showH5List = false;\n }\n if (this.activeSessionId === s.sessionId) return;\n\n // 移动端刚切换 showH5List=false,ChatDetail 尚未渲染完成,需要等待 nextTick\n if (!cd) {\n await this.$nextTick();\n cd = this.$refs.chatDetail;\n }\n if (cd) {\n cd.contentCache = {};\n cd.messages = [];\n cd.msgPage = 1;\n cd.msgTotal = 0;\n cd.loadingSessionMsg = true;\n }\n this.activeSessionId = s.sessionId;\n this.currentAgent = s.agentCode;\n this.agentInfo = s;\n try {\n if (s.suggestedQuestions) {\n this.agentInfo.suggestedQuestions = JSON.parse(s.suggestedQuestions);\n } else {\n this.agentInfo.suggestedQuestions = [];\n }\n } catch (err) {\n this.agentInfo.questionArr = [];\n console.warn('快捷提问解析失败', err);\n }\n const agent = this.agentList.find(a => a.agentCode === s.agentCode);\n this.currentAgentDesc = agent ? agent.description || '' : '';\n (0, _apichat.syncToken)((0, _cookie.getToken)(), s.sessionId);\n try {\n const res = await (0, _apichat.getSessionMessages)(s.sessionId, 1, 10);\n const list = Array.isArray(res) ? res : res.list || [];\n if (cd) {\n cd.msgTotal = res.total || list.length;\n cd.msgPage = 1;\n const asAsc = (list || []).slice().reverse();\n cd.messages = asAsc.map(m => ({\n role: m.role,\n content: m.content || '',\n thinking: m.thinking || '',\n toolCalls: [],\n agentName: m.role === 'assistant' ? s.agentName || '' : '',\n createTime: m.createTime || null,\n _key: m.createTime ? 'msg_' + m.createTime : 'msg_' + Date.now() + '_' + Math.random()\n }));\n if (cd.messages.length === 0 && agent) {\n const _agent = this.agentList.find(x => x.agentCode === this.currentAgent);\n cd.greeting = _agent ? _agent.greeting || '很高兴为您服务,请问有什么可以帮到您?' : '';\n }\n cd.loadingSessionMsg = false;\n await this.$nextTick();\n this.$nextTick(() => {\n cd.scrollToBottomOnce();\n cd.checkScrollBottom();\n });\n }\n } catch (e) {\n if (cd) {\n cd.messages = [];\n cd.loadingSessionMsg = false;\n }\n }\n },\n handleDeleteSession(s) {\n this.$confirm(`确认删除「${s.agentName || s.agentCode}」的会话?`, '提示', {\n type: 'warning'\n }).then(() => {\n (0, _apichat.deleteSession)(s.sessionId).then(() => {\n if (this.activeSessionId === s.sessionId) {\n this.activeSessionId = '';\n this.currentAgent = '';\n this.currentAgentDesc = '';\n const cd = this.$refs.chatDetail;\n if (cd) {\n cd.messages = [];\n cd.contentCache = {};\n }\n if (this.isMobile) {\n this.showH5List = false;\n this.showAgentSelect = true;\n } else {\n this.showAgentSelect = true;\n }\n }\n this.loadSessions();\n });\n }).catch(() => {});\n },\n closeOldSession() {}\n },\n beforeDestroy() {\n window.removeEventListener('resize', this.updateViewportState);\n document.removeEventListener('touchmove', this._onSwipeMove);\n document.removeEventListener('touchend', this._onSwipeEnd);\n }\n};\n\n//# sourceURL=webpack://ZjPluginIntelligent/./src/lib/components/chatMain/index.vue?./node_modules/_cache-loader@4.1.0@cache-loader/dist/cjs.js??ref--13-0!./node_modules/_babel-loader@8.4.1@babel-loader/lib!./node_modules/_cache-loader@4.1.0@cache-loader/dist/cjs.js??ref--1-0!./node_modules/_vue-loader@15.11.1@vue-loader/lib??vue-loader-options");
|
|
978
|
+
eval("\n\nvar _interopRequireDefault = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.28.4@@babel/runtime/helpers/interopRequireDefault.js */ \"./node_modules/_@babel_runtime@7.28.4@@babel/runtime/helpers/interopRequireDefault.js\").default;\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n__webpack_require__(/*! core-js/modules/es.iterator.constructor.js */ \"./node_modules/_core-js@3.45.1@core-js/modules/es.iterator.constructor.js\");\n__webpack_require__(/*! core-js/modules/es.iterator.find.js */ \"./node_modules/_core-js@3.45.1@core-js/modules/es.iterator.find.js\");\n__webpack_require__(/*! core-js/modules/es.iterator.map.js */ \"./node_modules/_core-js@3.45.1@core-js/modules/es.iterator.map.js\");\nvar _apichat = __webpack_require__(/*! @lib/api/apichat */ \"./src/lib/api/apichat.js\");\nvar _cookie = __webpack_require__(/*! @lib/utils/cookie.js */ \"./src/lib/utils/cookie.js\");\nvar _ChatSidebar = _interopRequireDefault(__webpack_require__(/*! ./ChatSidebar.vue */ \"./src/lib/components/chatMain/ChatSidebar.vue\"));\nvar _AgentSelector = _interopRequireDefault(__webpack_require__(/*! ./AgentSelector.vue */ \"./src/lib/components/chatMain/AgentSelector.vue\"));\nvar _ChatDetail = _interopRequireDefault(__webpack_require__(/*! ./ChatDetail.vue */ \"./src/lib/components/chatMain/ChatDetail.vue\"));\nvar _default = exports.default = {\n name: 'ChatMain',\n components: {\n ChatSidebar: _ChatSidebar.default,\n AgentSelector: _AgentSelector.default,\n ChatDetail: _ChatDetail.default\n },\n props: {\n Ak: {\n type: String,\n default: ''\n },\n Sk: {\n type: String,\n default: ''\n },\n imAccount: {\n type: String,\n default: ''\n },\n companyNo: {\n type: String,\n default: ''\n },\n isIntelShow: {\n default: false,\n type: Boolean\n },\n chatImToken: {\n default: '',\n type: String\n }\n },\n data() {\n // 首次渲染前检测窗口宽度,避免 H5 端先显示 PC 布局再切换导致闪烁\n const _isMobile = typeof window !== 'undefined' && window.innerWidth <= 768;\n return {\n agentList: [],\n currentAgent: '',\n currentAgentDesc: '',\n sessionsLoaded: false,\n sessionList: [],\n activeSessionId: '',\n loadingMore: false,\n showAgentSelect: !_isMobile,\n isMobile: _isMobile,\n showSidebar: false,\n showH5List: _isMobile,\n agentInfo: {},\n _swipeStartX: 0,\n _swipeStartY: 0,\n _swipeHandled: false\n };\n },\n created() {\n if (this.Ak || this.Sk) {\n (0, _apichat.setApiAuth)(this.Ak, this.Sk, this.imAccount, this.companyNo, this.chatImToken);\n }\n this.loadAgents();\n this.loadSessions();\n },\n mounted() {\n this.updateViewportState();\n window.addEventListener('resize', this.updateViewportState, {\n passive: true\n });\n // Android WebView 兼容:在 document 级别监听 touchmove/touchend\n // 避免可滚动子元素消费事件后不冒泡到父级\n document.addEventListener('touchmove', this._onSwipeMove, {\n passive: true\n });\n document.addEventListener('touchend', this._onSwipeEnd, {\n passive: true\n });\n },\n watch: {},\n methods: {\n // ── H5 侧滑手势 ──\n onSwipeTouchStart(e) {\n if (!this.isMobile) return;\n this._swipeStartX = e.touches[0].clientX;\n this._swipeStartY = e.touches[0].clientY;\n this._swipeHandled = false;\n },\n // 在 touchmove 中实时检测\n // 注意:不限制触摸起点位置(移除边缘限制),以兼容 Android 系统手势导航在左边缘的拦截\n _onSwipeMove(e) {\n if (!this.isMobile || this._swipeHandled) return;\n const moveX = e.touches[0].clientX;\n const moveY = e.touches[0].clientY;\n const diffX = moveX - this._swipeStartX;\n const diffY = moveY - this._swipeStartY;\n\n // 向右滑动超过 60px,且水平距离明显大于垂直距离(排除上下滚动干扰)\n if (diffX < 60) return;\n if (Math.abs(diffX) < Math.abs(diffY) * 2) return;\n this._swipeHandled = true;\n this._triggerSwipeAction();\n },\n // touchend 检测(兜底,兼容不支持 touchmove 的场景)\n _onSwipeEnd(e) {\n if (!this.isMobile || this._swipeHandled) return;\n const endX = e.changedTouches[0].clientX;\n const endY = e.changedTouches[0].clientY;\n const diffX = endX - this._swipeStartX;\n const diffY = endY - this._swipeStartY;\n\n // 向右滑动超过 60px,且水平距离明显大于垂直距离\n if (diffX < 60) return;\n if (Math.abs(diffX) < Math.abs(diffY) * 2) return;\n this._swipeHandled = true;\n this._triggerSwipeAction();\n },\n _triggerSwipeAction() {\n if (this.showH5List) {\n // 列表页 → 原生返回\n this.handleNativeBack();\n } else if (!this.showAgentSelect) {\n // 详情页/欢迎页 → 返回列表\n this.goBackToList();\n }\n },\n handleNewSessionInternal() {\n if (!this.currentAgent) return;\n if (this.activeSessionId) this.closeOldSession();\n (0, _apichat.startSession)(this.currentAgent).then(res => {\n this.activeSessionId = res.sessionId || '';\n this.loadSessions();\n const agent = this.agentList.find(a => a.agentCode === this.currentAgent);\n if (agent) this.addWelcomeMessage(agent);\n }).catch(() => {});\n },\n updateViewportState() {\n if (typeof window === 'undefined') return;\n const nextIsMobile = window.innerWidth <= 768;\n const wasMobile = this.isMobile;\n this.isMobile = nextIsMobile;\n if (!nextIsMobile) {\n this.showSidebar = false;\n this.showH5List = false;\n } else if (!wasMobile && nextIsMobile) {\n if (this.sessionList.length > 0 && !this.activeSessionId) {\n this.showH5List = true;\n this.showAgentSelect = false;\n }\n }\n },\n toggleSidebar() {\n if (!this.isMobile) return;\n this.showSidebar = !this.showSidebar;\n },\n closeSidebar() {\n this.showSidebar = false;\n },\n handleNativeBack() {\n if (this.$hybrid && typeof this.$hybrid.closePage === 'function') {\n this.$hybrid.closePage();\n } else if (window.history.length > 1) {\n window.history.back();\n }\n },\n handleSidebarBack() {\n this.handleNativeBack();\n },\n agentjumpclick() {\n const cd = this.$refs.chatDetail;\n if (cd && cd.sending) {\n this.$message.warning('AI正在生成内容,暂时请不要切换对话');\n return;\n }\n this.currentAgent = '';\n this.currentAgentDesc = '';\n this.activeSessionId = '';\n this.showAgentSelect = true;\n this.showH5List = false;\n this.closeSidebar();\n },\n goBackToList() {\n const cd = this.$refs.chatDetail;\n if (cd && cd.sending) {\n this.$message.warning('AI正在生成内容,暂时请不要切换对话');\n return;\n }\n if (cd) {\n if (cd.eventSource) {\n cd.eventSource.close();\n cd.eventSource = null;\n }\n cd.sending = false;\n cd.clearWaitTimer();\n cd.messages = [];\n cd.contentCache = {};\n }\n this.activeSessionId = '';\n this.currentAgent = '';\n this.currentAgentDesc = '';\n this.agentInfo = {};\n this.showH5List = true;\n this.showAgentSelect = false;\n this.closeSidebar();\n },\n loadAgents() {\n (0, _apichat.getChatAgents)().then(list => {\n this.agentList = list || [];\n }).catch(() => {});\n },\n loadSessions() {\n (0, _apichat.getSessionList)().then(list => {\n if (!this.activeSessionId) {\n this.sessionList = list || [];\n if (this.sessionList.length > 0) {\n if (this.isMobile) {\n this.showAgentSelect = false;\n this.showH5List = true;\n this.showSidebar = false;\n } else {\n this.switchSession(this.sessionList[0]);\n }\n }\n if (this.sessionList.length === 0) {\n this.showAgentSelect = true;\n this.showH5List = false;\n }\n } else {\n this.sessionList = list || [];\n let _item = list.find(res => res.sessionId == this.activeSessionId);\n try {\n if (_item && _item.suggestedQuestions) {\n _item.suggestedQuestions = JSON.parse(_item.suggestedQuestions);\n }\n _item && (this.agentInfo = _item);\n } catch (err) {\n this.agentInfo.questionArr = [];\n console.warn('快捷提问解析失败', err);\n }\n }\n }).catch(() => {});\n },\n startChatWithAgent(agent) {\n console.log('选择了助手', agent.agentCode, this.currentAgent);\n if (agent.agentCode == this.currentAgent) {\n return;\n }\n this.currentAgent = agent.agentCode;\n this.currentAgentDesc = agent.description || '';\n this.agentInfo = {};\n this.showAgentSelect = false;\n this.closeSidebar();\n if (this.isMobile) {\n this.showH5List = false;\n }\n const existing = this.sessionList.find(s => s.agentCode === agent.agentCode);\n if (existing) {\n this.switchSession(existing);\n } else {\n this.handleNewSession();\n }\n },\n handleNewSession() {\n if (!this.currentAgent) return;\n if (this.activeSessionId) this.closeOldSession();\n (0, _apichat.startSession)(this.currentAgent).then(res => {\n this.activeSessionId = res.sessionId || '';\n this.loadSessions();\n const agent = this.agentList.find(a => a.agentCode === this.currentAgent);\n if (agent) this.addWelcomeMessage(agent);\n }).catch(() => {});\n },\n addWelcomeMessage(agent) {\n const cd = this.$refs.chatDetail;\n if (cd) {\n const _agent = this.agentList.find(x => x.agentCode === this.currentAgent);\n cd.greeting = _agent ? _agent.greeting || '很高兴为您服务,请问有什么可以帮到您?' : '';\n }\n },\n async switchSession(s) {\n let cd = this.$refs.chatDetail;\n if (cd && cd.sending) {\n this.$message.warning('AI正在生成内容,暂时请不要切换对话');\n return;\n }\n this.showAgentSelect = false;\n this.closeSidebar();\n if (this.isMobile) {\n this.showH5List = false;\n }\n if (this.activeSessionId === s.sessionId) return;\n\n // 移动端刚切换 showH5List=false,ChatDetail 尚未渲染完成,需要等待 nextTick\n if (!cd) {\n await this.$nextTick();\n cd = this.$refs.chatDetail;\n }\n if (cd) {\n cd.contentCache = {};\n cd.messages = [];\n cd.msgPage = 1;\n cd.msgTotal = 0;\n cd.loadingSessionMsg = true;\n }\n this.activeSessionId = s.sessionId;\n this.currentAgent = s.agentCode;\n this.agentInfo = s;\n try {\n if (s.suggestedQuestions) {\n this.agentInfo.suggestedQuestions = JSON.parse(s.suggestedQuestions);\n } else {\n this.agentInfo.suggestedQuestions = [];\n }\n } catch (err) {\n this.agentInfo.questionArr = [];\n console.warn('快捷提问解析失败', err);\n }\n const agent = this.agentList.find(a => a.agentCode === s.agentCode);\n this.currentAgentDesc = agent ? agent.description || '' : '';\n (0, _apichat.syncToken)((0, _cookie.getToken)(), s.sessionId);\n try {\n const res = await (0, _apichat.getSessionMessages)(s.sessionId, 1, 10);\n const list = Array.isArray(res) ? res : res.list || [];\n if (cd) {\n cd.msgTotal = res.total || list.length;\n cd.msgPage = 1;\n const asAsc = (list || []).slice().reverse();\n cd.messages = asAsc.map(m => ({\n role: m.role,\n content: m.content || '',\n thinking: m.thinking || '',\n toolCalls: [],\n agentName: m.role === 'assistant' ? s.agentName || '' : '',\n createTime: m.createTime || null,\n _key: m.createTime ? 'msg_' + m.createTime : 'msg_' + Date.now() + '_' + Math.random()\n }));\n if (cd.messages.length === 0 && agent) {\n const _agent = this.agentList.find(x => x.agentCode === this.currentAgent);\n cd.greeting = _agent ? _agent.greeting || '很高兴为您服务,请问有什么可以帮到您?' : '';\n }\n cd.loadingSessionMsg = false;\n await this.$nextTick();\n this.$nextTick(() => {\n cd.scrollToBottomOnce();\n cd.checkScrollBottom();\n });\n }\n } catch (e) {\n if (cd) {\n cd.messages = [];\n cd.loadingSessionMsg = false;\n }\n }\n },\n handleDeleteSession(s) {\n this.$confirm(`确认删除「${s.agentName || s.agentCode}」的会话?`, '提示', {\n type: 'warning'\n }).then(() => {\n (0, _apichat.deleteSession)(s.sessionId).then(() => {\n if (this.activeSessionId === s.sessionId) {\n this.activeSessionId = '';\n this.currentAgent = '';\n this.currentAgentDesc = '';\n const cd = this.$refs.chatDetail;\n if (cd) {\n cd.messages = [];\n cd.contentCache = {};\n }\n if (this.isMobile) {\n this.showH5List = false;\n this.showAgentSelect = true;\n } else {\n this.showAgentSelect = true;\n }\n }\n this.loadSessions();\n });\n }).catch(() => {});\n },\n closeOldSession() {}\n },\n beforeDestroy() {\n window.removeEventListener('resize', this.updateViewportState);\n document.removeEventListener('touchmove', this._onSwipeMove);\n document.removeEventListener('touchend', this._onSwipeEnd);\n }\n};\n\n//# sourceURL=webpack://ZjPluginIntelligent/./src/lib/components/chatMain/index.vue?./node_modules/_cache-loader@4.1.0@cache-loader/dist/cjs.js??ref--13-0!./node_modules/_babel-loader@8.4.1@babel-loader/lib!./node_modules/_cache-loader@4.1.0@cache-loader/dist/cjs.js??ref--1-0!./node_modules/_vue-loader@15.11.1@vue-loader/lib??vue-loader-options");
|
|
979
979
|
|
|
980
980
|
/***/ }),
|
|
981
981
|
|
|
@@ -12608,7 +12608,7 @@ eval("module.exports = function(originalModule) {\n\tif (!originalModule.webpack
|
|
|
12608
12608
|
/*! exports provided: name, version, main, private, scripts, dependencies, devDependencies, browserslist, directories, keywords, license, default */
|
|
12609
12609
|
/***/ (function(module) {
|
|
12610
12610
|
|
|
12611
|
-
eval("module.exports = JSON.parse(\"{\\\"name\\\":\\\"zj-plugin-intelligent\\\",\\\"version\\\":\\\"1.2.5-beta.
|
|
12611
|
+
eval("module.exports = JSON.parse(\"{\\\"name\\\":\\\"zj-plugin-intelligent\\\",\\\"version\\\":\\\"1.2.5-beta.13\\\",\\\"main\\\":\\\"lib/ZjPluginIntelligent.umd.min.js\\\",\\\"private\\\":false,\\\"scripts\\\":{\\\"serve\\\":\\\"vue-cli-service serve\\\",\\\"build\\\":\\\"vue-cli-service build\\\",\\\"lib\\\":\\\"vue-cli-service build --target lib --name ZjPluginIntelligent --dest lib src/lib/index.js\\\",\\\"lib:test\\\":\\\"vue-cli-service build --mode test --target lib --name ZjPluginIntelligent --dest lib src/lib/index.js\\\"},\\\"dependencies\\\":{\\\"html2canvas\\\":\\\"^1.4.1\\\",\\\"markdown-it\\\":\\\"^14.1.0\\\"},\\\"devDependencies\\\":{\\\"@babel/preset-env\\\":\\\"^7.14.9\\\",\\\"@vue/cli-plugin-babel\\\":\\\"~4.5.0\\\",\\\"@vue/cli-plugin-eslint\\\":\\\"^4.5.13\\\",\\\"@vue/cli-plugin-vuex\\\":\\\"~4.5.0\\\",\\\"@vue/cli-service\\\":\\\"~4.5.0\\\",\\\"axios\\\":\\\"^0.27.2\\\",\\\"babel-eslint\\\":\\\"^10.1.0\\\",\\\"babel-plugin-component\\\":\\\"^1.1.1\\\",\\\"compression-webpack-plugin\\\":\\\"^6.0.3\\\",\\\"core-js\\\":\\\"^3.6.5\\\",\\\"element-ui\\\":\\\"^2.15.4\\\",\\\"eslint\\\":\\\"^7.30.0\\\",\\\"eslint-plugin-vue\\\":\\\"^7.13.0\\\",\\\"js-cookie\\\":\\\"^2.2.1\\\",\\\"node-sass\\\":\\\"^4.12.0\\\",\\\"obs-upload\\\":\\\"^1.0.4-alpha.0\\\",\\\"reconnecting-websocket\\\":\\\"^4.4.0\\\",\\\"sass-loader\\\":\\\"^8.0.2\\\",\\\"snowflake-id\\\":\\\"^1.1.0\\\",\\\"vue\\\":\\\"^2.6.11\\\",\\\"vue-template-compiler\\\":\\\"^2.6.11\\\",\\\"vuex\\\":\\\"^3.4.0\\\",\\\"pako\\\":\\\"^2.1.0\\\",\\\"webpack-bundle-analyzer\\\":\\\"^4.4.2\\\"},\\\"browserslist\\\":[\\\"> 1%\\\",\\\"last 2 versions\\\",\\\"not dead\\\"],\\\"directories\\\":{\\\"lib\\\":\\\"lib\\\"},\\\"keywords\\\":[],\\\"license\\\":\\\"ISC\\\"}\");\n\n//# sourceURL=webpack://ZjPluginIntelligent/./package.json?");
|
|
12612
12612
|
|
|
12613
12613
|
/***/ }),
|
|
12614
12614
|
|
|
@@ -984,7 +984,7 @@ eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n
|
|
|
984
984
|
/***/ (function(module, exports, __webpack_require__) {
|
|
985
985
|
|
|
986
986
|
"use strict";
|
|
987
|
-
eval("\n\nvar _interopRequireDefault = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.28.4@@babel/runtime/helpers/interopRequireDefault.js */ \"./node_modules/_@babel_runtime@7.28.4@@babel/runtime/helpers/interopRequireDefault.js\").default;\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n__webpack_require__(/*! core-js/modules/es.iterator.constructor.js */ \"./node_modules/_core-js@3.45.1@core-js/modules/es.iterator.constructor.js\");\n__webpack_require__(/*! core-js/modules/es.iterator.find.js */ \"./node_modules/_core-js@3.45.1@core-js/modules/es.iterator.find.js\");\n__webpack_require__(/*! core-js/modules/es.iterator.map.js */ \"./node_modules/_core-js@3.45.1@core-js/modules/es.iterator.map.js\");\nvar _apichat = __webpack_require__(/*! @lib/api/apichat */ \"./src/lib/api/apichat.js\");\nvar _cookie = __webpack_require__(/*! @lib/utils/cookie.js */ \"./src/lib/utils/cookie.js\");\nvar _ChatSidebar = _interopRequireDefault(__webpack_require__(/*! ./ChatSidebar.vue */ \"./src/lib/components/chatMain/ChatSidebar.vue\"));\nvar _AgentSelector = _interopRequireDefault(__webpack_require__(/*! ./AgentSelector.vue */ \"./src/lib/components/chatMain/AgentSelector.vue\"));\nvar _ChatDetail = _interopRequireDefault(__webpack_require__(/*! ./ChatDetail.vue */ \"./src/lib/components/chatMain/ChatDetail.vue\"));\nvar _default = exports.default = {\n name: 'ChatMain',\n components: {\n ChatSidebar: _ChatSidebar.default,\n AgentSelector: _AgentSelector.default,\n ChatDetail: _ChatDetail.default\n },\n props: {\n Ak: {\n type: String,\n default: ''\n },\n Sk: {\n type: String,\n default: ''\n },\n imAccount: {\n type: String,\n default: ''\n },\n companyNo: {\n type: String,\n default: ''\n },\n isIntelShow: {\n default: false,\n type: Boolean\n },\n chatImToken: {\n default: '',\n type: String\n }\n },\n data() {\n // 首次渲染前检测窗口宽度,避免 H5 端先显示 PC 布局再切换导致闪烁\n const _isMobile = typeof window !== 'undefined' && window.innerWidth <= 768;\n return {\n agentList: [],\n currentAgent: '',\n currentAgentDesc: '',\n sessionsLoaded: false,\n sessionList: [],\n activeSessionId: '',\n loadingMore: false,\n showAgentSelect: !_isMobile,\n isMobile: _isMobile,\n showSidebar: false,\n showH5List: _isMobile,\n agentInfo: {},\n _swipeStartX: 0,\n _swipeStartY: 0,\n _swipeHandled: false\n };\n },\n created() {\n if (this.Ak || this.Sk) {\n (0, _apichat.setApiAuth)(this.Ak, this.Sk, this.imAccount, this.companyNo, this.chatImToken);\n }\n this.loadAgents();\n this.loadSessions();\n },\n mounted() {\n this.updateViewportState();\n window.addEventListener('resize', this.updateViewportState, {\n passive: true\n });\n // Android WebView 兼容:在 document 级别监听 touchmove/touchend\n // 避免可滚动子元素消费事件后不冒泡到父级\n document.addEventListener('touchmove', this._onSwipeMove, {\n passive: true\n });\n document.addEventListener('touchend', this._onSwipeEnd, {\n passive: true\n });\n },\n watch: {},\n methods: {\n // ── H5 侧滑手势 ──\n onSwipeTouchStart(e) {\n if (!this.isMobile) return;\n this._swipeStartX = e.touches[0].clientX;\n this._swipeStartY = e.touches[0].clientY;\n this._swipeHandled = false;\n },\n // 在 touchmove 中实时检测(绕过 Android 可滚动区域冒泡问题)\n _onSwipeMove(e) {\n if (!this.isMobile || this._swipeHandled) return;\n const moveX = e.touches[0].clientX;\n const moveY = e.touches[0].clientY;\n const diffX = moveX - this._swipeStartX;\n const diffY = moveY - this._swipeStartY;\n if (this._swipeStartX > 30) return;\n if (diffX < 60) return;\n if (Math.abs(diffX) < Math.abs(diffY) * 2) return;\n this._swipeHandled = true;\n this._triggerSwipeAction();\n },\n // touchend 检测(兜底,兼容不支持 touchmove 的场景)\n _onSwipeEnd(e) {\n if (!this.isMobile || this._swipeHandled) return;\n const endX = e.changedTouches[0].clientX;\n const endY = e.changedTouches[0].clientY;\n const diffX = endX - this._swipeStartX;\n const diffY = endY - this._swipeStartY;\n\n // 从左侧边缘开始滑动(30px 内),向右滑动超过 60px,且水平距离明显大于垂直距离\n if (this._swipeStartX > 30) return;\n if (diffX < 60) return;\n if (Math.abs(diffX) < Math.abs(diffY) * 2) return;\n this._swipeHandled = true;\n this._triggerSwipeAction();\n },\n _triggerSwipeAction() {\n if (this.showH5List) {\n // 列表页 → 原生返回\n this.handleNativeBack();\n } else if (!this.showAgentSelect) {\n // 详情页/欢迎页 → 返回列表\n this.goBackToList();\n }\n },\n handleNewSessionInternal() {\n if (!this.currentAgent) return;\n if (this.activeSessionId) this.closeOldSession();\n (0, _apichat.startSession)(this.currentAgent).then(res => {\n this.activeSessionId = res.sessionId || '';\n this.loadSessions();\n const agent = this.agentList.find(a => a.agentCode === this.currentAgent);\n if (agent) this.addWelcomeMessage(agent);\n }).catch(() => {});\n },\n updateViewportState() {\n if (typeof window === 'undefined') return;\n const nextIsMobile = window.innerWidth <= 768;\n const wasMobile = this.isMobile;\n this.isMobile = nextIsMobile;\n if (!nextIsMobile) {\n this.showSidebar = false;\n this.showH5List = false;\n } else if (!wasMobile && nextIsMobile) {\n if (this.sessionList.length > 0 && !this.activeSessionId) {\n this.showH5List = true;\n this.showAgentSelect = false;\n }\n }\n },\n toggleSidebar() {\n if (!this.isMobile) return;\n this.showSidebar = !this.showSidebar;\n },\n closeSidebar() {\n this.showSidebar = false;\n },\n handleNativeBack() {\n if (this.$hybrid && typeof this.$hybrid.closePage === 'function') {\n this.$hybrid.closePage();\n } else if (window.history.length > 1) {\n window.history.back();\n }\n },\n handleSidebarBack() {\n this.handleNativeBack();\n },\n agentjumpclick() {\n const cd = this.$refs.chatDetail;\n if (cd && cd.sending) {\n this.$message.warning('AI正在生成内容,暂时请不要切换对话');\n return;\n }\n this.currentAgent = '';\n this.currentAgentDesc = '';\n this.activeSessionId = '';\n this.showAgentSelect = true;\n this.showH5List = false;\n this.closeSidebar();\n },\n goBackToList() {\n const cd = this.$refs.chatDetail;\n if (cd && cd.sending) {\n this.$message.warning('AI正在生成内容,暂时请不要切换对话');\n return;\n }\n if (cd) {\n if (cd.eventSource) {\n cd.eventSource.close();\n cd.eventSource = null;\n }\n cd.sending = false;\n cd.clearWaitTimer();\n cd.messages = [];\n cd.contentCache = {};\n }\n this.activeSessionId = '';\n this.currentAgent = '';\n this.currentAgentDesc = '';\n this.agentInfo = {};\n this.showH5List = true;\n this.showAgentSelect = false;\n this.closeSidebar();\n },\n loadAgents() {\n (0, _apichat.getChatAgents)().then(list => {\n this.agentList = list || [];\n }).catch(() => {});\n },\n loadSessions() {\n (0, _apichat.getSessionList)().then(list => {\n if (!this.activeSessionId) {\n this.sessionList = list || [];\n if (this.sessionList.length > 0) {\n if (this.isMobile) {\n this.showAgentSelect = false;\n this.showH5List = true;\n this.showSidebar = false;\n } else {\n this.switchSession(this.sessionList[0]);\n }\n }\n if (this.sessionList.length === 0) {\n this.showAgentSelect = true;\n this.showH5List = false;\n }\n } else {\n this.sessionList = list || [];\n let _item = list.find(res => res.sessionId == this.activeSessionId);\n try {\n if (_item && _item.suggestedQuestions) {\n _item.suggestedQuestions = JSON.parse(_item.suggestedQuestions);\n }\n _item && (this.agentInfo = _item);\n } catch (err) {\n this.agentInfo.questionArr = [];\n console.warn('快捷提问解析失败', err);\n }\n }\n }).catch(() => {});\n },\n startChatWithAgent(agent) {\n console.log('选择了助手', agent.agentCode, this.currentAgent);\n if (agent.agentCode == this.currentAgent) {\n return;\n }\n this.currentAgent = agent.agentCode;\n this.currentAgentDesc = agent.description || '';\n this.agentInfo = {};\n this.showAgentSelect = false;\n this.closeSidebar();\n if (this.isMobile) {\n this.showH5List = false;\n }\n const existing = this.sessionList.find(s => s.agentCode === agent.agentCode);\n if (existing) {\n this.switchSession(existing);\n } else {\n this.handleNewSession();\n }\n },\n handleNewSession() {\n if (!this.currentAgent) return;\n if (this.activeSessionId) this.closeOldSession();\n (0, _apichat.startSession)(this.currentAgent).then(res => {\n this.activeSessionId = res.sessionId || '';\n this.loadSessions();\n const agent = this.agentList.find(a => a.agentCode === this.currentAgent);\n if (agent) this.addWelcomeMessage(agent);\n }).catch(() => {});\n },\n addWelcomeMessage(agent) {\n const cd = this.$refs.chatDetail;\n if (cd) {\n const _agent = this.agentList.find(x => x.agentCode === this.currentAgent);\n cd.greeting = _agent ? _agent.greeting || '很高兴为您服务,请问有什么可以帮到您?' : '';\n }\n },\n async switchSession(s) {\n let cd = this.$refs.chatDetail;\n if (cd && cd.sending) {\n this.$message.warning('AI正在生成内容,暂时请不要切换对话');\n return;\n }\n this.showAgentSelect = false;\n this.closeSidebar();\n if (this.isMobile) {\n this.showH5List = false;\n }\n if (this.activeSessionId === s.sessionId) return;\n\n // 移动端刚切换 showH5List=false,ChatDetail 尚未渲染完成,需要等待 nextTick\n if (!cd) {\n await this.$nextTick();\n cd = this.$refs.chatDetail;\n }\n if (cd) {\n cd.contentCache = {};\n cd.messages = [];\n cd.msgPage = 1;\n cd.msgTotal = 0;\n cd.loadingSessionMsg = true;\n }\n this.activeSessionId = s.sessionId;\n this.currentAgent = s.agentCode;\n this.agentInfo = s;\n try {\n if (s.suggestedQuestions) {\n this.agentInfo.suggestedQuestions = JSON.parse(s.suggestedQuestions);\n } else {\n this.agentInfo.suggestedQuestions = [];\n }\n } catch (err) {\n this.agentInfo.questionArr = [];\n console.warn('快捷提问解析失败', err);\n }\n const agent = this.agentList.find(a => a.agentCode === s.agentCode);\n this.currentAgentDesc = agent ? agent.description || '' : '';\n (0, _apichat.syncToken)((0, _cookie.getToken)(), s.sessionId);\n try {\n const res = await (0, _apichat.getSessionMessages)(s.sessionId, 1, 10);\n const list = Array.isArray(res) ? res : res.list || [];\n if (cd) {\n cd.msgTotal = res.total || list.length;\n cd.msgPage = 1;\n const asAsc = (list || []).slice().reverse();\n cd.messages = asAsc.map(m => ({\n role: m.role,\n content: m.content || '',\n thinking: m.thinking || '',\n toolCalls: [],\n agentName: m.role === 'assistant' ? s.agentName || '' : '',\n createTime: m.createTime || null,\n _key: m.createTime ? 'msg_' + m.createTime : 'msg_' + Date.now() + '_' + Math.random()\n }));\n if (cd.messages.length === 0 && agent) {\n const _agent = this.agentList.find(x => x.agentCode === this.currentAgent);\n cd.greeting = _agent ? _agent.greeting || '很高兴为您服务,请问有什么可以帮到您?' : '';\n }\n cd.loadingSessionMsg = false;\n await this.$nextTick();\n this.$nextTick(() => {\n cd.scrollToBottomOnce();\n cd.checkScrollBottom();\n });\n }\n } catch (e) {\n if (cd) {\n cd.messages = [];\n cd.loadingSessionMsg = false;\n }\n }\n },\n handleDeleteSession(s) {\n this.$confirm(`确认删除「${s.agentName || s.agentCode}」的会话?`, '提示', {\n type: 'warning'\n }).then(() => {\n (0, _apichat.deleteSession)(s.sessionId).then(() => {\n if (this.activeSessionId === s.sessionId) {\n this.activeSessionId = '';\n this.currentAgent = '';\n this.currentAgentDesc = '';\n const cd = this.$refs.chatDetail;\n if (cd) {\n cd.messages = [];\n cd.contentCache = {};\n }\n if (this.isMobile) {\n this.showH5List = false;\n this.showAgentSelect = true;\n } else {\n this.showAgentSelect = true;\n }\n }\n this.loadSessions();\n });\n }).catch(() => {});\n },\n closeOldSession() {}\n },\n beforeDestroy() {\n window.removeEventListener('resize', this.updateViewportState);\n document.removeEventListener('touchmove', this._onSwipeMove);\n document.removeEventListener('touchend', this._onSwipeEnd);\n }\n};\n\n//# sourceURL=webpack://ZjPluginIntelligent/./src/lib/components/chatMain/index.vue?./node_modules/_cache-loader@4.1.0@cache-loader/dist/cjs.js??ref--13-0!./node_modules/_babel-loader@8.4.1@babel-loader/lib!./node_modules/_cache-loader@4.1.0@cache-loader/dist/cjs.js??ref--1-0!./node_modules/_vue-loader@15.11.1@vue-loader/lib??vue-loader-options");
|
|
987
|
+
eval("\n\nvar _interopRequireDefault = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.28.4@@babel/runtime/helpers/interopRequireDefault.js */ \"./node_modules/_@babel_runtime@7.28.4@@babel/runtime/helpers/interopRequireDefault.js\").default;\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n__webpack_require__(/*! core-js/modules/es.iterator.constructor.js */ \"./node_modules/_core-js@3.45.1@core-js/modules/es.iterator.constructor.js\");\n__webpack_require__(/*! core-js/modules/es.iterator.find.js */ \"./node_modules/_core-js@3.45.1@core-js/modules/es.iterator.find.js\");\n__webpack_require__(/*! core-js/modules/es.iterator.map.js */ \"./node_modules/_core-js@3.45.1@core-js/modules/es.iterator.map.js\");\nvar _apichat = __webpack_require__(/*! @lib/api/apichat */ \"./src/lib/api/apichat.js\");\nvar _cookie = __webpack_require__(/*! @lib/utils/cookie.js */ \"./src/lib/utils/cookie.js\");\nvar _ChatSidebar = _interopRequireDefault(__webpack_require__(/*! ./ChatSidebar.vue */ \"./src/lib/components/chatMain/ChatSidebar.vue\"));\nvar _AgentSelector = _interopRequireDefault(__webpack_require__(/*! ./AgentSelector.vue */ \"./src/lib/components/chatMain/AgentSelector.vue\"));\nvar _ChatDetail = _interopRequireDefault(__webpack_require__(/*! ./ChatDetail.vue */ \"./src/lib/components/chatMain/ChatDetail.vue\"));\nvar _default = exports.default = {\n name: 'ChatMain',\n components: {\n ChatSidebar: _ChatSidebar.default,\n AgentSelector: _AgentSelector.default,\n ChatDetail: _ChatDetail.default\n },\n props: {\n Ak: {\n type: String,\n default: ''\n },\n Sk: {\n type: String,\n default: ''\n },\n imAccount: {\n type: String,\n default: ''\n },\n companyNo: {\n type: String,\n default: ''\n },\n isIntelShow: {\n default: false,\n type: Boolean\n },\n chatImToken: {\n default: '',\n type: String\n }\n },\n data() {\n // 首次渲染前检测窗口宽度,避免 H5 端先显示 PC 布局再切换导致闪烁\n const _isMobile = typeof window !== 'undefined' && window.innerWidth <= 768;\n return {\n agentList: [],\n currentAgent: '',\n currentAgentDesc: '',\n sessionsLoaded: false,\n sessionList: [],\n activeSessionId: '',\n loadingMore: false,\n showAgentSelect: !_isMobile,\n isMobile: _isMobile,\n showSidebar: false,\n showH5List: _isMobile,\n agentInfo: {},\n _swipeStartX: 0,\n _swipeStartY: 0,\n _swipeHandled: false\n };\n },\n created() {\n if (this.Ak || this.Sk) {\n (0, _apichat.setApiAuth)(this.Ak, this.Sk, this.imAccount, this.companyNo, this.chatImToken);\n }\n this.loadAgents();\n this.loadSessions();\n },\n mounted() {\n this.updateViewportState();\n window.addEventListener('resize', this.updateViewportState, {\n passive: true\n });\n // Android WebView 兼容:在 document 级别监听 touchmove/touchend\n // 避免可滚动子元素消费事件后不冒泡到父级\n document.addEventListener('touchmove', this._onSwipeMove, {\n passive: true\n });\n document.addEventListener('touchend', this._onSwipeEnd, {\n passive: true\n });\n },\n watch: {},\n methods: {\n // ── H5 侧滑手势 ──\n onSwipeTouchStart(e) {\n if (!this.isMobile) return;\n this._swipeStartX = e.touches[0].clientX;\n this._swipeStartY = e.touches[0].clientY;\n this._swipeHandled = false;\n },\n // 在 touchmove 中实时检测\n // 注意:不限制触摸起点位置(移除边缘限制),以兼容 Android 系统手势导航在左边缘的拦截\n _onSwipeMove(e) {\n if (!this.isMobile || this._swipeHandled) return;\n const moveX = e.touches[0].clientX;\n const moveY = e.touches[0].clientY;\n const diffX = moveX - this._swipeStartX;\n const diffY = moveY - this._swipeStartY;\n\n // 向右滑动超过 60px,且水平距离明显大于垂直距离(排除上下滚动干扰)\n if (diffX < 60) return;\n if (Math.abs(diffX) < Math.abs(diffY) * 2) return;\n this._swipeHandled = true;\n this._triggerSwipeAction();\n },\n // touchend 检测(兜底,兼容不支持 touchmove 的场景)\n _onSwipeEnd(e) {\n if (!this.isMobile || this._swipeHandled) return;\n const endX = e.changedTouches[0].clientX;\n const endY = e.changedTouches[0].clientY;\n const diffX = endX - this._swipeStartX;\n const diffY = endY - this._swipeStartY;\n\n // 向右滑动超过 60px,且水平距离明显大于垂直距离\n if (diffX < 60) return;\n if (Math.abs(diffX) < Math.abs(diffY) * 2) return;\n this._swipeHandled = true;\n this._triggerSwipeAction();\n },\n _triggerSwipeAction() {\n if (this.showH5List) {\n // 列表页 → 原生返回\n this.handleNativeBack();\n } else if (!this.showAgentSelect) {\n // 详情页/欢迎页 → 返回列表\n this.goBackToList();\n }\n },\n handleNewSessionInternal() {\n if (!this.currentAgent) return;\n if (this.activeSessionId) this.closeOldSession();\n (0, _apichat.startSession)(this.currentAgent).then(res => {\n this.activeSessionId = res.sessionId || '';\n this.loadSessions();\n const agent = this.agentList.find(a => a.agentCode === this.currentAgent);\n if (agent) this.addWelcomeMessage(agent);\n }).catch(() => {});\n },\n updateViewportState() {\n if (typeof window === 'undefined') return;\n const nextIsMobile = window.innerWidth <= 768;\n const wasMobile = this.isMobile;\n this.isMobile = nextIsMobile;\n if (!nextIsMobile) {\n this.showSidebar = false;\n this.showH5List = false;\n } else if (!wasMobile && nextIsMobile) {\n if (this.sessionList.length > 0 && !this.activeSessionId) {\n this.showH5List = true;\n this.showAgentSelect = false;\n }\n }\n },\n toggleSidebar() {\n if (!this.isMobile) return;\n this.showSidebar = !this.showSidebar;\n },\n closeSidebar() {\n this.showSidebar = false;\n },\n handleNativeBack() {\n if (this.$hybrid && typeof this.$hybrid.closePage === 'function') {\n this.$hybrid.closePage();\n } else if (window.history.length > 1) {\n window.history.back();\n }\n },\n handleSidebarBack() {\n this.handleNativeBack();\n },\n agentjumpclick() {\n const cd = this.$refs.chatDetail;\n if (cd && cd.sending) {\n this.$message.warning('AI正在生成内容,暂时请不要切换对话');\n return;\n }\n this.currentAgent = '';\n this.currentAgentDesc = '';\n this.activeSessionId = '';\n this.showAgentSelect = true;\n this.showH5List = false;\n this.closeSidebar();\n },\n goBackToList() {\n const cd = this.$refs.chatDetail;\n if (cd && cd.sending) {\n this.$message.warning('AI正在生成内容,暂时请不要切换对话');\n return;\n }\n if (cd) {\n if (cd.eventSource) {\n cd.eventSource.close();\n cd.eventSource = null;\n }\n cd.sending = false;\n cd.clearWaitTimer();\n cd.messages = [];\n cd.contentCache = {};\n }\n this.activeSessionId = '';\n this.currentAgent = '';\n this.currentAgentDesc = '';\n this.agentInfo = {};\n this.showH5List = true;\n this.showAgentSelect = false;\n this.closeSidebar();\n },\n loadAgents() {\n (0, _apichat.getChatAgents)().then(list => {\n this.agentList = list || [];\n }).catch(() => {});\n },\n loadSessions() {\n (0, _apichat.getSessionList)().then(list => {\n if (!this.activeSessionId) {\n this.sessionList = list || [];\n if (this.sessionList.length > 0) {\n if (this.isMobile) {\n this.showAgentSelect = false;\n this.showH5List = true;\n this.showSidebar = false;\n } else {\n this.switchSession(this.sessionList[0]);\n }\n }\n if (this.sessionList.length === 0) {\n this.showAgentSelect = true;\n this.showH5List = false;\n }\n } else {\n this.sessionList = list || [];\n let _item = list.find(res => res.sessionId == this.activeSessionId);\n try {\n if (_item && _item.suggestedQuestions) {\n _item.suggestedQuestions = JSON.parse(_item.suggestedQuestions);\n }\n _item && (this.agentInfo = _item);\n } catch (err) {\n this.agentInfo.questionArr = [];\n console.warn('快捷提问解析失败', err);\n }\n }\n }).catch(() => {});\n },\n startChatWithAgent(agent) {\n console.log('选择了助手', agent.agentCode, this.currentAgent);\n if (agent.agentCode == this.currentAgent) {\n return;\n }\n this.currentAgent = agent.agentCode;\n this.currentAgentDesc = agent.description || '';\n this.agentInfo = {};\n this.showAgentSelect = false;\n this.closeSidebar();\n if (this.isMobile) {\n this.showH5List = false;\n }\n const existing = this.sessionList.find(s => s.agentCode === agent.agentCode);\n if (existing) {\n this.switchSession(existing);\n } else {\n this.handleNewSession();\n }\n },\n handleNewSession() {\n if (!this.currentAgent) return;\n if (this.activeSessionId) this.closeOldSession();\n (0, _apichat.startSession)(this.currentAgent).then(res => {\n this.activeSessionId = res.sessionId || '';\n this.loadSessions();\n const agent = this.agentList.find(a => a.agentCode === this.currentAgent);\n if (agent) this.addWelcomeMessage(agent);\n }).catch(() => {});\n },\n addWelcomeMessage(agent) {\n const cd = this.$refs.chatDetail;\n if (cd) {\n const _agent = this.agentList.find(x => x.agentCode === this.currentAgent);\n cd.greeting = _agent ? _agent.greeting || '很高兴为您服务,请问有什么可以帮到您?' : '';\n }\n },\n async switchSession(s) {\n let cd = this.$refs.chatDetail;\n if (cd && cd.sending) {\n this.$message.warning('AI正在生成内容,暂时请不要切换对话');\n return;\n }\n this.showAgentSelect = false;\n this.closeSidebar();\n if (this.isMobile) {\n this.showH5List = false;\n }\n if (this.activeSessionId === s.sessionId) return;\n\n // 移动端刚切换 showH5List=false,ChatDetail 尚未渲染完成,需要等待 nextTick\n if (!cd) {\n await this.$nextTick();\n cd = this.$refs.chatDetail;\n }\n if (cd) {\n cd.contentCache = {};\n cd.messages = [];\n cd.msgPage = 1;\n cd.msgTotal = 0;\n cd.loadingSessionMsg = true;\n }\n this.activeSessionId = s.sessionId;\n this.currentAgent = s.agentCode;\n this.agentInfo = s;\n try {\n if (s.suggestedQuestions) {\n this.agentInfo.suggestedQuestions = JSON.parse(s.suggestedQuestions);\n } else {\n this.agentInfo.suggestedQuestions = [];\n }\n } catch (err) {\n this.agentInfo.questionArr = [];\n console.warn('快捷提问解析失败', err);\n }\n const agent = this.agentList.find(a => a.agentCode === s.agentCode);\n this.currentAgentDesc = agent ? agent.description || '' : '';\n (0, _apichat.syncToken)((0, _cookie.getToken)(), s.sessionId);\n try {\n const res = await (0, _apichat.getSessionMessages)(s.sessionId, 1, 10);\n const list = Array.isArray(res) ? res : res.list || [];\n if (cd) {\n cd.msgTotal = res.total || list.length;\n cd.msgPage = 1;\n const asAsc = (list || []).slice().reverse();\n cd.messages = asAsc.map(m => ({\n role: m.role,\n content: m.content || '',\n thinking: m.thinking || '',\n toolCalls: [],\n agentName: m.role === 'assistant' ? s.agentName || '' : '',\n createTime: m.createTime || null,\n _key: m.createTime ? 'msg_' + m.createTime : 'msg_' + Date.now() + '_' + Math.random()\n }));\n if (cd.messages.length === 0 && agent) {\n const _agent = this.agentList.find(x => x.agentCode === this.currentAgent);\n cd.greeting = _agent ? _agent.greeting || '很高兴为您服务,请问有什么可以帮到您?' : '';\n }\n cd.loadingSessionMsg = false;\n await this.$nextTick();\n this.$nextTick(() => {\n cd.scrollToBottomOnce();\n cd.checkScrollBottom();\n });\n }\n } catch (e) {\n if (cd) {\n cd.messages = [];\n cd.loadingSessionMsg = false;\n }\n }\n },\n handleDeleteSession(s) {\n this.$confirm(`确认删除「${s.agentName || s.agentCode}」的会话?`, '提示', {\n type: 'warning'\n }).then(() => {\n (0, _apichat.deleteSession)(s.sessionId).then(() => {\n if (this.activeSessionId === s.sessionId) {\n this.activeSessionId = '';\n this.currentAgent = '';\n this.currentAgentDesc = '';\n const cd = this.$refs.chatDetail;\n if (cd) {\n cd.messages = [];\n cd.contentCache = {};\n }\n if (this.isMobile) {\n this.showH5List = false;\n this.showAgentSelect = true;\n } else {\n this.showAgentSelect = true;\n }\n }\n this.loadSessions();\n });\n }).catch(() => {});\n },\n closeOldSession() {}\n },\n beforeDestroy() {\n window.removeEventListener('resize', this.updateViewportState);\n document.removeEventListener('touchmove', this._onSwipeMove);\n document.removeEventListener('touchend', this._onSwipeEnd);\n }\n};\n\n//# sourceURL=webpack://ZjPluginIntelligent/./src/lib/components/chatMain/index.vue?./node_modules/_cache-loader@4.1.0@cache-loader/dist/cjs.js??ref--13-0!./node_modules/_babel-loader@8.4.1@babel-loader/lib!./node_modules/_cache-loader@4.1.0@cache-loader/dist/cjs.js??ref--1-0!./node_modules/_vue-loader@15.11.1@vue-loader/lib??vue-loader-options");
|
|
988
988
|
|
|
989
989
|
/***/ }),
|
|
990
990
|
|
|
@@ -12617,7 +12617,7 @@ eval("module.exports = function(originalModule) {\n\tif (!originalModule.webpack
|
|
|
12617
12617
|
/*! exports provided: name, version, main, private, scripts, dependencies, devDependencies, browserslist, directories, keywords, license, default */
|
|
12618
12618
|
/***/ (function(module) {
|
|
12619
12619
|
|
|
12620
|
-
eval("module.exports = JSON.parse(\"{\\\"name\\\":\\\"zj-plugin-intelligent\\\",\\\"version\\\":\\\"1.2.5-beta.
|
|
12620
|
+
eval("module.exports = JSON.parse(\"{\\\"name\\\":\\\"zj-plugin-intelligent\\\",\\\"version\\\":\\\"1.2.5-beta.13\\\",\\\"main\\\":\\\"lib/ZjPluginIntelligent.umd.min.js\\\",\\\"private\\\":false,\\\"scripts\\\":{\\\"serve\\\":\\\"vue-cli-service serve\\\",\\\"build\\\":\\\"vue-cli-service build\\\",\\\"lib\\\":\\\"vue-cli-service build --target lib --name ZjPluginIntelligent --dest lib src/lib/index.js\\\",\\\"lib:test\\\":\\\"vue-cli-service build --mode test --target lib --name ZjPluginIntelligent --dest lib src/lib/index.js\\\"},\\\"dependencies\\\":{\\\"html2canvas\\\":\\\"^1.4.1\\\",\\\"markdown-it\\\":\\\"^14.1.0\\\"},\\\"devDependencies\\\":{\\\"@babel/preset-env\\\":\\\"^7.14.9\\\",\\\"@vue/cli-plugin-babel\\\":\\\"~4.5.0\\\",\\\"@vue/cli-plugin-eslint\\\":\\\"^4.5.13\\\",\\\"@vue/cli-plugin-vuex\\\":\\\"~4.5.0\\\",\\\"@vue/cli-service\\\":\\\"~4.5.0\\\",\\\"axios\\\":\\\"^0.27.2\\\",\\\"babel-eslint\\\":\\\"^10.1.0\\\",\\\"babel-plugin-component\\\":\\\"^1.1.1\\\",\\\"compression-webpack-plugin\\\":\\\"^6.0.3\\\",\\\"core-js\\\":\\\"^3.6.5\\\",\\\"element-ui\\\":\\\"^2.15.4\\\",\\\"eslint\\\":\\\"^7.30.0\\\",\\\"eslint-plugin-vue\\\":\\\"^7.13.0\\\",\\\"js-cookie\\\":\\\"^2.2.1\\\",\\\"node-sass\\\":\\\"^4.12.0\\\",\\\"obs-upload\\\":\\\"^1.0.4-alpha.0\\\",\\\"reconnecting-websocket\\\":\\\"^4.4.0\\\",\\\"sass-loader\\\":\\\"^8.0.2\\\",\\\"snowflake-id\\\":\\\"^1.1.0\\\",\\\"vue\\\":\\\"^2.6.11\\\",\\\"vue-template-compiler\\\":\\\"^2.6.11\\\",\\\"vuex\\\":\\\"^3.4.0\\\",\\\"pako\\\":\\\"^2.1.0\\\",\\\"webpack-bundle-analyzer\\\":\\\"^4.4.2\\\"},\\\"browserslist\\\":[\\\"> 1%\\\",\\\"last 2 versions\\\",\\\"not dead\\\"],\\\"directories\\\":{\\\"lib\\\":\\\"lib\\\"},\\\"keywords\\\":[],\\\"license\\\":\\\"ISC\\\"}\");\n\n//# sourceURL=webpack://ZjPluginIntelligent/./package.json?");
|
|
12621
12621
|
|
|
12622
12622
|
/***/ }),
|
|
12623
12623
|
|
|
@@ -984,7 +984,7 @@ eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n
|
|
|
984
984
|
/***/ (function(module, exports, __webpack_require__) {
|
|
985
985
|
|
|
986
986
|
"use strict";
|
|
987
|
-
eval("\n\nvar _interopRequireDefault = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.28.4@@babel/runtime/helpers/interopRequireDefault.js */ \"./node_modules/_@babel_runtime@7.28.4@@babel/runtime/helpers/interopRequireDefault.js\").default;\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n__webpack_require__(/*! core-js/modules/es.iterator.constructor.js */ \"./node_modules/_core-js@3.45.1@core-js/modules/es.iterator.constructor.js\");\n__webpack_require__(/*! core-js/modules/es.iterator.find.js */ \"./node_modules/_core-js@3.45.1@core-js/modules/es.iterator.find.js\");\n__webpack_require__(/*! core-js/modules/es.iterator.map.js */ \"./node_modules/_core-js@3.45.1@core-js/modules/es.iterator.map.js\");\nvar _apichat = __webpack_require__(/*! @lib/api/apichat */ \"./src/lib/api/apichat.js\");\nvar _cookie = __webpack_require__(/*! @lib/utils/cookie.js */ \"./src/lib/utils/cookie.js\");\nvar _ChatSidebar = _interopRequireDefault(__webpack_require__(/*! ./ChatSidebar.vue */ \"./src/lib/components/chatMain/ChatSidebar.vue\"));\nvar _AgentSelector = _interopRequireDefault(__webpack_require__(/*! ./AgentSelector.vue */ \"./src/lib/components/chatMain/AgentSelector.vue\"));\nvar _ChatDetail = _interopRequireDefault(__webpack_require__(/*! ./ChatDetail.vue */ \"./src/lib/components/chatMain/ChatDetail.vue\"));\nvar _default = exports.default = {\n name: 'ChatMain',\n components: {\n ChatSidebar: _ChatSidebar.default,\n AgentSelector: _AgentSelector.default,\n ChatDetail: _ChatDetail.default\n },\n props: {\n Ak: {\n type: String,\n default: ''\n },\n Sk: {\n type: String,\n default: ''\n },\n imAccount: {\n type: String,\n default: ''\n },\n companyNo: {\n type: String,\n default: ''\n },\n isIntelShow: {\n default: false,\n type: Boolean\n },\n chatImToken: {\n default: '',\n type: String\n }\n },\n data() {\n // 首次渲染前检测窗口宽度,避免 H5 端先显示 PC 布局再切换导致闪烁\n const _isMobile = typeof window !== 'undefined' && window.innerWidth <= 768;\n return {\n agentList: [],\n currentAgent: '',\n currentAgentDesc: '',\n sessionsLoaded: false,\n sessionList: [],\n activeSessionId: '',\n loadingMore: false,\n showAgentSelect: !_isMobile,\n isMobile: _isMobile,\n showSidebar: false,\n showH5List: _isMobile,\n agentInfo: {},\n _swipeStartX: 0,\n _swipeStartY: 0,\n _swipeHandled: false\n };\n },\n created() {\n if (this.Ak || this.Sk) {\n (0, _apichat.setApiAuth)(this.Ak, this.Sk, this.imAccount, this.companyNo, this.chatImToken);\n }\n this.loadAgents();\n this.loadSessions();\n },\n mounted() {\n this.updateViewportState();\n window.addEventListener('resize', this.updateViewportState, {\n passive: true\n });\n // Android WebView 兼容:在 document 级别监听 touchmove/touchend\n // 避免可滚动子元素消费事件后不冒泡到父级\n document.addEventListener('touchmove', this._onSwipeMove, {\n passive: true\n });\n document.addEventListener('touchend', this._onSwipeEnd, {\n passive: true\n });\n },\n watch: {},\n methods: {\n // ── H5 侧滑手势 ──\n onSwipeTouchStart(e) {\n if (!this.isMobile) return;\n this._swipeStartX = e.touches[0].clientX;\n this._swipeStartY = e.touches[0].clientY;\n this._swipeHandled = false;\n },\n // 在 touchmove 中实时检测(绕过 Android 可滚动区域冒泡问题)\n _onSwipeMove(e) {\n if (!this.isMobile || this._swipeHandled) return;\n const moveX = e.touches[0].clientX;\n const moveY = e.touches[0].clientY;\n const diffX = moveX - this._swipeStartX;\n const diffY = moveY - this._swipeStartY;\n if (this._swipeStartX > 30) return;\n if (diffX < 60) return;\n if (Math.abs(diffX) < Math.abs(diffY) * 2) return;\n this._swipeHandled = true;\n this._triggerSwipeAction();\n },\n // touchend 检测(兜底,兼容不支持 touchmove 的场景)\n _onSwipeEnd(e) {\n if (!this.isMobile || this._swipeHandled) return;\n const endX = e.changedTouches[0].clientX;\n const endY = e.changedTouches[0].clientY;\n const diffX = endX - this._swipeStartX;\n const diffY = endY - this._swipeStartY;\n\n // 从左侧边缘开始滑动(30px 内),向右滑动超过 60px,且水平距离明显大于垂直距离\n if (this._swipeStartX > 30) return;\n if (diffX < 60) return;\n if (Math.abs(diffX) < Math.abs(diffY) * 2) return;\n this._swipeHandled = true;\n this._triggerSwipeAction();\n },\n _triggerSwipeAction() {\n if (this.showH5List) {\n // 列表页 → 原生返回\n this.handleNativeBack();\n } else if (!this.showAgentSelect) {\n // 详情页/欢迎页 → 返回列表\n this.goBackToList();\n }\n },\n handleNewSessionInternal() {\n if (!this.currentAgent) return;\n if (this.activeSessionId) this.closeOldSession();\n (0, _apichat.startSession)(this.currentAgent).then(res => {\n this.activeSessionId = res.sessionId || '';\n this.loadSessions();\n const agent = this.agentList.find(a => a.agentCode === this.currentAgent);\n if (agent) this.addWelcomeMessage(agent);\n }).catch(() => {});\n },\n updateViewportState() {\n if (typeof window === 'undefined') return;\n const nextIsMobile = window.innerWidth <= 768;\n const wasMobile = this.isMobile;\n this.isMobile = nextIsMobile;\n if (!nextIsMobile) {\n this.showSidebar = false;\n this.showH5List = false;\n } else if (!wasMobile && nextIsMobile) {\n if (this.sessionList.length > 0 && !this.activeSessionId) {\n this.showH5List = true;\n this.showAgentSelect = false;\n }\n }\n },\n toggleSidebar() {\n if (!this.isMobile) return;\n this.showSidebar = !this.showSidebar;\n },\n closeSidebar() {\n this.showSidebar = false;\n },\n handleNativeBack() {\n if (this.$hybrid && typeof this.$hybrid.closePage === 'function') {\n this.$hybrid.closePage();\n } else if (window.history.length > 1) {\n window.history.back();\n }\n },\n handleSidebarBack() {\n this.handleNativeBack();\n },\n agentjumpclick() {\n const cd = this.$refs.chatDetail;\n if (cd && cd.sending) {\n this.$message.warning('AI正在生成内容,暂时请不要切换对话');\n return;\n }\n this.currentAgent = '';\n this.currentAgentDesc = '';\n this.activeSessionId = '';\n this.showAgentSelect = true;\n this.showH5List = false;\n this.closeSidebar();\n },\n goBackToList() {\n const cd = this.$refs.chatDetail;\n if (cd && cd.sending) {\n this.$message.warning('AI正在生成内容,暂时请不要切换对话');\n return;\n }\n if (cd) {\n if (cd.eventSource) {\n cd.eventSource.close();\n cd.eventSource = null;\n }\n cd.sending = false;\n cd.clearWaitTimer();\n cd.messages = [];\n cd.contentCache = {};\n }\n this.activeSessionId = '';\n this.currentAgent = '';\n this.currentAgentDesc = '';\n this.agentInfo = {};\n this.showH5List = true;\n this.showAgentSelect = false;\n this.closeSidebar();\n },\n loadAgents() {\n (0, _apichat.getChatAgents)().then(list => {\n this.agentList = list || [];\n }).catch(() => {});\n },\n loadSessions() {\n (0, _apichat.getSessionList)().then(list => {\n if (!this.activeSessionId) {\n this.sessionList = list || [];\n if (this.sessionList.length > 0) {\n if (this.isMobile) {\n this.showAgentSelect = false;\n this.showH5List = true;\n this.showSidebar = false;\n } else {\n this.switchSession(this.sessionList[0]);\n }\n }\n if (this.sessionList.length === 0) {\n this.showAgentSelect = true;\n this.showH5List = false;\n }\n } else {\n this.sessionList = list || [];\n let _item = list.find(res => res.sessionId == this.activeSessionId);\n try {\n if (_item && _item.suggestedQuestions) {\n _item.suggestedQuestions = JSON.parse(_item.suggestedQuestions);\n }\n _item && (this.agentInfo = _item);\n } catch (err) {\n this.agentInfo.questionArr = [];\n console.warn('快捷提问解析失败', err);\n }\n }\n }).catch(() => {});\n },\n startChatWithAgent(agent) {\n console.log('选择了助手', agent.agentCode, this.currentAgent);\n if (agent.agentCode == this.currentAgent) {\n return;\n }\n this.currentAgent = agent.agentCode;\n this.currentAgentDesc = agent.description || '';\n this.agentInfo = {};\n this.showAgentSelect = false;\n this.closeSidebar();\n if (this.isMobile) {\n this.showH5List = false;\n }\n const existing = this.sessionList.find(s => s.agentCode === agent.agentCode);\n if (existing) {\n this.switchSession(existing);\n } else {\n this.handleNewSession();\n }\n },\n handleNewSession() {\n if (!this.currentAgent) return;\n if (this.activeSessionId) this.closeOldSession();\n (0, _apichat.startSession)(this.currentAgent).then(res => {\n this.activeSessionId = res.sessionId || '';\n this.loadSessions();\n const agent = this.agentList.find(a => a.agentCode === this.currentAgent);\n if (agent) this.addWelcomeMessage(agent);\n }).catch(() => {});\n },\n addWelcomeMessage(agent) {\n const cd = this.$refs.chatDetail;\n if (cd) {\n const _agent = this.agentList.find(x => x.agentCode === this.currentAgent);\n cd.greeting = _agent ? _agent.greeting || '很高兴为您服务,请问有什么可以帮到您?' : '';\n }\n },\n async switchSession(s) {\n let cd = this.$refs.chatDetail;\n if (cd && cd.sending) {\n this.$message.warning('AI正在生成内容,暂时请不要切换对话');\n return;\n }\n this.showAgentSelect = false;\n this.closeSidebar();\n if (this.isMobile) {\n this.showH5List = false;\n }\n if (this.activeSessionId === s.sessionId) return;\n\n // 移动端刚切换 showH5List=false,ChatDetail 尚未渲染完成,需要等待 nextTick\n if (!cd) {\n await this.$nextTick();\n cd = this.$refs.chatDetail;\n }\n if (cd) {\n cd.contentCache = {};\n cd.messages = [];\n cd.msgPage = 1;\n cd.msgTotal = 0;\n cd.loadingSessionMsg = true;\n }\n this.activeSessionId = s.sessionId;\n this.currentAgent = s.agentCode;\n this.agentInfo = s;\n try {\n if (s.suggestedQuestions) {\n this.agentInfo.suggestedQuestions = JSON.parse(s.suggestedQuestions);\n } else {\n this.agentInfo.suggestedQuestions = [];\n }\n } catch (err) {\n this.agentInfo.questionArr = [];\n console.warn('快捷提问解析失败', err);\n }\n const agent = this.agentList.find(a => a.agentCode === s.agentCode);\n this.currentAgentDesc = agent ? agent.description || '' : '';\n (0, _apichat.syncToken)((0, _cookie.getToken)(), s.sessionId);\n try {\n const res = await (0, _apichat.getSessionMessages)(s.sessionId, 1, 10);\n const list = Array.isArray(res) ? res : res.list || [];\n if (cd) {\n cd.msgTotal = res.total || list.length;\n cd.msgPage = 1;\n const asAsc = (list || []).slice().reverse();\n cd.messages = asAsc.map(m => ({\n role: m.role,\n content: m.content || '',\n thinking: m.thinking || '',\n toolCalls: [],\n agentName: m.role === 'assistant' ? s.agentName || '' : '',\n createTime: m.createTime || null,\n _key: m.createTime ? 'msg_' + m.createTime : 'msg_' + Date.now() + '_' + Math.random()\n }));\n if (cd.messages.length === 0 && agent) {\n const _agent = this.agentList.find(x => x.agentCode === this.currentAgent);\n cd.greeting = _agent ? _agent.greeting || '很高兴为您服务,请问有什么可以帮到您?' : '';\n }\n cd.loadingSessionMsg = false;\n await this.$nextTick();\n this.$nextTick(() => {\n cd.scrollToBottomOnce();\n cd.checkScrollBottom();\n });\n }\n } catch (e) {\n if (cd) {\n cd.messages = [];\n cd.loadingSessionMsg = false;\n }\n }\n },\n handleDeleteSession(s) {\n this.$confirm(`确认删除「${s.agentName || s.agentCode}」的会话?`, '提示', {\n type: 'warning'\n }).then(() => {\n (0, _apichat.deleteSession)(s.sessionId).then(() => {\n if (this.activeSessionId === s.sessionId) {\n this.activeSessionId = '';\n this.currentAgent = '';\n this.currentAgentDesc = '';\n const cd = this.$refs.chatDetail;\n if (cd) {\n cd.messages = [];\n cd.contentCache = {};\n }\n if (this.isMobile) {\n this.showH5List = false;\n this.showAgentSelect = true;\n } else {\n this.showAgentSelect = true;\n }\n }\n this.loadSessions();\n });\n }).catch(() => {});\n },\n closeOldSession() {}\n },\n beforeDestroy() {\n window.removeEventListener('resize', this.updateViewportState);\n document.removeEventListener('touchmove', this._onSwipeMove);\n document.removeEventListener('touchend', this._onSwipeEnd);\n }\n};\n\n//# sourceURL=webpack://ZjPluginIntelligent/./src/lib/components/chatMain/index.vue?./node_modules/_cache-loader@4.1.0@cache-loader/dist/cjs.js??ref--13-0!./node_modules/_babel-loader@8.4.1@babel-loader/lib!./node_modules/_cache-loader@4.1.0@cache-loader/dist/cjs.js??ref--1-0!./node_modules/_vue-loader@15.11.1@vue-loader/lib??vue-loader-options");
|
|
987
|
+
eval("\n\nvar _interopRequireDefault = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.28.4@@babel/runtime/helpers/interopRequireDefault.js */ \"./node_modules/_@babel_runtime@7.28.4@@babel/runtime/helpers/interopRequireDefault.js\").default;\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n__webpack_require__(/*! core-js/modules/es.iterator.constructor.js */ \"./node_modules/_core-js@3.45.1@core-js/modules/es.iterator.constructor.js\");\n__webpack_require__(/*! core-js/modules/es.iterator.find.js */ \"./node_modules/_core-js@3.45.1@core-js/modules/es.iterator.find.js\");\n__webpack_require__(/*! core-js/modules/es.iterator.map.js */ \"./node_modules/_core-js@3.45.1@core-js/modules/es.iterator.map.js\");\nvar _apichat = __webpack_require__(/*! @lib/api/apichat */ \"./src/lib/api/apichat.js\");\nvar _cookie = __webpack_require__(/*! @lib/utils/cookie.js */ \"./src/lib/utils/cookie.js\");\nvar _ChatSidebar = _interopRequireDefault(__webpack_require__(/*! ./ChatSidebar.vue */ \"./src/lib/components/chatMain/ChatSidebar.vue\"));\nvar _AgentSelector = _interopRequireDefault(__webpack_require__(/*! ./AgentSelector.vue */ \"./src/lib/components/chatMain/AgentSelector.vue\"));\nvar _ChatDetail = _interopRequireDefault(__webpack_require__(/*! ./ChatDetail.vue */ \"./src/lib/components/chatMain/ChatDetail.vue\"));\nvar _default = exports.default = {\n name: 'ChatMain',\n components: {\n ChatSidebar: _ChatSidebar.default,\n AgentSelector: _AgentSelector.default,\n ChatDetail: _ChatDetail.default\n },\n props: {\n Ak: {\n type: String,\n default: ''\n },\n Sk: {\n type: String,\n default: ''\n },\n imAccount: {\n type: String,\n default: ''\n },\n companyNo: {\n type: String,\n default: ''\n },\n isIntelShow: {\n default: false,\n type: Boolean\n },\n chatImToken: {\n default: '',\n type: String\n }\n },\n data() {\n // 首次渲染前检测窗口宽度,避免 H5 端先显示 PC 布局再切换导致闪烁\n const _isMobile = typeof window !== 'undefined' && window.innerWidth <= 768;\n return {\n agentList: [],\n currentAgent: '',\n currentAgentDesc: '',\n sessionsLoaded: false,\n sessionList: [],\n activeSessionId: '',\n loadingMore: false,\n showAgentSelect: !_isMobile,\n isMobile: _isMobile,\n showSidebar: false,\n showH5List: _isMobile,\n agentInfo: {},\n _swipeStartX: 0,\n _swipeStartY: 0,\n _swipeHandled: false\n };\n },\n created() {\n if (this.Ak || this.Sk) {\n (0, _apichat.setApiAuth)(this.Ak, this.Sk, this.imAccount, this.companyNo, this.chatImToken);\n }\n this.loadAgents();\n this.loadSessions();\n },\n mounted() {\n this.updateViewportState();\n window.addEventListener('resize', this.updateViewportState, {\n passive: true\n });\n // Android WebView 兼容:在 document 级别监听 touchmove/touchend\n // 避免可滚动子元素消费事件后不冒泡到父级\n document.addEventListener('touchmove', this._onSwipeMove, {\n passive: true\n });\n document.addEventListener('touchend', this._onSwipeEnd, {\n passive: true\n });\n },\n watch: {},\n methods: {\n // ── H5 侧滑手势 ──\n onSwipeTouchStart(e) {\n if (!this.isMobile) return;\n this._swipeStartX = e.touches[0].clientX;\n this._swipeStartY = e.touches[0].clientY;\n this._swipeHandled = false;\n },\n // 在 touchmove 中实时检测\n // 注意:不限制触摸起点位置(移除边缘限制),以兼容 Android 系统手势导航在左边缘的拦截\n _onSwipeMove(e) {\n if (!this.isMobile || this._swipeHandled) return;\n const moveX = e.touches[0].clientX;\n const moveY = e.touches[0].clientY;\n const diffX = moveX - this._swipeStartX;\n const diffY = moveY - this._swipeStartY;\n\n // 向右滑动超过 60px,且水平距离明显大于垂直距离(排除上下滚动干扰)\n if (diffX < 60) return;\n if (Math.abs(diffX) < Math.abs(diffY) * 2) return;\n this._swipeHandled = true;\n this._triggerSwipeAction();\n },\n // touchend 检测(兜底,兼容不支持 touchmove 的场景)\n _onSwipeEnd(e) {\n if (!this.isMobile || this._swipeHandled) return;\n const endX = e.changedTouches[0].clientX;\n const endY = e.changedTouches[0].clientY;\n const diffX = endX - this._swipeStartX;\n const diffY = endY - this._swipeStartY;\n\n // 向右滑动超过 60px,且水平距离明显大于垂直距离\n if (diffX < 60) return;\n if (Math.abs(diffX) < Math.abs(diffY) * 2) return;\n this._swipeHandled = true;\n this._triggerSwipeAction();\n },\n _triggerSwipeAction() {\n if (this.showH5List) {\n // 列表页 → 原生返回\n this.handleNativeBack();\n } else if (!this.showAgentSelect) {\n // 详情页/欢迎页 → 返回列表\n this.goBackToList();\n }\n },\n handleNewSessionInternal() {\n if (!this.currentAgent) return;\n if (this.activeSessionId) this.closeOldSession();\n (0, _apichat.startSession)(this.currentAgent).then(res => {\n this.activeSessionId = res.sessionId || '';\n this.loadSessions();\n const agent = this.agentList.find(a => a.agentCode === this.currentAgent);\n if (agent) this.addWelcomeMessage(agent);\n }).catch(() => {});\n },\n updateViewportState() {\n if (typeof window === 'undefined') return;\n const nextIsMobile = window.innerWidth <= 768;\n const wasMobile = this.isMobile;\n this.isMobile = nextIsMobile;\n if (!nextIsMobile) {\n this.showSidebar = false;\n this.showH5List = false;\n } else if (!wasMobile && nextIsMobile) {\n if (this.sessionList.length > 0 && !this.activeSessionId) {\n this.showH5List = true;\n this.showAgentSelect = false;\n }\n }\n },\n toggleSidebar() {\n if (!this.isMobile) return;\n this.showSidebar = !this.showSidebar;\n },\n closeSidebar() {\n this.showSidebar = false;\n },\n handleNativeBack() {\n if (this.$hybrid && typeof this.$hybrid.closePage === 'function') {\n this.$hybrid.closePage();\n } else if (window.history.length > 1) {\n window.history.back();\n }\n },\n handleSidebarBack() {\n this.handleNativeBack();\n },\n agentjumpclick() {\n const cd = this.$refs.chatDetail;\n if (cd && cd.sending) {\n this.$message.warning('AI正在生成内容,暂时请不要切换对话');\n return;\n }\n this.currentAgent = '';\n this.currentAgentDesc = '';\n this.activeSessionId = '';\n this.showAgentSelect = true;\n this.showH5List = false;\n this.closeSidebar();\n },\n goBackToList() {\n const cd = this.$refs.chatDetail;\n if (cd && cd.sending) {\n this.$message.warning('AI正在生成内容,暂时请不要切换对话');\n return;\n }\n if (cd) {\n if (cd.eventSource) {\n cd.eventSource.close();\n cd.eventSource = null;\n }\n cd.sending = false;\n cd.clearWaitTimer();\n cd.messages = [];\n cd.contentCache = {};\n }\n this.activeSessionId = '';\n this.currentAgent = '';\n this.currentAgentDesc = '';\n this.agentInfo = {};\n this.showH5List = true;\n this.showAgentSelect = false;\n this.closeSidebar();\n },\n loadAgents() {\n (0, _apichat.getChatAgents)().then(list => {\n this.agentList = list || [];\n }).catch(() => {});\n },\n loadSessions() {\n (0, _apichat.getSessionList)().then(list => {\n if (!this.activeSessionId) {\n this.sessionList = list || [];\n if (this.sessionList.length > 0) {\n if (this.isMobile) {\n this.showAgentSelect = false;\n this.showH5List = true;\n this.showSidebar = false;\n } else {\n this.switchSession(this.sessionList[0]);\n }\n }\n if (this.sessionList.length === 0) {\n this.showAgentSelect = true;\n this.showH5List = false;\n }\n } else {\n this.sessionList = list || [];\n let _item = list.find(res => res.sessionId == this.activeSessionId);\n try {\n if (_item && _item.suggestedQuestions) {\n _item.suggestedQuestions = JSON.parse(_item.suggestedQuestions);\n }\n _item && (this.agentInfo = _item);\n } catch (err) {\n this.agentInfo.questionArr = [];\n console.warn('快捷提问解析失败', err);\n }\n }\n }).catch(() => {});\n },\n startChatWithAgent(agent) {\n console.log('选择了助手', agent.agentCode, this.currentAgent);\n if (agent.agentCode == this.currentAgent) {\n return;\n }\n this.currentAgent = agent.agentCode;\n this.currentAgentDesc = agent.description || '';\n this.agentInfo = {};\n this.showAgentSelect = false;\n this.closeSidebar();\n if (this.isMobile) {\n this.showH5List = false;\n }\n const existing = this.sessionList.find(s => s.agentCode === agent.agentCode);\n if (existing) {\n this.switchSession(existing);\n } else {\n this.handleNewSession();\n }\n },\n handleNewSession() {\n if (!this.currentAgent) return;\n if (this.activeSessionId) this.closeOldSession();\n (0, _apichat.startSession)(this.currentAgent).then(res => {\n this.activeSessionId = res.sessionId || '';\n this.loadSessions();\n const agent = this.agentList.find(a => a.agentCode === this.currentAgent);\n if (agent) this.addWelcomeMessage(agent);\n }).catch(() => {});\n },\n addWelcomeMessage(agent) {\n const cd = this.$refs.chatDetail;\n if (cd) {\n const _agent = this.agentList.find(x => x.agentCode === this.currentAgent);\n cd.greeting = _agent ? _agent.greeting || '很高兴为您服务,请问有什么可以帮到您?' : '';\n }\n },\n async switchSession(s) {\n let cd = this.$refs.chatDetail;\n if (cd && cd.sending) {\n this.$message.warning('AI正在生成内容,暂时请不要切换对话');\n return;\n }\n this.showAgentSelect = false;\n this.closeSidebar();\n if (this.isMobile) {\n this.showH5List = false;\n }\n if (this.activeSessionId === s.sessionId) return;\n\n // 移动端刚切换 showH5List=false,ChatDetail 尚未渲染完成,需要等待 nextTick\n if (!cd) {\n await this.$nextTick();\n cd = this.$refs.chatDetail;\n }\n if (cd) {\n cd.contentCache = {};\n cd.messages = [];\n cd.msgPage = 1;\n cd.msgTotal = 0;\n cd.loadingSessionMsg = true;\n }\n this.activeSessionId = s.sessionId;\n this.currentAgent = s.agentCode;\n this.agentInfo = s;\n try {\n if (s.suggestedQuestions) {\n this.agentInfo.suggestedQuestions = JSON.parse(s.suggestedQuestions);\n } else {\n this.agentInfo.suggestedQuestions = [];\n }\n } catch (err) {\n this.agentInfo.questionArr = [];\n console.warn('快捷提问解析失败', err);\n }\n const agent = this.agentList.find(a => a.agentCode === s.agentCode);\n this.currentAgentDesc = agent ? agent.description || '' : '';\n (0, _apichat.syncToken)((0, _cookie.getToken)(), s.sessionId);\n try {\n const res = await (0, _apichat.getSessionMessages)(s.sessionId, 1, 10);\n const list = Array.isArray(res) ? res : res.list || [];\n if (cd) {\n cd.msgTotal = res.total || list.length;\n cd.msgPage = 1;\n const asAsc = (list || []).slice().reverse();\n cd.messages = asAsc.map(m => ({\n role: m.role,\n content: m.content || '',\n thinking: m.thinking || '',\n toolCalls: [],\n agentName: m.role === 'assistant' ? s.agentName || '' : '',\n createTime: m.createTime || null,\n _key: m.createTime ? 'msg_' + m.createTime : 'msg_' + Date.now() + '_' + Math.random()\n }));\n if (cd.messages.length === 0 && agent) {\n const _agent = this.agentList.find(x => x.agentCode === this.currentAgent);\n cd.greeting = _agent ? _agent.greeting || '很高兴为您服务,请问有什么可以帮到您?' : '';\n }\n cd.loadingSessionMsg = false;\n await this.$nextTick();\n this.$nextTick(() => {\n cd.scrollToBottomOnce();\n cd.checkScrollBottom();\n });\n }\n } catch (e) {\n if (cd) {\n cd.messages = [];\n cd.loadingSessionMsg = false;\n }\n }\n },\n handleDeleteSession(s) {\n this.$confirm(`确认删除「${s.agentName || s.agentCode}」的会话?`, '提示', {\n type: 'warning'\n }).then(() => {\n (0, _apichat.deleteSession)(s.sessionId).then(() => {\n if (this.activeSessionId === s.sessionId) {\n this.activeSessionId = '';\n this.currentAgent = '';\n this.currentAgentDesc = '';\n const cd = this.$refs.chatDetail;\n if (cd) {\n cd.messages = [];\n cd.contentCache = {};\n }\n if (this.isMobile) {\n this.showH5List = false;\n this.showAgentSelect = true;\n } else {\n this.showAgentSelect = true;\n }\n }\n this.loadSessions();\n });\n }).catch(() => {});\n },\n closeOldSession() {}\n },\n beforeDestroy() {\n window.removeEventListener('resize', this.updateViewportState);\n document.removeEventListener('touchmove', this._onSwipeMove);\n document.removeEventListener('touchend', this._onSwipeEnd);\n }\n};\n\n//# sourceURL=webpack://ZjPluginIntelligent/./src/lib/components/chatMain/index.vue?./node_modules/_cache-loader@4.1.0@cache-loader/dist/cjs.js??ref--13-0!./node_modules/_babel-loader@8.4.1@babel-loader/lib!./node_modules/_cache-loader@4.1.0@cache-loader/dist/cjs.js??ref--1-0!./node_modules/_vue-loader@15.11.1@vue-loader/lib??vue-loader-options");
|
|
988
988
|
|
|
989
989
|
/***/ }),
|
|
990
990
|
|
|
@@ -12617,7 +12617,7 @@ eval("module.exports = function(originalModule) {\n\tif (!originalModule.webpack
|
|
|
12617
12617
|
/*! exports provided: name, version, main, private, scripts, dependencies, devDependencies, browserslist, directories, keywords, license, default */
|
|
12618
12618
|
/***/ (function(module) {
|
|
12619
12619
|
|
|
12620
|
-
eval("module.exports = JSON.parse(\"{\\\"name\\\":\\\"zj-plugin-intelligent\\\",\\\"version\\\":\\\"1.2.5-beta.
|
|
12620
|
+
eval("module.exports = JSON.parse(\"{\\\"name\\\":\\\"zj-plugin-intelligent\\\",\\\"version\\\":\\\"1.2.5-beta.13\\\",\\\"main\\\":\\\"lib/ZjPluginIntelligent.umd.min.js\\\",\\\"private\\\":false,\\\"scripts\\\":{\\\"serve\\\":\\\"vue-cli-service serve\\\",\\\"build\\\":\\\"vue-cli-service build\\\",\\\"lib\\\":\\\"vue-cli-service build --target lib --name ZjPluginIntelligent --dest lib src/lib/index.js\\\",\\\"lib:test\\\":\\\"vue-cli-service build --mode test --target lib --name ZjPluginIntelligent --dest lib src/lib/index.js\\\"},\\\"dependencies\\\":{\\\"html2canvas\\\":\\\"^1.4.1\\\",\\\"markdown-it\\\":\\\"^14.1.0\\\"},\\\"devDependencies\\\":{\\\"@babel/preset-env\\\":\\\"^7.14.9\\\",\\\"@vue/cli-plugin-babel\\\":\\\"~4.5.0\\\",\\\"@vue/cli-plugin-eslint\\\":\\\"^4.5.13\\\",\\\"@vue/cli-plugin-vuex\\\":\\\"~4.5.0\\\",\\\"@vue/cli-service\\\":\\\"~4.5.0\\\",\\\"axios\\\":\\\"^0.27.2\\\",\\\"babel-eslint\\\":\\\"^10.1.0\\\",\\\"babel-plugin-component\\\":\\\"^1.1.1\\\",\\\"compression-webpack-plugin\\\":\\\"^6.0.3\\\",\\\"core-js\\\":\\\"^3.6.5\\\",\\\"element-ui\\\":\\\"^2.15.4\\\",\\\"eslint\\\":\\\"^7.30.0\\\",\\\"eslint-plugin-vue\\\":\\\"^7.13.0\\\",\\\"js-cookie\\\":\\\"^2.2.1\\\",\\\"node-sass\\\":\\\"^4.12.0\\\",\\\"obs-upload\\\":\\\"^1.0.4-alpha.0\\\",\\\"reconnecting-websocket\\\":\\\"^4.4.0\\\",\\\"sass-loader\\\":\\\"^8.0.2\\\",\\\"snowflake-id\\\":\\\"^1.1.0\\\",\\\"vue\\\":\\\"^2.6.11\\\",\\\"vue-template-compiler\\\":\\\"^2.6.11\\\",\\\"vuex\\\":\\\"^3.4.0\\\",\\\"pako\\\":\\\"^2.1.0\\\",\\\"webpack-bundle-analyzer\\\":\\\"^4.4.2\\\"},\\\"browserslist\\\":[\\\"> 1%\\\",\\\"last 2 versions\\\",\\\"not dead\\\"],\\\"directories\\\":{\\\"lib\\\":\\\"lib\\\"},\\\"keywords\\\":[],\\\"license\\\":\\\"ISC\\\"}\");\n\n//# sourceURL=webpack://ZjPluginIntelligent/./package.json?");
|
|
12621
12621
|
|
|
12622
12622
|
/***/ }),
|
|
12623
12623
|
|