diff --git a/apps/android-tv/app/src/gecko/java/com/moontvplus/tv/MainActivity.java b/apps/android-tv/app/src/gecko/java/com/moontvplus/tv/MainActivity.java
index 79202f5..cd31782 100644
--- a/apps/android-tv/app/src/gecko/java/com/moontvplus/tv/MainActivity.java
+++ b/apps/android-tv/app/src/gecko/java/com/moontvplus/tv/MainActivity.java
@@ -11,7 +11,6 @@ import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;
-import android.widget.TextView;
import org.mozilla.geckoview.GeckoRuntime;
import org.mozilla.geckoview.GeckoSession;
@@ -26,7 +25,6 @@ public class MainActivity extends Activity implements RemoteCommandHandler {
private GeckoView geckoView;
private boolean canGoBack = false;
private LocalRemoteServer localRemoteServer;
- private TextView remoteHintView;
private final Handler mainHandler = new Handler(Looper.getMainLooper());
@Override
@@ -73,21 +71,6 @@ public class MainActivity extends Activity implements RemoteCommandHandler {
private void setupLocalRemoteServer() {
localRemoteServer = new LocalRemoteServer(this);
localRemoteServer.start();
- String url = localRemoteServer.getRemoteUrl();
- if (url == null) return;
- remoteHintView = new TextView(this);
- remoteHintView.setText("局域网遥控:手机浏览器打开\n" + url);
- remoteHintView.setTextColor(0xFFE0E7FF);
- remoteHintView.setTextSize(13);
- remoteHintView.setPadding(18, 12, 18, 12);
- remoteHintView.setBackgroundColor(0xAA111827);
- addContentView(remoteHintView, new FrameLayout.LayoutParams(
- ViewGroup.LayoutParams.WRAP_CONTENT,
- ViewGroup.LayoutParams.WRAP_CONTENT
- ));
- mainHandler.postDelayed(() -> {
- if (remoteHintView != null) remoteHintView.setVisibility(View.GONE);
- }, 15000);
}
private int keyCodeForRemoteKey(String key, String digit) {
diff --git a/apps/android-tv/app/src/main/java/com/moontvplus/tv/LocalRemoteServer.java b/apps/android-tv/app/src/main/java/com/moontvplus/tv/LocalRemoteServer.java
index 28ddfcf..1158a2b 100644
--- a/apps/android-tv/app/src/main/java/com/moontvplus/tv/LocalRemoteServer.java
+++ b/apps/android-tv/app/src/main/java/com/moontvplus/tv/LocalRemoteServer.java
@@ -241,9 +241,11 @@ public class LocalRemoteServer {
private String remoteHtml() {
return "
" +
"MoonTVPlus 局域网遥控器LAN REMOTE
电视遥控器
同一局域网直连 MoonTVPlus TV,低延迟控制方向、播放和文本输入。
正在连接电视...
";
}
+
}
diff --git a/apps/android-tv/app/src/webview/java/com/moontvplus/tv/MainActivity.java b/apps/android-tv/app/src/webview/java/com/moontvplus/tv/MainActivity.java
index 3eded60..3fcc0fd 100644
--- a/apps/android-tv/app/src/webview/java/com/moontvplus/tv/MainActivity.java
+++ b/apps/android-tv/app/src/webview/java/com/moontvplus/tv/MainActivity.java
@@ -21,7 +21,6 @@ import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.FrameLayout;
-import android.widget.TextView;
import java.net.URLEncoder;
@@ -31,7 +30,6 @@ public class MainActivity extends Activity implements RemoteCommandHandler {
private View customView;
private WebChromeClient.CustomViewCallback customViewCallback;
private LocalRemoteServer localRemoteServer;
- private TextView remoteHintView;
private final Handler mainHandler = new Handler(Looper.getMainLooper());
@Override
@@ -148,10 +146,6 @@ public class MainActivity extends Activity implements RemoteCommandHandler {
return localRemoteServer == null ? -1 : localRemoteServer.getPort();
}
- @JavascriptInterface
- public void showHint() {
- mainHandler.post(() -> showLocalRemoteHint(true));
- }
}
private void injectLocalRemoteInfo() {
@@ -164,38 +158,9 @@ public class MainActivity extends Activity implements RemoteCommandHandler {
webView.evaluateJavascript(script, null);
}
- private void showLocalRemoteHint(boolean persistent) {
- String url = localRemoteServer == null ? null : localRemoteServer.getRemoteUrl();
- if (url == null) return;
- if (remoteHintView == null) {
- remoteHintView = new TextView(this);
- remoteHintView.setTextColor(0xFFE0E7FF);
- remoteHintView.setTextSize(13);
- remoteHintView.setPadding(18, 12, 18, 12);
- remoteHintView.setBackgroundColor(0xAA111827);
- FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
- ViewGroup.LayoutParams.WRAP_CONTENT,
- ViewGroup.LayoutParams.WRAP_CONTENT
- );
- params.leftMargin = 24;
- params.topMargin = 24;
- root.addView(remoteHintView, params);
- }
- remoteHintView.setText("局域网遥控:手机浏览器打开\n" + url);
- remoteHintView.setVisibility(View.VISIBLE);
- if (!persistent) {
- mainHandler.postDelayed(() -> {
- if (remoteHintView != null) {
- remoteHintView.setVisibility(View.GONE);
- }
- }, 15000);
- }
- }
-
private void setupLocalRemoteServer() {
localRemoteServer = new LocalRemoteServer(this);
localRemoteServer.start();
- showLocalRemoteHint(false);
}
private int keyCodeForRemoteKey(String key, String digit) {
diff --git a/src/app/tv/me/page.tsx b/src/app/tv/me/page.tsx
index eec25eb..1f19b33 100644
--- a/src/app/tv/me/page.tsx
+++ b/src/app/tv/me/page.tsx
@@ -37,7 +37,6 @@ const LOCAL_REMOTE_URL_KEY = 'moontv_local_remote_url';
type MoonTVLocalRemoteBridge = {
getRemoteUrl?: () => string;
- showHint?: () => void;
};
declare global {
@@ -89,7 +88,6 @@ export default function TVMePage() {
const [loggingOut, setLoggingOut] = useState(false);
const [error, setError] = useState('');
const [localRemoteUrl, setLocalRemoteUrl] = useState('');
- const [nativeHintAvailable, setNativeHintAvailable] = useState(false);
const [copyStatus, setCopyStatus] = useState('');
const [upDownAction, setUpDownAction] = useState(
DEFAULT_TV_PLAYER_UP_DOWN_ACTION
@@ -107,7 +105,6 @@ export default function TVMePage() {
useEffect(() => {
const readLocalRemoteUrl = () => {
const bridgeUrl = window.MoonTVLocalRemote?.getRemoteUrl?.() || '';
- setNativeHintAvailable(Boolean(window.MoonTVLocalRemote?.showHint));
setLocalRemoteUrl(
bridgeUrl ||
window.__MOONTV_LOCAL_REMOTE_URL ||
@@ -184,9 +181,6 @@ export default function TVMePage() {
};
- const showLocalRemoteHint = () => {
- window.MoonTVLocalRemote?.showHint?.();
- };
const copyLocalRemoteUrl = async () => {
if (!localRemoteUrl) return;
@@ -310,7 +304,7 @@ export default function TVMePage() {
手机扫码遥控
- 在同一 Wi‑Fi 下用手机打开遥控地址,不经过服务器,方向键和播放控制更低延迟。
+ 在同一 Wi‑Fi 下用手机扫描二维码或打开遥控地址。
{localRemoteUrl ? (
@@ -320,16 +314,6 @@ export default function TVMePage() {
{localRemoteUrl}
- {nativeHintAvailable && (
-
- )}
diff --git a/src/components/UserMenu.tsx b/src/components/UserMenu.tsx
index c83dabc..d655048 100644
--- a/src/components/UserMenu.tsx
+++ b/src/components/UserMenu.tsx
@@ -1372,8 +1372,21 @@ export const UserMenu: React.FC = () => {
const handleQrLoginResult = useCallback((rawValue: string) => {
try {
const url = new URL(rawValue, window.location.origin);
+
+ const isLocalRemoteUrl =
+ (url.protocol === 'http:' || url.protocol === 'https:') &&
+ url.searchParams.has('token') &&
+ (url.pathname === '/remote' || url.pathname.endsWith('/remote'));
+
+ if (isLocalRemoteUrl) {
+ setTvQrScannerStatus('识别成功,正在打开局域网遥控器...');
+ stopTvQrScanner();
+ window.location.href = url.href;
+ return true;
+ }
+
if (url.origin !== window.location.origin || url.pathname !== '/qr-login') {
- setTvQrScannerError('未识别到本站电视登录二维码,请扫描电视屏幕上的二维码。');
+ setTvQrScannerError('未识别到电视登录二维码或局域网遥控二维码,请扫描电视屏幕上的二维码。');
return false;
}
@@ -1388,7 +1401,7 @@ export const UserMenu: React.FC = () => {
window.location.href = `/qr-login?token=${encodeURIComponent(token)}`;
return true;
} catch {
- setTvQrScannerError('二维码内容无效,请扫描电视端显示的登录二维码。');
+ setTvQrScannerError('二维码内容无效,请扫描电视端显示的登录二维码或局域网遥控二维码。');
return false;
}
}, [stopTvQrScanner]);
@@ -1424,7 +1437,7 @@ export const UserMenu: React.FC = () => {
await tvQrVideoRef.current.play();
const detector = new BarcodeDetectorCtor({ formats: ['qr_code'] });
- setTvQrScannerStatus('请将电视屏幕上的登录二维码放入取景框');
+ setTvQrScannerStatus('请将电视屏幕上的登录二维码或局域网遥控二维码放入取景框');
const scan = async () => {
if (tvQrScanStopRef.current || !tvQrVideoRef.current) return;
@@ -4408,8 +4421,8 @@ export const UserMenu: React.FC = () => {
手机相机扫码
- 扫描电视登录二维码
- 识别成功后会进入手机确认登录页
+ 扫描电视二维码
+ 支持扫码登录,也支持打开局域网遥控器