tps-ui-components
Version:
TPS UI组件库 - 基于Vue 2和Element UI的企业级组件库
78 lines (68 loc) • 1.58 kB
JavaScript
// 导入工具函数
import ThemeManager from './utils/themeManager'
import request, { get, post, put, del, upload } from './utils/request'
// 导入组件
import TpsButton from './components/TpsButton'
import TpsCard from './components/TpsCard'
import TpsForm from './components/TpsForm'
import TpsTable from './components/TpsTable'
import TpsDialog from './components/TpsDialog'
import TpsNavigation from './components/TpsNavigation'
// 所有组件列表
const components = {
TpsButton,
TpsCard,
TpsForm,
TpsTable,
TpsDialog,
TpsNavigation
}
// 定义install方法,供Vue.use()调用
const install = function(Vue, opts = {}) {
// 注册所有组件
Object.keys(components).forEach(key => {
Vue.component(key, components[key])
})
// 安装主题管理器
Vue.use(ThemeManager)
// 挂载请求工具到Vue原型
Vue.prototype.$http = request
Vue.prototype.$get = get
Vue.prototype.$post = post
Vue.prototype.$put = put
Vue.prototype.$delete = del
Vue.prototype.$upload = upload
// 全局配置
if (opts.theme) {
Vue.prototype.$themeManager.changeTheme(opts.theme)
}
}
// 支持script标签引入
if (typeof window !== 'undefined' && window.Vue) {
install(window.Vue)
}
export default {
// 导出的install方法,供Vue.use()调用
install,
// 导出所有组件,支持按需引入
...components
}
// 导出工具函数
export {
ThemeManager,
request,
get,
post,
put,
del,
upload
}
// 导出所有组件
export {
TpsButton,
TpsCard,
TpsForm,
TpsTable,
TpsDialog,
TpsNavigation
}