Enhance Vite configuration with custom input for rollup, update ConnectScreen to validate IP input before connection, and modify DeviceContext to support dynamic IP handling in LuxsinAPI. Adjust VUPage to use BASE_URL for image previews.
This commit is contained in:
@@ -165,6 +165,17 @@ export const FILTER_TYPE_LABELS = ["Low Pass", "High Pass", "Band Pass", "Notch"
|
||||
export const DAC_ARC_LABELS = ["ARC", "eARC"];
|
||||
export const BT_STATUS_LABELS = ["Disconnected", "Playing", "Paused"];
|
||||
|
||||
function resolveDeviceProtocol(): "http" | "https" {
|
||||
if (typeof window !== "undefined" && window.location.protocol === "https:") {
|
||||
return "https";
|
||||
}
|
||||
return "http";
|
||||
}
|
||||
|
||||
function normalizeDeviceHost(input: string): string {
|
||||
return input.trim().replace(/^https?:\/\//i, "").replace(/\/+$/, "");
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// API Class
|
||||
// ============================================================
|
||||
@@ -172,7 +183,9 @@ export class LuxsinAPI {
|
||||
private baseUrl: string;
|
||||
|
||||
constructor(ip: string) {
|
||||
this.baseUrl = `http://${ip}`;
|
||||
const host = normalizeDeviceHost(ip);
|
||||
const protocol = resolveDeviceProtocol();
|
||||
this.baseUrl = `${protocol}://${host}`;
|
||||
}
|
||||
|
||||
async getDeviceState(): Promise<DeviceState> {
|
||||
|
||||
Reference in New Issue
Block a user