-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from IDEA-Research/feature/dataset_cover
Feature: optimize dataset cover image display logic
- Loading branch information
Showing
2 changed files
with
28 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,27 @@ | ||
import { isEmpty, isUndefined, includes } from 'lodash'; | ||
import { includes } from 'lodash'; | ||
|
||
/** | ||
* check cover url of dataset, and display cover image based on different situation | ||
* @param url | ||
* set cover image based on dataset type | ||
* @param type | ||
* @returns modified url | ||
*/ | ||
export const renderDatasetCover = (url: string, type: string[]) => { | ||
if (isUndefined(url) || isEmpty(url)) { | ||
let _img_index = 5; | ||
export const generateDefaultCover = (type: string[]) => { | ||
let _img_index: number = 5; | ||
|
||
if (includes(type, 'Classification')) { | ||
_img_index = 1; | ||
} | ||
if (includes(type, 'Detection')) { | ||
_img_index = 2; | ||
} | ||
if (includes(type, 'Segmentation')) { | ||
_img_index = 3; | ||
} | ||
if (includes(type, 'Matting')) { | ||
_img_index = 4; | ||
} | ||
if (includes(type, 'KeyPoints')) { | ||
_img_index = 5; | ||
} | ||
|
||
return require(`@/assets/images/cards/card_cover_${_img_index}.png`); | ||
} else if (/^http:/.test(url)) { | ||
return url; | ||
} else { | ||
return process.env.API_PATH + url; | ||
if (includes(type, 'Classification')) { | ||
_img_index = 1; | ||
} | ||
if (includes(type, 'Detection')) { | ||
_img_index = 2; | ||
} | ||
if (includes(type, 'Segmentation')) { | ||
_img_index = 3; | ||
} | ||
if (includes(type, 'Matting')) { | ||
_img_index = 4; | ||
} | ||
if (includes(type, 'KeyPoints')) { | ||
_img_index = 5; | ||
} | ||
|
||
return require(`@/assets/images/cards/card_cover_${_img_index}.png`); | ||
}; |