54 lines
1.3 KiB
TypeScript
54 lines
1.3 KiB
TypeScript
import { useIntl } from 'umi';
|
|
|
|
export enum LinkStatusMap {
|
|
ENABLED = '0',
|
|
DISABLED = '1',
|
|
}
|
|
export const useFriendLinkDict = () => {
|
|
const intl = useIntl();
|
|
|
|
// 友情链接状态选项
|
|
const linkStatusOptions = [
|
|
{
|
|
label: intl.formatMessage({ id: 'friendLink.enabled' }),
|
|
value: LinkStatusMap.ENABLED,
|
|
},
|
|
{
|
|
label: intl.formatMessage({ id: 'friendLink.disabled' }),
|
|
value: LinkStatusMap.DISABLED,
|
|
},
|
|
];
|
|
|
|
// 获取状态标签
|
|
const getLinkStatusText = (status: number) => {
|
|
const option = linkStatusOptions.find(item => item.value === status.toString());
|
|
return option ? option.label : '-';
|
|
};
|
|
|
|
// 友情链接分类类型选项
|
|
// type int 是 类型(0.普通展示、1.重点展示)
|
|
const categoryTypeOptions = [
|
|
{
|
|
label: intl.formatMessage({ id: 'friendLink.category.type.normal' }),
|
|
value: '0',
|
|
},
|
|
{
|
|
label: intl.formatMessage({ id: 'friendLink.category.type.featured' }),
|
|
value: '1',
|
|
},
|
|
];
|
|
|
|
// 获取分类类型标签
|
|
const getCategoryTypeText = (type: string) => {
|
|
const option = categoryTypeOptions.find(item => item.value === type);
|
|
return option ? option.label : '-';
|
|
};
|
|
|
|
return {
|
|
linkStatusOptions,
|
|
getLinkStatusText,
|
|
categoryTypeOptions,
|
|
getCategoryTypeText,
|
|
};
|
|
};
|