From bca14ebe7b268edbfab359a7b7f0d6df45051c76 Mon Sep 17 00:00:00 2001 From: LukeMackin Date: Wed, 22 Jul 2026 17:30:18 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20U-001=20=E8=AE=BE=E7=BD=AE=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=20=E2=80=94=20Gateway/Device/Connection=E4=B8=89?= =?UTF-8?q?=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Gateway标签: URL配置+心跳间隔+日志级别+自动连接 - Device标签: 设备名称+信息卡片 - Connection标签: 状态指示器+连接/断开按钮 - 引用@yuzu-gca/shared的DEFAULT_GATEWAY_CONFIG --- packages/client-android/App.tsx | 207 +++++++++++++++++++++++--------- 1 file changed, 153 insertions(+), 54 deletions(-) diff --git a/packages/client-android/App.tsx b/packages/client-android/App.tsx index 8c4629e..8144162 100644 --- a/packages/client-android/App.tsx +++ b/packages/client-android/App.tsx @@ -1,72 +1,171 @@ import { StatusBar } from 'expo-status-bar'; -import { useEffect, useState } from 'react'; -import { StyleSheet, Text, View, ActivityIndicator } from 'react-native'; -import { onAppStartCheckUpdate } from './src/updater/index'; +import { useState } from 'react'; +import { + StyleSheet, Text, View, TextInput, TouchableOpacity, + ScrollView, Switch, +} from 'react-native'; +import { DEFAULT_GATEWAY_CONFIG } from '@yuzu-gca/shared'; + +/** U-001: Settings Page for Yuzu GCA Android Client */ export default function App() { - const [status, setStatus] = useState<'checking' | 'up-to-date' | 'updating' | 'error'>('checking'); - const [message, setMessage] = useState('正在检查更新...'); + const [tab, setTab] = useState<'settings' | 'device' | 'connection'>('settings'); - useEffect(() => { - (async () => { - try { - const result = await onAppStartCheckUpdate(); - if (result.jsUpdate) { - setStatus('updating'); - setMessage('发现 JS 更新,正在下载...(下次启动生效)'); - } else if (result.apkUpdate) { - setStatus('updating'); - setMessage('安装包已就绪,重启后生效'); - } else { - setStatus('up-to-date'); - setMessage('已是最新版本'); - } - } catch (e: any) { - setStatus('error'); - setMessage(`更新检查失败: ${e.message}`); - } - })(); - }, []); + // Settings state + const [gatewayUrl, setGatewayUrl] = useState(DEFAULT_GATEWAY_CONFIG.url); + const [deviceName, setDeviceName] = useState('Android Device'); + const [autoConnect, setAutoConnect] = useState(true); + const [heartbeatInterval, setHeartbeatInterval] = useState(String(DEFAULT_GATEWAY_CONFIG.heartbeatInterval / 1000)); + const [logLevel, setLogLevel] = useState('info'); + + // Connection state + const [connStatus, setConnStatus] = useState<'disconnected' | 'connecting' | 'connected' | 'error'>('disconnected'); return ( + + {/* Header */} Yuzu GCA - Global Control Assistant - - {status === 'checking' && } - {message} + Settings + + {/* Tabs */} + + {(['settings', 'device', 'connection'] as const).map(t => ( + setTab(t)} style={[styles.tab, tab === t && styles.tabActive]}> + + {t === 'settings' ? 'Gateway' : t === 'device' ? 'Device' : 'Connection'} + + + ))} + + + {tab === 'settings' && ( + <> + {/* Gateway URL */} + Gateway URL + + + {/* Heartbeat Interval */} + Heartbeat (seconds) + + + {/* Auto-connect */} + + Auto-connect on start + + + + {/* Log Level */} + Log Level + + {(['debug', 'info', 'warn', 'error'] as const).map(lv => ( + setLogLevel(lv)} + > + {lv} + + ))} + + + )} + + {tab === 'device' && ( + <> + Device Name + + + Device Info + Platform: Android + MCP Server: {gatewayUrl ? 'Configured' : 'Not configured'} + Capabilities: 36 tools (7 implemented) + + + )} + + {tab === 'connection' && ( + <> + + + {connStatus === 'connected' ? '🟢 Connected' : + connStatus === 'connecting' ? '🟡 Connecting...' : + connStatus === 'error' ? '🔴 Error' : '⚫ Disconnected'} + + + setConnStatus(connStatus === 'disconnected' ? 'connecting' : 'disconnected')} + > + + {connStatus === 'disconnected' ? 'Connect' : 'Disconnect'} + + + + )} + ); } const styles = StyleSheet.create({ - container: { - flex: 1, - backgroundColor: '#0f172a', - alignItems: 'center', - justifyContent: 'center', - padding: 24, + container: { flex: 1, backgroundColor: '#0f172a', paddingTop: 48 }, + title: { fontSize: 28, fontWeight: '800', color: '#e2e8f0', textAlign: 'center' }, + subtitle: { fontSize: 12, color: '#64748b', textAlign: 'center', marginBottom: 16 }, + tabBar: { flexDirection: 'row', marginHorizontal: 16, marginBottom: 16 }, + tab: { + flex: 1, padding: 10, alignItems: 'center', + borderBottomWidth: 2, borderBottomColor: '#1e293b', }, - title: { - fontSize: 28, - fontWeight: '800', - color: '#e2e8f0', - marginBottom: 4, - }, - subtitle: { - fontSize: 14, - color: '#94a3b8', - marginBottom: 32, - }, - statusBar: { - flexDirection: 'row', - alignItems: 'center', - gap: 8, - }, - statusText: { - fontSize: 14, - color: '#94a3b8', + tabActive: { borderBottomColor: '#3b82f6' }, + tabText: { fontSize: 14, color: '#64748b' }, + tabTextActive: { color: '#3b82f6', fontWeight: '600' }, + body: { flex: 1, paddingHorizontal: 16 }, + label: { fontSize: 12, color: '#94a3b8', marginBottom: 4, marginTop: 12 }, + input: { + backgroundColor: '#1e293b', color: '#e2e8f0', borderRadius: 8, + padding: 12, fontSize: 14, marginBottom: 4, }, + switchRow: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', marginTop: 12 }, + chipRow: { flexDirection: 'row', gap: 8, marginTop: 4 }, + chip: { paddingHorizontal: 12, paddingVertical: 6, borderRadius: 16, backgroundColor: '#1e293b' }, + chipActive: { backgroundColor: '#1e40af' }, + chipText: { fontSize: 12, color: '#94a3b8' }, + chipTextActive: { color: '#fff' }, + infoCard: { backgroundColor: '#1e293b', borderRadius: 8, padding: 16, marginTop: 16 }, + infoTitle: { fontSize: 14, color: '#38bdf8', marginBottom: 8 }, + infoText: { fontSize: 12, color: '#94a3b8', marginTop: 4 }, + connIndicator: { borderRadius: 8, padding: 16, marginTop: 16, alignItems: 'center' }, + conn_connected: { backgroundColor: '#064e3b' }, + conn_connecting: { backgroundColor: '#78350f' }, + conn_error: { backgroundColor: '#7f1d1d' }, + conn_disconnected: { backgroundColor: '#1e293b' }, + connText: { fontSize: 16, color: '#e2e8f0' }, + btn: { borderRadius: 8, padding: 14, marginTop: 16, alignItems: 'center' }, + btnPrimary: { backgroundColor: '#1e40af' }, + btnDanger: { backgroundColor: '#991b1b' }, + btnText: { fontSize: 16, color: '#fff', fontWeight: '600' }, });