Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pro-layout
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
packages
pro-layout
Commits
a7b4a123
Commit
a7b4a123
authored
Dec 02, 2020
by
Sendya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: compile err
parent
e78771be
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
2 additions
and
124 deletions
+2
-124
generate.ts
scripts/generate.ts
+0
-120
index.tsx
src/PageContainer/index.tsx
+1
-3
tsconfig.json
tsconfig.json
+1
-1
No files found.
scripts/generate.ts
deleted
100644 → 0
View file @
e78771be
import
*
as
allIconDefs
from
'@ant-design/icons-svg'
;
import
{
IconDefinition
}
from
'@ant-design/icons-svg/es/types'
;
import
*
as
path
from
'path'
;
import
*
as
fs
from
'fs'
;
import
{
promisify
}
from
'util'
;
// eslint-disable-next-line import/no-extraneous-dependencies
import
{
template
}
from
'lodash'
;
const
writeFile
=
promisify
(
fs
.
writeFile
);
interface
IconDefinitionWithIdentifier
extends
IconDefinition
{
svgIdentifier
:
string
;
}
function
walk
<
T
>
(
fn
:
(
iconDef
:
IconDefinitionWithIdentifier
)
=>
Promise
<
T
>
)
{
return
Promise
.
all
(
Object
.
keys
(
allIconDefs
).
map
(
svgIdentifier
=>
{
const
iconDef
=
(
allIconDefs
as
{
[
id
:
string
]:
IconDefinition
})[
svgIdentifier
];
return
fn
({
svgIdentifier
,
...
iconDef
});
}),
);
}
async
function
generateIcons
()
{
const
iconsDir
=
path
.
join
(
__dirname
,
'../src/icons'
);
try
{
await
promisify
(
fs
.
access
)(
iconsDir
);
}
catch
(
err
)
{
await
promisify
(
fs
.
mkdir
)(
iconsDir
);
}
const
render
=
template
(
`
// GENERATE BY ./scripts/generate.ts
// DON NOT EDIT IT MANUALLY
import { SetupContext } from 'vue';
import <%= svgIdentifier %>Svg from '@ant-design/icons-svg/lib/asn/<%= svgIdentifier %>';
import AntdIcon, { AntdIconProps } from '@ant-design/icons-vue/lib/components/AntdIcon';
const <%= svgIdentifier %> = (props: AntdIconProps, context: SetupContext) => {
const p = { ...props, ...context.attrs };
return <AntdIcon {...p} icon={<%= svgIdentifier %>Svg}></AntdIcon>;
};
<%= svgIdentifier %>.displayName = '<%= svgIdentifier %>';
<%= svgIdentifier %>.inheritAttrs = false;
export default <%= svgIdentifier %>;
`
.
trim
(),
);
await
walk
(
async
({
svgIdentifier
})
=>
{
// generate icon file
await
writeFile
(
path
.
resolve
(
__dirname
,
`../src/icons/
${
svgIdentifier
}
.tsx`
),
render
({
svgIdentifier
}),
);
});
// generate icon index
const
entryText
=
Object
.
keys
(
allIconDefs
)
.
sort
()
.
map
(
svgIdentifier
=>
{
return
`export { default as
${
svgIdentifier
}
} from './
${
svgIdentifier
}
';`
;
})
.
join
(
'
\
n'
);
await
promisify
(
fs
.
appendFile
)(
path
.
resolve
(
__dirname
,
'../src/icons/index.tsx'
),
`
// GENERATE BY ./scripts/generate.ts
// DON NOT EDIT IT MANUALLY
${
entryText
}
`
.
trim
(),
);
}
async
function
generateEntries
()
{
const
render
=
template
(
`
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _<%= svgIdentifier %> = _interopRequireDefault(require('./lib/icons/<%= svgIdentifier %>'));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _default = _<%= svgIdentifier %>.default || _<%= svgIdentifier %>;
exports.default = _default;
module.exports = _default;
`
.
trim
(),
);
await
walk
(
async
({
svgIdentifier
})
=>
{
// generate `Icon.js` in root folder
await
writeFile
(
path
.
resolve
(
__dirname
,
`../
${
svgIdentifier
}
.js`
),
render
({
svgIdentifier
,
}),
);
// generate `Icon.d.ts` in root folder
await
writeFile
(
path
.
resolve
(
__dirname
,
`../
${
svgIdentifier
}
.d.ts`
),
`export { default } from './lib/icons/
${
svgIdentifier
}
';`
,
);
});
}
if
(
process
.
argv
[
2
]
===
'--target=icon'
)
{
generateIcons
();
}
if
(
process
.
argv
[
2
]
===
'--target=entry'
)
{
generateEntries
();
}
src/PageContainer/index.tsx
View file @
a7b4a123
...
@@ -7,7 +7,7 @@ import { AffixProps } from './interfaces/Affix';
...
@@ -7,7 +7,7 @@ import { AffixProps } from './interfaces/Affix';
/* replace antd ts define end */
/* replace antd ts define end */
import
{
useRouteContext
,
RouteContextProps
}
from
'../RouteContext'
;
import
{
useRouteContext
,
RouteContextProps
}
from
'../RouteContext'
;
import
{
useProProvider
}
from
'../ProProvider'
;
import
{
useProProvider
}
from
'../ProProvider'
;
import
{
Affix
,
PageHeader
,
Tabs
}
from
'ant-design-vue'
;
import
{
Affix
,
PageHeader
,
Tabs
,
Spin
}
from
'ant-design-vue'
;
import
GridContent
from
'../GridContent'
;
import
GridContent
from
'../GridContent'
;
import
FooterToolbar
from
'../FooterToolbar'
;
import
FooterToolbar
from
'../FooterToolbar'
;
import
'./index.less'
;
import
'./index.less'
;
...
@@ -156,8 +156,6 @@ const defaultPageHeaderRender = (
...
@@ -156,8 +156,6 @@ const defaultPageHeaderRender = (
tabActiveKey
,
tabActiveKey
,
prefixedClassName
:
value
.
prefixedClassName
,
prefixedClassName
:
value
.
prefixedClassName
,
})
}
})
}
{
...
header
}
preifxCls=
{
prefixCls
}
>
>
{
header
||
renderPageHeader
(
content
,
extraContent
,
value
.
prefixedClassName
)
}
{
header
||
renderPageHeader
(
content
,
extraContent
,
value
.
prefixedClassName
)
}
</
PageHeader
>
</
PageHeader
>
...
...
tsconfig.json
View file @
a7b4a123
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
"allowSyntheticDefaultImports"
:
true
,
"allowSyntheticDefaultImports"
:
true
,
"declaration"
:
true
,
"declaration"
:
true
,
"module"
:
"esnext"
,
"module"
:
"esnext"
,
"target"
:
"es
2018
"
,
"target"
:
"es
next
"
,
"moduleResolution"
:
"node"
,
"moduleResolution"
:
"node"
,
"jsx"
:
"preserve"
,
"jsx"
:
"preserve"
,
"esModuleInterop"
:
true
"esModuleInterop"
:
true
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment