Editor: init open deeplink in app
This commit is contained in:
parent
2bea864aeb
commit
6af9813196
@ -5,6 +5,7 @@ import Button from "@docspace/components/button";
|
|||||||
import Link from "@docspace/components/link";
|
import Link from "@docspace/components/link";
|
||||||
|
|
||||||
import { getLogoFromPath } from "@docspace/common/utils";
|
import { getLogoFromPath } from "@docspace/common/utils";
|
||||||
|
import { getDeepLink } from "../../helpers/deepLinkHelper";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
StyledSimpleNav,
|
StyledSimpleNav,
|
||||||
@ -14,7 +15,11 @@ import {
|
|||||||
StyledActionsWrapper,
|
StyledActionsWrapper,
|
||||||
} from "./StyledDeepLink";
|
} from "./StyledDeepLink";
|
||||||
|
|
||||||
const DeepLink = ({ fileInfo, logoUrls }) => {
|
const DL_ANDROID = "com.onlyoffice.documents";
|
||||||
|
const DL_IOS = "944896972";
|
||||||
|
const DL_URL = "oodocuments://openfile";
|
||||||
|
|
||||||
|
const DeepLink = ({ fileInfo, logoUrls, userEmail }) => {
|
||||||
const [isRemember, setIsRemember] = useState(false);
|
const [isRemember, setIsRemember] = useState(false);
|
||||||
|
|
||||||
const onChangeCheckbox = () => {
|
const onChangeCheckbox = () => {
|
||||||
@ -23,7 +28,12 @@ const DeepLink = ({ fileInfo, logoUrls }) => {
|
|||||||
|
|
||||||
const onOpenAppClick = () => {
|
const onOpenAppClick = () => {
|
||||||
if (isRemember) localStorage.setItem("defaultOpenDocument", "app");
|
if (isRemember) localStorage.setItem("defaultOpenDocument", "app");
|
||||||
console.log("onOpenAppClick");
|
window.location = getDeepLink(
|
||||||
|
window.location.origin,
|
||||||
|
userEmail,
|
||||||
|
fileInfo,
|
||||||
|
DL_URL
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const onStayBrowserClick = () => {
|
const onStayBrowserClick = () => {
|
||||||
|
@ -736,7 +736,13 @@ function Editor({
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (isShowDeepLink)
|
if (isShowDeepLink)
|
||||||
return <DeepLink fileInfo={fileInfo} logoUrls={logoUrls} />;
|
return (
|
||||||
|
<DeepLink
|
||||||
|
fileInfo={fileInfo}
|
||||||
|
logoUrls={logoUrls}
|
||||||
|
userEmail={user.email}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<EditorWrapper
|
<EditorWrapper
|
||||||
|
17
packages/editor/src/client/helpers/deepLinkHelper.js
Normal file
17
packages/editor/src/client/helpers/deepLinkHelper.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
export const getDeepLink = (location, email, file, url) => {
|
||||||
|
const jsonData = {
|
||||||
|
portal: location,
|
||||||
|
email: email,
|
||||||
|
file: {
|
||||||
|
id: file.fileId,
|
||||||
|
},
|
||||||
|
folder: {
|
||||||
|
id: file.folderId,
|
||||||
|
parentId: file.rootFolderId,
|
||||||
|
rootFolderType: file.rootFolderType,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const deepLinkData = window.btoa(JSON.stringify(jsonData));
|
||||||
|
|
||||||
|
return `${url}?data=${deepLinkData}`;
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user