add loading

This commit is contained in:
AceDataCloud committed 2021-09-04 20:13:13 +08:00
1 parent c7317334cf
commit d9d2c59295
7 files changed
+75 -10

No files matched your search

+52
View File
@@ -0,0 +1,52 @@
<template>
<full-loading
v-model:active="showing"
color="#409eff"
loader="bars"
:opacity="0.8"
:can-cancel="true"
:on-cancel="undefined"
:is-full-page="true"
/>
</template>
<script lang="ts">
import FullLoading from 'vue-loading-overlay';
import 'vue-loading-overlay/dist/vue-loading.css';
import { defineComponent } from 'vue';
export default defineComponent({
name: 'Loading',
components: {
FullLoading
},
data() {
return {
showing: false
};
},
props: {
loading: {
type: Boolean,
default: false
},
delay: {
type: Number,
default: 200
}
},
watch: {
loading: {
handler(val, oldVal) {
if (oldVal === true && val === false) {
setTimeout(() => {
this.showing = val;
}, this.delay);
} else {
this.showing = val;
}
}
}
}
});
</script>
+4 -6
View File
@@ -7,8 +7,7 @@
<el-row>
<el-col>
<el-menu :default-active="active" class="el-menu-demo" mode="horizontal" @select="onSelect">
<el-menu-item index="home" v-t="'common.nav.home'" v-if="false"></el-menu-item>
<el-menu-item index="editor" v-t="'common.nav.editor'"></el-menu-item>
<el-menu-item index="/content" v-t="'common.nav.content'"></el-menu-item>
</el-menu>
</el-col>
</el-row>
@@ -26,14 +25,13 @@ export default defineComponent({
},
computed: {
active() {
return this.$route.name;
console.log('this.$route', this.$route);
return this.$route.matched[0].path;
}
},
methods: {
onSelect(val: string) {
this.$router.push({
name: val
});
this.$router.push(val);
},
onHome() {
this.$router.push({
+2 -2
View File
@@ -1,4 +1,4 @@
import TopHeader from './TopHeader.vue';
import Breadcrumb from './Breadcrumb.vue';
export { TopHeader, Breadcrumb };
import Loading from './Loading.vue';
export { TopHeader, Breadcrumb, Loading };