mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-03-01 13:36:55 +08:00
modify(icons)
This commit is contained in:
parent
f3120d08b4
commit
9c6de6c345
@ -2,15 +2,16 @@ const fs = require('fs')
|
||||
const path = require('path')
|
||||
const rollup = require('rollup')
|
||||
const { plugins, external } = require('../rollup.config')
|
||||
const camelCase = require('lodash/camelCase')
|
||||
|
||||
const iconPath = path.resolve(__dirname, '..', 'src', '_icons')
|
||||
const iconNames = fs.readdirSync(iconPath).filter(name => name.endsWith('.vue'))
|
||||
|
||||
const iconIndex =
|
||||
`/** Never import this file! It is automatically generated for building icons fast */\n\n` +
|
||||
iconNames.map((iconName, index) => `import $${index} from './${iconName}'`).join('\n') +
|
||||
iconNames.map((iconName) => `import ${camelCase(iconName.match(/.*(?=.vue)/)[0])} from './${iconName}'`).join('\n') +
|
||||
'\n\nexport default {\n' +
|
||||
iconNames.map((_, index) => ` $${index},`).join('\n') +
|
||||
iconNames.map((iconName) => ` ${camelCase(iconName.match(/.*(?=.vue)/)[0])},`).join('\n') +
|
||||
'\n}'
|
||||
|
||||
const iconIndexPath = path.resolve(iconPath, 'index.js')
|
||||
@ -22,8 +23,6 @@ fs.writeFileSync(
|
||||
|
||||
const cjsIconPath = path.resolve(__dirname, '..', 'lib', 'icons')
|
||||
const esmIconPath = path.resolve(__dirname, '..', 'es', 'icons')
|
||||
const cjsPath = path.resolve(__dirname, '..', 'lib')
|
||||
const esmPath = path.resolve(__dirname, '..', 'es')
|
||||
|
||||
function createDirIfNotExists (...args) {
|
||||
if (!fs.existsSync(path.resolve(...args))) {
|
||||
@ -81,25 +80,4 @@ createDirIfNotExists(__dirname, '../es', 'icons')
|
||||
}
|
||||
)
|
||||
})
|
||||
let iconNamesCode = `export default {
|
||||
iconNames: ${JSON.stringify(iconNames)}
|
||||
}; `
|
||||
fs.writeFile(
|
||||
path.resolve(cjsPath, 'iconNames.js'),
|
||||
iconNamesCode,
|
||||
(err) => {
|
||||
if (err) {
|
||||
console.log(err)
|
||||
}
|
||||
}
|
||||
)
|
||||
fs.writeFile(
|
||||
path.resolve(esmPath, 'iconNames.js'),
|
||||
iconNamesCode,
|
||||
(err) => {
|
||||
if (err) {
|
||||
console.log(err)
|
||||
}
|
||||
}
|
||||
)
|
||||
})()
|
||||
|
@ -2,7 +2,7 @@
|
||||
```html
|
||||
<n-dynamic-input
|
||||
v-model="customValue"
|
||||
:on-add="onAdd"
|
||||
:on-create="onCreate"
|
||||
>
|
||||
<template v-slot="{ value }">
|
||||
<div style="width: 100%;">
|
||||
@ -41,11 +41,11 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onAdd () {
|
||||
onCreate (index) {
|
||||
return {
|
||||
isCheck: false,
|
||||
num: 1,
|
||||
string: 'A String'
|
||||
num: null,
|
||||
string: null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div>
|
||||
<div v-if="mode==='debug'">
|
||||
<n-input
|
||||
v-model="pattern"
|
||||
:style="{
|
||||
@ -23,36 +23,35 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import icons from '../../../../../lib/iconNames'
|
||||
import icons from '../../../../../src/_icons/index'
|
||||
import iconWrapper from './iconWrapper'
|
||||
import getScrollParent from '../../../../../lib/_utils/dom/getScrollParent'
|
||||
|
||||
function toHump (name) {
|
||||
return name.replace(/-([a-z])/g, function (all, letter) {
|
||||
return letter.toUpperCase()
|
||||
})
|
||||
}
|
||||
const components = {}
|
||||
components.iconWrapper = iconWrapper
|
||||
let names = []
|
||||
icons.iconNames.forEach(name => {
|
||||
const fileName = name.match(/.*(?=.vue)/)[0]
|
||||
const moduleName = toHump(fileName)
|
||||
names.push(fileName)
|
||||
components[moduleName] = () => import('naive-ui/lib/icons/' + fileName)
|
||||
})
|
||||
import getScrollParent from '../../../../../src/_utils/dom/getScrollParent'
|
||||
import { state } from '../../../../store'
|
||||
|
||||
export default {
|
||||
components: components,
|
||||
components: {
|
||||
iconWrapper,
|
||||
...icons
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
pattern: '',
|
||||
names: names,
|
||||
loadNumber: 20,
|
||||
container: null
|
||||
container: null,
|
||||
state: state
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
mode () {
|
||||
return this.state.mode
|
||||
},
|
||||
names () {
|
||||
let iconNames = []
|
||||
for (const key in icons) {
|
||||
iconNames.push(key)
|
||||
}
|
||||
return iconNames
|
||||
},
|
||||
filteredNames () {
|
||||
if (this.pattern.trim()) {
|
||||
const pattern = this.pattern.trim()
|
||||
|
@ -33,5 +33,6 @@ icons
|
||||
|-|-|-|
|
||||
|default|`()`||
|
||||
|
||||
## Icons
|
||||
<icons />
|
||||
<!-- ## Icons -->
|
||||
<icons/>
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -11,6 +11,9 @@ theme
|
||||
custom-icon
|
||||
depth
|
||||
```
|
||||
```component
|
||||
icons
|
||||
```
|
||||
|
||||
## Props
|
||||
|名称|类型|默认值|说明|
|
||||
@ -27,3 +30,4 @@ depth
|
||||
|-|-|-|
|
||||
|default|`()`||
|
||||
|
||||
<icons />
|
7468
src/_icons/index.js
7468
src/_icons/index.js
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user