feat: detail page subscribes to bridge status/events
This commit is contained in:
@@ -28,16 +28,42 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import router from '@system.router'
|
import router from '@system.router'
|
||||||
|
import bridge from '../../common/bridge.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
private: {
|
private: {
|
||||||
activeSession: 'demo-1',
|
activeSession: '未选择',
|
||||||
statusText: '未连接',
|
statusText: '未连接',
|
||||||
model: 'deepseek-chat',
|
model: 'deepseek-chat',
|
||||||
events: []
|
events: []
|
||||||
},
|
},
|
||||||
onInit() {
|
onInit() {
|
||||||
// 空壳:后续从 index 页/全局状态传入
|
// 空壳
|
||||||
|
},
|
||||||
|
onReady() {
|
||||||
|
this._unsub = bridge.subscribe({
|
||||||
|
status: (s) => {
|
||||||
|
this.statusText = s || '未连接'
|
||||||
|
},
|
||||||
|
message: (msg) => {
|
||||||
|
this.handleBridgeMessage(msg)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
bridge.refreshConn()
|
||||||
|
},
|
||||||
|
onDestroy() {
|
||||||
|
if (this._unsub) this._unsub()
|
||||||
|
},
|
||||||
|
handleBridgeMessage(msg) {
|
||||||
|
if (msg && msg.type === 'status' && msg.payload) {
|
||||||
|
this.activeSession = msg.payload.activeSessionId || this.activeSession
|
||||||
|
this.model = msg.payload.model || this.model
|
||||||
|
}
|
||||||
|
if (msg && msg.type === 'event' && msg.payload) {
|
||||||
|
try {
|
||||||
|
this.events.push(JSON.stringify(msg.payload).slice(0, 120))
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
openInput() {
|
openInput() {
|
||||||
router.push({ uri: '/pages/input' })
|
router.push({ uri: '/pages/input' })
|
||||||
|
|||||||
Reference in New Issue
Block a user