's'
This commit is contained in:
@@ -142,6 +142,13 @@ type Props = {
|
||||
const SCRCPY_URL = "https://github.com/Genymobile/scrcpy";
|
||||
const ESCRCPY_URL = "https://github.com/viarotel-org/escrcpy";
|
||||
|
||||
/** 与 LiveControlApp 一致:apiBase 为空时用根相对路径(同域 FastAPI 托管静态页)。 */
|
||||
function apiUrl(apiBase: string, path: string): string {
|
||||
const p = path.startsWith("/") ? path : `/${path}`;
|
||||
const b = (apiBase || "").trim().replace(/\/$/, "");
|
||||
return b ? `${b}${p}` : p;
|
||||
}
|
||||
|
||||
export function LiveAndroidStreamConsole({
|
||||
t,
|
||||
apiBase,
|
||||
@@ -188,10 +195,9 @@ export function LiveAndroidStreamConsole({
|
||||
const activeTransport = devices.find((d) => d.serial === serial)?.transport;
|
||||
const useFastShot = liveMs > 0;
|
||||
|
||||
const shotUrl =
|
||||
apiBase && serial
|
||||
? `${apiBase}/android/screenshot?serial=${encodeURIComponent(serial)}&ts=${frameTs}${useFastShot ? "&fast=1" : ""}`
|
||||
: "";
|
||||
const shotUrl = serial
|
||||
? `${apiUrl(apiBase, "/android/screenshot")}?serial=${encodeURIComponent(serial)}&ts=${frameTs}${useFastShot ? "&fast=1" : ""}`
|
||||
: "";
|
||||
|
||||
const bumpFrame = useCallback(() => {
|
||||
setFrameTs((n) => n + 1);
|
||||
@@ -230,7 +236,9 @@ export function LiveAndroidStreamConsole({
|
||||
let cancelled = false;
|
||||
void (async () => {
|
||||
try {
|
||||
const res = await fetch(`${apiBase}/android/display_metrics?serial=${encodeURIComponent(serial)}`);
|
||||
const res = await fetch(
|
||||
`${apiUrl(apiBase, "/android/display_metrics")}?serial=${encodeURIComponent(serial)}`,
|
||||
);
|
||||
const data = (await res.json()) as { width?: number; height?: number };
|
||||
if (!res.ok || cancelled) return;
|
||||
if (typeof data.width === "number" && typeof data.height === "number") {
|
||||
@@ -259,7 +267,7 @@ export function LiveAndroidStreamConsole({
|
||||
let cancelled = false;
|
||||
void (async () => {
|
||||
try {
|
||||
const res = await fetch(`${apiBase}/android/scrcpy/info`);
|
||||
const res = await fetch(apiUrl(apiBase, "/android/scrcpy/info"));
|
||||
const data = (await res.json()) as {
|
||||
server_jar?: boolean;
|
||||
adb_ok?: boolean;
|
||||
|
||||
Reference in New Issue
Block a user