增加状态显示
This commit is contained in:
4
.vscode/launch.json
vendored
4
.vscode/launch.json
vendored
@@ -8,7 +8,7 @@
|
|||||||
"mode": "debug",
|
"mode": "debug",
|
||||||
"program": "${workspaceFolder}/servers/walletman/cmd/server",
|
"program": "${workspaceFolder}/servers/walletman/cmd/server",
|
||||||
"cwd": "${workspaceFolder}/servers/walletman",
|
"cwd": "${workspaceFolder}/servers/walletman",
|
||||||
"preLaunchTask": "build walletman",
|
"buildFlags": "-buildvcs=false",
|
||||||
"env": {
|
"env": {
|
||||||
"PATH": "/Users/hybro/go/bin:${env:PATH}"
|
"PATH": "/Users/hybro/go/bin:${env:PATH}"
|
||||||
}
|
}
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
"mode": "debug",
|
"mode": "debug",
|
||||||
"program": "${workspaceFolder}/servers/usdtman/cmd/server",
|
"program": "${workspaceFolder}/servers/usdtman/cmd/server",
|
||||||
"cwd": "${workspaceFolder}/servers/usdtman",
|
"cwd": "${workspaceFolder}/servers/usdtman",
|
||||||
"preLaunchTask": "build usdtman",
|
"buildFlags": "-buildvcs=false",
|
||||||
"env": {
|
"env": {
|
||||||
"PATH": "/Users/hybro/go/bin:${env:PATH}"
|
"PATH": "/Users/hybro/go/bin:${env:PATH}"
|
||||||
}
|
}
|
||||||
|
|||||||
2
.vscode/tasks.json
vendored
2
.vscode/tasks.json
vendored
@@ -7,6 +7,7 @@
|
|||||||
"command": "go",
|
"command": "go",
|
||||||
"args": [
|
"args": [
|
||||||
"build",
|
"build",
|
||||||
|
"-buildvcs=false",
|
||||||
"-o",
|
"-o",
|
||||||
"${workspaceFolder}/servers/walletman/bin/server",
|
"${workspaceFolder}/servers/walletman/bin/server",
|
||||||
"./cmd/server"
|
"./cmd/server"
|
||||||
@@ -28,6 +29,7 @@
|
|||||||
"command": "go",
|
"command": "go",
|
||||||
"args": [
|
"args": [
|
||||||
"build",
|
"build",
|
||||||
|
"-buildvcs=false",
|
||||||
"-o",
|
"-o",
|
||||||
"${workspaceFolder}/servers/usdtman/bin/server",
|
"${workspaceFolder}/servers/usdtman/bin/server",
|
||||||
"./cmd/server"
|
"./cmd/server"
|
||||||
|
|||||||
26
App.tsx
26
App.tsx
@@ -58,6 +58,7 @@ export default class App extends Component<AppProps, WalletmanAppState> {
|
|||||||
showBharatPeBusinessBind: false,
|
showBharatPeBusinessBind: false,
|
||||||
showMobikwikPersonalBind: false,
|
showMobikwikPersonalBind: false,
|
||||||
showFreechargePersonalBind: false,
|
showFreechargePersonalBind: false,
|
||||||
|
proxyStatus: 'idle',
|
||||||
};
|
};
|
||||||
|
|
||||||
this.deviceId = DeviceInfo.getUniqueIdSync();
|
this.deviceId = DeviceInfo.getUniqueIdSync();
|
||||||
@@ -128,6 +129,7 @@ export default class App extends Component<AppProps, WalletmanAppState> {
|
|||||||
const { clientId } = this;
|
const { clientId } = this;
|
||||||
console.log('[Proxy] 初始化后台服务:', clientId, 'userId:', userId);
|
console.log('[Proxy] 初始化后台服务:', clientId, 'userId:', userId);
|
||||||
|
|
||||||
|
this.setState({ proxyStatus: 'connecting' });
|
||||||
await proxyBackgroundService.start({
|
await proxyBackgroundService.start({
|
||||||
wsUrl: Api.WS_URL,
|
wsUrl: Api.WS_URL,
|
||||||
clientId: this.clientId || '',
|
clientId: this.clientId || '',
|
||||||
@@ -138,12 +140,15 @@ export default class App extends Component<AppProps, WalletmanAppState> {
|
|||||||
reconnectMaxAttempts: Infinity,
|
reconnectMaxAttempts: Infinity,
|
||||||
onConnected: () => {
|
onConnected: () => {
|
||||||
console.log('[Proxy] 后台服务已连接');
|
console.log('[Proxy] 后台服务已连接');
|
||||||
|
this.setState({ proxyStatus: 'connected' });
|
||||||
},
|
},
|
||||||
onDisconnected: () => {
|
onDisconnected: () => {
|
||||||
console.log('[Proxy] 后台服务已断开');
|
console.log('[Proxy] 后台服务已断开');
|
||||||
|
this.setState({ proxyStatus: 'disconnected' });
|
||||||
},
|
},
|
||||||
onError: (error: string) => {
|
onError: (error: string) => {
|
||||||
console.warn('[Proxy] 错误:', error);
|
console.log('[Proxy] 错误:', error);
|
||||||
|
this.setState({ proxyStatus: 'error', proxyError: error });
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -554,6 +559,25 @@ export default class App extends Component<AppProps, WalletmanAppState> {
|
|||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
|
{(() => {
|
||||||
|
const { proxyStatus, proxyError } = this.state;
|
||||||
|
const cfg: Record<string, { label: string; color: string }> = {
|
||||||
|
idle: { label: '未连接', color: '#95a5a6' },
|
||||||
|
connecting: { label: '连接中…', color: '#f39c12' },
|
||||||
|
connected: { label: '已连接', color: '#2ecc71' },
|
||||||
|
disconnected: { label: '已断开', color: '#e74c3c' },
|
||||||
|
error: { label: '连接失败', color: '#e74c3c' },
|
||||||
|
};
|
||||||
|
const { label, color } = cfg[proxyStatus];
|
||||||
|
return (
|
||||||
|
<View style={{ flexDirection: 'row', alignItems: 'center', paddingVertical: 6, paddingHorizontal: 12 }}>
|
||||||
|
<View style={{ width: 8, height: 8, borderRadius: 4, backgroundColor: color, marginRight: 6 }} />
|
||||||
|
<Text style={{ color, fontSize: 13 }}>
|
||||||
|
Proxy {label}{proxyStatus === 'error' && proxyError ? `:${proxyError}` : ''}
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
})()}
|
||||||
{this.renderBindModal()}
|
{this.renderBindModal()}
|
||||||
<View style={[styles.bindButton, { backgroundColor: "transparent", flexDirection: "row", justifyContent: "space-between", alignItems: "center" }]}>
|
<View style={[styles.bindButton, { backgroundColor: "transparent", flexDirection: "row", justifyContent: "space-between", alignItems: "center" }]}>
|
||||||
<TouchableOpacity style={[styles.bindButton, { marginBottom: 0, width: '45%', backgroundColor: "#888888" }]} onPress={() => {
|
<TouchableOpacity style={[styles.bindButton, { marginBottom: 0, width: '45%', backgroundColor: "#888888" }]} onPress={() => {
|
||||||
|
|||||||
Submodule servers/walletman updated: 7a1528a420...0eaa98c661
4
types.ts
4
types.ts
@@ -22,4 +22,8 @@ export interface WalletmanAppState {
|
|||||||
|
|
||||||
/* Freecharge Personal */
|
/* Freecharge Personal */
|
||||||
showFreechargePersonalBind: boolean;
|
showFreechargePersonalBind: boolean;
|
||||||
|
|
||||||
|
/* Proxy 状态 */
|
||||||
|
proxyStatus: 'idle' | 'connecting' | 'connected' | 'disconnected' | 'error';
|
||||||
|
proxyError?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user