|
2 | 2 | // SPDX-License-Identifier: Apache-2.0 |
3 | 3 |
|
4 | 4 | import { BlockNodeModel } from "@/app/block/blocktypes"; |
5 | | -import { getApi, globalStore, WOS } from "@/app/store/global"; |
| 5 | +import { globalStore, WOS } from "@/app/store/global"; |
6 | 6 | import { RpcApi } from "@/app/store/wshclientapi"; |
7 | 7 | import { TabRpcClient } from "@/app/store/wshrpcutil"; |
8 | 8 | import { WebView, WebViewModel } from "@/app/view/webview/webview"; |
9 | | -import { fireAndForget } from "@/util/util"; |
10 | | -import { atom, useAtomValue } from "jotai"; |
11 | | -import { useCallback } from "react"; |
| 9 | +import { atom } from "jotai"; |
12 | 10 |
|
13 | | -const docsiteWebUrl = "https://docs.waveterm.dev/"; |
14 | | -const baseUrlRegex = /http[s]?:\/\/([^:\/])+(:\d+)?/; |
| 11 | +const docsiteUrl = "https://docs.waveterm.dev/?ref=app"; |
15 | 12 |
|
16 | 13 | class HelpViewModel extends WebViewModel { |
17 | 14 | get viewComponent(): ViewComponent { |
@@ -44,24 +41,10 @@ class HelpViewModel extends WebViewModel { |
44 | 41 | }, |
45 | 42 | ]; |
46 | 43 | }); |
47 | | - this.homepageUrl = atom(getApi().getDocsiteUrl()); |
| 44 | + this.homepageUrl = atom(docsiteUrl); |
48 | 45 | this.viewType = "help"; |
49 | 46 | this.viewIcon = atom("circle-question"); |
50 | 47 | this.viewName = atom("Help"); |
51 | | - |
52 | | - /* |
53 | | - Add callback to take the current embedded docsite url and return the equivalent page in the public docsite. |
54 | | - The port used by the embedded docsite changes every time the app runs and the current page may be cached from a previous run so we can't trust that it matches the current embedded url. |
55 | | - We have a regex at the top of this file that can extract the base part of the url (i.e. http://127.0.0.1:53288). We'll use this regex to strip the base part of the url from both the current |
56 | | - page and the embedded docsite url. Because we host the embedded docsite at a subdirectory, we also need to strip that (hence the second replace). Then, we can build the public url from whatever's left. |
57 | | - */ |
58 | | - this.modifyExternalUrl = (url: string) => { |
59 | | - const strippedDocsiteUrl = getApi().getDocsiteUrl().replace(baseUrlRegex, ""); |
60 | | - const strippedCurUrl = url.replace(baseUrlRegex, "").replace(strippedDocsiteUrl, ""); |
61 | | - const newUrl = docsiteWebUrl + strippedCurUrl; |
62 | | - console.log("modify-external-url", url, newUrl); |
63 | | - return newUrl; |
64 | | - }; |
65 | 48 | } |
66 | 49 |
|
67 | 50 | setZoomFactor(factor: number | null) { |
@@ -141,32 +124,9 @@ class HelpViewModel extends WebViewModel { |
141 | 124 | } |
142 | 125 |
|
143 | 126 | function HelpView(props: ViewComponentProps<HelpViewModel>) { |
144 | | - const model = props.model; |
145 | | - const homepageUrl = useAtomValue(model.homepageUrl); |
146 | | - |
147 | | - // Effect to update the docsite base url when the app restarts, since the webserver port is dynamic |
148 | | - const onFailLoad = useCallback( |
149 | | - (url: string) => |
150 | | - fireAndForget(async () => { |
151 | | - const newDocsiteUrl = getApi().getDocsiteUrl(); |
152 | | - |
153 | | - // Correct the homepage URL, if necessary |
154 | | - if (newDocsiteUrl !== homepageUrl) { |
155 | | - await model.setHomepageUrl(newDocsiteUrl, "block"); |
156 | | - } |
157 | | - |
158 | | - // Correct the base URL of the current page, if necessary |
159 | | - const newBaseUrl = baseUrlRegex.exec(newDocsiteUrl)?.[0]; |
160 | | - const curBaseUrl = baseUrlRegex.exec(url)?.[0]; |
161 | | - if (curBaseUrl && newBaseUrl && curBaseUrl !== newBaseUrl) { |
162 | | - model.loadUrl(url.replace(curBaseUrl, newBaseUrl), "fix-fail-load"); |
163 | | - } |
164 | | - }), |
165 | | - [homepageUrl] |
166 | | - ); |
167 | 127 | return ( |
168 | 128 | <div className="w-full h-full"> |
169 | | - <WebView {...props} onFailLoad={onFailLoad} /> |
| 129 | + <WebView {...props} /> |
170 | 130 | </div> |
171 | 131 | ); |
172 | 132 | } |
|
0 commit comments