mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-17 20:51:55 +01:00
Rename endpoint functions
This commit is contained in:
parent
8971e2feba
commit
4d29dd5b5f
@ -14,7 +14,7 @@ import * as services from "../frontend/app/store/services";
|
|||||||
import * as keyutil from "../frontend/util/keyutil";
|
import * as keyutil from "../frontend/util/keyutil";
|
||||||
import { fireAndForget } from "../frontend/util/util";
|
import { fireAndForget } from "../frontend/util/util";
|
||||||
|
|
||||||
import { getServerWebEndpoint, WebServerEndpointVarName, WSServerEndpointVarName } from "@/util/endpoints";
|
import { getWebServerEndpoint, WebServerEndpointVarName, WSServerEndpointVarName } from "@/util/endpoints";
|
||||||
import { WaveDevVarName, WaveDevViteVarName } from "@/util/isdev";
|
import { WaveDevVarName, WaveDevViteVarName } from "@/util/isdev";
|
||||||
import { sprintf } from "sprintf-js";
|
import { sprintf } from "sprintf-js";
|
||||||
const electronApp = electron.app;
|
const electronApp = electron.app;
|
||||||
@ -268,7 +268,7 @@ function shFrameNavHandler(event: Electron.Event<Electron.WebContentsWillFrameNa
|
|||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
event.frame.name == "pdfview" &&
|
event.frame.name == "pdfview" &&
|
||||||
(url.startsWith("blob:file:///") || url.startsWith(getServerWebEndpoint() + "/wave/stream-file?"))
|
(url.startsWith("blob:file:///") || url.startsWith(getWebServerEndpoint() + "/wave/stream-file?"))
|
||||||
) {
|
) {
|
||||||
// allowed
|
// allowed
|
||||||
return;
|
return;
|
||||||
@ -480,7 +480,7 @@ electron.ipcMain.on("open-external", (event, url) => {
|
|||||||
|
|
||||||
electron.ipcMain.on("download", (event, payload) => {
|
electron.ipcMain.on("download", (event, payload) => {
|
||||||
const window = electron.BrowserWindow.fromWebContents(event.sender);
|
const window = electron.BrowserWindow.fromWebContents(event.sender);
|
||||||
const streamingUrl = getServerWebEndpoint() + "/wave/stream-file?path=" + encodeURIComponent(payload.filePath);
|
const streamingUrl = getWebServerEndpoint() + "/wave/stream-file?path=" + encodeURIComponent(payload.filePath);
|
||||||
window.webContents.downloadURL(streamingUrl);
|
window.webContents.downloadURL(streamingUrl);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import { getLayoutStateAtomForTab } from "@/faraday/lib/layoutAtom";
|
|||||||
import { layoutTreeStateReducer } from "@/faraday/lib/layoutState";
|
import { layoutTreeStateReducer } from "@/faraday/lib/layoutState";
|
||||||
|
|
||||||
import { handleIncomingRpcMessage } from "@/app/store/wshrpc";
|
import { handleIncomingRpcMessage } from "@/app/store/wshrpc";
|
||||||
import { getServerWebEndpoint, getServerWSEndpoint } from "@/util/endpoints";
|
import { getWSServerEndpoint, getWebServerEndpoint } from "@/util/endpoints";
|
||||||
import * as layoututil from "@/util/layoututil";
|
import * as layoututil from "@/util/layoututil";
|
||||||
import { produce } from "immer";
|
import { produce } from "immer";
|
||||||
import * as jotai from "jotai";
|
import * as jotai from "jotai";
|
||||||
@ -270,7 +270,7 @@ function handleWSMessage(msg: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function initWS() {
|
function initWS() {
|
||||||
globalWS = new WSControl(getServerWSEndpoint(), globalStore, globalWindowId, "", (msg) => {
|
globalWS = new WSControl(getWSServerEndpoint(), globalStore, globalWindowId, "", (msg) => {
|
||||||
handleWSMessage(msg);
|
handleWSMessage(msg);
|
||||||
});
|
});
|
||||||
globalWS.connectNow("initWS");
|
globalWS.connectNow("initWS");
|
||||||
@ -324,7 +324,7 @@ async function fetchWaveFile(
|
|||||||
if (offset != null) {
|
if (offset != null) {
|
||||||
usp.set("offset", offset.toString());
|
usp.set("offset", offset.toString());
|
||||||
}
|
}
|
||||||
const resp = await fetch(getServerWebEndpoint() + "/wave/file?" + usp.toString());
|
const resp = await fetch(getWebServerEndpoint() + "/wave/file?" + usp.toString());
|
||||||
if (!resp.ok) {
|
if (!resp.ok) {
|
||||||
if (resp.status === 404) {
|
if (resp.status === 404) {
|
||||||
return { data: null, fileInfo: null };
|
return { data: null, fileInfo: null };
|
||||||
@ -367,6 +367,8 @@ function getObjectId(obj: any): number {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
PLATFORM,
|
||||||
|
WOS,
|
||||||
atoms,
|
atoms,
|
||||||
createBlock,
|
createBlock,
|
||||||
fetchWaveFile,
|
fetchWaveFile,
|
||||||
@ -378,12 +380,10 @@ export {
|
|||||||
globalStore,
|
globalStore,
|
||||||
globalWS,
|
globalWS,
|
||||||
initWS,
|
initWS,
|
||||||
PLATFORM,
|
|
||||||
sendWSCommand,
|
sendWSCommand,
|
||||||
setBlockFocus,
|
setBlockFocus,
|
||||||
setPlatform,
|
setPlatform,
|
||||||
useBlockAtom,
|
useBlockAtom,
|
||||||
useBlockCache,
|
useBlockCache,
|
||||||
useSettingsAtom,
|
useSettingsAtom,
|
||||||
WOS,
|
|
||||||
};
|
};
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
// WaveObjectStore
|
// WaveObjectStore
|
||||||
|
|
||||||
import { sendRpcCommand } from "@/app/store/wshrpc";
|
import { sendRpcCommand } from "@/app/store/wshrpc";
|
||||||
import { getServerWebEndpoint } from "@/util/endpoints";
|
import { getWebServerEndpoint } from "@/util/endpoints";
|
||||||
import * as jotai from "jotai";
|
import * as jotai from "jotai";
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { v4 as uuidv4 } from "uuid";
|
import { v4 as uuidv4 } from "uuid";
|
||||||
@ -79,7 +79,7 @@ function callBackendService(service: string, method: string, args: any[], noUICo
|
|||||||
const usp = new URLSearchParams();
|
const usp = new URLSearchParams();
|
||||||
usp.set("service", service);
|
usp.set("service", service);
|
||||||
usp.set("method", method);
|
usp.set("method", method);
|
||||||
const url = getServerWebEndpoint() + "/wave/service?" + usp.toString();
|
const url = getWebServerEndpoint() + "/wave/service?" + usp.toString();
|
||||||
const fetchPromise = fetch(url, {
|
const fetchPromise = fetch(url, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify(waveCall),
|
body: JSON.stringify(waveCall),
|
||||||
|
@ -6,7 +6,7 @@ import { Markdown } from "@/element/markdown";
|
|||||||
import { globalStore, useBlockAtom } from "@/store/global";
|
import { globalStore, useBlockAtom } from "@/store/global";
|
||||||
import * as services from "@/store/services";
|
import * as services from "@/store/services";
|
||||||
import * as WOS from "@/store/wos";
|
import * as WOS from "@/store/wos";
|
||||||
import { getServerWebEndpoint } from "@/util/endpoints";
|
import { getWebServerEndpoint } from "@/util/endpoints";
|
||||||
import * as util from "@/util/util";
|
import * as util from "@/util/util";
|
||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
import * as jotai from "jotai";
|
import * as jotai from "jotai";
|
||||||
@ -275,7 +275,7 @@ function MarkdownPreview({ contentAtom }: { contentAtom: jotai.Atom<Promise<stri
|
|||||||
|
|
||||||
function StreamingPreview({ fileInfo }: { fileInfo: FileInfo }) {
|
function StreamingPreview({ fileInfo }: { fileInfo: FileInfo }) {
|
||||||
const filePath = fileInfo.path;
|
const filePath = fileInfo.path;
|
||||||
const streamingUrl = getServerWebEndpoint() + "/wave/stream-file?path=" + encodeURIComponent(filePath);
|
const streamingUrl = getWebServerEndpoint() + "/wave/stream-file?path=" + encodeURIComponent(filePath);
|
||||||
if (fileInfo.mimetype == "application/pdf") {
|
if (fileInfo.mimetype == "application/pdf") {
|
||||||
return (
|
return (
|
||||||
<div className="view-preview view-preview-pdf">
|
<div className="view-preview view-preview-pdf">
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
import { WshServer } from "@/app/store/wshserver";
|
import { WshServer } from "@/app/store/wshserver";
|
||||||
import { createBlock } from "@/store/global";
|
import { createBlock } from "@/store/global";
|
||||||
import { getServerWebEndpoint } from "@/util/endpoints";
|
import { getWebServerEndpoint } from "@/util/endpoints";
|
||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
import * as jotai from "jotai";
|
import * as jotai from "jotai";
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
@ -117,7 +117,7 @@ function TermSticker({ sticker, config }: { sticker: StickerType; config: Sticke
|
|||||||
if (sticker.imgsrc == null) {
|
if (sticker.imgsrc == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const streamingUrl = getServerWebEndpoint() + "/wave/stream-file?path=" + encodeURIComponent(sticker.imgsrc);
|
const streamingUrl = getWebServerEndpoint() + "/wave/stream-file?path=" + encodeURIComponent(sticker.imgsrc);
|
||||||
return (
|
return (
|
||||||
<div className="term-sticker term-sticker-image" style={style} onClick={clickHandler}>
|
<div className="term-sticker term-sticker-image" style={style} onClick={clickHandler}>
|
||||||
<img src={streamingUrl} />
|
<img src={streamingUrl} />
|
||||||
|
@ -4,6 +4,6 @@ import { lazy } from "./util";
|
|||||||
export const WebServerEndpointVarName = "WAVE_SERVER_WEB_ENDPOINT";
|
export const WebServerEndpointVarName = "WAVE_SERVER_WEB_ENDPOINT";
|
||||||
export const WSServerEndpointVarName = "WAVE_SERVER_WS_ENDPOINT";
|
export const WSServerEndpointVarName = "WAVE_SERVER_WS_ENDPOINT";
|
||||||
|
|
||||||
export const getServerWebEndpoint = lazy(() => `http://${getEnv(WebServerEndpointVarName)}`);
|
export const getWebServerEndpoint = lazy(() => `http://${getEnv(WebServerEndpointVarName)}`);
|
||||||
|
|
||||||
export const getServerWSEndpoint = lazy(() => `ws://${getEnv(WSServerEndpointVarName)}`);
|
export const getWSServerEndpoint = lazy(() => `ws://${getEnv(WSServerEndpointVarName)}`);
|
||||||
|
Loading…
Reference in New Issue
Block a user