Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
LoadingBar
)
)
return instance
}
function remove() {
if (instance) {
instance.destroy()
instance = UNDEFINED
}
}
(Yox.prototype as any).$loadingBar = {
// 开始从 0 显示进度条,并自动加载进度
start(options?: Config) {
if (instance) {
remove()
}
return add(options)
},
// 结束进度条,自动补全剩余进度
finish() {
if (instance) {
instance.set('percent', 100)
setTimeout(remove, 300)
}
},
// 精确加载到指定的进度
update(data: Config) {
import Yox, { Data } from 'yox'
import { BODY } from '../constant'
import Alert from './Alert'
import Confirm from './Confirm'
type Arg = string | Data
const prototype = Yox.prototype as any
prototype.$alert = function (data: Arg) {
const props: Data = {}
if (Yox.is.object(data)) {
const obj = data as Data
props.closable = obj.closable
props.title = obj.title
props.content = obj.content
props.width = obj.width
props.okText = obj.okText
props.okType = obj.okType
props.onOk = obj.onOk
}
else {
}
instance.destroy()
})
setTimeout(
function () {
if (instance.$el) {
instance.show(props.top || 15, props.duration || 2000)
}
},
300
)
}
(Yox.prototype as any).$message = {
success(arg: Arg, onClose?: Function) {
addMessage('success', arg, onClose)
},
info(arg: Arg, onClose?: Function) {
addMessage('info', arg, onClose)
},
warning(arg: Arg, onClose?: Function) {
addMessage('warning', arg, onClose)
},
error(arg: Arg, onClose?: Function) {
addMessage('error', arg, onClose)
},
config(arg: Data) {
Yox.object.extend(config, arg)
}
}
}
instance.destroy()
})
setTimeout(
function () {
if (instance.$el) {
instance.show()
}
},
300
)
}
(Yox.prototype as any).$notification = {
success(props: Data, onClose?: Function) {
addNotification('success', props, onClose)
},
info(props: Data, onClose?: Function) {
addNotification('info', props, onClose)
},
warning(props: Data, onClose?: Function) {
addNotification('warning', props, onClose)
},
error(props: Data, onClose?: Function) {
addNotification('error', props, onClose)
},
config(options: Data) {
Yox.object.extend(config, options)
}
}