diff --git a/src/app/app.component.scss b/src/app/app.component.scss index 41b53cb..c6374ff 100644 --- a/src/app/app.component.scss +++ b/src/app/app.component.scss @@ -19,6 +19,17 @@ font-weight: 700; cursor: pointer; } + .close-button { + position: absolute !important; + right: 5px; + top: 5px; + width: 30px; + height: 30px; + cursor: pointer; + background-image: url("../img/icon_close9x9_normal.png"); + background-repeat: no-repeat; + background-position: center; + } } .linkset{ margin: 10px; diff --git a/src/app/title/title.component.ts b/src/app/title/title.component.ts index 3e0a792..3aaa127 100644 --- a/src/app/title/title.component.ts +++ b/src/app/title/title.component.ts @@ -1,5 +1,6 @@ -import {Left, WidgetType} from '@ui/index'; +import {Left, WidgetType, IconButton} from '@ui/index'; import TitleItem from './title_item/title_item.component'; +import {isDesigner, closeWindow} from '@shared/crud/crud.request'; const tabs = ['数据连接管理', '连接池状态']; const className = 'fr.title'; const Widget: WidgetType = { @@ -7,14 +8,32 @@ const Widget: WidgetType = { return { type: Left, cls: 'title', - items: BI.map(tabs, (index: number, text: string) => { - return { - type: TitleItem, - text, - }; - }), + items: [ + ...BI.map(tabs, (index: number, text: string) => { + return { + type: TitleItem, + text, + }; + }), + { + type:IconButton, + cls:'close-button', + handler() { + closeWindow(); + }, + invisible: true, + ref: _ref => { + this.CloseButton = _ref; + }, + }, + ], }; }, + mounted() { + if (isDesigner()) { + this.CloseButton.setVisible(true); + } + }, }; BI.shortcut(className, BI.inherit(BI.Widget, Widget)); diff --git a/src/img/icon_close9x9_normal.png b/src/img/icon_close9x9_normal.png new file mode 100644 index 0000000..198afc8 Binary files /dev/null and b/src/img/icon_close9x9_normal.png differ diff --git a/src/shared/crud/crud.request.ts b/src/shared/crud/crud.request.ts index 8196d6a..63d6495 100644 --- a/src/shared/crud/crud.request.ts +++ b/src/shared/crud/crud.request.ts @@ -1,6 +1,28 @@ import {linkList} from './curd.mock'; import {LinkType} from '@ui/type'; const Dec: any = (window as any).parent.Dec; +const PluginHelper: any = (window as any).PluginHelper; + +/** + * 是否是设计器 + */ +export function isDesigner(): boolean { + if (PluginHelper) { + return PluginHelper.isDesigner(); + } + + return false; +} + +/** + * 关闭窗口 + */ +export function closeWindow(): void{ + if (PluginHelper) { + return PluginHelper.closeWindow(); + } + console.log('关闭窗口'); +} /** * 获取数据连接列表 diff --git a/tsconfig.json b/tsconfig.json index ebd47d8..0aebbc0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,7 @@ "baseUrl": ".", "outDir": "./dist/", "sourceMap": true, - "noImplicitAny": true, + "noImplicitAny": false, "target": "es2017", "module": "es2015", "lib": [ diff --git a/types/globals.d.ts b/types/globals.d.ts index 1bf435b..3a1bc4b 100644 --- a/types/globals.d.ts +++ b/types/globals.d.ts @@ -5,3 +5,4 @@ interface Obj { declare let BI: Obj; declare const Fix: Obj; declare const Dec: Obj; +declare const PluginHelper: Obj;