Skip to content

Commit 24fcc84

Browse files
committed
feat: [Request] Default config for Notify plugin quasarframework#2069
1 parent 2962030 commit 24fcc84

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/plugins/notify.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const positionList = [
1010
'top', 'bottom', 'left', 'right', 'center'
1111
]
1212

13-
function init ({ $q, Vue }) {
13+
function init ({ $q, Vue, cfg: { notify: defaults = {} } }) {
1414
if (!document.body) {
1515
ready(() => {
1616
init.call(this, { $q, Vue })
@@ -42,16 +42,14 @@ function init ({ $q, Vue }) {
4242
console.error('Notify: parameter required')
4343
return false
4444
}
45-
let notif
46-
if (typeof config === 'string') {
47-
notif = {
48-
message: config,
49-
position: 'bottom'
50-
}
51-
}
52-
else {
53-
notif = clone(config)
54-
}
45+
46+
const notif = Object.assign(
47+
{},
48+
defaults,
49+
typeof config === 'string'
50+
? { message: config }
51+
: clone(config)
52+
)
5553

5654
if (notif.position) {
5755
if (!positionList.includes(notif.position)) {
@@ -78,12 +76,14 @@ function init ({ $q, Vue }) {
7876
const
7977
handler = item.handler,
8078
action = clone(item)
79+
8180
action.handler = typeof handler === 'function'
8281
? () => {
8382
handler()
8483
!item.noDismiss && close()
8584
}
8685
: () => close()
86+
8787
return action
8888
})
8989
}

0 commit comments

Comments
 (0)