!1797 优化:左侧图标自适应宽度

pull/1798/head
ChenX 3 years ago
parent 67519def21
commit c2d468662f

@ -23,6 +23,13 @@ export class CoolDownTime
}, time);
}
//防抖
Debounce(f: Function, time: number)
{
this.ExecFunc = f;
this.CoolDown(time);
}
//清除所有的状态
Clear()
{

@ -26,7 +26,7 @@ export class ErrorMonitoring
{
window.addEventListener('error', e =>
{
ReportError(e.error.stack);
ReportError(e.error?.stack ?? e.message);
});
window.addEventListener("unhandledrejection", e =>
{

@ -9,6 +9,7 @@
}
.bp3-card {
padding : 5px;
padding-top : 0px;
height : 100%;
display : flex;
flex-direction: column;
@ -47,12 +48,6 @@
span{
font-weight: 700 !important;
}
ul{
display : block !important;
list-style: none;
padding : 0;
position : relative;
}
.bp3-spinner{
position : absolute;
top : 50%;
@ -60,37 +55,35 @@
left : 50%;
margin-left: -20px;
}
li:hover{
background-color: #F1F2F4 !important;
cursor : default !important;
}
li{
ul{
width : max-content;
padding : 0;
flex-direction: column;
overflow : auto !important;
flex-wrap : nowrap !important;
gap: 5px;
li
{
width : auto !important;
height : auto !important;
list-style : none;
display : flex;
flex-direction : row;
justify-content : flex-start;
background-color: #F1F2F4;
width : 100% !important;
clear : both !important;
margin-bottom : 10px !important;
box-sizing : border-box;
padding-bottom : 20px !important;
img{
height: 100px !important;
width : 80px !important;
}
.categoryTag{
width : 30%;
height : 100%;
display: inline;
>span{
cursor: pointer;
gap: 5px;
&:hover{
color:#1890ff;
}
cursor : default !important;
background-color: #F1F2F4 !important;
}
img
{
width : 80px !important;
height: 100px !important;
}
.categoryOptions{
float: right;
width: 70%;
.bp3-button-text{
font-weight: 500 !important;
.categoryOptions
{
padding-top: 10px;
}
}
}

@ -1,11 +1,9 @@
import { action, observable } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
import { CoolDownTime } from '../../../Common/CoolDownTime';
import { commandMachine } from '../../../Editor/CommandMachine';
import { userConfig } from '../../../Editor/UserConfig';
import { ICON_CDN } from '../../IconEnum';
import { ToolsBlockStore } from '../TopToolBar/ToolsBlockStore';
import { ICommandIconInfo, TopToolBarBlockData } from '../TopToolBar/TopToolBarInterface';
import { ICommandIconInfo } from '../TopToolBar/TopToolBarInterface';
import './PropertiesPanel.less';
export interface ToolBarProps
@ -15,42 +13,50 @@ export interface ToolBarProps
@observer
export class ToolBar extends React.Component<ToolBarProps, {}>
{
@observable actualWidth: string;
@observable windowHeigth = window.innerHeight;
@observable windowWidth = window.innerWidth;
componentDidMount()
ulRef = React.createRef<HTMLUListElement>();
observer: ResizeObserver;
time = new CoolDownTime;
componentDidMount(): void
{
window.addEventListener('resize', this.calToolbarWidth, false);
this.observer = new ResizeObserver((entries: ResizeObserverEntry[]) =>
{
this.UpdateWidth();
});
this.observer.observe(this.ulRef.current);
}
@action
calToolbarWidth = () =>
componentWillUnmount(): void
{
const { iconList } = this.props;
this.windowHeigth = window.innerHeight;
this.windowWidth = window.innerWidth;
let iconNum = iconList.length;
let blocksData = ToolsBlockStore.GetInstance().blocksData as TopToolBarBlockData;
let drawIconNum = blocksData.draw.IconNum;
let headHeight = 0;
drawIconNum * 40 <= this.windowWidth ? headHeight = 108 : headHeight = 153;
if (this.windowHeigth > iconNum * 58 + (userConfig.smalliconmode ? (headHeight + 16) : 124))
this.actualWidth = "40px";
else if (this.windowHeigth < (iconNum % 2 == 1 ? iconNum + 1 : iconNum) * 58 / 2 + (userConfig.smalliconmode ? (headHeight + 17) : 125))
this.actualWidth = "130px";
else
this.actualWidth = "80px";
};
this.observer.disconnect();
}
componentDidUpdate(prevProps: Readonly<ToolBarProps>, prevState: Readonly<{}>, snapshot?: any): void
{
this.UpdateWidth();
}
private UpdateWidth()
{
this.time.Debounce(() =>
{
this.ulRef.current.parentElement.style.width = `${this.ulRef.current.scrollWidth}px`;
}, 50);
}
render()
{
const { iconList } = this.props;
const liStyle: React.CSSProperties = {
textAlign: "center",
writingMode: "horizontal-tb"
};
this.calToolbarWidth();
return (
<ul className="ul-unstyle" style={{ width: this.actualWidth }} >
<div style={{ display: "flex" }}>
<ul className='ul-unstyle'
style={{ display: "inline-flex" }}
ref={this.ulRef}
>
{
iconList.map((cmd, index) =>
iconList.map((cmd) =>
{
return (
<li key={cmd.command} title={cmd.command} style={liStyle}
@ -66,6 +72,7 @@ export class ToolBar extends React.Component<ToolBarProps, {}>
})
}
</ul>
</div>
);
}

@ -287,10 +287,10 @@ input[type=radio] {
flex-direction: column;
flex-wrap : wrap;
margin : 0;
width : 80px;
>li {
width : 40px;
height : 60px;
margin : 0;
padding: 0;
@ -302,21 +302,6 @@ input[type=radio] {
}
}
// 媒体查询 ToolBar
// @media screen and (min-height:1562px) {
// #toolbar ul {
// width: 40px;
// }
// }
@media screen and (max-height:810px) {
#toolbar ul {
display : flex;
flex-flow: wrap;
overflow : auto;
}
}
/*----------TopToolBar开始-----------*/
//顶部工具栏样式
#TopToolBar img {
@ -729,6 +714,7 @@ img {
margin: 10px;
}
}
.foot_left {
position: absolute;
left : 3%;
@ -738,6 +724,7 @@ img {
}
}
}
//-----批量修改文字工具结束--------
//视图窗口配置
@ -798,12 +785,14 @@ img {
border-radius: 5px;
}
.div2 {
width : 180px;
height : 90px;
border : 3px solid rgba(14, 133, 238, 0.589);
border-radius: 5px;
}
.div3 {
width : 180px;
height : 90px;
@ -879,6 +868,7 @@ img {
.div1 {
position: absolute;
}
.div2 {
margin-left: 181px;
}
@ -994,12 +984,16 @@ img {
}
}
}
//-----视图窗口配置结束--------
//-----文件编辑记录开始--------
#OperLogsModal {
.bp3-running-text table th, table.bp3-html-table th,
.bp3-running-text table td, table.bp3-html-table td{
.bp3-running-text table th,
table.bp3-html-table th,
.bp3-running-text table td,
table.bp3-html-table td {
vertical-align: middle;
padding : 10px;
height : 35px;
@ -1028,8 +1022,10 @@ img {
float: left;
}
.bp3-running-text table th, table.bp3-html-table th,
.bp3-running-text table td, table.bp3-html-table td{
.bp3-running-text table th,
table.bp3-html-table th,
.bp3-running-text table td,
table.bp3-html-table td {
vertical-align: middle;
padding : 10px;
height : 30px;
@ -1058,6 +1054,7 @@ img {
.bp3-toast-container.bp3-toast-container-top.historyToaster {
top: 10%;
}
//-----文件编辑记录结束--------
#TemplateList {
@ -1084,6 +1081,7 @@ img {
float : left;
margin-top: 5px;
}
.bp3-control-group.bp3-numeric-input {
@ -1169,15 +1167,12 @@ img {
margin-top : 5px;
margin-left: 130px;
.bp3-slider-axis
{
.bp3-slider-axis {
display: none;
}
.bp3-slider-handle
{
.bp3-slider-label
{
.bp3-slider-handle {
.bp3-slider-label {
display: none;
}
}
@ -1190,8 +1185,7 @@ img {
}
}
.bp3-dialog-footer
{
.bp3-dialog-footer {
padding : 7px 10px 7px 10px;
border-top : 1px solid #dddddd;
background-color: white;

Loading…
Cancel
Save