Skip to content

Commit 223602a

Browse files
committed
update
1 parent ca5b739 commit 223602a

File tree

12 files changed

+1562
-44
lines changed

12 files changed

+1562
-44
lines changed

package-lock.json

Lines changed: 1506 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@
7171
"style-loader": "^3.3.1",
7272
"stylelint": "^14.7.1",
7373
"stylelint-webpack-plugin": "^3.2.0",
74+
"svg-sprite-loader": "^6.0.11",
75+
"svgo-loader": "^4.0.0",
7476
"terser-webpack-plugin": "^5.3.1",
7577
"thread-loader": "^3.0.4",
7678
"typescript": "^4.4.4",

src/components/svg-icon/index.less

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.svg-icon {
2+
width: 1.1em;
3+
height: 1.1em;
4+
vertical-align: -0.2em;
5+
fill: currentColor;
6+
overflow: hidden;
7+
outline: none;
8+
}

src/components/svg-icon/index.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React, { LegacyRef } from 'react';
2+
import './index.less';
3+
4+
interface SvgIconProps extends React.HtmlHTMLAttributes<SVGSVGElement> {
5+
name: string;
6+
className?: string;
7+
}
8+
9+
const SvgIcon = React.forwardRef((props: SvgIconProps, ref: LegacyRef<SVGSVGElement>) => {
10+
const { name, className, ...rest } = props
11+
const svgClass = className ? 'svg-icon ' + className : 'svg-icon';
12+
const iconName = `#${name}`;
13+
return (
14+
<svg className={svgClass} aria-hidden="true" ref={ref} {...rest}>
15+
<use xlinkHref={iconName} />
16+
</svg>
17+
);
18+
});
19+
20+
export default SvgIcon;

src/icons/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const requireAll = requireContext => requireContext.keys().map(requireContext)
2+
const req = require.context('./svg', false, /\.svg$/)
3+
requireAll(req)

src/icons/svg/wenhao.svg

Lines changed: 1 addition & 0 deletions
Loading

src/icons/svg/zhedie-down.svg

Lines changed: 1 addition & 0 deletions
Loading

src/icons/svg/zhedie-right.svg

Lines changed: 1 addition & 0 deletions
Loading

src/pages/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import "slick-carousel/slick/slick-theme.css";
1010
import "less/index.less";
1111
import { ConfigProvider } from 'antd-mobile';
1212
import antdMobileConfigs from '@/core/antd-mobile-configs';
13-
13+
// 引入图标
14+
import "@/icons/index.js";
1415

1516
// 只在开发环境下引入
1617
// if (process.env.NODE_ENV === 'development') {

src/utils/object.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ export function filterObject(obj: object | undefined | null, callback: (value: a
5757
// 接收路径字符串或数组字符串,返回数组字符串表示路径
5858
export function pathToArr(path?: string | string[]) {
5959
if (path instanceof Array) return path;
60-
return typeof path === 'string' && path ? path.replace(/\]$/, '').split(/\.\[|\[\]|\]\[|\[|\]\.|\]|\./g) : [];
60+
const parts = typeof path === 'string' && path ? path.replace(/\]$/, '').replace(/^\[/, '').split(/\.\[|\[\]|\]\[|\[|\]\.|\]|\./g) : []
61+
return parts;
6162
}
6263

6364
// 根据路径获取目标对象中的单个值或多个值

0 commit comments

Comments
 (0)