You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
/**
|
|
|
|
|
* Icon 自定义组件,提供定制Icon组件能力
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import * as React from "react";
|
|
|
|
|
import { createFromIconfontCN } from "@ant-design/icons";
|
|
|
|
|
import { Util } from "@/utils";
|
|
|
|
|
|
|
|
|
|
export declare type IconType = React.ReactNode | string;
|
|
|
|
|
const hrmSalaryUrl = "/spa/hrmSalary/hrmSalaryCalculateDetail/";
|
|
|
|
|
const Icon = createFromIconfontCN({
|
|
|
|
|
scriptUrl: [
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
`${process.env.NODE_ENV === "dev" ? Util.getPublicPath() : hrmSalaryUrl}css/iconfont/iconfont.js`
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据参数构建图标
|
|
|
|
|
* @param icon
|
|
|
|
|
*/
|
|
|
|
|
export const buildIcon: (
|
|
|
|
|
type: string,
|
|
|
|
|
icon: IconType,
|
|
|
|
|
style?: React.CSSProperties,
|
|
|
|
|
className?: string
|
|
|
|
|
) => React.ReactNode | null = function (
|
|
|
|
|
type,
|
|
|
|
|
icon,
|
|
|
|
|
style = {},
|
|
|
|
|
className = ""
|
|
|
|
|
) {
|
|
|
|
|
let comp;
|
|
|
|
|
switch (type) {
|
|
|
|
|
case "IMAGE":
|
|
|
|
|
comp =
|
|
|
|
|
typeof icon === "string" ? (
|
|
|
|
|
<img
|
|
|
|
|
src={icon}
|
|
|
|
|
className={className}
|
|
|
|
|
style={{ width: 16, height: 16, ...style }}
|
|
|
|
|
/>
|
|
|
|
|
) : (
|
|
|
|
|
icon
|
|
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
comp =
|
|
|
|
|
typeof icon === "string" ? (
|
|
|
|
|
<Icon type={icon} style={style} className={className}/>
|
|
|
|
|
) : (
|
|
|
|
|
icon
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return comp;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default Icon;
|