mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-11-23 12:46:43 +00:00
feat: better summary
This commit is contained in:
parent
3a81ed2e55
commit
19be3bc81b
2 changed files with 22 additions and 21 deletions
|
|
@ -109,20 +109,18 @@ async function fetchSummaryInfo(): Promise<[string | undefined, string | undefin
|
||||||
async function work(focusingFile: string, res: [string | undefined, string | undefined]) {
|
async function work(focusingFile: string, res: [string | undefined, string | undefined]) {
|
||||||
if (!res[0]) {
|
if (!res[0]) {
|
||||||
const result = await tinymist.executeCommand("tinymist.getDocumentMetrics", [focusingFile]);
|
const result = await tinymist.executeCommand("tinymist.getDocumentMetrics", [focusingFile]);
|
||||||
if (!result) {
|
if (result) {
|
||||||
return;
|
const docMetrics = JSON.stringify(result);
|
||||||
|
res[0] = docMetrics;
|
||||||
}
|
}
|
||||||
const docMetrics = JSON.stringify(result);
|
|
||||||
res[0] = docMetrics;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!res[1]) {
|
if (!res[1]) {
|
||||||
const result2 = await tinymist.executeCommand("tinymist.getServerInfo", []);
|
const result2 = await tinymist.executeCommand("tinymist.getServerInfo", []);
|
||||||
if (!result2) {
|
if (result2) {
|
||||||
return;
|
const serverInfo = JSON.stringify(result2);
|
||||||
|
res[1] = serverInfo;
|
||||||
}
|
}
|
||||||
const serverInfo = JSON.stringify(result2);
|
|
||||||
res[1] = serverInfo;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -144,21 +142,17 @@ export default defineEditorTool({
|
||||||
const fontsExportConfig = JSON.stringify(fontsExportConfigure.data);
|
const fontsExportConfig = JSON.stringify(fontsExportConfigure.data);
|
||||||
const [docMetrics, serverInfo] = await fetchSummaryInfo();
|
const [docMetrics, serverInfo] = await fetchSummaryInfo();
|
||||||
|
|
||||||
if (!docMetrics || !serverInfo) {
|
if (!docMetrics) {
|
||||||
if (!docMetrics) {
|
vscode.window.showWarningMessage("No document metrics available");
|
||||||
vscode.window.showErrorMessage("No document metrics available");
|
}
|
||||||
}
|
if (!serverInfo) {
|
||||||
if (!serverInfo) {
|
vscode.window.showWarningMessage("No server info");
|
||||||
vscode.window.showErrorMessage("No server info");
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return substituteTemplateString(html, {
|
return substituteTemplateString(html, {
|
||||||
":[[preview:FontsExportConfigure]]:": fontsExportConfig,
|
":[[preview:FontsExportConfigure]]:": fontsExportConfig,
|
||||||
":[[preview:DocumentMetrics]]:": docMetrics,
|
":[[preview:DocumentMetrics]]:": docMetrics ?? "null",
|
||||||
":[[preview:ServerInfo]]:": serverInfo,
|
":[[preview:ServerInfo]]:": serverInfo ?? "null",
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,19 @@ type ServerInfoMap = Record<string, ServerInfo>;
|
||||||
export const Summary = () => {
|
export const Summary = () => {
|
||||||
const documentMetricsData = `:[[preview:DocumentMetrics]]:`;
|
const documentMetricsData = `:[[preview:DocumentMetrics]]:`;
|
||||||
const docMetrics = van.state<DocumentMetrics>(
|
const docMetrics = van.state<DocumentMetrics>(
|
||||||
documentMetricsData.startsWith(":") ? DOC_MOCK : JSON.parse(base64Decode(documentMetricsData)),
|
(documentMetricsData.startsWith(":")
|
||||||
|
? DOC_MOCK
|
||||||
|
: JSON.parse(base64Decode(documentMetricsData))) || {
|
||||||
|
fontInfo: [],
|
||||||
|
spanInfo: { sources: [] },
|
||||||
|
},
|
||||||
);
|
);
|
||||||
console.log("docMetrics", docMetrics);
|
console.log("docMetrics", docMetrics);
|
||||||
const serverInfoData = `:[[preview:ServerInfo]]:`;
|
const serverInfoData = `:[[preview:ServerInfo]]:`;
|
||||||
const serverInfos = van.state<ServerInfoMap>(
|
const serverInfos = van.state<ServerInfoMap>(
|
||||||
serverInfoData.startsWith(":") ? SERVER_INFO_MOCK : JSON.parse(base64Decode(serverInfoData)),
|
(serverInfoData.startsWith(":")
|
||||||
|
? SERVER_INFO_MOCK
|
||||||
|
: JSON.parse(base64Decode(serverInfoData))) || {},
|
||||||
);
|
);
|
||||||
console.log("serverInfos", serverInfos);
|
console.log("serverInfos", serverInfos);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue