Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 添加唯一 id 生成参数的覆盖逻辑 #561

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/react/src/runtime/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ export interface IIconConfig {
innerFillColor: string;
};
};

// 唯一ID 生成函数
guid?: () => string,
}

// 图标基础属性
Expand Down Expand Up @@ -232,7 +235,10 @@ export function IconWrapper(name: string, rtl: boolean, render: IconRender): Ico

const ICON_CONFIGS = useContext(IconContext);

const id = useMemo(guid, []);
let id = guid();
if (ICON_CONFIGS.guid && typeof ICON_CONFIGS.guid == 'function') {
id = ICON_CONFIGS.guid();
}

const svgProps = IconConverter(id, {
size,
Expand Down
10 changes: 8 additions & 2 deletions packages/vue-next/src/runtime/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ export interface IIconConfig {
innerFillColor: string;
};
};

// 唯一ID 生成函数
guid?: () => string,
}

// 图标基础属性
Expand Down Expand Up @@ -218,10 +221,13 @@ export function IconWrapper(name: string, rtl: boolean, render: IconRender): Ico
props: ['size', 'strokeWidth', 'strokeLinecap', 'strokeLinejoin', 'theme', 'fill', 'spin'],
setup: (props) => {

const id = guid();

const ICON_CONFIGS = inject(IconContext, DEFAULT_ICON_CONFIGS);

let id = guid();
if (ICON_CONFIGS.guid && typeof ICON_CONFIGS.guid == 'function') {
id = ICON_CONFIGS.guid();
}

return () => {

const {
Expand Down