/
githubmirror
/
Motrix
Обзор
Документация
Войти
/
githubmirror
/
Motrix
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/renderer/components/Msg/index.js
42 строки
987 B
Dr_rOot
fix: one msg notify twice error
18 фев 2019, 17:29
18 фев 2019, 17:29
e293b16
Код
Авторство
О чём код?
const queue = [] const maxLength = 5 export default { install: function (Vue, Message, defaultOption = {}) { Vue.prototype.$msg = new Proxy(Message, { get (obj, prop) { return (arg) => { if (!(arg instanceof Object)) { arg = { message: arg } } const task = { run () { obj[prop]({ ...defaultOption, ...arg, onClose (...data) { const currentTask = queue.pop() if (currentTask) { currentTask.run() } if (arg.onClose) { arg.onClose(...data) } } }) } } if (queue.length >= maxLength) { queue.pop() } queue.unshift(task) if (queue.length === 1) { queue.pop().run() } } } }) } }