mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-21 04:50:14 +08:00
refactor(loading-bar): remove some bad looking code
This commit is contained in:
parent
5cdd6e2a44
commit
3eb275c70b
@ -1,5 +1,5 @@
|
||||
import Confirm from './src/index.js'
|
||||
import { install } from '../../utils/installThemeableComponent'
|
||||
import { install } from '../../utils/installThemeableProperty'
|
||||
|
||||
Confirm.install = function (Vue) {
|
||||
Confirm.Vue = Vue
|
||||
|
@ -1,8 +1,8 @@
|
||||
/* istanbul ignore file */
|
||||
import LoadingBar from './src/main.js'
|
||||
import { install } from '../../utils/installThemeableComponent'
|
||||
import { install } from '../../utils/installThemeableProperty'
|
||||
|
||||
LoadingBar.install = function(Vue) {
|
||||
LoadingBar.install = function (Vue) {
|
||||
install(Vue, LoadingBar, '$NLoadingBar')
|
||||
LoadingBar.Vue = Vue
|
||||
}
|
||||
|
@ -37,7 +37,8 @@ export default {
|
||||
status: null,
|
||||
finishCallback: null,
|
||||
enter: false,
|
||||
theme: null
|
||||
theme: null,
|
||||
activeAction: null
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@ -50,14 +51,14 @@ export default {
|
||||
start (fromProgress = 0, toProgress = 80) {
|
||||
if (this.status === null) {
|
||||
this.status = 'starting'
|
||||
return this.$nextTick().then(() => {
|
||||
this.$refs.loadingBar.getBoundingClientRect()
|
||||
this.activeAction = this.$nextTick().then(() => {
|
||||
this.progress = toProgress
|
||||
return this.$nextTick()
|
||||
})
|
||||
return this.activeAction
|
||||
} else {
|
||||
this.progress = fromProgress
|
||||
return this.$nextTick().then(() => {
|
||||
this.activeAction = this.$nextTick().then(() => {
|
||||
this.$refs.loadingBar.style.transition = 'none'
|
||||
this.$refs.loadingBar.getBoundingClientRect()
|
||||
this.$refs.loadingBar.style.transition = null
|
||||
@ -65,24 +66,25 @@ export default {
|
||||
this.progress = toProgress
|
||||
return this.$nextTick()
|
||||
})
|
||||
return this.activeAction
|
||||
}
|
||||
},
|
||||
finish (callback) {
|
||||
this.finishCallback = callback
|
||||
if (this.status === 'finishing') {
|
||||
this.start(100, 100).then(() => {
|
||||
this.activeAction = this.start(100, 100).then(() => {
|
||||
this.finish(callback)
|
||||
})
|
||||
} else if (this.status === null) {
|
||||
this.progress = 100
|
||||
this.$nextTick().then(() => {
|
||||
this.activeAction = this.$nextTick().then(() => {
|
||||
this.$refs.loadingBar.style.transition = 'none'
|
||||
this.$refs.loadingBar.getBoundingClientRect()
|
||||
this.$refs.loadingBar.style.transition = null
|
||||
this.status = 'finishing'
|
||||
})
|
||||
} else {
|
||||
this.$nextTick().then(() => this.$nextTick()).then(() => {
|
||||
this.activeAction = this.activeAction.then(() => {
|
||||
this.progress = 100
|
||||
this.status = 'finishing'
|
||||
})
|
||||
@ -91,19 +93,19 @@ export default {
|
||||
error (callback) {
|
||||
this.finishCallback = callback
|
||||
if (this.status === 'error') {
|
||||
this.start(100, 100).then(() => {
|
||||
this.activeAction = this.start(100, 100).then(() => {
|
||||
this.error(callback)
|
||||
})
|
||||
} else if (this.status === null) {
|
||||
this.progress = 100
|
||||
this.$nextTick().then(() => {
|
||||
this.activeAction = this.$nextTick().then(() => {
|
||||
this.$refs.loadingBar.style.transition = 'none'
|
||||
this.$refs.loadingBar.getBoundingClientRect()
|
||||
this.$refs.loadingBar.style.transition = null
|
||||
this.status = 'error'
|
||||
})
|
||||
} else {
|
||||
this.$nextTick().then(() => this.$nextTick()).then(() => {
|
||||
this.activeAction = this.activeAction.then(() => {
|
||||
this.progress = 100
|
||||
this.status = 'error'
|
||||
})
|
||||
|
@ -1,7 +1,7 @@
|
||||
import Message from './src/main.js'
|
||||
import { install } from '../../utils/installThemeableComponent'
|
||||
import { install } from '../../utils/installThemeableProperty'
|
||||
|
||||
Message.install = function(Vue) {
|
||||
Message.install = function (Vue) {
|
||||
Message.Vue = Vue
|
||||
install(Vue, Message, '$NMessage')
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import NNotificationCell from './NotificationCell'
|
||||
import { getTheme } from '../../../utils/installThemeableComponent'
|
||||
import { getTheme } from '../../../utils/installThemeableProperty'
|
||||
|
||||
function setTheme (notificationContainer) {
|
||||
let theme = getTheme(this)
|
||||
|
@ -1,25 +0,0 @@
|
||||
export default {
|
||||
methods: {
|
||||
bubbleCall (componentName, functionName, ...params) {
|
||||
let parent = this.$parent || this.$root
|
||||
while (true) {
|
||||
if (parent) {
|
||||
const name = parent.$options.name
|
||||
if (Array.isArray(componentName)) {
|
||||
if (componentName.includes(name)) {
|
||||
parent[functionName](...params)
|
||||
break
|
||||
}
|
||||
} else {
|
||||
if (name === componentName) {
|
||||
parent[functionName](...params)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!parent || parent === this.$root) break
|
||||
parent = parent.$parent
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user