Hide 'Transfer file' and 'TCP tunneling' menu items in relay mode

Plan B for the punch UI: don't just grey out file transfer — hide it
entirely when the connection is relay. The user can't try to use it,
and we save the toast explanation.

When punch succeeds (P2P, direct), the menu items reappear.

Applied to:
  - Transfer file
  - TCP tunneling

(Leaving View camera and Terminal in the menu regardless of mode —
  they don't use server bandwidth significantly.)
This commit is contained in:
xuwenwei
2026-06-09 12:04:18 +08:00
parent 4ecbcaf252
commit 8ef7ff1ce9
+19 -22
View File
@@ -451,17 +451,25 @@ List<TTextMenu> toolbarControls(BuildContext context, String id, FFI ffi) {
} }
if (isDefaultConn && isDesktop) { if (isDefaultConn && isDesktop) {
v.add( // Custom fork: only show the "Transfer file" and "TCP tunneling" menu
TTextMenu( // items when the connection is P2P (direct). In relay mode, hide them
child: Text(translate('Transfer file')), // entirely so the user can't even try. Reason: server bandwidth is
onPressed: () { // scarce (5 Mbps for 4 users) and a single file transfer can saturate
if (!isDirectConnection(id)) { // it; better to surface the limitation up-front than show a disabled
showToast('中继模式:当前连接走服务器 21117 中转,文件传输已被禁用以避免占用过多服务器带宽。'); // grey item with a toast.
return; final showP2POnlyMenus = isDirectConnection(id);
} if (showP2POnlyMenus) {
connectWithToken(isFileTransfer: true); v.add(
}), TTextMenu(
); child: Text(translate('Transfer file')),
onPressed: () => connectWithToken(isFileTransfer: true)),
);
v.add(
TTextMenu(
child: Text(translate('TCP tunneling')),
onPressed: () => connectWithToken(isTcpTunneling: true)),
);
}
v.add( v.add(
TTextMenu( TTextMenu(
child: Text(translate('View camera')), child: Text(translate('View camera')),
@@ -472,17 +480,6 @@ List<TTextMenu> toolbarControls(BuildContext context, String id, FFI ffi) {
child: Text('${translate('Terminal')} (beta)'), child: Text('${translate('Terminal')} (beta)'),
onPressed: () => connectWithToken(isTerminal: true)), onPressed: () => connectWithToken(isTerminal: true)),
); );
v.add(
TTextMenu(
child: Text(translate('TCP tunneling')),
onPressed: () {
if (!isDirectConnection(id)) {
showToast('中继模式:TCP 隧道已被禁用以避免占用过多服务器带宽。');
return;
}
connectWithToken(isTcpTunneling: true);
}),
);
} }
// note // note
if (isDefaultConn && !bind.isDisableAccount()) { if (isDefaultConn && !bind.isDisableAccount()) {