This commit is contained in:
eric
2026-03-29 00:34:53 -05:00
parent e0b3ac43fc
commit af927c6dca
8 changed files with 1281 additions and 21 deletions

View File

@@ -3,6 +3,7 @@
import { type ChangeEvent, type MouseEvent, useCallback, useEffect, useMemo, useState } from "react";
import OverviewCharts from "@/components/OverviewCharts";
import { ConfigAdvisorPanel } from "@/components/console/ConfigAdvisorPanel";
import { normalizeBrowserReachableHttpUrl } from "@/lib/panelUrls";
type Lang = "zh" | "en";
@@ -236,6 +237,7 @@ export function LiveConsoleWorkspace() {
const [previewMode, setPreviewMode] = useState<PreviewMode>("tap");
const [previewPoint, setPreviewPoint] = useState<{ x: number; y: number } | null>(null);
const [fileImportKey, setFileImportKey] = useState(0);
const [configInsightVersion, setConfigInsightVersion] = useState(0);
const [shotObjectUrl, setShotObjectUrl] = useState<string | null>(null);
const [shotFetchErr, setShotFetchErr] = useState<string | null>(null);
const [shotLoading, setShotLoading] = useState(false);
@@ -642,6 +644,7 @@ export function LiveConsoleWorkspace() {
});
notify(tr("文件已保存", "File saved"));
await refreshFiles(rootId, filePath);
setConfigInsightVersion((value) => value + 1);
} catch (reason) {
notify((reason as Error).message);
} finally {
@@ -665,6 +668,7 @@ export function LiveConsoleWorkspace() {
});
notify(tr("文件已创建", "File created"));
await refreshFiles(rootId, nextPath);
setConfigInsightVersion((value) => value + 1);
} catch (reason) {
notify((reason as Error).message);
} finally {
@@ -687,6 +691,7 @@ export function LiveConsoleWorkspace() {
);
notify(tr("文件已删除", "File deleted"));
await refreshFiles(rootId);
setConfigInsightVersion((value) => value + 1);
} catch (reason) {
notify((reason as Error).message);
} finally {
@@ -711,6 +716,7 @@ export function LiveConsoleWorkspace() {
notify(tr("导入完成,已替换同名文件", "Import finished and replaced matching file"));
setFilePath(upload.name);
await refreshFiles(rootId, upload.name);
setConfigInsightVersion((value) => value + 1);
} catch (reason) {
notify((reason as Error).message);
} finally {
@@ -1518,6 +1524,20 @@ export function LiveConsoleWorkspace() {
</div>
</div>
<div className="mt-4 rounded-2xl border border-white/8 bg-black/20 px-4 py-3 font-mono text-[11px] text-slate-500">{filePath ? `${rootId} / ${filePath}` : tr("请选择文件", "Pick a file")}</div>
<div className="mt-4">
<ConfigAdvisorPanel
lang={lang}
rootId={rootId}
filePath={filePath}
fileContent={fileContent}
refreshKey={configInsightVersion}
busy={busy}
fetchJson={fetchJson}
notify={notify}
onChangeContent={setFileContent}
onRefreshListing={() => refreshFiles(rootId, filePath)}
/>
</div>
<textarea className="log-scroll mt-4 min-h-[32rem] w-full resize-y rounded-2xl border border-white/10 bg-black/45 p-4 font-mono text-xs leading-relaxed text-slate-200" spellCheck={false} value={fileContent} onChange={(event) => setFileContent(event.target.value)} />
</article>
</section>