Files
fe_supplier_frontend/src/dicts/friendLinkDict.ts

49 lines
1.1 KiB
TypeScript

import { useIntl } from 'umi';
export const useFriendLinkDict = () => {
const intl = useIntl();
// 友情链接状态选项
const linkStatusOptions = [
{
label: intl.formatMessage({ id: 'friendLink.enabled' }),
value: '1',
},
{
label: intl.formatMessage({ id: 'friendLink.disabled' }),
value: '0',
},
];
// 获取状态标签
const getLinkStatusText = (status: number) => {
const option = linkStatusOptions.find(item => item.value === status.toString());
return option ? option.label : '-';
};
// 友情链接分类类型选项
const categoryTypeOptions = [
{
label: intl.formatMessage({ id: 'friendLink.category.type.normal' }),
value: 'normal',
},
{
label: intl.formatMessage({ id: 'friendLink.category.type.featured' }),
value: 'featured',
},
];
// 获取分类类型标签
const getCategoryTypeText = (type: string) => {
const option = categoryTypeOptions.find(item => item.value === type);
return option ? option.label : '-';
};
return {
linkStatusOptions,
getLinkStatusText,
categoryTypeOptions,
getCategoryTypeText,
};
};