优化: 跨端链路协议对齐

- miniapp 配置域旧端点强制重置
- df-tunnel 隧道协议与 relay 现网对齐
- relay e2e 例程入 examples
This commit is contained in:
lxy
2026-10-04 16:27:31 +08:00
parent 7aa0da32f2
commit d9e0ce73d1
9 changed files with 248 additions and 126 deletions
+12 -12
View File
@@ -6,7 +6,7 @@ import { useAiChat } from '@/composables/useAiChat'
/**
* 设置页(连接配置查看/编辑 + 连接状态 + 连接操作)。
*
* 默认查看模式(只读展示 relayHost/deviceId/token,token 脱敏);点「编辑」进入编辑模式,
* 默认查看模式(只读展示 relayHost/channelId/token,token 脱敏);点「编辑」进入编辑模式,
* 保存时 setConfig 持久化并 resumeIfDisconnected 用新配置重连。连接态可「断开」,
* 断开态可「重连」,另展示最近状态详情(wsStatusDetail)辅助排查。
*
@@ -82,13 +82,13 @@ function onConnOp(): void {
/** 编辑态(false=查看模式,true=编辑模式;草稿保存时才 setConfig,取消丢弃) */
const editing = ref(false)
const draftRelayHost = ref('')
const draftDeviceId = ref('')
const draftChannelId = ref('')
const draftToken = ref('')
/** 进入编辑模式:以当前配置填充草稿 */
function enterEdit(): void {
draftRelayHost.value = cfg.value.relayHost
draftDeviceId.value = cfg.value.deviceId
draftChannelId.value = cfg.value.channelId
draftToken.value = cfg.value.token
editing.value = true
}
@@ -101,12 +101,12 @@ function cancelEdit(): void {
/** 保存编辑:setConfig 持久化 + 提示 + resumeIfDisconnected 用新配置重连 */
function saveEdit(): void {
const relayHost = draftRelayHost.value.trim()
const deviceId = draftDeviceId.value.trim()
if (!relayHost || !deviceId) {
uni.showToast({ title: '中继地址和设备 ID 不能为空', icon: 'none' })
const channelId = draftChannelId.value.trim()
if (!relayHost || !channelId) {
uni.showToast({ title: '中继地址和通道 ID 不能为空', icon: 'none' })
return
}
setConfig({ relayHost, deviceId, token: draftToken.value.trim() })
setConfig({ relayHost, channelId, token: draftToken.value.trim() })
editing.value = false
uni.showToast({ title: '已保存,正在重连…', icon: 'none' })
ai.resumeIfDisconnected()
@@ -139,7 +139,7 @@ function saveEdit(): void {
</view>
</view>
<!-- 连接配置(查看/编辑双模式:编辑可改 relayHost/deviceId/token) -->
<!-- 连接配置(查看/编辑双模式:编辑可改 relayHost/channelId/token) -->
<view class="card">
<view class="card-head">
<text class="card-title">连接配置</text>
@@ -151,13 +151,13 @@ function saveEdit(): void {
</view>
<view class="row">
<text class="row-label">中继地址</text>
<input v-if="editing" v-model="draftRelayHost" class="row-input" placeholder="ws://…/ws/miniapp" placeholder-class="row-ph" />
<input v-if="editing" v-model="draftRelayHost" class="row-input" placeholder="ws://…/ws/commander" placeholder-class="row-ph" />
<text v-else class="row-value mono">{{ cfg.relayHost }}</text>
</view>
<view class="row">
<text class="row-label">设备 ID</text>
<input v-if="editing" v-model="draftDeviceId" class="row-input" placeholder="桌面端设备 ID" placeholder-class="row-ph" />
<text v-else class="row-value mono">{{ cfg.deviceId }}</text>
<text class="row-label">通道 ID</text>
<input v-if="editing" v-model="draftChannelId" class="row-input" placeholder="u-relay 通道 ID" placeholder-class="row-ph" />
<text v-else class="row-value mono">{{ cfg.channelId }}</text>
</view>
<view class="row">
<text class="row-label">配对 Token</text>