| 123456789101112131415161718192021222324252627282930313233343536 |
- /**
- * 计算食物来源对应的path
- * @param {string} dataSource
- * @returns {String}
- */
- export function getFoodUrl(dataSource = '') {
- if (dataSource.indexOf('ENTRY') > -1) {
- return '/food/entry'
- } else if (dataSource.indexOf('CFCT') > -1) {
- return '/food/cfct'
- } else {
- return '/food'
- }
- }
- /**
- * 根据url判断食物来源
- * @param url
- * @returns {string}
- */
- export function getFoodSourceByUrl(url = '') {
- if (url.indexOf('entry') > -1) {
- return 'ENTRY'
- } else if (url.indexOf('cfct') > -1) {
- return 'CFCT'
- } else if (url.indexOf('usda') > -1) {
- return 'USDA'
- } else {
- return ''
- }
- }
- export function isUsda(dataSource) {
- return dataSource && dataSource.indexOf('USDA') > -1
- }
|