Skip to content

Commit 7da7559

Browse files
committed
chore: 优化new-component脚本
1 parent f89de6d commit 7da7559

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

scripts/new-component.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,12 @@ function initComponent(): InitRes {
6464
const content = `
6565
import React from 'react';
6666
import type { ${props} } from './${getFilename('types').replace(/\.ts$/, '')}';
67+
import { getComponentClass } from '@pkg/shared';
6768
68-
export const ${componentName}: React.FC<${props}> = (props) => {
69+
const rootName = getComponentClass('${config.name}');
6970
71+
export const ${componentName}: React.FC<${props}> = (props) => {
72+
return <div {...props} className={rootName}></div>;
7073
};
7174
`;
7275

@@ -75,7 +78,11 @@ export const ${componentName}: React.FC<${props}> = (props) => {
7578
function initTypes(): InitRes {
7679
const filename = getFilename('types');
7780
const content = `
78-
export interface ${config.componentName}Props {}
81+
import React from 'react';
82+
83+
export type DividerProps = React.HTMLAttributes<HTMLElement> & {
84+
name?: string;
85+
};
7986
`;
8087
return [filename, content];
8188
}

0 commit comments

Comments
 (0)