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 {
...
@@ -981,6 +981,9 @@ export default {
'rc.resource.filelist'
:
'File list'
,
'rc.resource.filelist'
:
'File list'
,
'rc.resource.sync'
:
'Sync remote files'
,
'rc.resource.sync'
:
'Sync remote files'
,
'rc.resource.copy'
:
'Copy as: {fillValue}'
,
'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.codeType'
:
'Code Type'
,
'rc.template.codeTypePlaceholder'
:
'Please select 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 {
...
@@ -940,6 +940,8 @@ export default {
'rc.resource.filelist'
:
'文件列表'
,
'rc.resource.filelist'
:
'文件列表'
,
'rc.resource.sync'
:
'同步目录结构'
,
'rc.resource.sync'
:
'同步目录结构'
,
'rc.resource.copy'
:
'复制为: {fillValue}'
,
'rc.resource.copy'
:
'复制为: {fillValue}'
,
'rc.resource.enable'
:
'未启用资源管理功能'
,
'rc.resource.enable.tips'
:
'请前往 [配置中心 -> 全局配置 -> Resource 配置] 中启用资源管理功能!!!'
,
'rc.template.codeType'
:
'代码类型'
,
'rc.template.codeType'
:
'代码类型'
,
'rc.template.codeTypePlaceholder'
:
'请选择代码类型!'
,
'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';
...
@@ -27,6 +27,8 @@ import FileShow from '@/pages/RegCenter/Resource/components/FileShow';
import
FileTree
from
'@/pages/RegCenter/Resource/components/FileTree'
;
import
FileTree
from
'@/pages/RegCenter/Resource/components/FileTree'
;
import
ResourceModal
from
'@/pages/RegCenter/Resource/components/ResourceModal'
;
import
ResourceModal
from
'@/pages/RegCenter/Resource/components/ResourceModal'
;
import
ResourcesUploadModal
from
'@/pages/RegCenter/Resource/components/ResourcesUploadModal'
;
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
{
import
{
handleGetOption
,
handleGetOption
,
handleOption
,
handleOption
,
...
@@ -41,12 +43,18 @@ import { unSupportView } from '@/utils/function';
...
@@ -41,12 +43,18 @@ import { unSupportView } from '@/utils/function';
import
{
l
}
from
'@/utils/intl'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
SplitPane
}
from
'@andrewray/react-multi-split-pane'
;
import
{
SplitPane
}
from
'@andrewray/react-multi-split-pane'
;
import
{
Pane
}
from
'@andrewray/react-multi-split-pane/dist/lib/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
{
ProCard
}
from
'@ant-design/pro-components'
;
import
{
history
}
from
'@umijs/max'
;
import
{
useAsyncEffect
}
from
'ahooks'
;
import
{
useAsyncEffect
}
from
'ahooks'
;
import
{
Button
,
Result
}
from
'antd'
;
import
{
MenuInfo
}
from
'rc-menu/es/interface'
;
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
[
resourceState
,
setResourceState
]
=
useState
<
ResourceState
>
(
InitResourceState
);
const
[
editModal
,
setEditModal
]
=
useState
<
string
>
(
''
);
const
[
editModal
,
setEditModal
]
=
useState
<
string
>
(
''
);
...
@@ -64,10 +72,20 @@ const ResourceOverView: React.FC = () => {
...
@@ -64,10 +72,20 @@ const ResourceOverView: React.FC = () => {
);
);
};
};
useAsyncEffect
(
async
()
=>
{
useEffect
(()
=>
{
await
refreshTree
();
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
* query content by id
* @type {(id: number) => Promise<void>}
* @type {(id: number) => Promise<void>}
...
@@ -253,87 +271,114 @@ const ResourceOverView: React.FC = () => {
...
@@ -253,87 +271,114 @@ const ResourceOverView: React.FC = () => {
*/
*/
return
(
return
(
<>
<>
<
ProCard
ghost
size=
{
'small'
}
bodyStyle=
{
{
height
:
parent
.
innerHeight
-
80
}
}
>
{
!
enableResource
?
(
<
SplitPane
<
ProCard
ghost
size=
{
'small'
}
bodyStyle=
{
{
height
:
parent
.
innerHeight
-
80
}
}
>
split=
{
'vertical'
}
<
Result
defaultSizes=
{
[
200
,
500
]
}
status=
'warning'
minSize=
{
200
}
style=
{
{
alignItems
:
'center'
,
justifyContent
:
'center'
}
}
className=
{
'split-pane'
}
icon=
{
<
WarningOutlined
/>
}
>
title=
{
l
(
'rc.resource.enable'
)
}
<
Pane
subTitle=
{
l
(
'rc.resource.enable.tips'
)
}
className=
{
'split-pane'
}
extra=
{
forwardRef=
{
refObject
}
<
Button
minSize=
{
200
}
onClick=
{
()
=>
{
size=
{
200
}
history
.
push
(
'/settings/globalsetting'
);
split=
{
'horizontal'
}
}
}
>
type=
'primary'
<
ProCard
key=
'globalsetting-to-jump'
hoverable
>
boxShadow
{
l
(
'menu.settings'
)
}
bodyStyle=
{
{
height
:
parent
.
innerHeight
-
80
}
}
</
Button
>
colSpan=
{
'18%'
}
}
/>
</
ProCard
>
)
:
(
<>
<
ProCard
ghost
size=
{
'small'
}
bodyStyle=
{
{
height
:
parent
.
innerHeight
-
80
}
}
>
<
SplitPane
split=
{
'vertical'
}
defaultSizes=
{
[
200
,
500
]
}
minSize=
{
200
}
className=
{
'split-pane'
}
>
>
<
FileTree
<
Pane
selectedKeys=
{
resourceState
.
selectedKeys
}
className=
{
'split-pane'
}
treeData=
{
resourceState
.
treeData
}
forwardRef=
{
refObject
}
onRightClick=
{
handleRightClick
}
minSize=
{
200
}
onNodeClick=
{
(
info
:
any
)
=>
handleNodeClick
(
info
)
}
size=
{
200
}
onSync=
{
handleSync
}
split=
{
'horizontal'
}
/>
>
<
RightContextMenu
<
ProCard
contextMenuPosition=
{
resourceState
.
contextMenuPosition
}
hoverable
open=
{
resourceState
.
contextMenuOpen
}
boxShadow
openChange=
{
()
=>
bodyStyle=
{
{
height
:
parent
.
innerHeight
-
80
}
}
setResourceState
((
prevState
)
=>
({
...
prevState
,
contextMenuOpen
:
false
}))
colSpan=
{
'18%'
}
}
>
items=
{
renderRightMenu
()
}
<
FileTree
onClick=
{
handleMenuClick
}
selectedKeys=
{
resourceState
.
selectedKeys
}
/>
treeData=
{
resourceState
.
treeData
}
</
ProCard
>
onRightClick=
{
handleRightClick
}
</
Pane
>
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
<
Pane
className=
{
'split-pane'
}
className=
{
'split-pane'
}
forwardRef=
{
refObject
}
forwardRef=
{
refObject
}
minSize=
{
100
}
minSize=
{
100
}
size=
{
100
}
size=
{
100
}
split=
{
'horizontal'
}
split=
{
'horizontal'
}
>
>
<
ProCard
hoverable
bodyStyle=
{
{
height
:
parent
.
innerHeight
}
}
>
<
ProCard
hoverable
bodyStyle=
{
{
height
:
parent
.
innerHeight
}
}
>
<
FileShow
<
FileShow
onChange=
{
handleContentChange
}
onChange=
{
handleContentChange
}
code=
{
resourceState
.
content
}
code=
{
resourceState
.
content
}
item=
{
resourceState
.
clickedNode
}
item=
{
resourceState
.
clickedNode
}
/>
/>
</
ProCard
>
</
ProCard
>
</
Pane
>
</
Pane
>
</
SplitPane
>
</
SplitPane
>
</
ProCard
>
</
ProCard
>
{
resourceState
.
editOpen
&&
(
{
resourceState
.
editOpen
&&
(
<
ResourceModal
<
ResourceModal
title=
{
title=
{
editModal
===
'createFolder'
editModal
===
'createFolder'
?
l
(
'right.menu.createFolder'
)
?
l
(
'right.menu.createFolder'
)
:
editModal
===
'rename'
:
editModal
===
'rename'
?
l
(
'right.menu.rename'
)
?
l
(
'right.menu.rename'
)
:
''
:
''
}
}
formValues=
{
resourceState
.
value
}
formValues=
{
resourceState
.
value
}
onOk=
{
handleModalSubmit
}
onOk=
{
handleModalSubmit
}
onClose=
{
handleModalCancel
}
onClose=
{
handleModalCancel
}
visible=
{
resourceState
.
editOpen
}
visible=
{
resourceState
.
editOpen
}
/>
/>
)
}
)
}
{
resourceState
.
uploadOpen
&&
(
{
resourceState
.
uploadOpen
&&
(
<
ResourcesUploadModal
<
ResourcesUploadModal
onUpload=
{
uploadValue
}
onUpload=
{
uploadValue
}
visible=
{
resourceState
.
uploadOpen
}
visible=
{
resourceState
.
uploadOpen
}
onOk=
{
handleUploadCancel
}
onOk=
{
handleUploadCancel
}
onClose=
{
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 @@
...
@@ -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
{
BaseConfigProperties
}
from
'@/types/SettingCenter/data'
;
import
{
createModelTypes
}
from
'@/utils/modelUtils'
;
import
{
createModelTypes
}
from
'@/utils/modelUtils'
;
import
{
Effect
}
from
'@@/plugin-dva/types'
;
import
{
Effect
}
from
'@@/plugin-dva/types'
;
...
@@ -28,6 +28,7 @@ const SYS_CONFIG = 'SysConfig';
...
@@ -28,6 +28,7 @@ const SYS_CONFIG = 'SysConfig';
export
type
SysConfigStateType
=
{
export
type
SysConfigStateType
=
{
dsConfig
:
BaseConfigProperties
[];
dsConfig
:
BaseConfigProperties
[];
enabledDs
:
boolean
;
enabledDs
:
boolean
;
enableResource
:
boolean
;
};
};
export
type
ConfigModelType
=
{
export
type
ConfigModelType
=
{
...
@@ -35,10 +36,12 @@ export type ConfigModelType = {
...
@@ -35,10 +36,12 @@ export type ConfigModelType = {
state
:
SysConfigStateType
;
state
:
SysConfigStateType
;
effects
:
{
effects
:
{
queryDsConfig
:
Effect
;
queryDsConfig
:
Effect
;
queryResourceConfig
:
Effect
;
};
};
reducers
:
{
reducers
:
{
saveDsConfig
:
Reducer
<
SysConfigStateType
>
;
saveDsConfig
:
Reducer
<
SysConfigStateType
>
;
updateEnabledDs
:
Reducer
<
SysConfigStateType
>
;
updateEnabledDs
:
Reducer
<
SysConfigStateType
>
;
updateEnableResource
:
Reducer
<
SysConfigStateType
>
;
};
};
};
};
...
@@ -46,7 +49,8 @@ const ConfigModel: ConfigModelType = {
...
@@ -46,7 +49,8 @@ const ConfigModel: ConfigModelType = {
namespace
:
SYS_CONFIG
,
namespace
:
SYS_CONFIG
,
state
:
{
state
:
{
dsConfig
:
[],
dsConfig
:
[],
enabledDs
:
false
enabledDs
:
false
,
enableResource
:
false
},
},
effects
:
{
effects
:
{
...
@@ -66,6 +70,23 @@ const ConfigModel: ConfigModelType = {
...
@@ -66,6 +70,23 @@ const ConfigModel: ConfigModelType = {
payload
:
enabledDs
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 = {
...
@@ -81,6 +102,12 @@ const ConfigModel: ConfigModelType = {
...
state
,
...
state
,
enabledDs
:
payload
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';
...
@@ -23,3 +23,7 @@ import { API_CONSTANTS } from '@/services/endpoints';
export
async
function
queryDsConfig
(
keyword
:
string
)
{
export
async
function
queryDsConfig
(
keyword
:
string
)
{
return
await
queryDataByParams
(
API_CONSTANTS
.
SYSTEM_GET_ONE_TYPE_CONFIG
,
{
type
:
keyword
});
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