feat: wire watch pages to @system.interconnect bridge
This commit is contained in:
+23
-11
@@ -50,17 +50,14 @@
|
||||
|
||||
<script>
|
||||
import router from '@system.router'
|
||||
import bridge from '../../common/bridge.js'
|
||||
|
||||
export default {
|
||||
private: {
|
||||
currentIndex: 1,
|
||||
sessions: [
|
||||
{ sessionId: 'demo-1', title: '原型演示会话', running: false },
|
||||
{ sessionId: 'demo-2', title: 'UI 对齐中', running: true },
|
||||
{ sessionId: 'demo-3', title: '待接入 Harness', running: false }
|
||||
],
|
||||
sessions: [],
|
||||
statusText: '未连接',
|
||||
activeTitle: '会话 demo-1',
|
||||
activeTitle: '未选择会话',
|
||||
settings: {
|
||||
serverUrl: 'ws://127.0.0.1:8787',
|
||||
userId: '',
|
||||
@@ -70,12 +67,19 @@ export default {
|
||||
},
|
||||
|
||||
onInit() {
|
||||
// 空壳:暂无逻辑
|
||||
// 空壳:仅预留
|
||||
},
|
||||
|
||||
onReady() {
|
||||
// 空壳:后续在此初始化 interconnect
|
||||
this.refreshConn()
|
||||
bridge.init({
|
||||
status: (s) => {
|
||||
this.statusText = s
|
||||
this.connText = s
|
||||
},
|
||||
message: (msg) => {
|
||||
this.handleBridgeMessage(msg)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
onSwipeChange(e) {
|
||||
@@ -116,8 +120,16 @@ export default {
|
||||
onTokenChange(e) { this.settings.token = e && e.value || '' },
|
||||
|
||||
refreshConn() {
|
||||
// 空壳:后续通过 interconnect getReadyState 获取真实连接状态
|
||||
this.connText = '手机/手表未连接'
|
||||
bridge.refreshConn()
|
||||
},
|
||||
|
||||
handleBridgeMessage(msg) {
|
||||
// 空壳:按 PROTOCOL.md 处理手机下发的 status/event 等
|
||||
if (msg && msg.type === 'status' && msg.payload) {
|
||||
this.statusText = msg.payload.statusText || this.statusText
|
||||
this.activeTitle = msg.payload.activeTitle || this.activeTitle
|
||||
if (msg.payload.sessions) this.sessions = msg.payload.sessions
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
<script>
|
||||
import router from '@system.router'
|
||||
import bridge from '../../common/bridge.js'
|
||||
|
||||
export default {
|
||||
private: {
|
||||
@@ -27,13 +28,11 @@ export default {
|
||||
},
|
||||
sendQuick(index) {
|
||||
const item = this.quick[index]
|
||||
// 空壳:后续通过 interconnect 发给手机/服务器
|
||||
console.log('quick send', item)
|
||||
bridge.sendCommand({ kind: 'quick', quick: item, content: item })
|
||||
this.text = item
|
||||
},
|
||||
sendText() {
|
||||
// 空壳:后续通过 interconnect 发送
|
||||
console.log('send text', this.text)
|
||||
bridge.sendText(this.text)
|
||||
},
|
||||
goBack() {
|
||||
router.back()
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
<script>
|
||||
import router from '@system.router'
|
||||
import bridge from '../../common/bridge.js'
|
||||
|
||||
export default {
|
||||
private: {
|
||||
@@ -31,8 +32,7 @@ export default {
|
||||
onUserChange(e) { this.userId = e && e.value || '' },
|
||||
onTokenChange(e) { this.token = e && e.value || '' },
|
||||
save() {
|
||||
// 空壳:后续持久化并与 index 页同步
|
||||
console.log('save settings', this.serverUrl, this.userId)
|
||||
bridge.sendSettings({ serverUrl: this.serverUrl, userId: this.userId, token: this.token })
|
||||
},
|
||||
goBack() {
|
||||
router.back()
|
||||
|
||||
Reference in New Issue
Block a user