|
@@ -1,9 +1,11 @@
|
|
|
import React, { useEffect, useState } from "react";
|
|
|
-import { Button, Tooltip, Divider, Dropdown } from "antd";
|
|
|
-import { DownOutlined } from "@ant-design/icons";
|
|
|
+import { Tooltip, Dropdown, DropDownProps } from "antd";
|
|
|
+import { CheckOutlined, DownOutlined } from "@ant-design/icons";
|
|
|
import { useModel } from "umi";
|
|
|
import TodoDrawer from "./TodoDrawer";
|
|
|
import AICreator from "./AICreator";
|
|
|
+import { useFullscreen, useLocalStorageState } from "ahooks";
|
|
|
+
|
|
|
export default function Toolbar() {
|
|
|
const {
|
|
|
addTable,
|
|
@@ -17,9 +19,10 @@ export default function Toolbar() {
|
|
|
project,
|
|
|
setProject,
|
|
|
onSave,
|
|
|
- onCreateByAi
|
|
|
+ onCreateByAi,
|
|
|
} = useModel("erModel");
|
|
|
const todoRef = React.useRef<{ open: () => void }>();
|
|
|
+ const [isFullscreen, { toggleFullscreen }] = useFullscreen(document.body);
|
|
|
const scaleMenu = {
|
|
|
style: {
|
|
|
width: 200,
|
|
@@ -70,6 +73,89 @@ export default function Toolbar() {
|
|
|
],
|
|
|
};
|
|
|
|
|
|
+ // 隐藏默认字段
|
|
|
+ const [hideDefaultColumn, setHideDefaultColumn] = useLocalStorageState(
|
|
|
+ "er-hideDefaultColumn",
|
|
|
+ {
|
|
|
+ defaultValue: false,
|
|
|
+ listenStorageChange: true
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ const layoutMenu: DropDownProps["menu"] = {
|
|
|
+ style: {
|
|
|
+ width: 120,
|
|
|
+ },
|
|
|
+ items: [
|
|
|
+ {
|
|
|
+ key: "1",
|
|
|
+ label: (
|
|
|
+ <span className="flex items-center">
|
|
|
+ <span className="inlineblock w-25px">
|
|
|
+ {project.setting.showMenu ? (
|
|
|
+ <CheckOutlined className="text-12px" />
|
|
|
+ ) : (
|
|
|
+ ""
|
|
|
+ )}
|
|
|
+ </span>
|
|
|
+ <span>菜单栏</span>
|
|
|
+ </span>
|
|
|
+ ),
|
|
|
+ onClick: () => {
|
|
|
+ setProject({
|
|
|
+ ...project,
|
|
|
+ setting: {
|
|
|
+ ...project.setting,
|
|
|
+ showMenu: !project.setting.showMenu,
|
|
|
+ },
|
|
|
+ });
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ key: "2",
|
|
|
+ label: (
|
|
|
+ <span className="flex items-center">
|
|
|
+ <span className="inlineblock w-25px">
|
|
|
+ {project.setting.showSidebar ? (
|
|
|
+ <CheckOutlined className="text-12px" />
|
|
|
+ ) : (
|
|
|
+ ""
|
|
|
+ )}
|
|
|
+ </span>
|
|
|
+ <span>侧边栏</span>
|
|
|
+ </span>
|
|
|
+ ),
|
|
|
+ onClick: () => {
|
|
|
+ setProject({
|
|
|
+ ...project,
|
|
|
+ setting: {
|
|
|
+ ...project.setting,
|
|
|
+ showSidebar: !project.setting.showSidebar,
|
|
|
+ },
|
|
|
+ });
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ key: "3",
|
|
|
+ type: "divider",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ key: "4",
|
|
|
+ label: (
|
|
|
+ <span className="flex items-center">
|
|
|
+ <span className="inlineblock w-25px">
|
|
|
+ {isFullscreen && <CheckOutlined className="text-12px" />}
|
|
|
+ </span>
|
|
|
+ <span>全屏</span>
|
|
|
+ </span>
|
|
|
+ ),
|
|
|
+ onClick: () => {
|
|
|
+ toggleFullscreen();
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+
|
|
|
const [scale, setScale] = useState(100);
|
|
|
|
|
|
useEffect(() => {
|
|
@@ -103,6 +189,30 @@ export default function Toolbar() {
|
|
|
<TodoDrawer ref={todoRef} />
|
|
|
</div>
|
|
|
<div className="flex items-center py-0px justify-center h-32px">
|
|
|
+ <div className="group">
|
|
|
+ <div className="btn flex flex-col items-center cursor-pointer py-4px px-10px hover:bg-gray-200">
|
|
|
+ <Dropdown menu={layoutMenu} placement="bottomLeft">
|
|
|
+ <span className="text-14px leading-18px">
|
|
|
+ <i className="iconfont icon-layout-5-line text-20px text-#666" />
|
|
|
+ <DownOutlined className="text-10px ml-4px" />
|
|
|
+ </span>
|
|
|
+ </Dropdown>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div className="group">
|
|
|
+ <div className="btn flex flex-col items-center cursor-pointer py-4px px-10px hover:bg-gray-200">
|
|
|
+ <Tooltip
|
|
|
+ title={`${hideDefaultColumn ? "隐藏" : "显示"}默认字段`}
|
|
|
+ >
|
|
|
+ <i
|
|
|
+ className={`iconfont text-20px leading-24px ${!hideDefaultColumn ? "icon-view" : "icon-hide"}`}
|
|
|
+ onClick={() => {
|
|
|
+ setHideDefaultColumn(!hideDefaultColumn);
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </Tooltip>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
<div className="group">
|
|
|
<div className="flex items-center">
|
|
|
<Tooltip title="撤销上一步操作">
|
|
@@ -176,15 +286,27 @@ export default function Toolbar() {
|
|
|
<div className="group">
|
|
|
<div className="flex items-center">
|
|
|
<Tooltip title="保存模型">
|
|
|
- <div className="btn flex flex-col items-center cursor-pointer py-4px px-10px hover:bg-gray-200" onClick={onSave}>
|
|
|
- <svg className="icon h-24px w-24px color-#666" aria-hidden="true">
|
|
|
+ <div
|
|
|
+ className="btn flex flex-col items-center cursor-pointer py-4px px-10px hover:bg-gray-200"
|
|
|
+ onClick={onSave}
|
|
|
+ >
|
|
|
+ <svg
|
|
|
+ className="icon h-24px w-24px color-#666"
|
|
|
+ aria-hidden="true"
|
|
|
+ >
|
|
|
<use xlinkHref="#icon-baocun"></use>
|
|
|
</svg>
|
|
|
</div>
|
|
|
</Tooltip>
|
|
|
<Tooltip title="待办项">
|
|
|
- <div className="btn flex flex-col items-center cursor-pointer py-4px px-10px hover:bg-gray-200" onClick={() => todoRef.current?.open()}>
|
|
|
- <svg className="icon h-24px w-24px color-#666" aria-hidden="true">
|
|
|
+ <div
|
|
|
+ className="btn flex flex-col items-center cursor-pointer py-4px px-10px hover:bg-gray-200"
|
|
|
+ onClick={() => todoRef.current?.open()}
|
|
|
+ >
|
|
|
+ <svg
|
|
|
+ className="icon h-24px w-24px color-#666"
|
|
|
+ aria-hidden="true"
|
|
|
+ >
|
|
|
<use xlinkHref="#icon-daiban"></use>
|
|
|
</svg>
|
|
|
</div>
|
|
@@ -197,12 +319,17 @@ export default function Toolbar() {
|
|
|
<div className="group">
|
|
|
<div className="flex items-center">
|
|
|
<Tooltip title="AI助手">
|
|
|
- <AICreator
|
|
|
- trigger={<div className="btn flex flex-col items-center cursor-pointer py-4px px-10px hover:bg-gray-200">
|
|
|
- <svg className="icon h-24px w-24px color-#666" aria-hidden="true">
|
|
|
- <use xlinkHref="#icon-AI1"></use>
|
|
|
- </svg>
|
|
|
- </div>}
|
|
|
+ <AICreator
|
|
|
+ trigger={
|
|
|
+ <div className="btn flex flex-col items-center cursor-pointer py-4px px-10px hover:bg-gray-200">
|
|
|
+ <svg
|
|
|
+ className="icon h-24px w-24px color-#666"
|
|
|
+ aria-hidden="true"
|
|
|
+ >
|
|
|
+ <use xlinkHref="#icon-AI1"></use>
|
|
|
+ </svg>
|
|
|
+ </div>
|
|
|
+ }
|
|
|
onChange={onCreateByAi}
|
|
|
/>
|
|
|
</Tooltip>
|
|
@@ -238,7 +365,7 @@ export default function Toolbar() {
|
|
|
<Dropdown menu={scaleMenu}>
|
|
|
<span className="text-14px leading-18px w-120px">
|
|
|
<span>{scale}%</span>
|
|
|
- <DownOutlined className="text-12px ml-4px" />
|
|
|
+ <DownOutlined className="text-10px ml-4px" />
|
|
|
</span>
|
|
|
</Dropdown>
|
|
|
</div>
|