维护所有模块的多语言功能,对接友情分类接口和友情链接接口
This commit is contained in:
48
src/dicts/friendLinkDict.ts
Normal file
48
src/dicts/friendLinkDict.ts
Normal file
@ -0,0 +1,48 @@
|
||||
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,
|
||||
};
|
||||
};
|
Reference in New Issue
Block a user