Merge pull request #4 from SolarifyDev/access-ome-office-app

接入OME Office APP数据
This commit is contained in:
Ted 2025-02-21 16:39:00 +08:00 committed by GitHub
commit 521b0c2fbd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 84 additions and 57 deletions

View File

@ -13,7 +13,6 @@ import SendWhiteIcon from "../icons/send-white.svg";
import BrainIcon from "../icons/brain.svg";
import RenameIcon from "../icons/rename.svg";
import EditIcon from "../icons/rename.svg";
import ExportIcon from "../icons/share.svg";
import ReturnIcon from "../icons/return.svg";
import CopyIcon from "../icons/copy.svg";
import SpeakIcon from "../icons/speak.svg";
@ -1283,6 +1282,7 @@ function _Chat() {
});
};
const appstore = useAppConfig();
const accessStore = useAccessStore();
const [speechStatus, setSpeechStatus] = useState(false);
const [speechLoading, setSpeechLoading] = useState(false);
@ -1340,7 +1340,10 @@ function _Chat() {
) {
const copiedHello = Object.assign({}, BOT_HELLO);
if (!accessStore.isAuthorized()) {
copiedHello.content = Locale.Error.Unauthorized;
if (!isEmpty(appstore.omeToken)) {
} else {
copiedHello.content = Locale.Error.Unauthorized;
}
}
context.push(copiedHello);
}
@ -1569,6 +1572,7 @@ function _Chat() {
const imagesData: string[] = [];
for (let i = 0; i < files.length; i++) {
const file = event.target.files[i];
console.log("file", file);
uploadImageRemote(file)
.then((dataUrl) => {
imagesData.push(dataUrl);
@ -1735,7 +1739,7 @@ function _Chat() {
/>
</div>
)}
<div className="window-action-button">
{/* <div className="window-action-button">
<IconButton
icon={<ExportIcon />}
bordered
@ -1744,7 +1748,7 @@ function _Chat() {
setShowExport(true);
}}
/>
</div>
</div> */}
{showMaxIcon && (
<div className="window-action-button">
<IconButton

View File

@ -262,15 +262,42 @@ export function Home() {
}, []);
useEffect(() => {
window.parent.postMessage("omemetis is ready", "*");
if (window.ReactNativeWebView) {
try {
const message = {
data: "omemetis is ready",
url: location.origin,
};
window.ReactNativeWebView.postMessage(JSON.stringify(message));
} catch {}
} else {
window.parent.postMessage("omemetis is ready", "*");
}
const handleMessage = (event: any) => {
if (!event.origin.includes("omeoffice")) {
return; // 如果不是信任的源,忽略消息
}
const data = event.data;
if (!isEmpty(event?.data?.omeToken))
appConfig.setOmeToken(event.data.omeToken);
if (isEmpty(data) || (typeof data === "string" && data === "")) return;
if (window.ReactNativeWebView) {
try {
const params = JSON.parse(data);
if (!isEmpty(params?.ometoken) && params?.from === "OmeOfficeApp") {
appConfig.setOmeToken(params?.ometoken ?? "");
}
} catch {}
} else {
if (
!event.origin.includes("omeoffice") &&
!event.origin.includes("localhost")
) {
return; // 如果不是信任的源,忽略消息
}
if (!isEmpty(event?.data?.ometoken))
appConfig.setOmeToken(event.data.ometoken);
}
};
window.addEventListener("message", handleMessage);

View File

@ -49,8 +49,7 @@ import Locale, {
changeLang,
getLang,
} from "../locales";
import { copyToClipboard, clientUpdate, semverCompare } from "../utils";
import Link from "next/link";
import { copyToClipboard, semverCompare } from "../utils";
import {
Anthropic,
Azure,
@ -67,7 +66,6 @@ import {
RELEASE_URL,
STORAGE_KEY,
ServiceProvider,
SlotID,
UPDATE_URL,
Stability,
Iflytek,
@ -1510,7 +1508,7 @@ export function Settings() {
</Popover>
</ListItem>
<ListItem
{/* <ListItem
title={Locale.Settings.Update.Version(currentVersion ?? "unknown")}
subTitle={
checkingUpdate
@ -1541,7 +1539,7 @@ export function Settings() {
onClick={() => checkUpdate(true)}
/>
)}
</ListItem>
</ListItem> */}
<ListItem title={Locale.Settings.SendKey}>
<Select
@ -1774,7 +1772,7 @@ export function Settings() {
</ListItem>
</List>
<List id={SlotID.CustomModel}>
{/* <List id={SlotID.CustomModel}>
{saasStartComponent}
{accessCodeComponent}
@ -1871,7 +1869,7 @@ export function Settings() {
}
></input>
</ListItem>
</List>
</List> */}
<List>
<ModelConfigList

View File

@ -3,14 +3,12 @@ import React, { Fragment, useEffect, useMemo, useRef, useState } from "react";
import styles from "./home.module.scss";
import { IconButton } from "./button";
import SettingsIcon from "../icons/settings.svg";
import ChatGptIcon from "../icons/chatgpt.svg";
import AddIcon from "../icons/add.svg";
import DeleteIcon from "../icons/delete.svg";
import MaskIcon from "../icons/mask.svg";
import McpIcon from "../icons/mcp.svg";
import DragIcon from "../icons/drag.svg";
import DiscoveryIcon from "../icons/discovery.svg";
import Locale from "../locales";
@ -24,7 +22,7 @@ import {
Path,
} from "../constant";
import { Link, useNavigate } from "react-router-dom";
import { useNavigate } from "react-router-dom";
import { isIOS, useMobileScreen } from "../utils";
import dynamic from "next/dynamic";
import { Selector, showConfirm } from "./ui-lib";
@ -278,13 +276,13 @@ export function SideBar(props: { className?: string }) {
shadow
/>
)}
<IconButton
{/* <IconButton
icon={<DiscoveryIcon />}
text={shouldNarrow ? undefined : Locale.Discovery.Name}
className={styles["sidebar-bar-button"]}
onClick={() => setshowDiscoverySelector(true)}
shadow
/>
/> */}
</div>
{showDiscoverySelector && (
<Selector
@ -325,7 +323,7 @@ export function SideBar(props: { className?: string }) {
}}
/>
</div>
<div className={styles["sidebar-action"]}>
{/* <div className={styles["sidebar-action"]}>
<Link to={Path.Settings}>
<IconButton
aria={Locale.Settings.Title}
@ -333,7 +331,7 @@ export function SideBar(props: { className?: string }) {
shadow
/>
</Link>
</div>
</div> */}
</>
}
secondaryAction={

View File

@ -33,7 +33,7 @@ export const CN_MASKS: BuiltinMask[] = [
},
],
modelConfig: {
model: "gpt-3.5-turbo",
model: "gpt-4o-mini",
temperature: 1,
max_tokens: 2000,
presence_penalty: 0,
@ -59,7 +59,7 @@ export const CN_MASKS: BuiltinMask[] = [
},
],
modelConfig: {
model: "gpt-3.5-turbo",
model: "gpt-4o-mini",
temperature: 1,
max_tokens: 2000,
presence_penalty: 0,
@ -85,7 +85,7 @@ export const CN_MASKS: BuiltinMask[] = [
},
],
modelConfig: {
model: "gpt-3.5-turbo",
model: "gpt-4o-mini",
temperature: 1,
max_tokens: 2000,
presence_penalty: 0,
@ -111,7 +111,7 @@ export const CN_MASKS: BuiltinMask[] = [
},
],
modelConfig: {
model: "gpt-3.5-turbo",
model: "gpt-4o-mini",
temperature: 1,
max_tokens: 2000,
presence_penalty: 0,
@ -137,7 +137,7 @@ export const CN_MASKS: BuiltinMask[] = [
},
],
modelConfig: {
model: "gpt-3.5-turbo",
model: "gpt-4o-mini",
temperature: 1,
max_tokens: 2000,
presence_penalty: 0,
@ -163,7 +163,7 @@ export const CN_MASKS: BuiltinMask[] = [
},
],
modelConfig: {
model: "gpt-3.5-turbo",
model: "gpt-4o-mini",
temperature: 1,
max_tokens: 2000,
presence_penalty: 0,
@ -189,7 +189,7 @@ export const CN_MASKS: BuiltinMask[] = [
},
],
modelConfig: {
model: "gpt-3.5-turbo",
model: "gpt-4o-mini",
temperature: 1,
max_tokens: 2000,
presence_penalty: 0,
@ -215,7 +215,7 @@ export const CN_MASKS: BuiltinMask[] = [
},
],
modelConfig: {
model: "gpt-3.5-turbo",
model: "gpt-4o-mini",
temperature: 1,
max_tokens: 2000,
presence_penalty: 0,
@ -247,7 +247,7 @@ export const CN_MASKS: BuiltinMask[] = [
},
],
modelConfig: {
model: "gpt-3.5-turbo",
model: "gpt-4o-mini",
temperature: 0.5,
max_tokens: 2000,
presence_penalty: 0,
@ -273,7 +273,7 @@ export const CN_MASKS: BuiltinMask[] = [
},
],
modelConfig: {
model: "gpt-3.5-turbo",
model: "gpt-4o-mini",
temperature: 1,
max_tokens: 2000,
presence_penalty: 0,
@ -306,7 +306,7 @@ export const CN_MASKS: BuiltinMask[] = [
},
],
modelConfig: {
model: "gpt-3.5-turbo",
model: "gpt-4o-mini",
temperature: 1,
max_tokens: 2000,
presence_penalty: 0,
@ -339,7 +339,7 @@ export const CN_MASKS: BuiltinMask[] = [
},
],
modelConfig: {
model: "gpt-3.5-turbo",
model: "gpt-4o-mini",
temperature: 1,
max_tokens: 2000,
presence_penalty: 0,
@ -397,7 +397,7 @@ export const CN_MASKS: BuiltinMask[] = [
},
],
modelConfig: {
model: "gpt-3.5-turbo",
model: "gpt-4o-mini",
temperature: 1,
max_tokens: 2000,
presence_penalty: 0,
@ -429,7 +429,7 @@ export const CN_MASKS: BuiltinMask[] = [
},
],
modelConfig: {
model: "gpt-4",
model: "gpt-4o-mini",
temperature: 0.5,
max_tokens: 2000,
presence_penalty: 0,

View File

@ -14,7 +14,7 @@ export const EN_MASKS: BuiltinMask[] = [
},
],
modelConfig: {
model: "gpt-4",
model: "gpt-4o-mini",
temperature: 0.3,
max_tokens: 2000,
presence_penalty: 0,
@ -60,7 +60,7 @@ export const EN_MASKS: BuiltinMask[] = [
},
],
modelConfig: {
model: "gpt-4",
model: "gpt-4o-mini",
temperature: 0.5,
max_tokens: 2000,
presence_penalty: 0,
@ -86,7 +86,7 @@ export const EN_MASKS: BuiltinMask[] = [
},
],
modelConfig: {
model: "gpt-3.5-turbo",
model: "gpt-4o-mini",
temperature: 0.5,
max_tokens: 2000,
presence_penalty: 0,
@ -118,7 +118,7 @@ export const EN_MASKS: BuiltinMask[] = [
},
],
modelConfig: {
model: "gpt-4",
model: "gpt-4o-mini",
temperature: 0.5,
max_tokens: 2000,
presence_penalty: 0,

View File

@ -33,7 +33,7 @@ export const TW_MASKS: BuiltinMask[] = [
},
],
modelConfig: {
model: "gpt-3.5-turbo",
model: "gpt-4o-mini",
temperature: 1,
max_tokens: 2000,
presence_penalty: 0,
@ -59,7 +59,7 @@ export const TW_MASKS: BuiltinMask[] = [
},
],
modelConfig: {
model: "gpt-3.5-turbo",
model: "gpt-4o-mini",
temperature: 1,
max_tokens: 2000,
presence_penalty: 0,
@ -85,7 +85,7 @@ export const TW_MASKS: BuiltinMask[] = [
},
],
modelConfig: {
model: "gpt-3.5-turbo",
model: "gpt-4o-mini",
temperature: 1,
max_tokens: 2000,
presence_penalty: 0,
@ -111,7 +111,7 @@ export const TW_MASKS: BuiltinMask[] = [
},
],
modelConfig: {
model: "gpt-3.5-turbo",
model: "gpt-4o-mini",
temperature: 1,
max_tokens: 2000,
presence_penalty: 0,
@ -137,7 +137,7 @@ export const TW_MASKS: BuiltinMask[] = [
},
],
modelConfig: {
model: "gpt-3.5-turbo",
model: "gpt-4o-mini",
temperature: 1,
max_tokens: 2000,
presence_penalty: 0,
@ -163,7 +163,7 @@ export const TW_MASKS: BuiltinMask[] = [
},
],
modelConfig: {
model: "gpt-3.5-turbo",
model: "gpt-4o-mini",
temperature: 1,
max_tokens: 2000,
presence_penalty: 0,
@ -189,7 +189,7 @@ export const TW_MASKS: BuiltinMask[] = [
},
],
modelConfig: {
model: "gpt-3.5-turbo",
model: "gpt-4o-mini",
temperature: 1,
max_tokens: 2000,
presence_penalty: 0,
@ -215,7 +215,7 @@ export const TW_MASKS: BuiltinMask[] = [
},
],
modelConfig: {
model: "gpt-3.5-turbo",
model: "gpt-4o-mini",
temperature: 1,
max_tokens: 2000,
presence_penalty: 0,
@ -247,7 +247,7 @@ export const TW_MASKS: BuiltinMask[] = [
},
],
modelConfig: {
model: "gpt-3.5-turbo",
model: "gpt-4o-mini",
temperature: 0.5,
max_tokens: 2000,
presence_penalty: 0,
@ -273,7 +273,7 @@ export const TW_MASKS: BuiltinMask[] = [
},
],
modelConfig: {
model: "gpt-3.5-turbo",
model: "gpt-4o-mini",
temperature: 1,
max_tokens: 2000,
presence_penalty: 0,
@ -306,7 +306,7 @@ export const TW_MASKS: BuiltinMask[] = [
},
],
modelConfig: {
model: "gpt-3.5-turbo",
model: "gpt-4o-mini",
temperature: 1,
max_tokens: 2000,
presence_penalty: 0,
@ -339,7 +339,7 @@ export const TW_MASKS: BuiltinMask[] = [
},
],
modelConfig: {
model: "gpt-3.5-turbo",
model: "gpt-4o-mini",
temperature: 1,
max_tokens: 2000,
presence_penalty: 0,
@ -397,7 +397,7 @@ export const TW_MASKS: BuiltinMask[] = [
},
],
modelConfig: {
model: "gpt-3.5-turbo",
model: "gpt-4o-mini",
temperature: 1,
max_tokens: 2000,
presence_penalty: 0,
@ -429,7 +429,7 @@ export const TW_MASKS: BuiltinMask[] = [
},
],
modelConfig: {
model: "gpt-4",
model: "gpt-4o-mini",
temperature: 0.5,
max_tokens: 2000,
presence_penalty: 0,

View File

@ -138,7 +138,7 @@ export function uploadImage(file: Blob): Promise<string> {
})
.then((res) => res.json())
.then((res) => {
// console.log("res", res);
console.log("upload res", res);
if (res?.code == 0 && res?.data) {
return res?.data;
}