页面跳转添加loading,添加全局loading

This commit is contained in:
李志鹏
2025-12-12 10:34:10 +08:00
parent 652d89d3be
commit ed83044f81
6 changed files with 50 additions and 21 deletions

View File

@@ -1,7 +1,16 @@
<template>
<router-view/>
<div class="loading" v-show="loading"><a-spin delay="0.5" /></div>
</template>
<script setup>
import { computed } from 'vue';
import { useStore } from 'vuex';
const store = useStore();
const loading = computed(() => store.state.loading || store.state.view_loading);
</script>
<style lang="less">
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
@@ -9,7 +18,19 @@
-moz-osx-font-smoothing: grayscale;
height: 100%;
}
.loading{
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.4);
display: flex;
align-items: center;
justify-content: center;
z-index: 999999999999;
color: #fff;
}
.ipad{
*{
-webkit-touch-callout:none;

View File

@@ -553,13 +553,14 @@ export default defineComponent({
loginType: "EMAIL",
userId: this.userId,
};
this.$emit('update:isMask',true)
this.store.commit('set_loading', true)
Https.axiosPost(Https.httpUrls.accountLogin, data)
.then((rv: any) => {
this.setSuccessLogin(rv);
this.setSuccessLogin(rv);
this.store.commit('set_loading', false)
})
.catch((res) => {
this.$emit('update:isMask',false)
this.store.commit('set_loading', false)
});
},1000)
},

View File

@@ -498,6 +498,7 @@ function isTimeRangePassed(timeRange) {
}
router.beforeEach((to: any, from, next) => {
store.commit("set_view_loading", true);
//系统维护时间
const time = '2025-11-21T23:00:00 - 2025-11-22T00:00:00';
if (isTimeRangePassed(time) == 'in_progress') {
@@ -540,5 +541,7 @@ router.beforeEach((to: any, from, next) => {
// if(systemUser == 0){//游客用户只能进入这两个页面
});
router.afterEach((to, from) => {
store.commit("set_view_loading", false);
});
export default router;

View File

@@ -13,10 +13,18 @@ export interface RootState{
export default createStore<RootState>({
state: {
loading: false,
view_loading: false,
},
getters: {
},
mutations: {
set_loading(state, v){
state.loading = v;
},
set_view_loading(state, v){
state.view_loading = v;
},
},
actions: {
},

View File

@@ -427,7 +427,7 @@
<div class="userSystem" v-show="pastDuePage">
{{ $t('Header.pastDue') }}
</div>
<div class="router" v-if="!getLangIsShowMark">
<div class="router" v-if="!loading">
<home
ref="home"
@setNewProject="() => (leftShow = true)"
@@ -442,10 +442,10 @@
<UpgradePlan ref="UpgradePlan"></UpgradePlan>
<TaskPage ref="TaskPage"></TaskPage>
<div class="mark_loading" v-show="getLangIsShowMark">
<!-- <div class="mark_loading" v-show="loading">
<a-spin size="large" />
</div>
<!-- <RobotAssist v-if="!getLangIsShowMark"></RobotAssist> -->
</div> -->
<!-- <RobotAssist v-if="!loading"></RobotAssist> -->
<scaleVideo ref="scaleVideo"></scaleVideo>
<!-- 进行续订 -->
<renew ref="renew"></renew>
@@ -656,7 +656,7 @@ export default defineComponent({
})
let activeCredits = ref(false)
let getLangIsShowMark = ref(true)
let loading = computed(() => (store.state.loading))
let messageNum = computed(() => {
return store.state.UserHabit.messageSystem.messageNum
})
@@ -1070,7 +1070,7 @@ export default defineComponent({
isMurmur,
credits,
activeCredits,
getLangIsShowMark,
loading,
messageNum,
messageType,
...toRefs(stateList),
@@ -1128,11 +1128,11 @@ export default defineComponent({
this.store
.dispatch('getLangType')
.then(() => {
this.getLangIsShowMark = false
this.store.commit('set_loading', false)
resolve()
})
.catch(() => {
this.getLangIsShowMark = false
this.store.commit('set_loading', false)
reject()
})
})
@@ -1334,7 +1334,7 @@ export default defineComponent({
})
},
setLang(v) {
this.getLangIsShowMark = true
store.commit('set_loading', true)
Https.axiosGet(Https.httpUrls.changeUserLanguage, { params: { language: v } })
.then(rv => {
if (rv) {
@@ -1351,11 +1351,11 @@ export default defineComponent({
window.location.reload()
// window.location.href = '/home';
}
this.getLangIsShowMark = false
store.commit('set_loading', false)
}
})
.catch(() => {
this.getLangIsShowMark = false
store.commit('set_loading', false)
})
},

View File

@@ -43,15 +43,12 @@
<span>{{ t('Login.LogonToAiDA') }}</span>
</div>
<div class="info" v-show="!loginType">{{ t('Login.Infomation') }}</div>
<personal ref="personal" v-if="loginType == 'personal'" v-model:isMask="isMask"></personal>
<personal ref="personal" v-if="loginType == 'personal'"></personal>
<school ref="school" v-if="loginType == 'school'"></school>
<enterprise ref="enterprise" v-if="loginType == 'enterprise'"></enterprise>
</div>
</div>
<div class="mark_loading" v-show="isMask">
<a-spin size="large" />
</div>
</div>
</div>
</template>
@@ -103,7 +100,6 @@ export default defineComponent({
const loginData = reactive({
loginType: "",
isMask: false,
});
const dataDom = reactive({
personal: null as any,