添加日志窗口,辅助测试。
This commit is contained in:
@@ -1066,3 +1066,172 @@
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
/* ===== 调试按钮(顶部Header) ===== */
|
||||
.debug-top-btn {
|
||||
flex-shrink: 0;
|
||||
background: rgba(108, 99, 255, 0.15);
|
||||
}
|
||||
|
||||
.debug-top-btn:active {
|
||||
background: rgba(108, 99, 255, 0.3);
|
||||
}
|
||||
|
||||
.debug-top-text {
|
||||
font-size: 18rpx;
|
||||
font-weight: 700;
|
||||
color: #6c63ff;
|
||||
}
|
||||
|
||||
/* ===== 调试面板(居中弹窗) ===== */
|
||||
.debug-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
z-index: 9999;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 40rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.debug-panel {
|
||||
width: 100%;
|
||||
max-height: 80vh;
|
||||
background: #1e1e2e;
|
||||
border-radius: 24rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.debug-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 28rpx 32rpx 20rpx;
|
||||
border-bottom: 1rpx solid rgba(255, 255, 255, 0.08);
|
||||
}
|
||||
|
||||
.debug-title {
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
color: #cdd6f4;
|
||||
}
|
||||
|
||||
.debug-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 28rpx;
|
||||
}
|
||||
|
||||
.debug-clear-btn {
|
||||
font-size: 24rpx;
|
||||
color: #f38ba8;
|
||||
padding: 6rpx 16rpx;
|
||||
border-radius: 12rpx;
|
||||
background: rgba(243, 139, 168, 0.12);
|
||||
}
|
||||
|
||||
.debug-close-btn {
|
||||
font-size: 32rpx;
|
||||
color: #a6adc8;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.debug-section {
|
||||
padding: 20rpx 24rpx;
|
||||
border-bottom: 1rpx solid rgba(255, 255, 255, 0.05);
|
||||
}
|
||||
|
||||
.debug-label {
|
||||
font-size: 24rpx;
|
||||
color: #89b4fa;
|
||||
font-weight: 600;
|
||||
margin-bottom: 12rpx;
|
||||
}
|
||||
|
||||
/* 状态网格 */
|
||||
.debug-state-grid {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12rpx 28rpx;
|
||||
}
|
||||
|
||||
.debug-state-item {
|
||||
font-size: 24rpx;
|
||||
color: #cdd6f4;
|
||||
}
|
||||
|
||||
.state-key {
|
||||
color: #a6adc8;
|
||||
}
|
||||
|
||||
.state-val {
|
||||
color: #cdd6f4;
|
||||
}
|
||||
|
||||
.state-val-ok {
|
||||
color: #a6e3a1;
|
||||
}
|
||||
|
||||
.state-val-err {
|
||||
color: #f38ba8;
|
||||
}
|
||||
|
||||
.state-val-warn {
|
||||
color: #f9e2af;
|
||||
}
|
||||
|
||||
/* 原始消息展示 */
|
||||
.debug-raw-box {
|
||||
max-height: 400rpx;
|
||||
background: rgba(0, 0, 0, 0.25);
|
||||
border-radius: 12rpx;
|
||||
padding: 16rpx;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.debug-json {
|
||||
font-size: 20rpx;
|
||||
color: #bac2de;
|
||||
font-family: 'Courier New', monospace;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.debug-empty {
|
||||
font-size: 22rpx;
|
||||
color: #585b70;
|
||||
font-style: italic;
|
||||
padding: 12rpx 0;
|
||||
}
|
||||
|
||||
/* 本轮消息列表项 */
|
||||
.debug-round-item {
|
||||
padding: 12rpx 0;
|
||||
border-bottom: 1rpx solid rgba(255, 255, 255, 0.04);
|
||||
}
|
||||
|
||||
.debug-round-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.debug-round-index {
|
||||
font-size: 22rpx;
|
||||
color: #f5c2e7;
|
||||
font-weight: 600;
|
||||
margin-bottom: 6rpx;
|
||||
}
|
||||
|
||||
.debug-round-time {
|
||||
font-size: 20rpx;
|
||||
color: #585b70;
|
||||
font-weight: 400;
|
||||
margin-left: 12rpx;
|
||||
}
|
||||
|
||||
@@ -108,6 +108,9 @@
|
||||
<view class="head-btn log-out" @click="logOut">
|
||||
<view class="iconfont icon-tuichu"></view>
|
||||
</view>
|
||||
<view class="head-btn debug-top-btn" @click="toggleDebugPanel">
|
||||
<text class="debug-top-text">{{ showDebugPanel ? '✕' : 'LOG' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
@@ -340,6 +343,62 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- ===== 调试面板:Socket 原始消息 ===== -->
|
||||
<view v-if="showDebugPanel" class="debug-overlay" @click="showDebugPanel = false">
|
||||
<view class="debug-panel" @click.stop>
|
||||
<view class="debug-header">
|
||||
<text class="debug-title">Socket 调试日志</text>
|
||||
<view class="debug-actions">
|
||||
<text class="debug-clear-btn" @click="clearDebugRound">清空</text>
|
||||
<text class="debug-close-btn" @click="showDebugPanel = false">✕</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 当前状态概览 -->
|
||||
<view class="debug-section">
|
||||
<view class="debug-label">当前状态</view>
|
||||
<view class="debug-state-grid">
|
||||
<view class="debug-state-item">
|
||||
<text class="state-key">连接:</text>
|
||||
<text :class="socketStore.isConnected ? 'state-val-ok' : 'state-val-err'">{{ socketStore.connectionStatus }}</text>
|
||||
</view>
|
||||
<view class="debug-state-item">
|
||||
<text class="state-key">AI思考:</text>
|
||||
<text :class="socketStore.isThinking ? 'state-val-warn' : 'state-val-ok'">{{ socketStore.isThinking ? '是' : '否' }}</text>
|
||||
</view>
|
||||
<view class="debug-state-item">
|
||||
<text class="state-key">流式ID:</text>
|
||||
<text class="state-val">{{ streamingMessageId || '-' }}</text>
|
||||
</view>
|
||||
<view class="debug-state-item">
|
||||
<text class="state-key">SessionID:</text>
|
||||
<text class="state-val">{{ (currentSessionId || '').slice(-8) || '-' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 最后一帧原始消息 -->
|
||||
<view class="debug-section">
|
||||
<view class="debug-label">最后一帧接收</view>
|
||||
<scroll-view class="debug-raw-box" scroll-y v-if="socketStore.lastReceiveRaw">
|
||||
<text class="debug-json">{{ formatDebugJson(socketStore.lastReceiveRaw.data) }}</text>
|
||||
</scroll-view>
|
||||
<text v-else class="debug-empty">暂无接收数据</text>
|
||||
</view>
|
||||
|
||||
<!-- 本轮所有消息 -->
|
||||
<view class="debug-section">
|
||||
<view class="debug-label">本轮消息 ({{ socketStore.questionRoundMessages.length }}条)</view>
|
||||
<scroll-view class="debug-raw-box" scroll-y>
|
||||
<view v-for="(msg, i) in socketStore.questionRoundMessages" :key="i" class="debug-round-item">
|
||||
<view class="debug-round-index">#{{ i + 1 }} <text class="debug-round-time">{{ formatDebugTime(msg.time) }}</text></view>
|
||||
<text class="debug-json">{{ formatDebugJson(msg.data) }}</text>
|
||||
</view>
|
||||
<text v-if="!socketStore.questionRoundMessages.length" class="debug-empty">暂无本轮消息</text>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</template>
|
||||
|
||||
@@ -1010,6 +1069,9 @@ import { openFile as openFileNative, downloadAndOpen } from '@/utils/fileOpener.
|
||||
const showMessageModal = ref(false)
|
||||
const detailLinks = ref([])
|
||||
|
||||
// 调试面板
|
||||
const showDebugPanel = ref(false)
|
||||
|
||||
// 点击气泡内容:拦截链接点击,否则 AI 对话弹出详情
|
||||
const handleChatContentClick = (e, message) => {
|
||||
// 在事件路径中向上查找 .chat-inline-link 元素
|
||||
@@ -1353,6 +1415,8 @@ import { openFile as openFileNative, downloadAndOpen } from '@/utils/fileOpener.
|
||||
// 发送AI消息
|
||||
const sendAIMessage = async () => {
|
||||
try {
|
||||
// 调试:开始新的提问轮次,记录本轮所有 socket 消息
|
||||
socketStore.startNewRound()
|
||||
let messageContent = textMessage.value
|
||||
// 立即添加用户消息到列表(使用完整的 messageContent,包含文件信息)
|
||||
allmessages.value = [...allmessages.value, {
|
||||
@@ -2019,6 +2083,35 @@ import { openFile as openFileNative, downloadAndOpen } from '@/utils/fileOpener.
|
||||
})
|
||||
|
||||
// 离开 AI 对话页面时断开 socket
|
||||
// ===== 调试面板相关 =====
|
||||
const toggleDebugPanel = () => {
|
||||
showDebugPanel.value = !showDebugPanel.value
|
||||
}
|
||||
|
||||
const clearDebugRound = () => {
|
||||
socketStore.clearRoundMessages()
|
||||
}
|
||||
|
||||
const formatDebugJson = (data) => {
|
||||
try {
|
||||
return JSON.stringify(data, null, 2)
|
||||
} catch {
|
||||
return String(data)
|
||||
}
|
||||
}
|
||||
|
||||
const formatDebugTime = (isoStr) => {
|
||||
try {
|
||||
const t = new Date(isoStr)
|
||||
const h = t.getHours().toString().padStart(2, '0')
|
||||
const m = t.getMinutes().toString().padStart(2, '0')
|
||||
const s = t.getSeconds().toString().padStart(2, '0')
|
||||
return `${h}:${m}:${s}`
|
||||
} catch {
|
||||
return isoStr
|
||||
}
|
||||
}
|
||||
|
||||
onUnload(() => {
|
||||
socketStore.disconnect()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user