Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dlink
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhaowei
dlink
Commits
fa4e61cb
Commit
fa4e61cb
authored
Jan 22, 2022
by
wenmo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化状态与SQL编辑器性能
parent
21325641
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
177 additions
and
151 deletions
+177
-151
index.tsx
dlink-web/src/components/Studio/StudioEdit/index.tsx
+50
-65
data.d.ts
dlink-web/src/components/Studio/StudioEvent/data.d.ts
+2
-2
index.tsx
dlink-web/src/components/Studio/StudioMenu/index.tsx
+13
-6
index.tsx
dlink-web/src/components/Studio/StudioTabs/index.tsx
+34
-31
index.tsx
dlink-web/src/components/Studio/index.tsx
+3
-2
model.ts
dlink-web/src/pages/FlinkSqlStudio/model.ts
+54
-45
Welcome.tsx
dlink-web/src/pages/Welcome.tsx
+21
-0
No files found.
dlink-web/src/components/Studio/StudioEdit/index.tsx
View file @
fa4e61cb
...
@@ -6,7 +6,7 @@ import {connect,Dispatch} from "umi";
...
@@ -6,7 +6,7 @@ import {connect,Dispatch} from "umi";
import
{
DocumentStateType
}
from
"@/pages/Document/model"
;
import
{
DocumentStateType
}
from
"@/pages/Document/model"
;
import
{
DocumentTableListItem
}
from
"@/pages/Document/data"
;
import
{
DocumentTableListItem
}
from
"@/pages/Document/data"
;
import
{
parseSqlMetaData
}
from
"@/components/Studio/StudioEvent/Utils"
;
import
{
parseSqlMetaData
}
from
"@/components/Studio/StudioEvent/Utils"
;
import
{
Column
,
MetaData
}
from
"@/components/Studio/StudioEvent/data"
;
import
{
Column
,
MetaData
,
SqlMetaData
}
from
"@/components/Studio/StudioEvent/data"
;
import
StudioExplain
from
"@/components/Studio/StudioConsole/StudioExplain"
;
import
StudioExplain
from
"@/components/Studio/StudioConsole/StudioExplain"
;
import
{
format
}
from
"sql-formatter"
;
import
{
format
}
from
"sql-formatter"
;
...
@@ -27,41 +27,31 @@ const FlinkSqlEditor = (props:any) => {
...
@@ -27,41 +27,31 @@ const FlinkSqlEditor = (props:any) => {
height
=
'100%'
,
height
=
'100%'
,
width
=
'100%'
,
width
=
'100%'
,
language
=
'sql'
,
language
=
'sql'
,
onChange
=
(
val
:
string
,
event
:
{
changes
:
{
text
:
any
}[]
}
)
=>
{},
onChange
=
(
val
:
string
,
event
:
any
)
=>
{},
options
=
{
options
=
{
selectOnLineNumbers
:
true
,
selectOnLineNumbers
:
true
,
renderSideBySide
:
false
,
renderSideBySide
:
false
,
},
},
tabs
,
sql
,
monaco
,
// sqlMetaData,
fillDocuments
,
fillDocuments
,
}
=
props
;
}
=
props
;
const
editorInstance
:
any
=
useRef
<
any
>
();
const
editorInstance
:
any
=
useRef
<
any
>
();
const
monacoInstance
:
any
=
useRef
();
const
monacoInstance
:
any
=
useRef
();
const
[
modalVisible
,
handleModalVisible
]
=
useState
<
boolean
>
(
false
);
const
[
modalVisible
,
handleModalVisible
]
=
useState
<
boolean
>
(
false
);
const
[
metaData
,
setMetaData
]
=
useState
<
SqlMetaData
>
({});
const
getTabIndex
=
():
number
=>
{
const
[
code
,
setCode
]
=
useState
<
string
>
(
sql
);
for
(
let
i
=
0
;
i
<
tabs
.
panes
.
length
;
i
++
){
if
(
tabs
.
panes
[
i
].
key
==
tabsKey
){
return
i
;
}
}
return
0
;
};
const
tabIndex
=
getTabIndex
();
const
code
:
any
=
useRef
(
tabs
.
panes
[
tabIndex
].
value
?
tabs
.
panes
[
tabIndex
].
value
:
''
);
const
cache
:
any
=
useRef
(
code
.
current
);
useEffect
(
useEffect
(
()
=>
()
=>
{
()
=>
()
=>
{
provider
.
dispose
();
reloadCompletion
();
},
},
[
code
]);
[]
);
useImperativeHandle
(
editorInstance
,
()
=>
({
useImperativeHandle
(
editorInstance
,
()
=>
({
handleSetEditorVal
,
handleSetEditorVal
,
getEditorData
:
()
=>
c
ache
.
current
,
getEditorData
:
()
=>
c
ode
,
}));
}));
const
handleSetEditorVal
=
(
value
:
string
):
void
=>
{
const
handleSetEditorVal
=
(
value
:
string
):
void
=>
{
...
@@ -82,23 +72,34 @@ const FlinkSqlEditor = (props:any) => {
...
@@ -82,23 +72,34 @@ const FlinkSqlEditor = (props:any) => {
}
}
};
};
const
onChangeHandle
=
(
val
:
string
,
event
:
{
changes
:
{
text
:
any
}[]
})
=>
{
const
onChangeHandle
=
(
val
:
string
,
event
:
any
)
=>
{
let
sqlMetaData
=
parseSqlMetaData
(
val
);
setCode
(
val
);
props
.
saveMetaData
(
sqlMetaData
,
tabs
,
tabIndex
);
onChange
(
val
,
event
);
onChange
(
val
,
event
);
/*const curWord = event.changes[0].text;
/*let newSqlMetaData = parseSqlMetaData(val);
if (curWord === ';') {
setMetaData(newSqlMetaData);
cache.current = val +'\r\n';
props.saveSqlMetaData(newSqlMetaData,tabsKey);*/
setRefresh(!refresh); // 刷新页面
return;
}
cache.current = val;*/
props
.
saveSql
(
val
);
props
.
saveSql
(
val
);
};
};
const
reloadCompletion
=
()
=>
{
let
newSqlMetaData
=
parseSqlMetaData
(
code
);
setMetaData
({...
newSqlMetaData
});
provider
.
dispose
();
// 清空提示项
provider
=
monacoInstance
.
current
.
languages
.
registerCompletionItemProvider
(
'sql'
,
{
provideCompletionItems
()
{
return
{
suggestions
:
buildSuggestions
(),
};
},
// quickSuggestions: false,
// triggerCharacters: ['$', '.', '='],
});
};
const
buildSuggestions
=
()
=>
{
const
buildSuggestions
=
()
=>
{
let
suggestions
:
ISuggestions
[]
=
[];
let
suggestions
:
ISuggestions
[]
=
[];
tabs
.
panes
[
tabIndex
].
sqlMetaData
?.
metaData
?.
forEach
((
item
:
MetaData
)
=>
{
console
.
log
(
metaData
);
metaData
.
metaData
?.
forEach
((
item
:
MetaData
)
=>
{
suggestions
.
push
({
suggestions
.
push
({
label
:
item
.
table
,
label
:
item
.
table
,
kind
:
_monaco
.
languages
.
CompletionItemKind
.
Constant
,
kind
:
_monaco
.
languages
.
CompletionItemKind
.
Constant
,
...
@@ -141,9 +142,6 @@ const FlinkSqlEditor = (props:any) => {
...
@@ -141,9 +142,6 @@ const FlinkSqlEditor = (props:any) => {
const
editorDidMountHandle
=
(
editor
:
any
,
monaco
:
any
)
=>
{
const
editorDidMountHandle
=
(
editor
:
any
,
monaco
:
any
)
=>
{
monacoInstance
.
current
=
monaco
;
monacoInstance
.
current
=
monaco
;
editorInstance
.
current
=
editor
;
editorInstance
.
current
=
editor
;
editor
.
addCommand
(
monaco
.
KeyMod
.
Alt
|
monaco
.
KeyCode
.
KEY_1
,
function
(){
props
.
saveText
(
tabs
,
tabIndex
);
})
editor
.
addCommand
(
monaco
.
KeyMod
.
Alt
|
monaco
.
KeyCode
.
KEY_2
,
function
(){
editor
.
addCommand
(
monaco
.
KeyMod
.
Alt
|
monaco
.
KeyCode
.
KEY_2
,
function
(){
handleModalVisible
(
true
);
handleModalVisible
(
true
);
...
@@ -151,17 +149,9 @@ const FlinkSqlEditor = (props:any) => {
...
@@ -151,17 +149,9 @@ const FlinkSqlEditor = (props:any) => {
editor
.
addCommand
(
monaco
.
KeyMod
.
Alt
|
monaco
.
KeyCode
.
KEY_3
,
function
(){
editor
.
addCommand
(
monaco
.
KeyMod
.
Alt
|
monaco
.
KeyCode
.
KEY_3
,
function
(){
editor
.
getAction
([
'editor.action.formatDocument'
]).
_run
();
editor
.
getAction
([
'editor.action.formatDocument'
]).
_run
();
})
})
provider
.
dispose
();
// 清空提示项
// 提示项设值
reloadCompletion
();
provider
=
monaco
.
languages
.
registerCompletionItemProvider
(
'sql'
,
{
provideCompletionItems
()
{
return
{
suggestions
:
buildSuggestions
(),
};
},
// quickSuggestions: false,
// triggerCharacters: ['$', '.', '='],
});
monaco
.
languages
.
registerDocumentRangeFormattingEditProvider
(
'sql'
,
{
monaco
.
languages
.
registerDocumentRangeFormattingEditProvider
(
'sql'
,
{
provideDocumentRangeFormattingEdits
(
model
,
range
,
options
)
{
provideDocumentRangeFormattingEdits
(
model
,
range
,
options
)
{
var
formatted
=
format
(
model
.
getValueInRange
(
range
),
{
var
formatted
=
format
(
model
.
getValueInRange
(
range
),
{
...
@@ -181,11 +171,11 @@ const FlinkSqlEditor = (props:any) => {
...
@@ -181,11 +171,11 @@ const FlinkSqlEditor = (props:any) => {
return
(
return
(
<
React
.
Fragment
>
<
React
.
Fragment
>
<
MonacoEditor
<
MonacoEditor
ref=
{
tabs
.
panes
[
tabIndex
].
monaco
}
ref=
{
monaco
}
width=
{
width
}
width=
{
width
}
height=
{
height
}
height=
{
height
}
language=
{
language
}
language=
{
language
}
value=
{
tabs
.
panes
[
tabIndex
].
valu
e
}
value=
{
cod
e
}
options=
{
options
}
options=
{
options
}
onChange=
{
onChangeHandle
}
onChange=
{
onChangeHandle
}
theme=
"vs-dark"
theme=
"vs-dark"
...
@@ -201,28 +191,23 @@ const FlinkSqlEditor = (props:any) => {
...
@@ -201,28 +191,23 @@ const FlinkSqlEditor = (props:any) => {
}
}
const
mapDispatchToProps
=
(
dispatch
:
Dispatch
)
=>
({
const
mapDispatchToProps
=
(
dispatch
:
Dispatch
)
=>
({
saveText
:(
tabs
:
any
,
tabIndex
:
any
)
=>
dispatch
({
/*
saveText:(tabs:any,tabIndex:any)=>dispatch({
type: "Studio/saveTask",
type: "Studio/saveTask",
payload: tabs.panes[tabIndex].task,
payload: tabs.panes[tabIndex].task,
}),
}),
*/
saveSql
:(
val
:
any
)
=>
dispatch
({
saveSql
:(
val
:
any
)
=>
dispatch
({
type
:
"Studio/saveSql"
,
type
:
"Studio/saveSql"
,
payload
:
val
,
payload
:
val
,
}),
}),
saveSqlMetaData
:(
sqlMetaData
:
any
,
key
:
number
)
=>
dispatch
({
saveMetaData
:(
sqlMetaData
:
any
,
tabs
:
any
,
tabIndex
:
any
)
=>
dispatch
({
type
:
"Studio/saveSqlMetaData"
,
type
:
"Studio/saveSqlMetaData"
,
payload
:
{
payload
:
{
activeKey
:
tabs
.
panes
[
tabIndex
].
key
,
activeKey
:
key
,
sqlMetaData
,
sqlMetaData
,
isModified
:
true
,
isModified
:
true
,
}
}
})
}),
})
})
export
default
connect
(({
Studio
,
Document
}:
{
Studio
:
StateType
,
Document
:
DocumentStateType
})
=>
({
export
default
connect
(({
Document
}:
{
Document
:
DocumentStateType
})
=>
({
current
:
Studio
.
current
,
sql
:
Studio
.
sql
,
tabs
:
Studio
.
tabs
,
monaco
:
Studio
.
monaco
,
fillDocuments
:
Document
.
fillDocuments
,
fillDocuments
:
Document
.
fillDocuments
,
}),
mapDispatchToProps
)(
FlinkSqlEditor
);
}),
mapDispatchToProps
)(
FlinkSqlEditor
);
dlink-web/src/components/Studio/StudioEvent/data.d.ts
View file @
fa4e61cb
export
type
SqlMetaData
=
{
export
type
SqlMetaData
=
{
statement
:
string
,
statement
?
:
string
,
metaData
:
MetaData
[],
metaData
?
:
MetaData
[],
};
};
export
type
MetaData
=
{
export
type
MetaData
=
{
table
:
string
,
table
:
string
,
...
...
dlink-web/src/components/Studio/StudioMenu/index.tsx
View file @
fa4e61cb
...
@@ -35,11 +35,11 @@ const menu = (
...
@@ -35,11 +35,11 @@ const menu = (
const
StudioMenu
=
(
props
:
any
)
=>
{
const
StudioMenu
=
(
props
:
any
)
=>
{
const
{
tabs
,
current
,
currentPath
,
form
,
width
,
height
,
refs
,
dispatch
,
currentSession
}
=
props
;
const
{
isFullScreen
,
tabs
,
current
,
currentPath
,
form
,
width
,
height
,
refs
,
dispatch
,
currentSession
}
=
props
;
const
[
modalVisible
,
handleModalVisible
]
=
useState
<
boolean
>
(
false
);
const
[
modalVisible
,
handleModalVisible
]
=
useState
<
boolean
>
(
false
);
const
[
exportModalVisible
,
handleExportModalVisible
]
=
useState
<
boolean
>
(
false
);
const
[
exportModalVisible
,
handleExportModalVisible
]
=
useState
<
boolean
>
(
false
);
const
[
graphModalVisible
,
handleGraphModalVisible
]
=
useState
<
boolean
>
(
false
);
const
[
graphModalVisible
,
handleGraphModalVisible
]
=
useState
<
boolean
>
(
false
);
const
[
editModalVisible
,
handleEditModalVisible
]
=
useState
<
boolean
>
(
false
);
//
const [editModalVisible, handleEditModalVisible] = useState<boolean>(false);
const
[
graphData
,
setGraphData
]
=
useState
();
const
[
graphData
,
setGraphData
]
=
useState
();
const
onKeyDown
=
useCallback
((
e
)
=>
{
const
onKeyDown
=
useCallback
((
e
)
=>
{
...
@@ -52,7 +52,8 @@ const StudioMenu = (props: any) => {
...
@@ -52,7 +52,8 @@ const StudioMenu = (props: any) => {
if
(
e
.
keyCode
===
113
){
if
(
e
.
keyCode
===
113
){
e
.
preventDefault
();
e
.
preventDefault
();
if
(
current
)
{
if
(
current
)
{
handleEditModalVisible
(
true
);
// handleEditModalVisible(true);
props
.
changeFullScreen
(
true
);
}
}
}
}
},
[
current
]);
},
[
current
]);
...
@@ -463,16 +464,18 @@ const StudioMenu = (props: any) => {
...
@@ -463,16 +464,18 @@ const StudioMenu = (props: any) => {
>
>
<
SqlExport
id=
{
current
.
task
.
id
}
/>
<
SqlExport
id=
{
current
.
task
.
id
}
/>
</
ModalForm
>:
undefined
}
</
ModalForm
>:
undefined
}
{
current
?<
Modal
{
current
&&
isFullScreen
?<
Modal
width=
{
width
}
width=
{
width
}
bodyStyle=
{
{
padding
:
0
}
}
bodyStyle=
{
{
padding
:
0
}
}
style=
{
{
top
:
0
,
padding
:
0
,
margin
:
0
,
maxWidth
:
'100vw'
}
}
style=
{
{
top
:
0
,
padding
:
0
,
margin
:
0
,
maxWidth
:
'100vw'
}
}
destroyOnClose
destroyOnClose
maskClosable=
{
false
}
maskClosable=
{
false
}
closable=
{
false
}
closable=
{
false
}
visible=
{
editModalVisible
}
visible=
{
isFullScreen
}
footer=
{
null
}
footer=
{
null
}
onCancel=
{
()
=>
handleEditModalVisible
(
false
)
}
>
onCancel=
{
()
=>
{
props
.
changeFullScreen
(
false
);
}
}
>
<
StudioTabs
width=
{
width
}
height=
{
height
}
/>
<
StudioTabs
width=
{
width
}
height=
{
height
}
/>
</
Modal
>:
undefined
}
</
Modal
>:
undefined
}
</
Row
>
</
Row
>
...
@@ -487,10 +490,14 @@ const mapDispatchToProps = (dispatch: Dispatch)=>({
...
@@ -487,10 +490,14 @@ const mapDispatchToProps = (dispatch: Dispatch)=>({
}),
saveTabs
:(
tabs
:
any
)
=>
dispatch
({
}),
saveTabs
:(
tabs
:
any
)
=>
dispatch
({
type
:
"Studio/saveTabs"
,
type
:
"Studio/saveTabs"
,
payload
:
tabs
,
payload
:
tabs
,
}),
changeFullScreen
:(
isFull
:
boolean
)
=>
dispatch
({
type
:
"Studio/changeFullScreen"
,
payload
:
isFull
,
}),
}),
});
});
export
default
connect
(({
Studio
}:
{
Studio
:
StateType
})
=>
({
export
default
connect
(({
Studio
}:
{
Studio
:
StateType
})
=>
({
isFullScreen
:
Studio
.
isFullScreen
,
current
:
Studio
.
current
,
current
:
Studio
.
current
,
currentPath
:
Studio
.
currentPath
,
currentPath
:
Studio
.
currentPath
,
tabs
:
Studio
.
tabs
,
tabs
:
Studio
.
tabs
,
...
...
dlink-web/src/components/Studio/StudioTabs/index.tsx
View file @
fa4e61cb
...
@@ -6,33 +6,23 @@ import styles from './index.less';
...
@@ -6,33 +6,23 @@ import styles from './index.less';
import
StudioEdit
from
'../StudioEdit'
;
import
StudioEdit
from
'../StudioEdit'
;
import
{
DIALECT
}
from
'../conf'
;
import
{
DIALECT
}
from
'../conf'
;
import
StudioHome
from
"@/components/Studio/StudioHome"
;
import
StudioHome
from
"@/components/Studio/StudioHome"
;
import
{
Dispatch
}
from
"@@/plugin-dva/connect"
;
const
{
TabPane
}
=
Tabs
;
const
{
TabPane
}
=
Tabs
;
const
EditorTabs
=
(
props
:
any
)
=>
{
const
EditorTabs
=
(
props
:
any
)
=>
{
const
{
tabs
,
dispatch
,
current
,
toolHeight
,
width
,
height
}
=
props
;
const
{
tabs
,
current
,
toolHeight
,
width
,
height
}
=
props
;
const
onChange
=
(
activeKey
:
any
)
=>
{
const
onChange
=
(
activeKey
:
any
)
=>
{
dispatch
&&
props
.
saveToolHeight
(
toolHeight
);
dispatch
({
props
.
changeActiveKey
(
activeKey
);
type
:
'Studio/saveToolHeight'
,
payload
:
toolHeight
-
0.0001
,
});
dispatch
({
type
:
'Studio/changeActiveKey'
,
payload
:
activeKey
,
});
};
};
const
onEdit
=
(
targetKey
:
any
,
action
:
any
)
=>
{
const
onEdit
=
(
targetKey
:
any
,
action
:
any
)
=>
{
if
(
action
===
'add'
)
{
if
(
action
===
'add'
)
{
add
();
add
();
}
else
if
(
action
===
'remove'
)
{
}
else
if
(
action
===
'remove'
)
{
dispatch
&&
props
.
saveToolHeight
(
toolHeight
-
0.0001
);
dispatch
({
type
:
'Studio/saveToolHeight'
,
payload
:
toolHeight
-
0.0001
,
});
// if (current.isModified) {
// if (current.isModified) {
// saveTask(current, dispatch);
// saveTask(current, dispatch);
// }
// }
...
@@ -61,23 +51,11 @@ const EditorTabs = (props: any) => {
...
@@ -61,23 +51,11 @@ const EditorTabs = (props: any) => {
newActiveKey
=
newPanes
[
0
].
key
;
newActiveKey
=
newPanes
[
0
].
key
;
}
}
}
}
dispatch
({
props
.
saveTabs
(
newPanes
,
newActiveKey
);
type
:
'Studio/saveTabs'
,
payload
:
{
activeKey
:
newActiveKey
,
panes
:
newPanes
,
},
});
};
};
const
handleClickMenu
=
(
e
:
any
,
current
)
=>
{
const
handleClickMenu
=
(
e
:
any
,
current
)
=>
{
dispatch
({
props
.
closeTabs
(
current
,
e
.
key
);
type
:
'Studio/closeTabs'
,
payload
:
{
deleteType
:
e
.
key
,
current
},
});
};
};
const
menu
=
(
pane
)
=>
(
const
menu
=
(
pane
)
=>
(
...
@@ -118,10 +96,13 @@ const EditorTabs = (props: any) => {
...
@@ -118,10 +96,13 @@ const EditorTabs = (props: any) => {
className=
{
styles
[
'edit-tabs'
]
}
className=
{
styles
[
'edit-tabs'
]
}
style=
{
{
height
:
height
?
height
:
toolHeight
}
}
style=
{
{
height
:
height
?
height
:
toolHeight
}
}
>
>
{
tabs
.
panes
.
map
((
pane
)
=>
(
{
tabs
.
panes
.
map
((
pane
,
i
)
=>
(
<
TabPane
tab=
{
Tab
(
pane
)
}
key=
{
pane
.
key
}
closable=
{
pane
.
closable
}
>
<
TabPane
tab=
{
Tab
(
pane
)
}
key=
{
pane
.
key
}
closable=
{
pane
.
closable
}
>
<
StudioEdit
<
StudioEdit
tabsKey=
{
pane
.
key
}
tabsKey=
{
pane
.
key
}
sql=
{
pane
.
value
}
monaco=
{
pane
.
monaco
}
// sqlMetaData=
{
pane
.
sqlMetaData
}
height=
{
height
?
height
:(
toolHeight
-
32
)
}
height=
{
height
?
height
:(
toolHeight
-
32
)
}
width=
{
width
}
width=
{
width
}
language=
{
current
.
task
.
dialect
===
DIALECT
.
JAVA
?
'java'
:
'sql'
}
language=
{
current
.
task
.
dialect
===
DIALECT
.
JAVA
?
'java'
:
'sql'
}
...
@@ -133,9 +114,31 @@ const EditorTabs = (props: any) => {
...
@@ -133,9 +114,31 @@ const EditorTabs = (props: any) => {
);
);
};
};
const
mapDispatchToProps
=
(
dispatch
:
Dispatch
)
=>
({
closeTabs
:(
current
:
any
,
key
:
string
)
=>
dispatch
({
type
:
'Studio/closeTabs'
,
payload
:
{
deleteType
:
key
,
current
},
}),
saveTabs
:(
newPanes
:
any
,
newActiveKey
:
number
)
=>
dispatch
({
type
:
'Studio/saveTabs'
,
payload
:
{
activeKey
:
newActiveKey
,
panes
:
newPanes
,
},
}),
saveToolHeight
:(
toolHeight
:
number
)
=>
dispatch
({
type
:
'Studio/saveToolHeight'
,
payload
:
toolHeight
-
0.0001
,
}),
changeActiveKey
:(
activeKey
:
number
)
=>
dispatch
({
type
:
'Studio/changeActiveKey'
,
payload
:
activeKey
,
}),
})
export
default
connect
(({
Studio
}:
{
Studio
:
StateType
})
=>
({
export
default
connect
(({
Studio
}:
{
Studio
:
StateType
})
=>
({
current
:
Studio
.
current
,
current
:
Studio
.
current
,
sql
:
Studio
.
sql
,
sql
:
Studio
.
sql
,
tabs
:
Studio
.
tabs
,
tabs
:
Studio
.
tabs
,
toolHeight
:
Studio
.
toolHeight
,
toolHeight
:
Studio
.
toolHeight
,
}))(
EditorTabs
);
})
,
mapDispatchToProps
)(
EditorTabs
);
dlink-web/src/components/Studio/index.tsx
View file @
fa4e61cb
...
@@ -20,7 +20,7 @@ import DraggleVerticalLayout from "@/components/DraggleLayout/DraggleVerticalLay
...
@@ -20,7 +20,7 @@ import DraggleVerticalLayout from "@/components/DraggleLayout/DraggleVerticalLay
const
Studio
=
(
props
:
any
)
=>
{
const
Studio
=
(
props
:
any
)
=>
{
const
{
rightClickMenu
,
toolHeight
,
toolLeftWidth
,
toolRightWidth
,
dispatch
}
=
props
;
const
{
isFullScreen
,
rightClickMenu
,
toolHeight
,
toolLeftWidth
,
toolRightWidth
,
dispatch
}
=
props
;
const
[
form
]
=
Form
.
useForm
();
const
[
form
]
=
Form
.
useForm
();
const
VIEW
=
{
const
VIEW
=
{
leftToolWidth
:
300
,
leftToolWidth
:
300
,
...
@@ -134,7 +134,7 @@ const Studio = (props: any) => {
...
@@ -134,7 +134,7 @@ const Studio = (props: any) => {
}
}
/>
}
}
/>
</
Col
>
</
Col
>
<
Col
>
<
Col
>
<
StudioTabs
width=
{
size
.
width
-
toolRightWidth
-
toolLeftWidth
}
/>
{
!
isFullScreen
?<
StudioTabs
width=
{
size
.
width
-
toolRightWidth
-
toolLeftWidth
}
/>:
undefined
}
</
Col
>
</
Col
>
</
DraggleLayout
>
</
DraggleLayout
>
<
Col
id=
'StudioRightTool'
className=
{
styles
[
"vertical-tabs"
]
}
>
<
Col
id=
'StudioRightTool'
className=
{
styles
[
"vertical-tabs"
]
}
>
...
@@ -155,6 +155,7 @@ const Studio = (props: any) => {
...
@@ -155,6 +155,7 @@ const Studio = (props: any) => {
};
};
export
default
connect
(({
Studio
}:
{
Studio
:
StateType
})
=>
({
export
default
connect
(({
Studio
}:
{
Studio
:
StateType
})
=>
({
isFullScreen
:
Studio
.
isFullScreen
,
rightClickMenu
:
Studio
.
rightClickMenu
,
rightClickMenu
:
Studio
.
rightClickMenu
,
toolHeight
:
Studio
.
toolHeight
,
toolHeight
:
Studio
.
toolHeight
,
toolLeftWidth
:
Studio
.
toolLeftWidth
,
toolLeftWidth
:
Studio
.
toolLeftWidth
,
...
...
dlink-web/src/pages/FlinkSqlStudio/model.ts
View file @
fa4e61cb
...
@@ -136,6 +136,7 @@ export type SessionType = {
...
@@ -136,6 +136,7 @@ export type SessionType = {
}
}
export
type
StateType
=
{
export
type
StateType
=
{
isFullScreen
:
boolean
;
toolHeight
?:
number
;
toolHeight
?:
number
;
toolRightWidth
?:
number
;
toolRightWidth
?:
number
;
toolLeftWidth
?:
number
;
toolLeftWidth
?:
number
;
...
@@ -147,7 +148,7 @@ export type StateType = {
...
@@ -147,7 +148,7 @@ export type StateType = {
currentSession
?:
SessionType
;
currentSession
?:
SessionType
;
current
?:
TabsItemType
;
current
?:
TabsItemType
;
sql
?:
string
;
sql
?:
string
;
monaco
?:
any
;
//
monaco?: any;
currentPath
?:
string
[];
currentPath
?:
string
[];
tabs
?:
TabsType
;
tabs
?:
TabsType
;
session
?:
SessionType
[];
session
?:
SessionType
[];
...
@@ -165,12 +166,13 @@ export type ModelType = {
...
@@ -165,12 +166,13 @@ export type ModelType = {
saveTask
:
Effect
;
saveTask
:
Effect
;
};
};
reducers
:
{
reducers
:
{
changeFullScreen
:
Reducer
<
StateType
>
;
saveToolHeight
:
Reducer
<
StateType
>
;
saveToolHeight
:
Reducer
<
StateType
>
;
saveToolRightWidth
:
Reducer
<
StateType
>
;
saveToolRightWidth
:
Reducer
<
StateType
>
;
saveToolLeftWidth
:
Reducer
<
StateType
>
;
saveToolLeftWidth
:
Reducer
<
StateType
>
;
saveSql
:
Reducer
<
StateType
>
;
saveSql
:
Reducer
<
StateType
>
;
saveCurrentPath
:
Reducer
<
StateType
>
;
saveCurrentPath
:
Reducer
<
StateType
>
;
saveMonaco
:
Reducer
<
StateType
>
;
//
saveMonaco: Reducer<StateType>;
saveSqlMetaData
:
Reducer
<
StateType
>
;
saveSqlMetaData
:
Reducer
<
StateType
>
;
saveTabs
:
Reducer
<
StateType
>
;
saveTabs
:
Reducer
<
StateType
>
;
closeTabs
:
Reducer
<
StateType
>
;
closeTabs
:
Reducer
<
StateType
>
;
...
@@ -193,6 +195,7 @@ export type ModelType = {
...
@@ -193,6 +195,7 @@ export type ModelType = {
const
Model
:
ModelType
=
{
const
Model
:
ModelType
=
{
namespace
:
'Studio'
,
namespace
:
'Studio'
,
state
:
{
state
:
{
isFullScreen
:
false
,
toolHeight
:
400
,
toolHeight
:
400
,
toolRightWidth
:
300
,
toolRightWidth
:
300
,
toolLeftWidth
:
300
,
toolLeftWidth
:
300
,
...
@@ -206,7 +209,7 @@ const Model: ModelType = {
...
@@ -206,7 +209,7 @@ const Model: ModelType = {
},
},
current
:
undefined
,
current
:
undefined
,
sql
:
''
,
sql
:
''
,
monaco
:
{},
//
monaco: {},
currentPath
:
[
'引导页'
],
currentPath
:
[
'引导页'
],
tabs
:
{
tabs
:
{
activeKey
:
0
,
activeKey
:
0
,
...
@@ -233,6 +236,12 @@ const Model: ModelType = {
...
@@ -233,6 +236,12 @@ const Model: ModelType = {
},
},
reducers
:
{
reducers
:
{
changeFullScreen
(
state
,
{
payload
})
{
return
{
...
state
,
isFullScreen
:
payload
,
};
},
saveToolHeight
(
state
,
{
payload
})
{
saveToolHeight
(
state
,
{
payload
})
{
return
{
return
{
...
state
,
...
state
,
...
@@ -250,19 +259,19 @@ const Model: ModelType = {
...
@@ -250,19 +259,19 @@ const Model: ModelType = {
};
};
},
},
saveSql
(
state
,
{
payload
})
{
saveSql
(
state
,
{
payload
})
{
const
{
tabs
}
=
state
;
const
newTabs
=
state
.
tabs
;
const
newCurrent
=
state
.
current
;
const
newCurrent
=
state
.
current
;
newCurrent
.
value
=
payload
;
newCurrent
.
value
=
payload
;
for
(
let
i
=
0
;
i
<
t
abs
.
panes
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
newT
abs
.
panes
.
length
;
i
++
)
{
if
(
tabs
.
panes
[
i
].
key
==
t
abs
.
activeKey
)
{
if
(
newTabs
.
panes
[
i
].
key
==
newT
abs
.
activeKey
)
{
t
abs
.
panes
[
i
].
value
=
payload
;
newT
abs
.
panes
[
i
].
value
=
payload
;
tabs
.
panes
[
i
].
task
&&
(
t
abs
.
panes
[
i
].
task
.
statement
=
payload
);
newTabs
.
panes
[
i
].
task
&&
(
newT
abs
.
panes
[
i
].
task
.
statement
=
payload
);
}
}
}
}
return
{
return
{
...
state
,
...
state
,
current
:
newCurrent
,
current
:
{...
newCurrent
}
,
tabs
,
tabs
:{...
newTabs
}
,
};
};
},
},
saveCurrentPath
(
state
,
{
payload
})
{
saveCurrentPath
(
state
,
{
payload
})
{
...
@@ -271,32 +280,30 @@ const Model: ModelType = {
...
@@ -271,32 +280,30 @@ const Model: ModelType = {
currentPath
:
payload
,
currentPath
:
payload
,
};
};
},
},
saveMonaco
(
state
,
{
payload
})
{
/*
saveMonaco(state, {payload}) {
return {
return {
...state,
...state,
monaco
:
{
monaco:payload,
...
payload
},
};
};
},
},
*/
saveSqlMetaData
(
state
,
{
payload
})
{
saveSqlMetaData
(
state
,
{
payload
})
{
const
newCurrent
=
state
.
current
;
const
newCurrent
=
state
.
current
;
const
newTabs
=
state
.
tabs
;
const
newTabs
=
state
.
tabs
;
if
(
newCurrent
.
key
==
payload
.
activeKey
){
if
(
newCurrent
.
key
==
payload
.
activeKey
){
newCurrent
.
sqlMetaData
=
payload
.
sqlMetaData
;
newCurrent
.
sqlMetaData
=
{...
payload
.
sqlMetaData
}
;
newCurrent
.
isModified
=
payload
.
isModified
;
newCurrent
.
isModified
=
payload
.
isModified
;
}
}
for
(
let
i
=
0
;
i
<
newTabs
.
panes
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
newTabs
.
panes
.
length
;
i
++
)
{
if
(
newTabs
.
panes
[
i
].
key
==
payload
.
activeKey
)
{
if
(
newTabs
.
panes
[
i
].
key
==
payload
.
activeKey
)
{
newTabs
.
panes
[
i
].
sqlMetaData
=
payload
.
sqlMetaData
;
newTabs
.
panes
[
i
].
sqlMetaData
=
{...
payload
.
sqlMetaData
}
;
newTabs
.
panes
[
i
].
isModified
=
payload
.
isModified
;
newTabs
.
panes
[
i
].
isModified
=
payload
.
isModified
;
break
;
break
;
}
}
}
}
return
{
return
{
...
state
,
...
state
,
current
:
newCurrent
,
current
:
{...
newCurrent
}
,
tabs
:
newTabs
,
tabs
:
{...
newTabs
}
,
};
};
},
},
saveTabs
(
state
,
{
payload
})
{
saveTabs
(
state
,
{
payload
})
{
...
@@ -320,7 +327,7 @@ const Model: ModelType = {
...
@@ -320,7 +327,7 @@ const Model: ModelType = {
...
newCurrent
,
...
newCurrent
,
isModified
:
false
,
isModified
:
false
,
},
},
tabs
:
payload
,
tabs
:
{...
payload
}
,
currentPath
:
newCurrent
.
path
,
currentPath
:
newCurrent
.
path
,
};
};
},
},
...
@@ -341,8 +348,8 @@ const Model: ModelType = {
...
@@ -341,8 +348,8 @@ const Model: ModelType = {
}
}
return
{
return
{
...
state
,
...
state
,
current
:
newCurrent
,
current
:
{...
newCurrent
}
,
tabs
:
newTabs
,
tabs
:
{...
newTabs
}
,
};
};
},
},
closeTabs
(
state
,
{
payload
})
{
closeTabs
(
state
,
{
payload
})
{
...
@@ -362,23 +369,23 @@ const Model: ModelType = {
...
@@ -362,23 +369,23 @@ const Model: ModelType = {
return
{
return
{
...
state
,
...
state
,
current
:
newCurrent
,
current
:
{...
newCurrent
}
,
tabs
:
newTabs
tabs
:
{...
newTabs
}
};
};
},
},
changeActiveKey
(
state
,
{
payload
})
{
changeActiveKey
(
state
,
{
payload
})
{
const
newTabs
=
state
.
tabs
;
const
newTabs
=
state
?.
tabs
;
let
newCurrent
=
state
.
current
;
let
newCurrent
=
state
?.
current
;
newTabs
.
activeKey
=
payload
;
for
(
let
i
=
0
;
i
<
newTabs
.
panes
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
newTabs
.
panes
.
length
;
i
++
)
{
if
(
newTabs
.
panes
[
i
].
key
==
payload
)
{
if
(
newTabs
.
panes
[
i
].
key
==
payload
)
{
newTabs
.
activeKey
=
payload
;
newCurrent
=
newTabs
.
panes
[
i
];
newCurrent
=
newTabs
.
panes
[
i
];
}
}
}
}
return
{
return
{
...
state
,
...
state
,
current
:
newCurrent
,
current
:
{...
newCurrent
}
,
tabs
:
newTabs
,
tabs
:
{...
newTabs
}
,
currentPath
:
newCurrent
.
path
,
currentPath
:
newCurrent
.
path
,
};
};
},
},
...
@@ -396,14 +403,14 @@ const Model: ModelType = {
...
@@ -396,14 +403,14 @@ const Model: ModelType = {
}
}
return
{
return
{
...
state
,
...
state
,
current
:
newCurrent
,
current
:
{...
newCurrent
}
,
tabs
:
newTabs
,
tabs
:
{...
newTabs
}
,
};
};
},
},
saveSession
(
state
,
{
payload
})
{
saveSession
(
state
,
{
payload
})
{
return
{
return
{
...
state
,
...
state
,
session
:
payload
,
session
:
[...
payload
]
,
};
};
},
},
showRightClickMenu
(
state
,
{
payload
})
{
showRightClickMenu
(
state
,
{
payload
})
{
...
@@ -431,44 +438,46 @@ const Model: ModelType = {
...
@@ -431,44 +438,46 @@ const Model: ModelType = {
},
},
saveResult
(
state
,
{
payload
})
{
saveResult
(
state
,
{
payload
})
{
const
newTabs
=
state
?.
tabs
;
const
newTabs
=
state
?.
tabs
;
le
t
newCurrent
=
state
?.
current
;
cons
t
newCurrent
=
state
?.
current
;
for
(
let
i
=
0
;
i
<
newTabs
.
panes
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
newTabs
.
panes
.
length
;
i
++
)
{
if
(
newTabs
.
panes
[
i
].
key
==
newTabs
.
activeKey
)
{
if
(
newTabs
.
panes
[
i
].
key
==
payload
.
key
)
{
newTabs
.
panes
[
i
].
console
.
result
.
result
=
payload
;
newTabs
.
panes
[
i
].
console
.
result
.
result
=
payload
.
datas
;
newCurrent
=
newTabs
.
panes
[
i
];
if
(
newCurrent
.
key
==
payload
.
key
){
newCurrent
.
console
=
newTabs
.
panes
[
i
].
console
;
}
break
;
break
;
}
}
}
}
return
{
return
{
...
state
,
...
state
,
current
:
newCurrent
,
current
:
{...
newCurrent
}
,
tabs
:
newTabs
,
tabs
:
{...
newTabs
}
,
};
};
},
},
saveCluster
(
state
,
{
payload
})
{
saveCluster
(
state
,
{
payload
})
{
return
{
return
{
...
state
,
...
state
,
cluster
:
payload
,
cluster
:
[...
payload
]
,
};
};
},
saveSessionCluster
(
state
,
{
payload
})
{
},
saveSessionCluster
(
state
,
{
payload
})
{
return
{
return
{
...
state
,
...
state
,
sessionCluster
:
payload
,
sessionCluster
:
[...
payload
]
,
};
};
},
saveClusterConfiguration
(
state
,
{
payload
})
{
},
saveClusterConfiguration
(
state
,
{
payload
})
{
return
{
return
{
...
state
,
...
state
,
clusterConfiguration
:
payload
,
clusterConfiguration
:
[...
payload
]
,
};
};
},
saveDataBase
(
state
,
{
payload
})
{
},
saveDataBase
(
state
,
{
payload
})
{
return
{
return
{
...
state
,
...
state
,
database
:
payload
,
database
:
[...
payload
]
,
};
};
},
saveEnv
(
state
,
{
payload
})
{
},
saveEnv
(
state
,
{
payload
})
{
return
{
return
{
...
state
,
...
state
,
env
:
payload
,
env
:
[...
payload
]
,
};
};
},
saveChart
(
state
,
{
payload
})
{
},
saveChart
(
state
,
{
payload
})
{
let
newTabs
=
state
?.
tabs
;
let
newTabs
=
state
?.
tabs
;
...
@@ -482,8 +491,8 @@ const Model: ModelType = {
...
@@ -482,8 +491,8 @@ const Model: ModelType = {
}
}
return
{
return
{
...
state
,
...
state
,
current
:
newCurrent
,
current
:
{...
newCurrent
}
,
tabs
:
newTabs
,
tabs
:
{...
newTabs
}
,
};
};
},
},
},
},
...
...
dlink-web/src/pages/Welcome.tsx
View file @
fa4e61cb
...
@@ -589,6 +589,27 @@ export default (): React.ReactNode => {
...
@@ -589,6 +589,27 @@ export default (): React.ReactNode => {
<
li
>
<
li
>
<
Link
>
新增 F2 全屏开发
</
Link
>
<
Link
>
新增 F2 全屏开发
</
Link
>
</
li
>
</
li
>
<
li
>
<
Link
>
升级 SpringBoot 至 2.6.3
</
Link
>
</
li
>
<
li
>
<
Link
>
优化 日志依赖
</
Link
>
</
li
>
<
li
>
<
Link
>
修复 前端 state 赋值 bug
</
Link
>
</
li
>
<
li
>
<
Link
>
修复 异常预览内容溢出 bug
</
Link
>
</
li
>
<
li
>
<
Link
>
修复 数据预览特殊条件下无法获取数据的 bug
</
Link
>
</
li
>
<
li
>
<
Link
>
优化 SQL编辑器性能
</
Link
>
</
li
>
<
li
>
<
Link
>
修复 全屏开发退出后 sql 不同步
</
Link
>
</
li
>
</
ul
>
</
ul
>
</
Paragraph
>
</
Paragraph
>
</
Timeline
.
Item
>
</
Timeline
.
Item
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment