分享码功能的实现,并修复了几个 bug

This commit is contained in:
eafonyang
2026-06-15 18:00:06 +08:00
parent b620805e13
commit b421fe1ca3
12 changed files with 756 additions and 222 deletions
+18 -8
View File
@@ -30,6 +30,7 @@ import {
} from "@/lib/aiApi";
import { buildPeqSvgCurveData, getFilterType, PeqBandForResponse } from "@/lib/peqAudio";
import { buildPeqPresetBody } from "@/lib/luxsinApi";
import { cn } from "@/lib/utils";
import {
ArrowUp,
@@ -622,6 +623,8 @@ export default function AIPage({ variant = "page", onClose }: AIPageProps = {})
autoPre: selected?.autoPre,
brand: selected?.brand,
model: selected?.model,
target: selected?.target,
form: selected?.form,
filters: (selectedFilters ?? peqState.filters ?? []) as OptimizePeqPayload["filters"],
});
} catch {
@@ -641,21 +644,28 @@ export default function AIPage({ variant = "page", onClose }: AIPageProps = {})
}
const nextApplied = !msg.applied;
const targetPeq = nextApplied ? msg.afterPeq : msg.beforePeq;
const metaSource = currentDevicePeq ?? targetPeq;
setApplyingId(msg.id);
try {
await api.upgradePeqChange({
peqChange: {
name: targetPeq.name ?? msg.name,
filters: (targetPeq.filters ?? []).map((f) => ({
peqChange: buildPeqPresetBody(
{
name: targetPeq.name ?? msg.name ?? metaSource?.name ?? "",
brand: targetPeq.brand ?? metaSource?.brand,
model: targetPeq.model ?? metaSource?.model,
target: targetPeq.target ?? metaSource?.target,
form: targetPeq.form ?? metaSource?.form,
autoPre: targetPeq.autoPre ?? metaSource?.autoPre,
preamp: targetPeq.preamp ?? metaSource?.preamp,
canDel: targetPeq.canDel ?? metaSource?.canDel,
},
(targetPeq.filters ?? []).map((f) => ({
type: getFilterType(f.type),
fc: (f.fc ?? f.frequency ?? 1000) as number,
gain: f.gain,
q: f.q,
})),
autoPre: targetPeq.autoPre,
preamp: targetPeq.preamp,
canDel: targetPeq.canDel,
},
),
});
await updateMessageApplied(msg.id, nextApplied);
await api.refreshState();
@@ -679,7 +689,7 @@ export default function AIPage({ variant = "page", onClose }: AIPageProps = {})
setApplyingId(null);
}
},
[aiText, api, refreshCurrentDevicePeq],
[aiText, api, currentDevicePeq, refreshCurrentDevicePeq],
);
const openCompare = useCallback(