Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
VisualDL
提交
381d8b80
V
VisualDL
项目概览
PaddlePaddle
/
VisualDL
大约 1 年 前同步成功
通知
88
Star
4655
Fork
642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
5
Wiki
分析
仓库
DevOps
项目成员
Pages
V
VisualDL
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
5
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
381d8b80
编写于
9月 05, 2020
作者:
P
Peter Pan
提交者:
GitHub
9月 05, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: restore selected model when navigating back to graph page (#789)
上级
767c6d30
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
20 addition
and
10 deletion
+20
-10
frontend/packages/core/src/hooks/useGlobalState.ts
frontend/packages/core/src/hooks/useGlobalState.ts
+3
-1
frontend/packages/core/src/hooks/useRequest.ts
frontend/packages/core/src/hooks/useRequest.ts
+1
-1
frontend/packages/core/src/pages/graph.tsx
frontend/packages/core/src/pages/graph.tsx
+16
-8
未找到文件。
frontend/packages/core/src/hooks/useGlobalState.ts
x
→
frontend/packages/core/src/hooks/useGlobalState.ts
浏览文件 @
381d8b80
...
...
@@ -4,10 +4,12 @@ import type {Dispatch} from 'react';
export
interface
GlobalState
{
runs
:
string
[];
model
:
FileList
|
File
[]
|
null
;
}
export
const
globalState
:
GlobalState
=
{
runs
:
[]
runs
:
[],
model
:
null
};
export
const
GlobalStateContext
=
createContext
<
GlobalState
>
(
globalState
);
...
...
frontend/packages/core/src/hooks/useRequest.ts
浏览文件 @
381d8b80
...
...
@@ -21,7 +21,7 @@ function useRequest<D = unknown, E = unknown>(
config
?:
ConfigInterface
<
D
,
E
,
fetcherFn
<
D
>>
):
Response
<
D
,
E
>
{
const
{
data
,
error
,
...
other
}
=
useSWR
<
D
,
E
>
(
key
,
fetcher
,
config
);
const
loading
=
useMemo
(()
=>
!
data
&&
!
error
,
[
data
,
error
]);
const
loading
=
useMemo
(()
=>
!
!
key
&&
!
data
&&
!
error
,
[
key
,
data
,
error
]);
return
{
data
,
error
,
loading
,
...
other
};
}
...
...
frontend/packages/core/src/pages/graph.tsx
浏览文件 @
381d8b80
...
...
@@ -20,6 +20,7 @@ import Search from '~/components/GraphPage/Search';
import
Title
from
'
~/components/Title
'
;
import
Uploader
from
'
~/components/GraphPage/Uploader
'
;
import
styled
from
'
styled-components
'
;
import
useGlobalState
from
'
~/hooks/useGlobalState
'
;
import
useRequest
from
'
~/hooks/useRequest
'
;
import
{
useTranslation
}
from
'
react-i18next
'
;
...
...
@@ -70,23 +71,30 @@ const Loading = styled.div`
const
Graph
:
FunctionComponent
=
()
=>
{
const
{
t
}
=
useTranslation
([
'
graph
'
,
'
common
'
]);
const
{
data
,
loading
}
=
useRequest
<
BlobResponse
>
(
'
/graph/graph
'
,
blobFetcher
);
const
[
globalState
,
globalDispatch
]
=
useGlobalState
(
);
const
graph
=
useRef
<
GraphRef
>
(
null
);
const
file
=
useRef
<
HTMLInputElement
>
(
null
);
const
[
files
,
setFiles
]
=
useState
<
FileList
|
File
[]
|
null
>
(
nul
l
);
const
[
files
,
setFiles
]
=
useState
<
FileList
|
File
[]
|
null
>
(
globalState
.
mode
l
);
const
onClickFile
=
useCallback
(()
=>
{
if
(
file
.
current
)
{
file
.
current
.
value
=
''
;
file
.
current
.
click
();
}
},
[]);
const
onChangeFile
=
useCallback
((
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
const
onChangeFile
=
useCallback
(
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
const
target
=
e
.
target
;
if
(
target
&&
target
.
files
&&
target
.
files
.
length
)
{
globalDispatch
({
model
:
target
.
files
});
setFiles
(
target
.
files
);
}
},
[]);
},
[
globalDispatch
]
);
const
{
data
,
loading
}
=
useRequest
<
BlobResponse
>
(
files
?
null
:
'
/graph/graph
'
,
blobFetcher
);
useEffect
(()
=>
{
if
(
data
?.
data
.
size
)
{
setFiles
([
new
File
([
data
.
data
],
data
.
filename
||
'
unknwon_model
'
)]);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录