Skip to content

Commit

Permalink
feat(frontend): cache selected label
Browse files Browse the repository at this point in the history
  • Loading branch information
gary-Shen committed Apr 17, 2024
1 parent f3e193f commit 65d7c62
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions apps/frontend/src/pages/tasks.[id].samples.[id]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,13 @@ const AnnotationPage = () => {
[config, task],
);

const handleLabelChange = useCallback((label: ILabel) => {
// 缓存当前标签
localStorage.setItem('annotator::label', label.value);
}, []);

const selectedLabel = localStorage.getItem('annotator::label');

if (task?.media_type === MediaType.IMAGE) {
content = (
<ImageAnnotator
Expand All @@ -244,6 +251,8 @@ const AnnotationPage = () => {
editingSample={editingSample}
config={config}
requestEdit={requestEdit}
onLabelChange={handleLabelChange}
selectedLabel={selectedLabel}
preAnnotationLabels={preAnnotationConfig}
preAnnotations={preAnnotations}
/>
Expand All @@ -259,6 +268,8 @@ const AnnotationPage = () => {
toolbarRight={topActionContent}
renderSidebar={renderSidebar}
requestEdit={requestEdit}
onLabelChange={handleLabelChange}
selectedLabel={selectedLabel}
preAnnotationLabels={preAnnotationConfig}
preAnnotations={preAnnotations}
/>
Expand All @@ -274,6 +285,8 @@ const AnnotationPage = () => {
toolbarRight={topActionContent}
renderSidebar={renderSidebar}
requestEdit={requestEdit}
onLabelChange={handleLabelChange}
selectedLabel={selectedLabel}
preAnnotationLabels={preAnnotationConfig}
preAnnotations={preAnnotations}
/>
Expand Down

0 comments on commit 65d7c62

Please sign in to comment.