From 4f3410f4f1cfd0eb9737b8ae6fb5c401e4467974 Mon Sep 17 00:00:00 2001 From: Ted <2508067350@qq.com> Date: Wed, 19 Feb 2025 10:27:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5OME=20Office=20APP=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/components/home.tsx | 27 ++++++++++++++++++++++++++- app/components/settings.tsx | 2 +- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/app/components/home.tsx b/app/components/home.tsx index 16e33c763..1c0a9a528 100644 --- a/app/components/home.tsx +++ b/app/components/home.tsx @@ -30,7 +30,7 @@ import { type ClientApi, getClientApi } from "../client/api"; import { useAccessStore } from "../store"; import clsx from "clsx"; import { initializeMcpSystem, isMcpEnabled } from "../mcp/actions"; -import { isEmpty } from "lodash-es"; +import { isEmpty, isString } from "lodash-es"; export function Loading(props: { noLogo?: boolean }) { return ( @@ -264,7 +264,32 @@ export function Home() { useEffect(() => { window.parent.postMessage("omemetis is ready", "*"); + try { + const message = { + data: "omemetis is ready", + url: location.origin, + }; + + window.ReactNativeWebView.postMessage(JSON.stringify(message)); + } catch { + console.log("window.ReactNativeWebView Err"); + } + const handleMessage = (event: any) => { + const data = event.data; + + if (isString(data)) { + try { + const params = JSON.parse(data); + + if (!isEmpty(params?.omeToken) && params?.from === "OmeOfficeApp") + appConfig.setOmeToken(params?.omeToken ?? ""); + } catch {} + + return; + } + + // 逻辑判断 是对象还是字符串 if (!event.origin.includes("omeoffice")) { return; // 如果不是信任的源,忽略消息 } diff --git a/app/components/settings.tsx b/app/components/settings.tsx index 68ebcf084..0f9386397 100644 --- a/app/components/settings.tsx +++ b/app/components/settings.tsx @@ -1775,7 +1775,7 @@ export function Settings() { - {saasStartComponent} + {/* {saasStartComponent} */} {accessCodeComponent} {!accessStore.hideUserApiKey && (