Skip to content

Commit

Permalink
feat: support options api call for service component
Browse files Browse the repository at this point in the history
  • Loading branch information
cuixiaorui committed Nov 28, 2020
1 parent b2ee721 commit c850826
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
5 changes: 3 additions & 2 deletions packages/message-box/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import MessageBox from './src/MessageBox.js'
import MessageBoxComponent from './src/MessageBox.vue'

export function useMsgbox() {
return MessageBox
}

export default MessageBoxComponent
export default {
service: MessageBox
}
4 changes: 3 additions & 1 deletion packages/message/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ export function useMessage() {
return Message
}

export default Message
export default {
service: Message
}
5 changes: 3 additions & 2 deletions packages/notification/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import Notification from './Notification.js'
import NotificationComponent from './Notification.vue'

export function useNotify() {
return Notification
}

export default NotificationComponent
export default {
service: Notification
}
18 changes: 15 additions & 3 deletions src/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ import ElAlert from '../packages/alert'

import ElLoading, { useLoading } from '../packages/loading'

import { useMessage } from '../packages/message'
import ElMessage, { useMessage } from '../packages/message'

import { useMsgbox } from '../packages/message-box'
import ElMessageBox, { useMsgbox } from '../packages/message-box'

import { useNotify } from '../packages/notification'
import ElNotification, { useNotify } from '../packages/notification'
// Navigation
import ElMenu from '../packages/menu'
import ElMenuItem from '../packages/menu-item'
Expand Down Expand Up @@ -183,6 +183,18 @@ const install = (app, opts = {}) => {
components.forEach((component) => {
app.use(component)
})

applyOptions(app)
}

function applyOptions(app) {
app.config.globalProperties.$loading = ElLoading.service
app.config.globalProperties.$msgbox = ElMessageBox.service
app.config.globalProperties.$alert = ElMessageBox.service.alert
app.config.globalProperties.$confirm = ElMessageBox.service.confirm
app.config.globalProperties.$prompt = ElMessageBox.service.prompt
app.config.globalProperties.$notify = ElNotification.service
app.config.globalProperties.$message = ElMessage.service
}

const elementUI = {
Expand Down

0 comments on commit c850826

Please sign in to comment.