mirror of https://gitee.com/cf-fz/WebCAD.git
!2181 新增:输出日志分类及交互,命令搜索列表颜色区分
parent
ea5cb6f080
commit
65310883cc
@ -0,0 +1,63 @@
|
||||
import { Checkbox, Icon, IconName, MaybeElement } from "@blueprintjs/core";
|
||||
import { observer } from "mobx-react";
|
||||
import React, { useEffect, useRef } from 'react';
|
||||
import { LogType } from "../../../Common/Log";
|
||||
import { CommandStore } from "../../Store/CommandStore";
|
||||
|
||||
|
||||
const CommandTypeModal = (props: { store: CommandStore; }) =>
|
||||
{
|
||||
const { store } = props;
|
||||
const wrench = useRef<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
document.addEventListener("click", ClickHiddenModal, false);
|
||||
document.addEventListener("keydown", KeyDownHiddenModal, false);
|
||||
|
||||
return () =>
|
||||
{
|
||||
document.removeEventListener("click", ClickHiddenModal, false);
|
||||
document.removeEventListener("keydown", KeyDownHiddenModal, false);
|
||||
};
|
||||
}, [store.showCmdModal]);
|
||||
|
||||
const ClickHiddenModal = (e: MouseEvent) =>
|
||||
{
|
||||
const target = e.target as HTMLElement;
|
||||
if (wrench.current && !wrench.current.contains(target))
|
||||
store.OnHandleShowCmdModalChange(false);
|
||||
};
|
||||
|
||||
const KeyDownHiddenModal = () =>
|
||||
{
|
||||
store.OnHandleShowCmdModalChange(false);
|
||||
};
|
||||
|
||||
const commandTypeList = [
|
||||
{ label: "全部", type: LogType.All },
|
||||
{ label: "错误", icon: "error", type: LogType.Error },
|
||||
{ label: "警告", icon: "warning-sign", type: LogType.Warning },
|
||||
{ label: "信息", icon: "info-sign", type: LogType.Info },
|
||||
{ label: "命令", icon: "console", type: LogType.Command },
|
||||
];
|
||||
|
||||
return <div className={"command-setting-wrench"} ref={wrench}>
|
||||
{
|
||||
commandTypeList.map((commandType) => (
|
||||
<Checkbox
|
||||
checked={store.showCmdTypeList.has(commandType.type)}
|
||||
onClick={(e) =>
|
||||
{
|
||||
store.OnHandleCommandTypeChange(commandType.type);
|
||||
}}
|
||||
>
|
||||
{commandType.type === LogType.All ? null : <Icon icon={commandType.icon as IconName | MaybeElement} style={{ marginRight: "4px" }} className={`command-${commandType.icon}`} />}
|
||||
<span >{commandType.label}</span>
|
||||
</Checkbox>
|
||||
))
|
||||
}
|
||||
<div className="command-eject" onClick={() => { store.OnHandleShowCmdModalChange(false); }}> <Icon icon="eject" /></div>
|
||||
</div>;
|
||||
};
|
||||
export default observer(CommandTypeModal);
|
@ -1,11 +1,50 @@
|
||||
import * as React from 'react';
|
||||
|
||||
import { app } from '../../ApplicationServices/Application';
|
||||
import { CommandMsg } from '../Store/CommandStore';
|
||||
|
||||
//每行日志输出 {命令调用或者其他的日志}
|
||||
export class CommandLine extends React.Component<{ msg: CommandMsg; }, {}>
|
||||
{
|
||||
render()
|
||||
{
|
||||
return <div className="terminal-commandResult"><span>{this.props.msg.msg}</span></div>;
|
||||
const { msg } = this.props;
|
||||
return (
|
||||
<div className="terminal-commandResult">
|
||||
<span className={`terminal-${msg.type.toLocaleLowerCase()}`}>
|
||||
{
|
||||
msg.genre === "normal" ?
|
||||
<>
|
||||
{msg.msg}
|
||||
{msg.entity && msg.entity.length > 0 ?
|
||||
<b
|
||||
className='terminal-control'
|
||||
onClick={() =>
|
||||
{
|
||||
app.Editor.SetSelection(msg.entity);
|
||||
app.Viewer.ZoomtoEntitys(msg.entity);
|
||||
}}
|
||||
>
|
||||
点击查看
|
||||
</b> : null}
|
||||
</> :
|
||||
<>
|
||||
{msg.info && msg.info.map((v) =>
|
||||
{
|
||||
if (v.entity && v.entity.length > 0)
|
||||
return <strong className='strong-message' onClick={() =>
|
||||
{
|
||||
app.Editor.SetSelection(v.entity);
|
||||
app.Viewer.ZoomtoEntitys(v.entity);
|
||||
}}>
|
||||
{v.msg}
|
||||
</strong>;
|
||||
return <span className="normal-message">{v.msg}</span>;
|
||||
})}
|
||||
</>
|
||||
}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue