|
|
|
@ -1,11 +1,13 @@
|
|
|
|
|
import { Button, Intent } from "@blueprintjs/core";
|
|
|
|
|
import { observable } from "mobx";
|
|
|
|
|
import React, { useEffect, useRef, useState } from "react";
|
|
|
|
|
import { SendFile } from "../../Add-on/SendCADFileOnKF";
|
|
|
|
|
import { app } from "../../ApplicationServices/Application";
|
|
|
|
|
import { deflate } from "../../Common/SerializeMaterial";
|
|
|
|
|
import { StoreageKeys } from "../../Common/StoreageKeys";
|
|
|
|
|
import { CADFiler } from "../../DatabaseServices/CADFiler";
|
|
|
|
|
import { FileServer } from "../../DatabaseServices/FileServer";
|
|
|
|
|
import { userConfig } from "../../Editor/UserConfig";
|
|
|
|
|
import { CMD_INPUT_ID } from "./commandLineInput/InputHint";
|
|
|
|
|
|
|
|
|
|
export let IsOpenChat = observable.box(false);; //是否打开了客服界面
|
|
|
|
|
|
|
|
|
|
//客服界面重置
|
|
|
|
|
export const ChatReset = () =>
|
|
|
|
@ -115,7 +117,7 @@ export const ChatButton = () =>
|
|
|
|
|
<>
|
|
|
|
|
{load ? (
|
|
|
|
|
<Button
|
|
|
|
|
className={"TopPanel_Btn02"}
|
|
|
|
|
className={"TopPanel_Btn04"}
|
|
|
|
|
small={true}
|
|
|
|
|
icon="people"
|
|
|
|
|
text="在线客服"
|
|
|
|
@ -123,8 +125,23 @@ export const ChatButton = () =>
|
|
|
|
|
intent={Intent.PRIMARY}
|
|
|
|
|
onClick={(e) =>
|
|
|
|
|
{
|
|
|
|
|
if (window["easemobim"])
|
|
|
|
|
if (window["easemobim"] && !IsOpenChat.get())
|
|
|
|
|
{
|
|
|
|
|
let prevFocusedEl = null;
|
|
|
|
|
let timerId: NodeJS.Timer;
|
|
|
|
|
|
|
|
|
|
function CheckIframeFocus()
|
|
|
|
|
{
|
|
|
|
|
let focusedEl = document.activeElement;
|
|
|
|
|
if (focusedEl !== prevFocusedEl)
|
|
|
|
|
{
|
|
|
|
|
prevFocusedEl = focusedEl;
|
|
|
|
|
let isInIframe = focusedEl.tagName === "IFRAME";
|
|
|
|
|
if (isInIframe)
|
|
|
|
|
app.Editor.MaskManage.ShowMask();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
window["easemobim"].bind({
|
|
|
|
|
configId,
|
|
|
|
|
onmessage(message)
|
|
|
|
@ -137,65 +154,32 @@ export const ChatButton = () =>
|
|
|
|
|
setBadge(badgeCountRef.current);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//发送当前文件
|
|
|
|
|
//客服发送当前文件
|
|
|
|
|
if (message.message.value === "~")
|
|
|
|
|
{
|
|
|
|
|
const SendFile = async () =>
|
|
|
|
|
{
|
|
|
|
|
let cadFile = app.Database.FileWrite();
|
|
|
|
|
let vf = new CADFiler();
|
|
|
|
|
app.Viewer.CameraCtrl.WriteFile(vf);
|
|
|
|
|
cadFile.Write(vf.Data);
|
|
|
|
|
cadFile.Write(app.Editor.UCSMatrix.toArray());
|
|
|
|
|
|
|
|
|
|
let str = deflate(cadFile.ToString());
|
|
|
|
|
|
|
|
|
|
let res = await fetch("https://chenfeng.tech:7123/upload", {
|
|
|
|
|
method: "POST",
|
|
|
|
|
mode: "cors",
|
|
|
|
|
body: str,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (res.status === 200)
|
|
|
|
|
{
|
|
|
|
|
let resV = await res.json();
|
|
|
|
|
let fileid = resV.file_id;
|
|
|
|
|
let fileServer = FileServer.GetInstance() as FileServer;
|
|
|
|
|
|
|
|
|
|
window["easemobim"] && window["easemobim"].sendExt({
|
|
|
|
|
ext: {
|
|
|
|
|
"imageName": "mallImage3.png",
|
|
|
|
|
"type": "custom",//custom代表自定义消息,无需修改
|
|
|
|
|
"msgtype": {
|
|
|
|
|
"order": {
|
|
|
|
|
"title": "这是我当前绘制的图纸", // 标题
|
|
|
|
|
"desc": fileServer.currentFileInfo.name || "未命名", // 图纸名称
|
|
|
|
|
"price": "", // 图纸大小
|
|
|
|
|
"img_url": "https://cdn.qicad.com/webcadapp.png", // 图纸logo
|
|
|
|
|
"item_url": window.location.origin + "/?open_temp=" + fileid // 图纸连接
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
SendFile();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// window["easemobim"].restore();
|
|
|
|
|
},
|
|
|
|
|
onopen()
|
|
|
|
|
{
|
|
|
|
|
// console.log("open");
|
|
|
|
|
IsOpenChat.set(true);
|
|
|
|
|
timerId = setInterval(CheckIframeFocus, 100);
|
|
|
|
|
app.Editor.MaskManage.ShowMask();
|
|
|
|
|
badgeCountRef.current = 0;
|
|
|
|
|
setBadge(0);
|
|
|
|
|
isOpenRef.current = true;
|
|
|
|
|
},
|
|
|
|
|
onclose()
|
|
|
|
|
{
|
|
|
|
|
// console.log("close");
|
|
|
|
|
clearInterval(timerId);
|
|
|
|
|
isOpenRef.current = false;
|
|
|
|
|
if (!app.Editor.ModalManage.CurrentModal?.IsModal)
|
|
|
|
|
{
|
|
|
|
|
app.Editor.MaskManage.Clear();
|
|
|
|
|
//嵌入式网页关闭后聚焦一下命令输入框
|
|
|
|
|
document.getElementById(CMD_INPUT_ID).focus();
|
|
|
|
|
}
|
|
|
|
|
IsOpenChat.set(false);
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|