chore(config): 新增 WebRTC 信令地址环境变量,放宽 pnpm 版本约束并移除 overrides
This commit is contained in:
1 parent
e49473758c
commit
2bd5b89380
7 files changed
+419
-15
No files matched your search
@@ -0,0 +1,18 @@
|
||||
import request from "@/utils/request";
|
||||
|
||||
export async function openRemoteControlSignal(sn: string) {
|
||||
const defaultUrl = new URL(
|
||||
"/ws/signal",
|
||||
import.meta.env.VITE_APP_API_URL || window.location.origin,
|
||||
);
|
||||
if (defaultUrl.protocol === "https:") defaultUrl.protocol = "wss:";
|
||||
const url = new URL(import.meta.env.VITE_WEBRTC_SIGNAL_URL || defaultUrl.href);
|
||||
if (url.protocol !== "wss:") throw new Error("远程协助需要 WSS 信令服务器");
|
||||
const ticket = await request<unknown, string>({
|
||||
url: "/api/v1/device/remote-control/ticket",
|
||||
method: "post",
|
||||
params: { sn },
|
||||
});
|
||||
url.searchParams.set("ticket", ticket);
|
||||
return new WebSocket(url);
|
||||
}
|
||||
Reference in new issue
Block a user