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

+1
View File
@@ -18,6 +18,7 @@
"prettier": "^2.3.2",
"vue": "^3.2.6",
"vue-i18n": "^9.1.7",
"vue-loading-overlay": "^4.0",
"vue-router": "^4.0.11",
"vuex": "^4.0.2"
},
+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 };
+5 -2
View File
@@ -1,6 +1,7 @@
<template>
<el-row :gutter="20">
<el-col :span="16" :offset="4">
<loading :loading="loading" />
<div class="px-4 pt-4">
<div id="vditor" class="vditor" />
</div>
@@ -10,7 +11,7 @@
<script lang="ts">
import Vditor from '@/libs/vditor/index';
import { Breadcrumb } from '@/components/common/index';
import { Breadcrumb, Loading } from '@/components/common/index';
import { defaultOptions } from '@/settings/editor';
import '@/libs/vditor/assets/scss/index.scss';
import { defineComponent } from 'vue';
@@ -26,7 +27,8 @@ interface IData {
export default defineComponent({
components: {
Breadcrumb
Breadcrumb,
Loading
},
data(): IData {
return {
@@ -37,6 +39,7 @@ export default defineComponent({
};
},
async mounted() {
this.loading = true;
ArticleService.get(this.id).then(({ data: data }: { data: IArticleDetailResponse }): void => {
console.log('data', data);
this.item = data;
+6
View File
@@ -8,6 +8,12 @@ export default {
},
component: () => import('@/layouts/Content.vue'),
children: [
{
path: '',
redirect: {
name: 'article-index'
}
},
{
path: 'article',
name: 'article-index',
+5
View File
@@ -2416,6 +2416,11 @@ vue-i18n@^9.1.7:
"@intlify/vue-devtools" "9.1.7"
"@vue/devtools-api" "^6.0.0-beta.7"
vue-loading-overlay@^4.0:
version "4.0.4"
resolved "https://registry.yarnpkg.com/vue-loading-overlay/-/vue-loading-overlay-4.0.4.tgz#8ddad8ca6b4d3e9eedf3805321e2fb08c0b52e74"
integrity sha512-ADIEUXLo+IEpK8hd2+iqhZtEV3m0WNh5FlGvAc6FWG0KJAEHGTGUFdugQgAtM6Y3iFZc/ovzMd7A9dN+7QC7hw==
vue-router@^4.0.11:
version "4.0.11"
resolved "https://registry.yarnpkg.com/vue-router/-/vue-router-4.0.11.tgz#cd649a0941c635281763a20965b599643ddc68ed"