fix: 添加新icon与复制兼容
This commit is contained in:
parent
70ffe63766
commit
f47c8533a9
@ -15,18 +15,38 @@ const demo = () => {
|
||||
}
|
||||
};
|
||||
|
||||
async function copyTextToClipboard(textToCopy: string, successMessage?: string): Promise<void> {
|
||||
const copyTextToClipboard = async (textToCopy: string, successMessage?: string): Promise<void> => {
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
try {
|
||||
// 使用现代API尝试复制
|
||||
await navigator.clipboard.writeText(textToCopy);
|
||||
message.success(successMessage)
|
||||
} catch (error) {
|
||||
// 如果浏览器不支持或者用户拒绝了权限,可以考虑降级处理
|
||||
// 但在这个示例中,我们直接捕获异常并记录日志
|
||||
message.error('复制失败')
|
||||
console.error('Failed to copy: ', error);
|
||||
}} else {
|
||||
fallbackCopyTextToClipboard(textToCopy,successMessage);
|
||||
}
|
||||
}
|
||||
|
||||
const fallbackCopyTextToClipboard = (textToCopy: string, successMessage?: string) => {
|
||||
// 创建隐藏的textarea来模拟复制操作
|
||||
const input = document.createElement('input');
|
||||
input.setAttribute('value', textToCopy);
|
||||
document.body.appendChild(input);
|
||||
input.select();
|
||||
try {
|
||||
if (document.execCommand('copy')) {
|
||||
message.success(successMessage)
|
||||
} else {
|
||||
console.error('传统方式复制失败');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('传统方式复制出错:', error);
|
||||
} finally {
|
||||
document.body.removeChild(input);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div>
|
||||
|
14
packages/icon-v2/src/icons/Map.tsx
Normal file
14
packages/icon-v2/src/icons/Map.tsx
Normal file
@ -0,0 +1,14 @@
|
||||
import React from 'react';
|
||||
import { CustomSVGProps } from '../type';
|
||||
|
||||
const Map = (props: CustomSVGProps) => (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 16 16" {...props}>
|
||||
<path
|
||||
fill="#191919"
|
||||
fillRule="nonzero"
|
||||
d="M3.498 9a.5.5 0 1 1 0 1H2.91l-.8 3.999h11.779l-.8-3.999h-.59a.5.5 0 0 1-.492-.41l-.008-.09a.5.5 0 0 1 .5-.5H13.5a.5.5 0 0 1 .49.403l1 4.999a.5.5 0 0 1-.49.598h-13a.5.5 0 0 1-.49-.598l1-5a.5.5 0 0 1 .49-.401h.998ZM8 1a4.5 4.5 0 0 1 4.5 4.5c0 1.653-1.396 3.747-4.156 6.363a.5.5 0 0 1-.688 0C4.896 9.247 3.5 7.153 3.5 5.5A4.5 4.5 0 0 1 8 1Zm0 1a3.5 3.5 0 0 0-3.5 3.5c0 1.2 1.096 2.93 3.312 5.123l.188.182.188-.182c2.131-2.11 3.226-3.79 3.307-4.982L11.5 5.5A3.5 3.5 0 0 0 8 2Zm0 1.5a2 2 0 1 1 0 4 2 2 0 0 1 0-4Zm0 1a1 1 0 1 0 0 2 1 1 0 0 0 0-2Z"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
|
||||
export default Map;
|
14
packages/icon-v2/src/icons/Screenl.tsx
Normal file
14
packages/icon-v2/src/icons/Screenl.tsx
Normal file
@ -0,0 +1,14 @@
|
||||
import React from 'react';
|
||||
import { CustomSVGProps } from '../type';
|
||||
|
||||
const Screenl = (props: CustomSVGProps) => (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 16 16" {...props}>
|
||||
<path
|
||||
fill="#191919"
|
||||
fillRule="nonzero"
|
||||
d="M12.994 1C14.102 1 15 1.897 15 3.006v9.988A2.005 2.005 0 0 1 12.994 15H3.006A2.005 2.005 0 0 1 1 12.994V3.006C1 1.898 1.897 1 3.006 1h9.988Zm0 1H3.006C2.45 2 2 2.45 2 3.006v9.988C2 13.55 2.45 14 3.006 14h9.988C13.55 14 14 13.55 14 12.994V3.006C14 2.45 13.55 2 12.994 2ZM8.997 3C9.551 3 10 3.456 10 3.995v8.01c0 .55-.438.995-1.003.995H4.003A1.006 1.006 0 0 1 3 12.005v-8.01C3 3.445 3.438 3 4.003 3h4.994Z"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
|
||||
export default Screenl;
|
14
packages/icon-v2/src/icons/Screenm.tsx
Normal file
14
packages/icon-v2/src/icons/Screenm.tsx
Normal file
@ -0,0 +1,14 @@
|
||||
import React from 'react';
|
||||
import { CustomSVGProps } from '../type';
|
||||
|
||||
const Screenm = (props: CustomSVGProps) => (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 16 16" {...props}>
|
||||
<path
|
||||
fill="#191919"
|
||||
fillRule="nonzero"
|
||||
d="M12.994 1C14.102 1 15 1.897 15 3.006v9.988A2.005 2.005 0 0 1 12.994 15H3.006A2.005 2.005 0 0 1 1 12.994V3.006C1 1.898 1.897 1 3.006 1h9.988Zm0 1H3.006C2.45 2 2 2.45 2 3.006v9.988C2 13.55 2.45 14 3.006 14h9.988C13.55 14 14 13.55 14 12.994V3.006C14 2.45 13.55 2 12.994 2ZM7 3c.552 0 1 .456 1 .995v8.01c0 .55-.444.995-1 .995H4c-.552 0-1-.456-1-.995v-8.01C3 3.445 3.444 3 4 3h3Z"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
|
||||
export default Screenm;
|
14
packages/icon-v2/src/icons/Screens.tsx
Normal file
14
packages/icon-v2/src/icons/Screens.tsx
Normal file
@ -0,0 +1,14 @@
|
||||
import React from 'react';
|
||||
import { CustomSVGProps } from '../type';
|
||||
|
||||
const Screens = (props: CustomSVGProps) => (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 16 16" {...props}>
|
||||
<path
|
||||
fill="#191919"
|
||||
fillRule="nonzero"
|
||||
d="M12.994 1C14.102 1 15 1.897 15 3.006v9.988A2.005 2.005 0 0 1 12.994 15H3.006A2.005 2.005 0 0 1 1 12.994V3.006C1 1.898 1.897 1 3.006 1h9.988Zm0 1H3.006C2.45 2 2 2.45 2 3.006v9.988C2 13.55 2.45 14 3.006 14h9.988C13.55 14 14 13.55 14 12.994V3.006C14 2.45 13.55 2 12.994 2ZM5.001 3c.552 0 .999.456.999.995v8.01c0 .55-.443.995-.999.995H3.999C3.447 13 3 12.544 3 12.005v-8.01c0-.55.443-.995.999-.995h1.002Z"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
|
||||
export default Screens;
|
@ -112,4 +112,7 @@ export { default as View } from './icons/View';
|
||||
export { default as Warningfilled } from './icons/Warningfilled';
|
||||
export { default as Zoomin } from './icons/Zoomin';
|
||||
export { default as Zoomoff } from './icons/Zoomoff';
|
||||
|
||||
export { default as Map } from './icons/Map';
|
||||
export { default as Screenl } from './icons/Screenl';
|
||||
export { default as Screenm } from './icons/Screenm';
|
||||
export { default as Screens } from './icons/Screens';
|
||||
|
Loading…
Reference in New Issue
Block a user