Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dinky
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
wangpeng
dinky
Commits
0ded9c19
Unverified
Commit
0ded9c19
authored
Apr 15, 2024
by
Zzm0809
Committed by
GitHub
Apr 15, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Optimization] optimizing the rendering logic of resource management (#3397)
Signed-off-by:
Zzm0809
<
934230207@qq.com
>
Co-authored-by:
Zzm0809
<
Zzm0809@users.noreply.github.com
>
parent
934b3f85
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
164 additions
and
83 deletions
+164
-83
pages.ts
dinky-web/src/locales/en-US/pages.ts
+3
-0
pages.ts
dinky-web/src/locales/zh-CN/pages.ts
+2
-0
index.tsx
.../RegCenter/Resource/components/ResourceOverView/index.tsx
+126
-81
model.ts
dinky-web/src/pages/SettingCenter/GlobalSetting/model.ts
+29
-2
service.ts
dinky-web/src/pages/SettingCenter/GlobalSetting/service.ts
+4
-0
No files found.
dinky-web/src/locales/en-US/pages.ts
View file @
0ded9c19
...
...
@@ -981,6 +981,9 @@ export default {
'rc.resource.filelist'
:
'File list'
,
'rc.resource.sync'
:
'Sync remote files'
,
'rc.resource.copy'
:
'Copy as: {fillValue}'
,
'rc.resource.enable'
:
'Resource management function is not enabled'
,
'rc.resource.enable.tips'
:
'Please go to [Setting Center -> Global Settings -> Resource Configuration] to enable the resource management function!!!'
,
'rc.template.codeType'
:
'Code Type'
,
'rc.template.codeTypePlaceholder'
:
'Please select code type! '
,
...
...
dinky-web/src/locales/zh-CN/pages.ts
View file @
0ded9c19
...
...
@@ -940,6 +940,8 @@ export default {
'rc.resource.filelist'
:
'文件列表'
,
'rc.resource.sync'
:
'同步目录结构'
,
'rc.resource.copy'
:
'复制为: {fillValue}'
,
'rc.resource.enable'
:
'未启用资源管理功能'
,
'rc.resource.enable.tips'
:
'请前往 [配置中心 -> 全局配置 -> Resource 配置] 中启用资源管理功能!!!'
,
'rc.template.codeType'
:
'代码类型'
,
'rc.template.codeTypePlaceholder'
:
'请选择代码类型!'
,
...
...
dinky-web/src/pages/RegCenter/Resource/components/ResourceOverView/index.tsx
View file @
0ded9c19
...
...
@@ -27,6 +27,8 @@ import FileShow from '@/pages/RegCenter/Resource/components/FileShow';
import
FileTree
from
'@/pages/RegCenter/Resource/components/FileTree'
;
import
ResourceModal
from
'@/pages/RegCenter/Resource/components/ResourceModal'
;
import
ResourcesUploadModal
from
'@/pages/RegCenter/Resource/components/ResourcesUploadModal'
;
import
{
CONFIG_MODEL_ASYNC
,
SysConfigStateType
}
from
'@/pages/SettingCenter/GlobalSetting/model'
;
import
{
SettingConfigKeyEnum
}
from
'@/pages/SettingCenter/GlobalSetting/SettingOverView/constants'
;
import
{
handleGetOption
,
handleOption
,
...
...
@@ -41,12 +43,18 @@ import { unSupportView } from '@/utils/function';
import
{
l
}
from
'@/utils/intl'
;
import
{
SplitPane
}
from
'@andrewray/react-multi-split-pane'
;
import
{
Pane
}
from
'@andrewray/react-multi-split-pane/dist/lib/Pane'
;
import
{
WarningOutlined
}
from
'@ant-design/icons'
;
import
{
ProCard
}
from
'@ant-design/pro-components'
;
import
{
history
}
from
'@umijs/max'
;
import
{
useAsyncEffect
}
from
'ahooks'
;
import
{
Button
,
Result
}
from
'antd'
;
import
{
MenuInfo
}
from
'rc-menu/es/interface'
;
import
React
,
{
useCallback
,
useRef
,
useState
}
from
'react'
;
import
React
,
{
useCallback
,
useEffect
,
useRef
,
useState
}
from
'react'
;
import
{
connect
}
from
'umi'
;
const
ResourceOverView
:
React
.
FC
<
connect
>
=
(
props
)
=>
{
const
{
dispatch
,
enableResource
}
=
props
;
const
ResourceOverView
:
React
.
FC
=
()
=>
{
const
[
resourceState
,
setResourceState
]
=
useState
<
ResourceState
>
(
InitResourceState
);
const
[
editModal
,
setEditModal
]
=
useState
<
string
>
(
''
);
...
...
@@ -64,10 +72,20 @@ const ResourceOverView: React.FC = () => {
);
};
useAsyncEffect
(
async
()
=>
{
await
refreshTree
();
useEffect
(()
=>
{
dispatch
({
type
:
CONFIG_MODEL_ASYNC
.
queryResourceConfig
,
payload
:
SettingConfigKeyEnum
.
RESOURCE
.
toLowerCase
()
});
},
[]);
useAsyncEffect
(
async
()
=>
{
// if enableResource is true, then refresh the tree, otherwise do nothing
if
(
enableResource
)
{
await
refreshTree
();
}
},
[
enableResource
]);
/**
* query content by id
* @type {(id: number) => Promise<void>}
...
...
@@ -253,87 +271,114 @@ const ResourceOverView: React.FC = () => {
*/
return
(
<>
<
ProCard
ghost
size=
{
'small'
}
bodyStyle=
{
{
height
:
parent
.
innerHeight
-
80
}
}
>
<
SplitPane
split=
{
'vertical'
}
defaultSizes=
{
[
200
,
500
]
}
minSize=
{
200
}
className=
{
'split-pane'
}
>
<
Pane
className=
{
'split-pane'
}
forwardRef=
{
refObject
}
minSize=
{
200
}
size=
{
200
}
split=
{
'horizontal'
}
>
<
ProCard
hoverable
boxShadow
bodyStyle=
{
{
height
:
parent
.
innerHeight
-
80
}
}
colSpan=
{
'18%'
}
{
!
enableResource
?
(
<
ProCard
ghost
size=
{
'small'
}
bodyStyle=
{
{
height
:
parent
.
innerHeight
-
80
}
}
>
<
Result
status=
'warning'
style=
{
{
alignItems
:
'center'
,
justifyContent
:
'center'
}
}
icon=
{
<
WarningOutlined
/>
}
title=
{
l
(
'rc.resource.enable'
)
}
subTitle=
{
l
(
'rc.resource.enable.tips'
)
}
extra=
{
<
Button
onClick=
{
()
=>
{
history
.
push
(
'/settings/globalsetting'
);
}
}
type=
'primary'
key=
'globalsetting-to-jump'
>
{
l
(
'menu.settings'
)
}
</
Button
>
}
/>
</
ProCard
>
)
:
(
<>
<
ProCard
ghost
size=
{
'small'
}
bodyStyle=
{
{
height
:
parent
.
innerHeight
-
80
}
}
>
<
SplitPane
split=
{
'vertical'
}
defaultSizes=
{
[
200
,
500
]
}
minSize=
{
200
}
className=
{
'split-pane'
}
>
<
FileTree
selectedKeys=
{
resourceState
.
selectedKeys
}
treeData=
{
resourceState
.
treeData
}
onRightClick=
{
handleRightClick
}
onNodeClick=
{
(
info
:
any
)
=>
handleNodeClick
(
info
)
}
onSync=
{
handleSync
}
/>
<
RightContextMenu
contextMenuPosition=
{
resourceState
.
contextMenuPosition
}
open=
{
resourceState
.
contextMenuOpen
}
openChange=
{
()
=>
setResourceState
((
prevState
)
=>
({
...
prevState
,
contextMenuOpen
:
false
}))
}
items=
{
renderRightMenu
()
}
onClick=
{
handleMenuClick
}
/>
</
ProCard
>
</
Pane
>
<
Pane
className=
{
'split-pane'
}
forwardRef=
{
refObject
}
minSize=
{
200
}
size=
{
200
}
split=
{
'horizontal'
}
>
<
ProCard
hoverable
boxShadow
bodyStyle=
{
{
height
:
parent
.
innerHeight
-
80
}
}
colSpan=
{
'18%'
}
>
<
FileTree
selectedKeys=
{
resourceState
.
selectedKeys
}
treeData=
{
resourceState
.
treeData
}
onRightClick=
{
handleRightClick
}
onNodeClick=
{
(
info
:
any
)
=>
handleNodeClick
(
info
)
}
onSync=
{
handleSync
}
/>
<
RightContextMenu
contextMenuPosition=
{
resourceState
.
contextMenuPosition
}
open=
{
resourceState
.
contextMenuOpen
}
openChange=
{
()
=>
setResourceState
((
prevState
)
=>
({
...
prevState
,
contextMenuOpen
:
false
}))
}
items=
{
renderRightMenu
()
}
onClick=
{
handleMenuClick
}
/>
</
ProCard
>
</
Pane
>
<
Pane
className=
{
'split-pane'
}
forwardRef=
{
refObject
}
minSize=
{
100
}
size=
{
100
}
split=
{
'horizontal'
}
>
<
ProCard
hoverable
bodyStyle=
{
{
height
:
parent
.
innerHeight
}
}
>
<
FileShow
onChange=
{
handleContentChange
}
code=
{
resourceState
.
content
}
item=
{
resourceState
.
clickedNode
}
/>
</
ProCard
>
</
Pane
>
</
SplitPane
>
</
ProCard
>
{
resourceState
.
editOpen
&&
(
<
ResourceModal
title=
{
editModal
===
'createFolder'
?
l
(
'right.menu.createFolder'
)
:
editModal
===
'rename'
?
l
(
'right.menu.rename'
)
:
''
}
formValues=
{
resourceState
.
value
}
onOk=
{
handleModalSubmit
}
onClose=
{
handleModalCancel
}
visible=
{
resourceState
.
editOpen
}
/>
)
}
{
resourceState
.
uploadOpen
&&
(
<
ResourcesUploadModal
onUpload=
{
uploadValue
}
visible=
{
resourceState
.
uploadOpen
}
onOk=
{
handleUploadCancel
}
onClose=
{
handleUploadCancel
}
/>
<
Pane
className=
{
'split-pane'
}
forwardRef=
{
refObject
}
minSize=
{
100
}
size=
{
100
}
split=
{
'horizontal'
}
>
<
ProCard
hoverable
bodyStyle=
{
{
height
:
parent
.
innerHeight
}
}
>
<
FileShow
onChange=
{
handleContentChange
}
code=
{
resourceState
.
content
}
item=
{
resourceState
.
clickedNode
}
/>
</
ProCard
>
</
Pane
>
</
SplitPane
>
</
ProCard
>
{
resourceState
.
editOpen
&&
(
<
ResourceModal
title=
{
editModal
===
'createFolder'
?
l
(
'right.menu.createFolder'
)
:
editModal
===
'rename'
?
l
(
'right.menu.rename'
)
:
''
}
formValues=
{
resourceState
.
value
}
onOk=
{
handleModalSubmit
}
onClose=
{
handleModalCancel
}
visible=
{
resourceState
.
editOpen
}
/>
)
}
{
resourceState
.
uploadOpen
&&
(
<
ResourcesUploadModal
onUpload=
{
uploadValue
}
visible=
{
resourceState
.
uploadOpen
}
onOk=
{
handleUploadCancel
}
onClose=
{
handleUploadCancel
}
/>
)
}
</>
)
}
</>
);
};
export
default
ResourceOverView
;
export
default
connect
(({
SysConfig
}:
{
SysConfig
:
SysConfigStateType
})
=>
({
enableResource
:
SysConfig
.
enableResource
}))(
ResourceOverView
);
dinky-web/src/pages/SettingCenter/GlobalSetting/model.ts
View file @
0ded9c19
...
...
@@ -17,7 +17,7 @@
*
*/
import
{
queryDsConfig
}
from
'@/pages/SettingCenter/GlobalSetting/service'
;
import
{
queryDsConfig
,
queryResourceConfig
}
from
'@/pages/SettingCenter/GlobalSetting/service'
;
import
{
BaseConfigProperties
}
from
'@/types/SettingCenter/data'
;
import
{
createModelTypes
}
from
'@/utils/modelUtils'
;
import
{
Effect
}
from
'@@/plugin-dva/types'
;
...
...
@@ -28,6 +28,7 @@ const SYS_CONFIG = 'SysConfig';
export
type
SysConfigStateType
=
{
dsConfig
:
BaseConfigProperties
[];
enabledDs
:
boolean
;
enableResource
:
boolean
;
};
export
type
ConfigModelType
=
{
...
...
@@ -35,10 +36,12 @@ export type ConfigModelType = {
state
:
SysConfigStateType
;
effects
:
{
queryDsConfig
:
Effect
;
queryResourceConfig
:
Effect
;
};
reducers
:
{
saveDsConfig
:
Reducer
<
SysConfigStateType
>
;
updateEnabledDs
:
Reducer
<
SysConfigStateType
>
;
updateEnableResource
:
Reducer
<
SysConfigStateType
>
;
};
};
...
...
@@ -46,7 +49,8 @@ const ConfigModel: ConfigModelType = {
namespace
:
SYS_CONFIG
,
state
:
{
dsConfig
:
[],
enabledDs
:
false
enabledDs
:
false
,
enableResource
:
false
},
effects
:
{
...
...
@@ -66,6 +70,23 @@ const ConfigModel: ConfigModelType = {
payload
:
enabledDs
});
}
},
*
queryResourceConfig
({
payload
},
{
call
,
put
})
{
const
response
:
BaseConfigProperties
[]
=
yield
call
(
queryResourceConfig
,
payload
);
yield
put
({
type
:
'saveDsConfig'
,
payload
:
response
||
[]
});
if
(
response
&&
response
.
length
>
0
)
{
const
enableResource
=
response
.
some
(
(
item
:
BaseConfigProperties
)
=>
item
.
key
===
'sys.resource.settings.base.enable'
&&
item
.
value
===
true
);
yield
put
({
type
:
'updateEnableResource'
,
payload
:
enableResource
});
}
}
},
...
...
@@ -81,6 +102,12 @@ const ConfigModel: ConfigModelType = {
...
state
,
enabledDs
:
payload
};
},
updateEnableResource
(
state
,
{
payload
})
{
return
{
...
state
,
enableResource
:
payload
};
}
}
};
...
...
dinky-web/src/pages/SettingCenter/GlobalSetting/service.ts
View file @
0ded9c19
...
...
@@ -23,3 +23,7 @@ import { API_CONSTANTS } from '@/services/endpoints';
export
async
function
queryDsConfig
(
keyword
:
string
)
{
return
await
queryDataByParams
(
API_CONSTANTS
.
SYSTEM_GET_ONE_TYPE_CONFIG
,
{
type
:
keyword
});
}
export
async
function
queryResourceConfig
(
keyword
:
string
)
{
return
await
queryDataByParams
(
API_CONSTANTS
.
SYSTEM_GET_ONE_TYPE_CONFIG
,
{
type
:
keyword
});
}
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