Files
controller-v2/client/src/lib/deviceIp.ts
T

12 lines
455 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/** 从地址栏 ?ip= 读取设备 IPhash 路由下 query 仍在 search 上) */
export function getDeviceIpFromUrl(): string | null {
if (typeof window === "undefined") return null;
const ip = new URLSearchParams(window.location.search).get("ip");
const trimmed = ip?.trim();
return trimmed || null;
}
export function resolveInitialDeviceIp(): string {
return getDeviceIpFromUrl() ?? localStorage.getItem("luxsin_ip") ?? "192.168.2.30";
}