mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-21 16:38:23 +01:00
74cda378f8
This will take the latest artifact from the waveterm-docs repo and embed it in the app binary. When the help view is launched, it will be served from our backend. If the embedded copy doesn't exist, such as in unpackaged versions of the app or in locally packaged versions, it will use the hosted site instead. There is a sibling PR in the docs repository to build the embedded version of the app (strips out some external links, removes Algolia DocSearch, updates the baseUrl) https://github.com/wavetermdev/waveterm-docs/pull/46
28 lines
966 B
TypeScript
28 lines
966 B
TypeScript
import { getWebServerEndpoint } from "@/util/endpoints";
|
|
import { fetch } from "@/util/fetchutil";
|
|
import { ipcMain } from "electron";
|
|
|
|
const docsiteWebUrl = "https://docs.waveterm.dev/";
|
|
let docsiteUrl: string;
|
|
|
|
ipcMain.on("get-docsite-url", (event) => {
|
|
event.returnValue = docsiteUrl;
|
|
});
|
|
|
|
export async function initDocsite() {
|
|
const docsiteEmbeddedUrl = getWebServerEndpoint() + "/docsite/";
|
|
try {
|
|
const response = await fetch(docsiteEmbeddedUrl);
|
|
if (response.ok) {
|
|
console.log("Embedded docsite is running, using embedded version for help view");
|
|
docsiteUrl = docsiteEmbeddedUrl;
|
|
} else {
|
|
console.log("Embedded docsite is not running, using web version for help view", response);
|
|
docsiteUrl = docsiteWebUrl;
|
|
}
|
|
} catch (error) {
|
|
console.log("Failed to fetch docsite url, using web version for help view", error);
|
|
docsiteUrl = docsiteWebUrl;
|
|
}
|
|
}
|