empty master
This commit is contained in:
parent
92c1162255
commit
67d534df27
276 changed files with 0 additions and 28368 deletions
|
@ -1,112 +0,0 @@
|
|||
import LoadingBar from './loading-bar';
|
||||
|
||||
let loadingBarInstance;
|
||||
let color = 'primary';
|
||||
let failedColor = 'error';
|
||||
let height = 2;
|
||||
let timer;
|
||||
|
||||
function getLoadingBarInstance () {
|
||||
loadingBarInstance = loadingBarInstance || LoadingBar.newInstance({
|
||||
color: color,
|
||||
failedColor: failedColor,
|
||||
height: height
|
||||
});
|
||||
|
||||
return loadingBarInstance;
|
||||
}
|
||||
|
||||
function update(options) {
|
||||
let instance = getLoadingBarInstance();
|
||||
|
||||
instance.update(options);
|
||||
}
|
||||
|
||||
function hide() {
|
||||
setTimeout(() => {
|
||||
update({
|
||||
show: false
|
||||
});
|
||||
setTimeout(() => {
|
||||
update({
|
||||
percent: 0
|
||||
});
|
||||
}, 200);
|
||||
}, 800);
|
||||
}
|
||||
|
||||
function clearTimer() {
|
||||
if (timer) {
|
||||
clearInterval(timer);
|
||||
timer = null;
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
start () {
|
||||
if (timer) return;
|
||||
|
||||
let percent = 0;
|
||||
|
||||
update({
|
||||
percent: percent,
|
||||
status: 'success',
|
||||
show: true
|
||||
});
|
||||
|
||||
timer = setInterval(() => {
|
||||
percent += Math.floor(Math.random () * 3 + 5);
|
||||
if (percent > 95) {
|
||||
clearTimer();
|
||||
}
|
||||
update({
|
||||
percent: percent,
|
||||
status: 'success',
|
||||
show: true
|
||||
});
|
||||
}, 200);
|
||||
},
|
||||
update (percent) {
|
||||
clearTimer();
|
||||
update({
|
||||
percent: percent,
|
||||
status: 'success',
|
||||
show: true
|
||||
});
|
||||
},
|
||||
finish () {
|
||||
clearTimer();
|
||||
update({
|
||||
percent: 100,
|
||||
status: 'success',
|
||||
show: true
|
||||
});
|
||||
hide();
|
||||
},
|
||||
error () {
|
||||
clearTimer();
|
||||
update({
|
||||
percent: 100,
|
||||
status: 'error',
|
||||
show: true
|
||||
});
|
||||
hide();
|
||||
},
|
||||
config (options) {
|
||||
if (options.color) {
|
||||
color = options.color;
|
||||
}
|
||||
if (options.failedColor) {
|
||||
failedColor = options.failedColor;
|
||||
}
|
||||
if (options.height) {
|
||||
height = options.height;
|
||||
}
|
||||
},
|
||||
destroy () {
|
||||
clearTimer();
|
||||
let instance = getLoadingBarInstance();
|
||||
loadingBarInstance = null;
|
||||
instance.destroy();
|
||||
}
|
||||
};
|
|
@ -1,42 +0,0 @@
|
|||
import LoadingBar from './loading-bar.vue';
|
||||
import Vue from 'vue';
|
||||
import { camelcaseToHyphen } from '../../utils/assist';
|
||||
|
||||
LoadingBar.newInstance = properties => {
|
||||
const _props = properties || {};
|
||||
|
||||
let props = '';
|
||||
Object.keys(_props).forEach(prop => {
|
||||
props += ' :' + camelcaseToHyphen(prop) + '=' + prop;
|
||||
});
|
||||
|
||||
const div = document.createElement('div');
|
||||
div.innerHTML = `<loading-bar${props}></loading-bar>`;
|
||||
document.body.appendChild(div);
|
||||
|
||||
const loading_bar = new Vue({
|
||||
el: div,
|
||||
data: _props,
|
||||
components: { LoadingBar }
|
||||
}).$children[0];
|
||||
|
||||
return {
|
||||
update (options) {
|
||||
if ('percent' in options) {
|
||||
loading_bar.percent = options.percent;
|
||||
}
|
||||
if (options.status) {
|
||||
loading_bar.status = options.status;
|
||||
}
|
||||
if ('show' in options) {
|
||||
loading_bar.show = options.show;
|
||||
}
|
||||
},
|
||||
component: loading_bar,
|
||||
destroy () {
|
||||
document.body.removeChild(div);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export default LoadingBar;
|
|
@ -1,77 +0,0 @@
|
|||
<template>
|
||||
<div :class="classes" :style="outerStyles" v-show="show" transition="fade">
|
||||
<div :class="innerClasses" :style="styles"></div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { oneOf } from '../../utils/assist';
|
||||
|
||||
const prefixCls = 'ivu-loading-bar';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
percent: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
color: {
|
||||
type: String,
|
||||
default: 'primary'
|
||||
},
|
||||
failedColor: {
|
||||
type: String,
|
||||
default: 'error'
|
||||
},
|
||||
height: {
|
||||
type: Number,
|
||||
default: 2
|
||||
},
|
||||
status: {
|
||||
type: String,
|
||||
validator (value) {
|
||||
return oneOf(value, ['success', 'error']);
|
||||
},
|
||||
default: 'success'
|
||||
},
|
||||
show: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
classes () {
|
||||
return `${prefixCls}`;
|
||||
},
|
||||
innerClasses () {
|
||||
return [
|
||||
`${prefixCls}-inner`,
|
||||
{
|
||||
[`${prefixCls}-inner-color-primary`]: this.color === 'primary' && this.status === 'success',
|
||||
[`${prefixCls}-inner-failed-color-error`]: this.failedColor === 'error' && this.status === 'error'
|
||||
}
|
||||
];
|
||||
},
|
||||
outerStyles () {
|
||||
return {
|
||||
height: `${this.height}px`
|
||||
};
|
||||
},
|
||||
styles () {
|
||||
let style = {
|
||||
width: `${this.percent}%`,
|
||||
height: `${this.height}px`
|
||||
};
|
||||
|
||||
if (this.color !== 'primary' && this.status === 'success') {
|
||||
style.backgroundColor = this.color;
|
||||
}
|
||||
|
||||
if (this.failedColor !== 'error' && this.status === 'error') {
|
||||
style.backgroundColor = this.failedColor;
|
||||
}
|
||||
|
||||
return style;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue