index.js
3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/***
* 打包的组件的出口
*/
// 导入颜色选择器组件
// import '@/plugins/element.js'
import { Table, TableColumn, Popover, Button, ButtonGroup, Loading, Input, Form, FormItem, Pagination, Tooltip, Icon, Select, Option, DatePicker, Dropdown, DropdownItem, DropdownMenu, Dialog, MessageBox, Tabs, TabPane ,Checkbox,CheckboxGroup,Image,Drawer} from '@/plugins/element.js'
import '@/theme/theme.scss'
// 一次性注册所有的过滤器 本地测试
import filters from '@/filters'
// 导入基础组件
import TestComp from './TestComp'
import GLExternal from './External'
import GLButton from './Button'
import GLDialog from './GLDialog'
import GLTable from './Table'
import GLFooter from './Footer'
import GLSearch from './GlSearch'
import GLSearchItem from './GlSearchItem'
import GLCombiForm from './GlCombiForm'
import GLTableButton from './GlTableButton'
import GLTabs from './GLTabs'
import GLTableOption from './GLTableOption'
import GLImage from './GLImage'
import GLDrawer from './GLDrawer'
import GLVideo from './GLVideo'
// 导入业务组件
import GLProvince from './GLProvince'
import GLFull from './GLFull'
import GLEditor from './Editor'
import GLBcTest from '@/bcPackages/GLBcTest'
//el原始组件
const ElComponent = [Table, TableColumn, Popover, Button, ButtonGroup, Loading, Input, Form, FormItem, Pagination, Tooltip, Icon, Select, Option, DatePicker, Dropdown, DropdownItem, DropdownMenu, Dialog, MessageBox, Tabs, TabPane,Checkbox,CheckboxGroup,Image,Drawer]
// 业务组件导入列表
const BcComponent = [GLBcTest]
// 存储组件列表
const components = [TestComp, GLExternal, GLButton, GLDialog, GLTable, GLFooter, GLSearch, GLSearchItem, GLCombiForm, GLTableButton, GLProvince, GLFull, GLEditor, GLTabs,GLTableOption,GLImage,GLDrawer,GLVideo].concat(ElComponent).concat(BcComponent)
// console.log('components: ', components);
// 定义 install 方法,接收 Vue 作为参数。如果使用 use 注册插件,则所有的组件都将被注册
const install = function (Vue) {
// 注册全局过滤器(一次性注册)
Object.keys(filters).forEach(key => {
Vue.filter(key, filters[key])
})
// 判断是否安装
if (install.installed) return
// 遍历注册全局组件
components.map(component => {
if (!component.name) return
Vue.component(component.name, component)
})
}
// 判断是否是直接引入文件
if (typeof window !== 'undefined' && window.Vue) {
install(window.Vue)
}
/**
*
* @param {*} compArr 组件数组,将他们转化为obj导出
* @returns compObj {}
*/
const getNameComp = compArr => {
if (compArr.length === 0) return
let compObj = {}
compArr.forEach(item => {
compObj[item.name] = item
})
return compObj
}
export default {
// 导出的对象必须具有 install,才能被 Vue.use() 方法安装
install,
...getNameComp(ElComponent),
// ...BcComponent,
// 基础组件
TestComp,
GLExternal,
GLButton,
GLDialog,
GLTable,
GLFooter,
GLSearch,
GLSearchItem,
GLCombiForm,
GLTableButton,
GLTabs,
GLTableOption,
GLImage,
GLDrawer,
GLVideo,
//业务组件
GLProvince,
GLBcTest,
GLFull,
GLEditor
}