mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-11-20 20:05:34 +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]) {
|
||||
if (!res[0]) {
|
||||
const result = await tinymist.executeCommand("tinymist.getDocumentMetrics", [focusingFile]);
|
||||
if (!result) {
|
||||
return;
|
||||
if (result) {
|
||||
const docMetrics = JSON.stringify(result);
|
||||
res[0] = docMetrics;
|
||||
}
|
||||
const docMetrics = JSON.stringify(result);
|
||||
res[0] = docMetrics;
|
||||
}
|
||||
|
||||
if (!res[1]) {
|
||||
const result2 = await tinymist.executeCommand("tinymist.getServerInfo", []);
|
||||
if (!result2) {
|
||||
return;
|
||||
if (result2) {
|
||||
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 [docMetrics, serverInfo] = await fetchSummaryInfo();
|
||||
|
||||
if (!docMetrics || !serverInfo) {
|
||||
if (!docMetrics) {
|
||||
vscode.window.showErrorMessage("No document metrics available");
|
||||
}
|
||||
if (!serverInfo) {
|
||||
vscode.window.showErrorMessage("No server info");
|
||||
}
|
||||
|
||||
return;
|
||||
if (!docMetrics) {
|
||||
vscode.window.showWarningMessage("No document metrics available");
|
||||
}
|
||||
if (!serverInfo) {
|
||||
vscode.window.showWarningMessage("No server info");
|
||||
}
|
||||
|
||||
return substituteTemplateString(html, {
|
||||
":[[preview:FontsExportConfigure]]:": fontsExportConfig,
|
||||
":[[preview:DocumentMetrics]]:": docMetrics,
|
||||
":[[preview:ServerInfo]]:": serverInfo,
|
||||
":[[preview:DocumentMetrics]]:": docMetrics ?? "null",
|
||||
":[[preview:ServerInfo]]:": serverInfo ?? "null",
|
||||
});
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -20,12 +20,19 @@ type ServerInfoMap = Record<string, ServerInfo>;
|
|||
export const Summary = () => {
|
||||
const documentMetricsData = `:[[preview: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);
|
||||
const serverInfoData = `:[[preview:ServerInfo]]:`;
|
||||
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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue