Skip to content

Commit

Permalink
feat: 扩展mountIconSpriteToDom方法
Browse files Browse the repository at this point in the history
  • Loading branch information
qkiroc committed Oct 24, 2023
1 parent 7120e1a commit 8bd9c89
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions packages/amis/src/renderers/Form/IconSelectStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ export interface SvgIconGroup {

export let svgIcons: SvgIconGroup[] = [];

function getSvgMountNode() {
const node = document.getElementById('amis-icon-manage-mount-node');
function getSvgMountNode(nodeId: string = 'amis-icon-manage-mount-node') {
const node = document.getElementById(nodeId);

if (node) {
return node;
} else {
const newNode = document.createElement('div');
newNode.setAttribute('id', 'amis-icon-manage-mount-node');
newNode.setAttribute('id', nodeId);
newNode.setAttribute('style', 'width:0;height:0;visibility:hidden;');

if (document.body.firstElementChild) {
Expand All @@ -35,9 +35,9 @@ function getSvgMountNode() {
}
}

export function mountIconSpiriteToDom(spirite: string) {
const node = getSvgMountNode();
node && (node.innerHTML = spirite);
export function mountIconSpriteToDom(sprite: string, nodeId?: string) {
const node = getSvgMountNode(nodeId);
node && (node.innerHTML = sprite);
}

type refreshIconListFunc = null | (() => any);
Expand All @@ -47,17 +47,17 @@ export let refreshIconList: refreshIconListFunc = null;
export function setRefreshSvgListAction(
func: ({
setSvgIconList,
mountIconSpiriteToDom
mountIconSpriteToDom
}: {
setSvgIconList: (arr: SvgIconGroup[]) => void;
mountIconSpiriteToDom: (str: string) => void;
mountIconSpriteToDom: (str: string) => void;
}) => any
) {
if (func && typeof func === 'function') {
refreshIconList = () =>
func({
setSvgIconList,
mountIconSpiriteToDom
mountIconSpriteToDom
});
} else {
refreshIconList = null;
Expand Down

0 comments on commit 8bd9c89

Please sign in to comment.