refactor: 优化全局组件定义

This commit is contained in:
pipipi-pikachu 2022-06-24 15:45:20 +08:00
parent e62fbd839d
commit ee4f27faef
3 changed files with 123 additions and 339 deletions

232
src/components.d.ts vendored
View File

@ -1,119 +1,11 @@
import FileInput from '@/components/FileInput.vue' import { icons } from '@/plugins/icon'
import CheckboxButton from '@/components/CheckboxButton.vue' import { components } from '@/plugins/component'
import CheckboxButtonGroup from '@/components/CheckboxButtonGroup.vue'
import ColorPicker from '@/components/ColorPicker/index.vue'
import FullscreenSpin from '@/components/FullscreenSpin.vue'
import { type Icon = typeof icons
PlayOne, type CustomComponent = typeof components
FullScreenPlay,
Lock,
Unlock,
Ppt,
Format,
Picture,
FullScreen,
List,
OrderedList,
Helpcenter,
FlipVertically,
FlipHorizontally,
FontSize,
Code,
TextBold,
TextItalic,
TextUnderline,
Strikethrough,
Edit,
Quote,
BackgroundColor,
Group,
Ungroup,
Back,
Next,
Fullwidth,
AlignTop,
AlignLeft,
AlignRight,
AlignBottom,
AlignVertically,
AlignHorizontally,
BringToFront,
SendToBack,
AlignTextLeft,
AlignTextRight,
AlignTextCenter,
RowHeight,
Write,
InsertTable,
AddText,
Fill,
Tailoring,
Effects,
ColorFilter,
Down,
Plus,
Minus,
Connection,
BringToFrontOne,
SentToBack,
Github,
ChartProportion,
ChartHistogram,
ChartHistogramOne,
ChartLineArea,
ChartRing,
ChartScatter,
ChartLine,
ChartPie,
Text,
Rotate,
LeftTwo,
RightTwo,
Platte,
UpOne,
DownOne,
Close,
CloseSmall,
Undo,
Transform,
Click,
Theme,
ArrowCircleLeft,
GraphicDesign,
Logout,
Erase,
Clear,
FolderClose,
AlignTextTopOne,
AlignTextBottomOne,
AlignTextMiddleOne,
Pause,
VolumeMute,
VolumeNotice,
VolumeSmall,
VideoTwo,
Formula,
LinkOne,
FullScreenOne,
OffScreenOne,
Power,
ListView,
Magic,
HighLight,
Share,
IndentLeft,
IndentRight,
VerticalSpacingBetweenItems,
Copy,
Delete,
Square,
Round,
Needle,
} from '@icon-park/vue-next'
declare module 'vue' { declare module 'vue' {
export interface GlobalComponents { export interface GlobalComponents extends Icon, CustomComponent {
// antd 组件 // antd 组件
InputNumber: typeof import('ant-design-vue')['InputNumber'] InputNumber: typeof import('ant-design-vue')['InputNumber']
@ -140,120 +32,6 @@ declare module 'vue' {
Checkbox: typeof import('ant-design-vue')['Checkbox'] Checkbox: typeof import('ant-design-vue')['Checkbox']
Drawer: typeof import('ant-design-vue')['Drawer'] Drawer: typeof import('ant-design-vue')['Drawer']
Spin: typeof import('ant-design-vue')['Spin'] Spin: typeof import('ant-design-vue')['Spin']
// 自定义组件
FileInput: typeof FileInput
CheckboxButton: typeof CheckboxButton
CheckboxButtonGroup: typeof CheckboxButtonGroup
ColorPicker: typeof ColorPicker
FullscreenSpin: typeof FullscreenSpin
// IconPark 图标组件
IconPlayOne: typeof PlayOne
IconFullScreenPlay: typeof FullScreenPlay
IconLock: typeof Lock
IconUnlock: typeof Unlock
IconPpt: typeof Ppt
IconFormat: typeof Format
IconPicture: typeof Picture
IconFullScreen: typeof FullScreen
IconList: typeof List
IconOrderedList: typeof OrderedList
IconHelpcenter: typeof Helpcenter
IconFlipVertically: typeof FlipVertically
IconFlipHorizontally: typeof FlipHorizontally
IconFontSize: typeof FontSize
IconCode: typeof Code
IconTextBold: typeof TextBold
IconTextItalic: typeof TextItalic
IconTextUnderline: typeof TextUnderline
IconStrikethrough: typeof Strikethrough
IconEdit: typeof Edit
IconQuote: typeof Quote
IconBackgroundColor: typeof BackgroundColor
IconGroup: typeof Group
IconUngroup: typeof Ungroup
IconBack: typeof Back
IconNext: typeof Next
IconFullwidth: typeof Fullwidth
IconAlignTop: typeof AlignTop
IconAlignLeft: typeof AlignLeft
IconAlignRight: typeof AlignRight
IconAlignBottom: typeof AlignBottom
IconAlignVertically: typeof AlignVertically
IconAlignHorizontally: typeof AlignHorizontally
IconBringToFront: typeof BringToFront
IconSendToBack: typeof SendToBack
IconAlignTextLeft: typeof AlignTextLeft
IconAlignTextRight: typeof AlignTextRight
IconAlignTextCenter: typeof AlignTextCenter
IconRowHeight: typeof RowHeight
IconWrite: typeof Write
IconInsertTable: typeof InsertTable
IconAddText: typeof AddText
IconFill: typeof Fill
IconTailoring: typeof Tailoring
IconEffects: typeof Effects
IconColorFilter: typeof ColorFilter
IconDown: typeof Down
IconPlus: typeof Plus
IconMinus: typeof Minus
IconConnection: typeof Connection
IconBringToFrontOne: typeof BringToFrontOne
IconSentToBack: typeof SentToBack
IconGithub: typeof Github
IconChartProportion: typeof ChartProportion
IconChartHistogram: typeof ChartHistogram
IconChartHistogramOne: typeof ChartHistogramOne
IconChartLineArea: typeof ChartLineArea
IconChartRing: typeof ChartRing
IconChartScatter: typeof ChartScatter
IconChartLine: typeof ChartLine
IconChartPie: typeof ChartPie
IconText: typeof Text
IconRotate: typeof Rotate
IconLeftTwo: typeof LeftTwo
IconRightTwo: typeof RightTwo
IconPlatte: typeof Platte
IconUpOne: typeof UpOne
IconDownOne: typeof DownOne
IconClose: typeof Close
IconCloseSmall: typeof CloseSmall
IconUndo: typeof Undo
IconTransform: typeof Transform
IconClick: typeof Click
IconTheme: typeof Theme
IconArrowCircleLeft: typeof ArrowCircleLeft
IconGraphicDesign: typeof GraphicDesign
IconLogout: typeof Logout
IconErase: typeof Erase
IconClear: typeof Clear
IconFolderClose: typeof FolderClose
IconAlignTextTopOne: typeof AlignTextTopOne
IconAlignTextBottomOne: typeof AlignTextBottomOne
IconAlignTextMiddleOne: typeof AlignTextMiddleOne
IconPause: typeof Pause
IconVolumeMute: typeof VolumeMute
IconVolumeNotice: typeof VolumeNotice
IconVolumeSmall: typeof VolumeSmall
IconVideoTwo: typeof VideoTwo
IconFormula: typeof Formula
IconLinkOne: typeof LinkOne
IconFullScreenOne: typeof FullScreenOne
IconOffScreenOne: typeof OffScreenOne
IconPower: typeof Power
IconListView: typeof ListView
IconMagic: typeof Magic
IconHighLight: typeof HighLight
IconShare: typeof Share
IconIndentLeft: typeof IndentLeft
IconIndentRight: typeof IndentRight
IconVerticalSpacingBetweenItems: typeof VerticalSpacingBetweenItems
IconCopy: typeof Copy
IconDelete: typeof Delete
IconSquare: typeof Square
IconRound: typeof Round
IconNeedle: typeof Needle
} }
} }

View File

@ -6,12 +6,18 @@ import CheckboxButtonGroup from '@/components/CheckboxButtonGroup.vue'
import ColorPicker from '@/components/ColorPicker/index.vue' import ColorPicker from '@/components/ColorPicker/index.vue'
import FullscreenSpin from '@/components/FullscreenSpin.vue' import FullscreenSpin from '@/components/FullscreenSpin.vue'
export const components = {
FileInput,
CheckboxButton,
CheckboxButtonGroup,
ColorPicker,
FullscreenSpin,
}
export default { export default {
install(app: App) { install(app: App) {
app.component('FileInput', FileInput) for (const key of Object.keys(components)) {
app.component('CheckboxButton', CheckboxButton) app.component(key, components[key])
app.component('CheckboxButtonGroup', CheckboxButtonGroup) }
app.component('ColorPicker', ColorPicker)
app.component('FullscreenSpin', FullscreenSpin)
} }
} }

View File

@ -109,118 +109,118 @@ import {
Needle, Needle,
} from '@icon-park/vue-next' } from '@icon-park/vue-next'
const icons = { export const icons = {
PlayOne, IconPlayOne: PlayOne,
FullScreenPlay, IconFullScreenPlay: FullScreenPlay,
Lock, IconLock: Lock,
Unlock, IconUnlock: Unlock,
Ppt, IconPpt: Ppt,
Format, IconFormat: Format,
Picture, IconPicture: Picture,
FullScreen, IconFullScreen: FullScreen,
List, IconList: List,
OrderedList, IconOrderedList: OrderedList,
Helpcenter, IconHelpcenter: Helpcenter,
FlipVertically, IconFlipVertically: FlipVertically,
FlipHorizontally, IconFlipHorizontally: FlipHorizontally,
FontSize, IconFontSize: FontSize,
Code, IconCode: Code,
TextBold, IconTextBold: TextBold,
TextItalic, IconTextItalic: TextItalic,
TextUnderline, IconTextUnderline: TextUnderline,
Strikethrough, IconStrikethrough: Strikethrough,
Edit, IconEdit: Edit,
Quote, IconQuote: Quote,
BackgroundColor, IconBackgroundColor: BackgroundColor,
Group, IconGroup: Group,
Ungroup, IconUngroup: Ungroup,
Back, IconBack: Back,
Next, IconNext: Next,
Fullwidth, IconFullwidth: Fullwidth,
AlignTop, IconAlignTop: AlignTop,
AlignLeft, IconAlignLeft: AlignLeft,
AlignRight, IconAlignRight: AlignRight,
AlignBottom, IconAlignBottom: AlignBottom,
AlignVertically, IconAlignVertically: AlignVertically,
AlignHorizontally, IconAlignHorizontally: AlignHorizontally,
BringToFront, IconBringToFront: BringToFront,
SendToBack, IconSendToBack: SendToBack,
AlignTextLeft, IconAlignTextLeft: AlignTextLeft,
AlignTextRight, IconAlignTextRight: AlignTextRight,
AlignTextCenter, IconAlignTextCenter: AlignTextCenter,
RowHeight, IconRowHeight: RowHeight,
Write, IconWrite: Write,
InsertTable, IconInsertTable: InsertTable,
AddText, IconAddText: AddText,
Fill, IconFill: Fill,
Tailoring, IconTailoring: Tailoring,
Effects, IconEffects: Effects,
ColorFilter, IconColorFilter: ColorFilter,
Down, IconDown: Down,
Plus, IconPlus: Plus,
Minus, IconMinus: Minus,
Connection, IconConnection: Connection,
BringToFrontOne, IconBringToFrontOne: BringToFrontOne,
SentToBack, IconSentToBack: SentToBack,
Github, IconGithub: Github,
ChartProportion, IconChartProportion: ChartProportion,
ChartHistogram, IconChartHistogram: ChartHistogram,
ChartHistogramOne, IconChartHistogramOne: ChartHistogramOne,
ChartLineArea, IconChartLineArea: ChartLineArea,
ChartRing, IconChartRing: ChartRing,
ChartScatter, IconChartScatter: ChartScatter,
ChartLine, IconChartLine: ChartLine,
ChartPie, IconChartPie: ChartPie,
Text, IconText: Text,
Rotate, IconRotate: Rotate,
LeftTwo, IconLeftTwo: LeftTwo,
RightTwo, IconRightTwo: RightTwo,
Platte, IconPlatte: Platte,
UpOne, IconUpOne: UpOne,
DownOne, IconDownOne: DownOne,
Close, IconClose: Close,
CloseSmall, IconCloseSmall: CloseSmall,
Undo, IconUndo: Undo,
Transform, IconTransform: Transform,
Click, IconClick: Click,
Theme, IconTheme: Theme,
ArrowCircleLeft, IconArrowCircleLeft: ArrowCircleLeft,
GraphicDesign, IconGraphicDesign: GraphicDesign,
Logout, IconLogout: Logout,
Erase, IconErase: Erase,
Clear, IconClear: Clear,
FolderClose, IconFolderClose: FolderClose,
AlignTextTopOne, IconAlignTextTopOne: AlignTextTopOne,
AlignTextBottomOne, IconAlignTextBottomOne: AlignTextBottomOne,
AlignTextMiddleOne, IconAlignTextMiddleOne: AlignTextMiddleOne,
Pause, IconPause: Pause,
VolumeMute, IconVolumeMute: VolumeMute,
VolumeNotice, IconVolumeNotice: VolumeNotice,
VolumeSmall, IconVolumeSmall: VolumeSmall,
VideoTwo, IconVideoTwo: VideoTwo,
Formula, IconFormula: Formula,
LinkOne, IconLinkOne: LinkOne,
FullScreenOne, IconFullScreenOne: FullScreenOne,
OffScreenOne, IconOffScreenOne: OffScreenOne,
Power, IconPower: Power,
ListView, IconListView: ListView,
Magic, IconMagic: Magic,
HighLight, IconHighLight: HighLight,
Share, IconShare: Share,
IndentLeft, IconIndentLeft: IndentLeft,
IndentRight, IconIndentRight: IndentRight,
VerticalSpacingBetweenItems, IconVerticalSpacingBetweenItems: VerticalSpacingBetweenItems,
Copy, IconCopy: Copy,
Delete, IconDelete: Delete,
Square, IconSquare: Square,
Round, IconRound: Round,
Needle, IconNeedle: Needle,
} }
export default { export default {
install(app: App) { install(app: App) {
for (const key of Object.keys(icons)) { for (const key of Object.keys(icons)) {
app.component(`Icon${key}`, icons[key]) app.component(key, icons[key])
} }
} }
} }