@vtx/components 4.0.0-beta.62 → 4.0.0-beta.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/vtx-icon/index.js +52 -80
- package/es/vtx-icon/index.js1 +90 -0
- package/lib/vtx-icon/index.js +54 -97
- package/lib/vtx-icon/index.js1 +90 -0
- package/package.json +1 -1
package/es/vtx-icon/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
var _excluded = ["
|
|
2
|
+
var _excluded = ["width", "height", "style", "className"],
|
|
3
|
+
_excluded2 = ["type", "size", "className", "style", "color", "fileType"];
|
|
3
4
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
5
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
6
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -7,99 +8,70 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
7
8
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
9
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
9
10
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
10
|
-
import {
|
|
11
|
+
import { memo } from 'react';
|
|
12
|
+
import AlignRightOutlined from "./svg/alignRightOutlined.js";
|
|
13
|
+
import ColumnHeightOutlined from "./svg/columnHeightOutlined.js";
|
|
14
|
+
import DownOutlined from "./svg/downOutlined.js";
|
|
15
|
+
import Fullscreen from "./svg/fullscreen.js";
|
|
16
|
+
import RedoOutlined from "./svg/redoOutlined.js";
|
|
17
|
+
import RightOutlined from "./svg/rightOutlined.js";
|
|
18
|
+
import SettingOutlined from "./svg/settingOutlined.js";
|
|
11
19
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
20
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
21
|
var iconComponents = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return import("./svg/downOutlined.js");
|
|
23
|
-
}),
|
|
24
|
-
fullscreen: /*#__PURE__*/lazy(function () {
|
|
25
|
-
return import("./svg/fullscreen.js");
|
|
26
|
-
}),
|
|
27
|
-
redoOutlined: /*#__PURE__*/lazy(function () {
|
|
28
|
-
return import("./svg/redoOutlined.js");
|
|
29
|
-
}),
|
|
30
|
-
rightOutlined: /*#__PURE__*/lazy(function () {
|
|
31
|
-
return import("./svg/rightOutlined.js");
|
|
32
|
-
}),
|
|
33
|
-
settingOutlined: /*#__PURE__*/lazy(function () {
|
|
34
|
-
return import("./svg/settingOutlined.js");
|
|
35
|
-
})
|
|
36
|
-
// 新增其他图标...
|
|
22
|
+
alignRightOutlined: AlignRightOutlined,
|
|
23
|
+
columnHeightOutlined: ColumnHeightOutlined,
|
|
24
|
+
downOutlined: DownOutlined,
|
|
25
|
+
fullscreen: Fullscreen,
|
|
26
|
+
redoOutlined: RedoOutlined,
|
|
27
|
+
rightOutlined: RightOutlined,
|
|
28
|
+
settingOutlined: SettingOutlined
|
|
29
|
+
// 低频图标如果确实需要,可以再考虑 lazy
|
|
37
30
|
};
|
|
38
|
-
var
|
|
39
|
-
var
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
className = _ref$className === void 0 ? '' : _ref$className,
|
|
44
|
-
_ref$style = _ref.style,
|
|
45
|
-
style = _ref$style === void 0 ? {} : _ref$style,
|
|
46
|
-
color = _ref.color,
|
|
47
|
-
_ref$fileType = _ref.fileType,
|
|
48
|
-
fileType = _ref$fileType === void 0 ? 'webp' : _ref$fileType,
|
|
31
|
+
var EmptySvg = function EmptySvg(_ref) {
|
|
32
|
+
var width = _ref.width,
|
|
33
|
+
height = _ref.height,
|
|
34
|
+
style = _ref.style,
|
|
35
|
+
className = _ref.className,
|
|
49
36
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
37
|
+
return /*#__PURE__*/_jsx("svg", _objectSpread({
|
|
38
|
+
width: width,
|
|
39
|
+
height: height,
|
|
40
|
+
style: style,
|
|
41
|
+
className: className
|
|
42
|
+
}, props));
|
|
43
|
+
};
|
|
44
|
+
var VtxIcon = /*#__PURE__*/memo(function (_ref2) {
|
|
45
|
+
var type = _ref2.type,
|
|
46
|
+
_ref2$size = _ref2.size,
|
|
47
|
+
size = _ref2$size === void 0 ? 16 : _ref2$size,
|
|
48
|
+
_ref2$className = _ref2.className,
|
|
49
|
+
className = _ref2$className === void 0 ? '' : _ref2$className,
|
|
50
|
+
_ref2$style = _ref2.style,
|
|
51
|
+
style = _ref2$style === void 0 ? {} : _ref2$style,
|
|
52
|
+
color = _ref2.color,
|
|
53
|
+
_ref2$fileType = _ref2.fileType,
|
|
54
|
+
fileType = _ref2$fileType === void 0 ? 'webp' : _ref2$fileType,
|
|
55
|
+
props = _objectWithoutProperties(_ref2, _excluded2);
|
|
50
56
|
var width = props.width || size;
|
|
51
57
|
var height = props.height || size;
|
|
52
58
|
if (!type) {
|
|
53
59
|
return null;
|
|
54
60
|
}
|
|
55
|
-
// const SvgComponent = useMemo(() => {
|
|
56
|
-
// // 动态导入并缓存结果
|
|
57
|
-
// return lazy(() => import(/* @vite-ignore */`./svg/${type}.js`));
|
|
58
|
-
// }, [type]);
|
|
59
|
-
|
|
60
|
-
var SvgComponent = useMemo(function () {
|
|
61
|
-
// 兜底:找不到对应图标时,返回一个空组件(避免报错)
|
|
62
|
-
return iconComponents[type] || /*#__PURE__*/lazy(function () {
|
|
63
|
-
return Promise.resolve({
|
|
64
|
-
default: function _default() {
|
|
65
|
-
return /*#__PURE__*/_jsx("svg", {
|
|
66
|
-
width: width,
|
|
67
|
-
height: height
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
}, [type, width, height]);
|
|
73
61
|
|
|
74
62
|
// 默认返回空元素
|
|
75
63
|
if (fileType == 'svg') {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
style: _objectSpread({
|
|
81
|
-
width: width,
|
|
82
|
-
height: height
|
|
83
|
-
}, style)
|
|
84
|
-
}),
|
|
85
|
-
children: /*#__PURE__*/_jsx(SvgComponent, _objectSpread({
|
|
86
|
-
className: className,
|
|
87
|
-
style: _objectSpread({
|
|
88
|
-
width: width,
|
|
89
|
-
height: height
|
|
90
|
-
}, style),
|
|
91
|
-
fill: color
|
|
92
|
-
}, props))
|
|
93
|
-
});
|
|
94
|
-
} catch (error) {
|
|
95
|
-
// 如果动态导入失败,返回空的 SVG 元素
|
|
96
|
-
return /*#__PURE__*/_jsx("svg", _objectSpread({
|
|
64
|
+
var SvgComponent = iconComponents[type] || EmptySvg;
|
|
65
|
+
return /*#__PURE__*/_jsx(SvgComponent, _objectSpread({
|
|
66
|
+
className: className,
|
|
67
|
+
style: _objectSpread({
|
|
97
68
|
width: width,
|
|
98
|
-
height: height
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
69
|
+
height: height
|
|
70
|
+
}, style),
|
|
71
|
+
width: width,
|
|
72
|
+
height: height,
|
|
73
|
+
fill: color
|
|
74
|
+
}, props));
|
|
103
75
|
} else {
|
|
104
76
|
return (
|
|
105
77
|
/*#__PURE__*/
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { lazy, memo, Suspense, useMemo } from 'react';
|
|
2
|
+
import AlignRightOutlined from './svg/alignRightOutlined.js';
|
|
3
|
+
import ColumnHeightOutlined from './svg/columnHeightOutlined.js';
|
|
4
|
+
import DownOutlined from './svg/downOutlined.js';
|
|
5
|
+
import Fullscreen from './svg/fullscreen.js';
|
|
6
|
+
import RedoOutlined from './svg/redoOutlined.js';
|
|
7
|
+
import RightOutlined from './svg/rightOutlined.js';
|
|
8
|
+
import SettingOutlined from './svg/settingOutlined.js';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
const iconComponents = {
|
|
12
|
+
alignRightOutlined: AlignRightOutlined,
|
|
13
|
+
columnHeightOutlined: ColumnHeightOutlined,
|
|
14
|
+
downOutlined: DownOutlined,
|
|
15
|
+
fullscreen: Fullscreen,
|
|
16
|
+
redoOutlined: RedoOutlined,
|
|
17
|
+
rightOutlined: RightOutlined,
|
|
18
|
+
settingOutlined: SettingOutlined,
|
|
19
|
+
// 低频图标如果确实需要,可以再考虑 lazy
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// const iconComponents = {
|
|
23
|
+
// // 核心:添加你需要的所有图标, 动态导入有的组件会失败
|
|
24
|
+
// alignRightOutlined: lazy(() => import('./svg/alignRightOutlined.js')),
|
|
25
|
+
// columnHeightOutlined: lazy(() => import('./svg/columnHeightOutlined.js')),
|
|
26
|
+
// downOutlined: lazy(() => import('./svg/downOutlined.js')),
|
|
27
|
+
// fullscreen: lazy(() => import('./svg/fullscreen.js')),
|
|
28
|
+
// redoOutlined: lazy(() => import('./svg/redoOutlined.js')),
|
|
29
|
+
// rightOutlined: lazy(() => import('./svg/rightOutlined.js')),
|
|
30
|
+
// settingOutlined: lazy(() => import('./svg/settingOutlined.js')),
|
|
31
|
+
// // 新增其他图标...
|
|
32
|
+
// };
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
const VtxIcon = memo(({
|
|
36
|
+
type,
|
|
37
|
+
size = 16,
|
|
38
|
+
className = '',
|
|
39
|
+
style = {},
|
|
40
|
+
color,
|
|
41
|
+
fileType = 'webp',
|
|
42
|
+
...props
|
|
43
|
+
}) => {
|
|
44
|
+
const width = props.width || size;
|
|
45
|
+
const height = props.height || size;
|
|
46
|
+
if (!type) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
// const SvgComponent = useMemo(() => {
|
|
50
|
+
// // 动态导入并缓存结果
|
|
51
|
+
// return lazy(() => import(/* @vite-ignore */`./svg/${type}.js`));
|
|
52
|
+
// }, [type]);
|
|
53
|
+
|
|
54
|
+
const SvgComponent = useMemo(() => {
|
|
55
|
+
// 兜底:找不到对应图标时,返回一个空组件(避免报错)
|
|
56
|
+
return iconComponents[type] || lazy(() => Promise.resolve({ default: () => <svg width={width} height={height} /> }));
|
|
57
|
+
}, [type, width, height]);
|
|
58
|
+
|
|
59
|
+
// 默认返回空元素
|
|
60
|
+
if (fileType == 'svg') {
|
|
61
|
+
try {
|
|
62
|
+
// const SvgComponent = lazy(() => import(`./svg/${type}.js`));
|
|
63
|
+
return (
|
|
64
|
+
<Suspense fallback={<div style={{ width, height, ...style }} />}>
|
|
65
|
+
<SvgComponent
|
|
66
|
+
className={className}
|
|
67
|
+
style={{ width, height, ...style }}
|
|
68
|
+
fill={color}
|
|
69
|
+
{...props}
|
|
70
|
+
/>
|
|
71
|
+
</Suspense>
|
|
72
|
+
);
|
|
73
|
+
} catch (error) {
|
|
74
|
+
// 如果动态导入失败,返回空的 SVG 元素
|
|
75
|
+
return (
|
|
76
|
+
<svg width={width} height={height} style={style} className={className} {...props} />
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
return (
|
|
81
|
+
// <img
|
|
82
|
+
// src={require(`./assets/${type}.${fileType}`)}
|
|
83
|
+
// style={{ width, height, ...style }}
|
|
84
|
+
// />
|
|
85
|
+
<></>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
export { VtxIcon }
|
|
90
|
+
export default VtxIcon;
|
package/lib/vtx-icon/index.js
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.default = exports.VtxIcon = void 0;
|
|
7
8
|
var _react = require("react");
|
|
9
|
+
var _alignRightOutlined = _interopRequireDefault(require("./svg/alignRightOutlined.js"));
|
|
10
|
+
var _columnHeightOutlined = _interopRequireDefault(require("./svg/columnHeightOutlined.js"));
|
|
11
|
+
var _downOutlined = _interopRequireDefault(require("./svg/downOutlined.js"));
|
|
12
|
+
var _fullscreen = _interopRequireDefault(require("./svg/fullscreen.js"));
|
|
13
|
+
var _redoOutlined = _interopRequireDefault(require("./svg/redoOutlined.js"));
|
|
14
|
+
var _rightOutlined = _interopRequireDefault(require("./svg/rightOutlined.js"));
|
|
15
|
+
var _settingOutlined = _interopRequireDefault(require("./svg/settingOutlined.js"));
|
|
8
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
|
-
var _excluded = ["
|
|
10
|
-
|
|
17
|
+
var _excluded = ["width", "height", "style", "className"],
|
|
18
|
+
_excluded2 = ["type", "size", "className", "style", "color", "fileType"];
|
|
19
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
20
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12
21
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
22
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -15,112 +24,60 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
15
24
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
16
25
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
17
26
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
18
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
19
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
20
27
|
var iconComponents = {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return _interopRequireWildcard(require("./svg/columnHeightOutlined.js"));
|
|
30
|
-
});
|
|
31
|
-
}),
|
|
32
|
-
downOutlined: /*#__PURE__*/(0, _react.lazy)(function () {
|
|
33
|
-
return Promise.resolve().then(function () {
|
|
34
|
-
return _interopRequireWildcard(require("./svg/downOutlined.js"));
|
|
35
|
-
});
|
|
36
|
-
}),
|
|
37
|
-
fullscreen: /*#__PURE__*/(0, _react.lazy)(function () {
|
|
38
|
-
return Promise.resolve().then(function () {
|
|
39
|
-
return _interopRequireWildcard(require("./svg/fullscreen.js"));
|
|
40
|
-
});
|
|
41
|
-
}),
|
|
42
|
-
redoOutlined: /*#__PURE__*/(0, _react.lazy)(function () {
|
|
43
|
-
return Promise.resolve().then(function () {
|
|
44
|
-
return _interopRequireWildcard(require("./svg/redoOutlined.js"));
|
|
45
|
-
});
|
|
46
|
-
}),
|
|
47
|
-
rightOutlined: /*#__PURE__*/(0, _react.lazy)(function () {
|
|
48
|
-
return Promise.resolve().then(function () {
|
|
49
|
-
return _interopRequireWildcard(require("./svg/rightOutlined.js"));
|
|
50
|
-
});
|
|
51
|
-
}),
|
|
52
|
-
settingOutlined: /*#__PURE__*/(0, _react.lazy)(function () {
|
|
53
|
-
return Promise.resolve().then(function () {
|
|
54
|
-
return _interopRequireWildcard(require("./svg/settingOutlined.js"));
|
|
55
|
-
});
|
|
56
|
-
})
|
|
57
|
-
// 新增其他图标...
|
|
28
|
+
alignRightOutlined: _alignRightOutlined.default,
|
|
29
|
+
columnHeightOutlined: _columnHeightOutlined.default,
|
|
30
|
+
downOutlined: _downOutlined.default,
|
|
31
|
+
fullscreen: _fullscreen.default,
|
|
32
|
+
redoOutlined: _redoOutlined.default,
|
|
33
|
+
rightOutlined: _rightOutlined.default,
|
|
34
|
+
settingOutlined: _settingOutlined.default
|
|
35
|
+
// 低频图标如果确实需要,可以再考虑 lazy
|
|
58
36
|
};
|
|
59
|
-
var
|
|
60
|
-
var
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
className = _ref$className === void 0 ? '' : _ref$className,
|
|
65
|
-
_ref$style = _ref.style,
|
|
66
|
-
style = _ref$style === void 0 ? {} : _ref$style,
|
|
67
|
-
color = _ref.color,
|
|
68
|
-
_ref$fileType = _ref.fileType,
|
|
69
|
-
fileType = _ref$fileType === void 0 ? 'webp' : _ref$fileType,
|
|
37
|
+
var EmptySvg = function EmptySvg(_ref) {
|
|
38
|
+
var width = _ref.width,
|
|
39
|
+
height = _ref.height,
|
|
40
|
+
style = _ref.style,
|
|
41
|
+
className = _ref.className,
|
|
70
42
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
43
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", _objectSpread({
|
|
44
|
+
width: width,
|
|
45
|
+
height: height,
|
|
46
|
+
style: style,
|
|
47
|
+
className: className
|
|
48
|
+
}, props));
|
|
49
|
+
};
|
|
50
|
+
var VtxIcon = exports.VtxIcon = /*#__PURE__*/(0, _react.memo)(function (_ref2) {
|
|
51
|
+
var type = _ref2.type,
|
|
52
|
+
_ref2$size = _ref2.size,
|
|
53
|
+
size = _ref2$size === void 0 ? 16 : _ref2$size,
|
|
54
|
+
_ref2$className = _ref2.className,
|
|
55
|
+
className = _ref2$className === void 0 ? '' : _ref2$className,
|
|
56
|
+
_ref2$style = _ref2.style,
|
|
57
|
+
style = _ref2$style === void 0 ? {} : _ref2$style,
|
|
58
|
+
color = _ref2.color,
|
|
59
|
+
_ref2$fileType = _ref2.fileType,
|
|
60
|
+
fileType = _ref2$fileType === void 0 ? 'webp' : _ref2$fileType,
|
|
61
|
+
props = _objectWithoutProperties(_ref2, _excluded2);
|
|
71
62
|
var width = props.width || size;
|
|
72
63
|
var height = props.height || size;
|
|
73
64
|
if (!type) {
|
|
74
65
|
return null;
|
|
75
66
|
}
|
|
76
|
-
// const SvgComponent = useMemo(() => {
|
|
77
|
-
// // 动态导入并缓存结果
|
|
78
|
-
// return lazy(() => import(/* @vite-ignore */`./svg/${type}.js`));
|
|
79
|
-
// }, [type]);
|
|
80
|
-
|
|
81
|
-
var SvgComponent = (0, _react.useMemo)(function () {
|
|
82
|
-
// 兜底:找不到对应图标时,返回一个空组件(避免报错)
|
|
83
|
-
return iconComponents[type] || /*#__PURE__*/(0, _react.lazy)(function () {
|
|
84
|
-
return Promise.resolve({
|
|
85
|
-
default: function _default() {
|
|
86
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
|
|
87
|
-
width: width,
|
|
88
|
-
height: height
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
}, [type, width, height]);
|
|
94
67
|
|
|
95
68
|
// 默认返回空元素
|
|
96
69
|
if (fileType == 'svg') {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
style: _objectSpread({
|
|
102
|
-
width: width,
|
|
103
|
-
height: height
|
|
104
|
-
}, style)
|
|
105
|
-
}),
|
|
106
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(SvgComponent, _objectSpread({
|
|
107
|
-
className: className,
|
|
108
|
-
style: _objectSpread({
|
|
109
|
-
width: width,
|
|
110
|
-
height: height
|
|
111
|
-
}, style),
|
|
112
|
-
fill: color
|
|
113
|
-
}, props))
|
|
114
|
-
});
|
|
115
|
-
} catch (error) {
|
|
116
|
-
// 如果动态导入失败,返回空的 SVG 元素
|
|
117
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", _objectSpread({
|
|
70
|
+
var SvgComponent = iconComponents[type] || EmptySvg;
|
|
71
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(SvgComponent, _objectSpread({
|
|
72
|
+
className: className,
|
|
73
|
+
style: _objectSpread({
|
|
118
74
|
width: width,
|
|
119
|
-
height: height
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
75
|
+
height: height
|
|
76
|
+
}, style),
|
|
77
|
+
width: width,
|
|
78
|
+
height: height,
|
|
79
|
+
fill: color
|
|
80
|
+
}, props));
|
|
124
81
|
} else {
|
|
125
82
|
return (
|
|
126
83
|
/*#__PURE__*/
|
|
@@ -132,4 +89,4 @@ var VtxIcon = exports.VtxIcon = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
132
89
|
);
|
|
133
90
|
}
|
|
134
91
|
});
|
|
135
|
-
var
|
|
92
|
+
var _default = exports.default = VtxIcon;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { lazy, memo, Suspense, useMemo } from 'react';
|
|
2
|
+
import AlignRightOutlined from './svg/alignRightOutlined.js';
|
|
3
|
+
import ColumnHeightOutlined from './svg/columnHeightOutlined.js';
|
|
4
|
+
import DownOutlined from './svg/downOutlined.js';
|
|
5
|
+
import Fullscreen from './svg/fullscreen.js';
|
|
6
|
+
import RedoOutlined from './svg/redoOutlined.js';
|
|
7
|
+
import RightOutlined from './svg/rightOutlined.js';
|
|
8
|
+
import SettingOutlined from './svg/settingOutlined.js';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
const iconComponents = {
|
|
12
|
+
alignRightOutlined: AlignRightOutlined,
|
|
13
|
+
columnHeightOutlined: ColumnHeightOutlined,
|
|
14
|
+
downOutlined: DownOutlined,
|
|
15
|
+
fullscreen: Fullscreen,
|
|
16
|
+
redoOutlined: RedoOutlined,
|
|
17
|
+
rightOutlined: RightOutlined,
|
|
18
|
+
settingOutlined: SettingOutlined,
|
|
19
|
+
// 低频图标如果确实需要,可以再考虑 lazy
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// const iconComponents = {
|
|
23
|
+
// // 核心:添加你需要的所有图标, 动态导入有的组件会失败
|
|
24
|
+
// alignRightOutlined: lazy(() => import('./svg/alignRightOutlined.js')),
|
|
25
|
+
// columnHeightOutlined: lazy(() => import('./svg/columnHeightOutlined.js')),
|
|
26
|
+
// downOutlined: lazy(() => import('./svg/downOutlined.js')),
|
|
27
|
+
// fullscreen: lazy(() => import('./svg/fullscreen.js')),
|
|
28
|
+
// redoOutlined: lazy(() => import('./svg/redoOutlined.js')),
|
|
29
|
+
// rightOutlined: lazy(() => import('./svg/rightOutlined.js')),
|
|
30
|
+
// settingOutlined: lazy(() => import('./svg/settingOutlined.js')),
|
|
31
|
+
// // 新增其他图标...
|
|
32
|
+
// };
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
const VtxIcon = memo(({
|
|
36
|
+
type,
|
|
37
|
+
size = 16,
|
|
38
|
+
className = '',
|
|
39
|
+
style = {},
|
|
40
|
+
color,
|
|
41
|
+
fileType = 'webp',
|
|
42
|
+
...props
|
|
43
|
+
}) => {
|
|
44
|
+
const width = props.width || size;
|
|
45
|
+
const height = props.height || size;
|
|
46
|
+
if (!type) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
// const SvgComponent = useMemo(() => {
|
|
50
|
+
// // 动态导入并缓存结果
|
|
51
|
+
// return lazy(() => import(/* @vite-ignore */`./svg/${type}.js`));
|
|
52
|
+
// }, [type]);
|
|
53
|
+
|
|
54
|
+
const SvgComponent = useMemo(() => {
|
|
55
|
+
// 兜底:找不到对应图标时,返回一个空组件(避免报错)
|
|
56
|
+
return iconComponents[type] || lazy(() => Promise.resolve({ default: () => <svg width={width} height={height} /> }));
|
|
57
|
+
}, [type, width, height]);
|
|
58
|
+
|
|
59
|
+
// 默认返回空元素
|
|
60
|
+
if (fileType == 'svg') {
|
|
61
|
+
try {
|
|
62
|
+
// const SvgComponent = lazy(() => import(`./svg/${type}.js`));
|
|
63
|
+
return (
|
|
64
|
+
<Suspense fallback={<div style={{ width, height, ...style }} />}>
|
|
65
|
+
<SvgComponent
|
|
66
|
+
className={className}
|
|
67
|
+
style={{ width, height, ...style }}
|
|
68
|
+
fill={color}
|
|
69
|
+
{...props}
|
|
70
|
+
/>
|
|
71
|
+
</Suspense>
|
|
72
|
+
);
|
|
73
|
+
} catch (error) {
|
|
74
|
+
// 如果动态导入失败,返回空的 SVG 元素
|
|
75
|
+
return (
|
|
76
|
+
<svg width={width} height={height} style={style} className={className} {...props} />
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
return (
|
|
81
|
+
// <img
|
|
82
|
+
// src={require(`./assets/${type}.${fileType}`)}
|
|
83
|
+
// style={{ width, height, ...style }}
|
|
84
|
+
// />
|
|
85
|
+
<></>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
export { VtxIcon }
|
|
90
|
+
export default VtxIcon;
|