12 lines
455 B
TypeScript
12 lines
455 B
TypeScript
|
|
/** 从地址栏 ?ip= 读取设备 IP(hash 路由下 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";
|
|||
|
|
}
|