!2146 修复:客服界面关闭后聚焦问题,增加发送当前文件给客服命令

pull/2160/head
林三 2 years ago committed by ChenX
parent 77f21a04fa
commit 28bc1c285c

@ -0,0 +1,77 @@
import { Intent } from "@blueprintjs/core";
import { app } from "../ApplicationServices/Application";
import { deflate } from "../Common/SerializeMaterial";
import { CADFiler } from "../DatabaseServices/CADFiler";
import { FileServer } from "../DatabaseServices/FileServer";
import { Command } from "../Editor/CommandMachine";
import { IsOpenChat } from "../UI/Components/ChatButton";
import { AppToaster } from "../UI/Components/Toaster";
export 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 // 图纸连接
}
}
}
});
return true;
}
return false;
};
export class Command_SendCADFileOnKf implements Command
{
NoHistory = true;
async exec()
{
if (!IsOpenChat.get())
{
AppToaster.show({
message: "请打开客服界面后使用发送文件命令!",
timeout: 3000,
intent: Intent.DANGER,
});
return;
}
SendFile().then(ok =>
{
AppToaster.show({
message: ok ? "发送成功!" : "发送失败!",
timeout: 3000,
intent: ok ? Intent.SUCCESS : Intent.WARNING,
});
});
}
}

@ -351,4 +351,5 @@ export enum CommandNames
VisibleInRender = "VISIBLEINRENDER", //渲染器中显示实体
UnVisibleInRender = "UNVISIBLEINRENDER", //渲染器中隐藏实体
SendCADFileToKF = "SENDCADFILETOKF",//发送当前文件给在线客服
}

@ -187,6 +187,7 @@ import { Command_Rotate, Command_RotateRefer } from "../Add-on/Rotate";
import { RotateLayerBoard } from "../Add-on/RotateLayerBoard";
import { New, Save, SaveAs, SaveToLocal } from "../Add-on/Save";
import { Command_Scale } from "../Add-on/Scale";
import { Command_SendCADFileOnKf } from "../Add-on/SendCADFileOnKF";
import { SetSmoothEdge } from "../Add-on/SetSmoothEdge/SetSmoothEdge";
import { Command_ShareView } from "../Add-on/ShareView/Command_ShareView";
import { SwitchLines } from "../Add-on/ShowLines";
@ -834,6 +835,9 @@ export function registerCommand()
commandMachine.RegisterCommand("ParseWall", new Command_ParseRoomWall());
//画廊命令
commandMachine.RegisterCommand(CommandNames.Gallery, new Command_Gallery());
//在线客服
commandMachine.RegisterCommand(CommandNames.SendCADFileToKF, new Command_SendCADFileOnKf());
}
export async function LimitCommand()

@ -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);
},
});
}

@ -2434,6 +2434,15 @@ export const CommandList: ICommand[] = [
chName: "保存到本地",
chDes: "将当前文件保存到本地",
},
{
typeId: "file",
link: `#`,
defaultCustom: CommandNames.SendCADFileToKF,
command: CommandNames.SendCADFileToKF,
type: "文件",
chName: "发送当前文件给在线客服",
chDes: "发送当前文件给在线客服(需要打开在线客服界面才能发送)",
},
{
icon: IconEnum.Print,
typeId: "file",

@ -12,7 +12,7 @@ import { Light } from '../../DatabaseServices/Lights/Light';
import { PointLight } from '../../DatabaseServices/Lights/PointLight';
import { RectAreaLight } from '../../DatabaseServices/Lights/RectAreaLight';
import { SpotLight } from '../../DatabaseServices/Lights/SpotLight';
import { commandMachine, CommandWrap } from '../../Editor/CommandMachine';
import { CommandWrap, commandMachine } from '../../Editor/CommandMachine';
import { CommandState } from '../../Editor/CommandState';
import { LightsMenu } from '../../Editor/LightsMenu';
import { SnapMenuFixed } from '../../Editor/SnapMenuFixed';
@ -25,7 +25,7 @@ import { RightPanelStore } from '../Store/RightPanelStore/RightPanelStore';
import { TopPanelStore } from '../Store/TopPanelStore';
import { userConfigStore } from '../Store/UserConfigStore';
import { BoardModalType } from "./Board/BoardModalType";
import { ChatButton } from './ChatButton';
import { ChatButton, IsOpenChat } from './ChatButton';
import { AppConfirm } from './Common/Confirm';
import { SettingPanel } from './SettingPanel/SettingPanel';
import SoucePanel from './SourceManage/SoucePanel';
@ -152,6 +152,17 @@ export class TopPanel extends React.Component<{ store?: TopPanelStore; }, {}>
/>
}
<ChatButton />
{
IsOpenChat.get() && <Button
className={"TopPanel_Btn04"}
style={MarginStyle}
small={true}
icon="people"
text="发送图纸"
intent={Intent.PRIMARY}
onClick={() => commandMachine.ExecCommand(CommandNames.SendCADFileToKF)}
/>
}
<Button
style={MarginStyle}
small={true}

@ -17,6 +17,8 @@ import { CommandInputHeight } from '../CommandInput/CommandInputUI';
import { SwitchServerStore } from '../Modal/SwitchServerStore';
import './InputHint.css';
export const CMD_INPUT_ID = "CMD_INPUT_ID";
interface InputHintProps
{
keyWordList: Array<KeyWord>,//关键字列表
@ -322,8 +324,8 @@ export class InputHint extends React.Component<InputHintProps, InputHitState>
);
})
}
<input
id={CMD_INPUT_ID}
disabled={CommandStore.GetInstance().disableInput}
type="text"
style={{ flex: 1, minWidth: 0, height: CommandInputHeight, border: "none" }}

@ -148,7 +148,7 @@
/**********TopPanel大小调整*****************/
//TopPanel缩小
@media screen and (max-width: 1540px) {
@media screen and (max-width: 1630px) {
#TopPanel{
.TopPanel_Btn01{
display: none;
@ -156,7 +156,7 @@
}
}
@media screen and (max-width: 1440px) {
@media screen and (max-width: 1530px) {
#TopPanel{
.TopPanel_Btn02{
display: none;
@ -164,6 +164,22 @@
}
}
@media screen and (max-width: 1425px) {
#TopPanel{
.TopPanel_Btn03{
display: none;
}
}
}
@media screen and (max-width: 1320px) {
#TopPanel{
.TopPanel_Btn04{
display: none;
}
}
}
@media screen and (max-width: 1240px) {
#TopPanel .Group_Button Button{
font-size: 0;

Loading…
Cancel
Save