mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-04-24 15:01:22 +08:00
refactor code
This commit is contained in:
parent
e966f38e4b
commit
88d2d68d32
@ -10,7 +10,7 @@
|
||||
/>
|
||||
<div class="icons">
|
||||
<icon-wrapper
|
||||
v-for="name in filteredNames.slice(0, loadNumber)"
|
||||
v-for="name in displayNames"
|
||||
:key="name"
|
||||
:name="name"
|
||||
>
|
||||
@ -46,7 +46,7 @@ export default {
|
||||
return this.state.mode
|
||||
},
|
||||
names () {
|
||||
let iconNames = []
|
||||
const iconNames = []
|
||||
for (const key in icons) {
|
||||
iconNames.push(key)
|
||||
}
|
||||
@ -61,6 +61,9 @@ export default {
|
||||
return name
|
||||
})
|
||||
}
|
||||
},
|
||||
displayNames () {
|
||||
return this.filteredNames.slice(0, this.loadNumber)
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
|
@ -10,7 +10,7 @@
|
||||
/>
|
||||
<div class="icons">
|
||||
<icon-wrapper
|
||||
v-for="name in filteredNames.slice(0, loadNumber)"
|
||||
v-for="name in displayNames"
|
||||
:key="name"
|
||||
:name="name"
|
||||
>
|
||||
@ -46,7 +46,7 @@ export default {
|
||||
return this.state.mode
|
||||
},
|
||||
names () {
|
||||
let iconNames = []
|
||||
const iconNames = []
|
||||
for (const key in icons) {
|
||||
iconNames.push(key)
|
||||
}
|
||||
@ -61,6 +61,9 @@ export default {
|
||||
return name
|
||||
})
|
||||
}
|
||||
},
|
||||
displayNames () {
|
||||
return this.filteredNames.slice(0, loadNumber)
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
|
@ -1,30 +1,30 @@
|
||||
// const fs = require('fs')
|
||||
// const path = require('path')
|
||||
// const _ = require('lodash')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const _ = require('lodash')
|
||||
|
||||
// const files = fs.readdirSync(__dirname).filter(name => name.endsWith('.svg'))
|
||||
const files = fs.readdirSync(__dirname).filter(name => name.endsWith('.svg'))
|
||||
|
||||
// // console.log(files.map(file => file.replace('.vue', '')).map(file => `import ${_.camelCase(file)} from 'naive-ui/lib/icons/${file}'`).join('\n'))
|
||||
// console.log(files.map(file => file.replace('.vue', '')).map(file => `import ${_.camelCase(file)} from 'naive-ui/lib/icons/${file}'`).join('\n'))
|
||||
|
||||
// // console.log(files.map(file => file.replace('.vue', '')).map(file => `'${file}'`).join(',\n'))
|
||||
// console.log(files.map(file => file.replace('.vue', '')).map(file => `'${file}'`).join(',\n'))
|
||||
|
||||
// files.forEach(name => {
|
||||
// const file = fs.readFileSync(path.resolve(__dirname, name)).toString()
|
||||
// const vue = `<template>${file}</template>`
|
||||
// fs.writeFileSync(path.resolve(__dirname, name.replace(/.svg$/, '.vue')), vue)
|
||||
// })
|
||||
files.forEach(name => {
|
||||
const file = fs.readFileSync(path.resolve(__dirname, name)).toString()
|
||||
const vue = `<template>${file}</template>`
|
||||
fs.writeFileSync(path.resolve(__dirname, name.replace(/.svg$/, '.vue')), vue)
|
||||
})
|
||||
|
||||
// // const vues = files.map(file => file.replace(/.svg$/, '.vue'))
|
||||
// const vues = files.map(file => file.replace(/.svg$/, '.vue'))
|
||||
|
||||
// // // const indexFile = `${
|
||||
// // // vues.map(vue => `import ${_.camelCase(vue.replace(/.vue$/, ''))} from './${vue}'`).join('\n')
|
||||
// // // }
|
||||
// // const indexFile = `${
|
||||
// // vues.map(vue => `import ${_.camelCase(vue.replace(/.vue$/, ''))} from './${vue}'`).join('\n')
|
||||
// // }
|
||||
|
||||
// // // export {
|
||||
// // // ${vues.map(vue => ' ' + _.camelCase(vue.replace(/.vue$/, ''))).join(',\n')}
|
||||
// // // }
|
||||
// // // `
|
||||
// // export {
|
||||
// // ${vues.map(vue => ' ' + _.camelCase(vue.replace(/.vue$/, ''))).join(',\n')}
|
||||
// // }
|
||||
// // `
|
||||
|
||||
// // // fs.writeFileSync(path.resolve(__dirname, 'index.js'), indexFile)
|
||||
// // fs.writeFileSync(path.resolve(__dirname, 'index.js'), indexFile)
|
||||
|
||||
// files.forEach(file => fs.unlinkSync(path.resolve(__dirname, file)))
|
||||
files.forEach(file => fs.unlinkSync(path.resolve(__dirname, file)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user