fix(frontend): stop chart svg height warnings and idle consult status 404s
This commit is contained in:
@@ -67,7 +67,11 @@ export async function GET(request: Request) {
|
||||
if (error) {
|
||||
return NextResponse.json({ error: "暂时无法读取咨询状态" }, { status: 503 });
|
||||
}
|
||||
if (!data || typeof data.session_id !== "string") {
|
||||
if (activeLookup) {
|
||||
if (!data || typeof data.session_id !== "string") {
|
||||
return new NextResponse(null, { status: 204 });
|
||||
}
|
||||
} else if (!data || typeof data.session_id !== "string") {
|
||||
return NextResponse.json({ error: "咨询请求不存在" }, { status: 404 });
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@ export function WesternWheelSvg({ western: suppliedWestern, skeleton = false }:
|
||||
<svg
|
||||
viewBox={`0 0 ${SIZE} ${SIZE}`}
|
||||
width="100%"
|
||||
height="auto"
|
||||
role="img"
|
||||
aria-label={skeleton ? undefined : "回归黄道本命盘,上升在左,宫位按 Placidus"}
|
||||
aria-hidden={skeleton || undefined}
|
||||
|
||||
@@ -299,7 +299,6 @@ export function VedicChartSvgDrawing({ chart: suppliedChart, ariaLabel, highligh
|
||||
<svg
|
||||
viewBox={`0 0 ${CHART_VIEWBOX_WIDTH} ${viewBoxHeight}`}
|
||||
width="100%"
|
||||
height="auto"
|
||||
role="img"
|
||||
aria-label={ariaLabel}
|
||||
data-skeleton={skeleton ? "true" : undefined}
|
||||
|
||||
@@ -585,8 +585,8 @@ export async function fetchConsultationStatus(sessionId: string, requestId: stri
|
||||
|
||||
export async function fetchActiveConsultationStatus(signal?: AbortSignal): Promise<ConsultationStatus | null> {
|
||||
const response = await fetch("/api/consult/status", { signal, cache: "no-store" });
|
||||
if (response.status === 204 || response.status === 404) return null;
|
||||
const payload: unknown = await response.json().catch(() => null);
|
||||
if (response.status === 404) return null;
|
||||
if (!response.ok) throw new Error(payloadMessage(payload, "暂时无法恢复后台回答"));
|
||||
const status = parseConsultationStatus(payload);
|
||||
if (status.status !== "reserved") throw new Error("后台回答状态无效");
|
||||
|
||||
@@ -34,8 +34,7 @@ export function reportChartExportSvg(chart: NorthIndianChartModel, ariaLabel: st
|
||||
const rendered = serializeSvgNode(VedicChartSvgDrawing({ chart, ariaLabel, chartId: "export-chart" }))
|
||||
.replace(/<defs>[\s\S]*?<\/defs>/g, "")
|
||||
.replace(/ clip-path="[^"]*"/g, "")
|
||||
.replace(/<svg\b/, '<svg xmlns="http://www.w3.org/2000/svg"')
|
||||
.replace(/height="auto"/, 'height="452"')
|
||||
.replace(/<svg\b/, '<svg xmlns="http://www.w3.org/2000/svg" height="452"')
|
||||
.replace(/class="([^"]*)"/g, (_match, classes: string) => {
|
||||
if (classes.includes("personal-report-chart-cell")) return 'fill="none" stroke="currentColor" stroke-width="1.25"';
|
||||
if (classes.includes("personal-report-chart-retrograde")) return 'stroke="currentColor" stroke-width="1.9"';
|
||||
|
||||
Reference in New Issue
Block a user