Refactor Vite configuration for improved chunking strategy and caching. Enhance DeviceContext with new upgradePeqChange method for PEQ updates. Update audio page to support localized labels and dynamic volume control. Introduce new filter types and improve EQPage functionality with enhanced frequency response visualization.

This commit is contained in:
yangy
2026-04-17 17:57:39 +08:00
parent 4246e8ce27
commit 0e7670c215
12 changed files with 1103 additions and 153 deletions
+51 -2
View File
@@ -37,7 +37,13 @@ export function decodeCustomBase64(encoded: string): string {
}
export function encodeCustomBase64(data: string): string {
const standard = btoa(data);
// btoa only supports Latin1; convert UTF-8 bytes to a binary string first.
const bytes = new TextEncoder().encode(data);
let binary = "";
for (let i = 0; i < bytes.length; i++) {
binary += String.fromCharCode(bytes[i]);
}
const standard = btoa(binary);
let translated = "";
for (let i = 0; i < standard.length; i++) {
const char = standard.charAt(i);
@@ -61,6 +67,8 @@ export interface DeviceState {
output: number;
audioFormat: string;
pcm: number;
hdmimutepolar: number;
hdmiType: number;
vu: number;
vuSensor: number;
vu_count: number;
@@ -115,12 +123,29 @@ export interface PeqFilter {
export interface PeqState {
filters: PeqFilter[];
peqSelect?: number;
peq?: Array<{
name: string;
filters?: PeqFilter[];
filters?: PeqFilter[] | string;
autoPre?: number;
preamp?: number;
canDel?: number;
brand?: string;
model?: string;
}>;
}
/** POST body for `/dev/info.cgi` — full peq preset update (custom base64 `json` field). */
export interface PeqChangePayload {
peqChange: {
name: string;
filters: PeqFilter[];
autoPre?: number;
preamp?: number;
canDel?: number;
};
}
// ============================================================
// Input/Output Labels
// ============================================================
@@ -183,6 +208,28 @@ export class LuxsinAPI {
});
}
/** Full peq preset: name, filters, autoPre, preamp, canDel — same encoding as legacy `upgradePeq`. */
async upgradePeqChange(body: PeqChangePayload): Promise<void> {
const payload = JSON.stringify(body);
const encoded = encodeCustomBase64(payload);
await fetch(`${this.baseUrl}/dev/info.cgi`, {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: `json=${encodeURIComponent(encoded)}`,
});
}
/** Remove one or more headphone PEQ profiles. */
async removePeq(names: string[]): Promise<void> {
const payload = JSON.stringify({ peqRemove: names });
const encoded = encodeCustomBase64(payload);
await fetch(`${this.baseUrl}/dev/info.cgi`, {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" },
body: `json=${encodeURIComponent(encoded)}`,
});
}
setVolume(volume: number) { return this.setSetting({ volume }); }
setInput(input: number) { return this.setSetting({ input }); }
setOutput(output: number) { return this.setSetting({ output }); }
@@ -227,6 +274,8 @@ export const MOCK_DEVICE_STATE: DeviceState = {
output: 0,
audioFormat: "PCM 44.1 KHz",
pcm: 1,
hdmimutepolar: 0,
hdmiType: 0,
vu: 0,
vuSensor: 0,
vu_count: 5,