Commit fe5a904e authored by xiaoye's avatar xiaoye

增加转场动画

parent da7fb52f
<template> <template>
<transition name = 'move_right_slow'> <transition name = 'move_right'>
<view v-show = 'loading' id = 'background'> <view v-show = 'loading.end' class = 'background' :style = "{ '--index' : index.end }">
<view id = 'pic'></view> <view class = 'pic'></view>
</view>
</transition>
<transition name = 'move_left'>
<view v-show = 'loading.start' class = 'background' :style = "{ '--index' : index.start }">
<view class = 'pic'></view>
</view> </view>
</transition> </transition>
<Tabulator/> <Tabulator/>
...@@ -9,21 +14,63 @@ ...@@ -9,21 +14,63 @@
<script setup lang = 'ts'> <script setup lang = 'ts'>
import { ref, reactive, onMounted, onUnmounted, onBeforeMount, watch} from 'vue'; import { ref, reactive, onMounted, onUnmounted, onBeforeMount, watch} from 'vue';
import Tabulator from './tabulator.vue'; import Tabulator from './tabulator.vue';
let loading = ref(true); import emitter from '../script/emitter.ts';
onMounted(async () => { import Const from '../script/const.ts';
let loading = reactive({
start : false,
end : true
});
let index = reactive({
start : 100,
end : 99
});
const changeUrl = async (url : string) : Promise<void> => {
loading.start = true;
await (new Promise(resolve => setTimeout(resolve, 500))); await (new Promise(resolve => setTimeout(resolve, 500)));
loading.value = false; window.location.replace(url);
}
const show = async () : Promise<void> => {
if (loading.start) {
loading.end = true;
await (new Promise(resolve => setTimeout(resolve, 500)));
index.end = 100;
index.start = 99;
loading.start = false;
await (new Promise(resolve => setTimeout(resolve, 500)));
loading.end = false;
index.end = 99;
index.start = 100;
return;
}
await (new Promise(resolve => setTimeout(resolve, 500)));
loading.end = false;
}
onBeforeMount(() : void => {
// @ts-ignore
emitter.on(Const.changeUrl, changeUrl);
emitter.on(Const.show, show);
})
onUnmounted(() : void => {
// @ts-ignore
emitter.off(Const.changeUrl, changeUrl);
emitter.off(Const.show, show);
}); });
</script> </script>
<style scoped lang = 'scss'> <style scoped lang = 'scss'>
@import '../style/transition.scss'; @import '../style/transition.scss';
#background { .background {
position: fixed; position: fixed;
// background: linear-gradient(45deg, rgb(0, 162, 255), rgb(0, 72, 255)); // background: linear-gradient(45deg, rgb(0, 162, 255), rgb(0, 72, 255));
width: 100vw; width: 100vw;
height: 100vh; height: 100vh;
z-index: 2; z-index: var(--index);
#pic { .pic {
// background-image: url("./static/pic.png"); // background-image: url("./static/pic.png");
width: 100%; width: 100%;
height: 100%; height: 100%;
......
...@@ -179,12 +179,9 @@ ...@@ -179,12 +179,9 @@
if (!page.drawer && page.tournament) if (!page.drawer && page.tournament)
tournament.init(tournament.this as Tournament); tournament.init(tournament.this as Tournament);
}, },
tournament : async(v : number = 0): Promise<void> => { tournament : (v : number = 0): void => {
page.menu = false;
await (new Promise(resolve => setTimeout(resolve, 500)));
page.tournament = true;
const url = window.location.href.split('/?'); const url = window.location.href.split('/?');
window.location.replace(`${url[0].replace(/\/?$/, '')}/tournament/${search.result.tournaments[v].id}${url[1] ? `/?${url[1]}` : ''}`); emitter.emit(Const.changeUrl, `${url[0].replace(/\/?$/, '')}/${search.result.tournaments[v].id}${url[1] ? `/?${url[1]}` : ''}`);
}, },
menu : async(): Promise<void> => { menu : async(): Promise<void> => {
page.tournament = false; page.tournament = false;
...@@ -411,6 +408,27 @@ ...@@ -411,6 +408,27 @@
} }
}); });
const loading = async () : Promise<void> => {
const url = window.location.hash.match(/#\/(.*?)(?:\?|$)/);
if (url) {
if (!isNaN(parseInt(url[1]))) {
page.menu = false;
page.tournament = true;
emitter.emit(Const.showTournament);
return;
} else if (url[1].length == 0) {
page.tournament = false;
page.menu = true;
search.mine();
await search.on();
emitter.emit(Const.show);
return;
}
}
const i = window.location.href.split('/?');
emitter.emit(Const.changeUrl, `${window.location.origin}/#${i[1] ? `/?${i[1]}` : '/'}`);
};
onBeforeMount(() : void => { onBeforeMount(() : void => {
Uniapp.chkScreen(size.get); Uniapp.chkScreen(size.get);
document.addEventListener("click", page.show.clear); document.addEventListener("click", page.show.clear);
...@@ -418,19 +436,8 @@ ...@@ -418,19 +436,8 @@
// @ts-ignore // @ts-ignore
emitter.on(Const.tournamentReload, tournament.init); emitter.on(Const.tournamentReload, tournament.init);
emitter.on(Const.createOff, creator.off); emitter.on(Const.createOff, creator.off);
window.addEventListener('hashchange', loading);
const url = window.location.pathname.match(/\/tournament\/([^\/]+)(?=\/|$)/); loading();
if (url && !isNaN(parseInt(url[1]))) {
page.menu = false;
page.tournament = true;
} else {
if (window.location.pathname.length > 1)
window.location.replace(window.location.href.replace(window.location.pathname, ''))
else {
search.mine();
search.on();
}
}
}); });
onMounted(() => { onMounted(() => {
...@@ -444,6 +451,7 @@ ...@@ -444,6 +451,7 @@
// @ts-ignore // @ts-ignore
emitter.off(Const.tournamentReload, tournament.init); emitter.off(Const.tournamentReload, tournament.init);
emitter.off(Const.createOff, creator.off); emitter.off(Const.createOff, creator.off);
window.removeEventListener('hashchange', loading);
}); });
watch(() => { return search.date; }, () => { watch(() => { return search.date; }, () => {
......
...@@ -395,7 +395,6 @@ ...@@ -395,7 +395,6 @@
for (const i of del_list) for (const i of del_list)
await participant.del(i); await participant.del(i);
await participant.search(); await participant.search();
console.log(participant.array)
} }
}; };
await UniApp.selectFile(['.ydk', '.txt'], f); await UniApp.selectFile(['.ydk', '.txt'], f);
...@@ -491,7 +490,7 @@ ...@@ -491,7 +490,7 @@
page.reload(); page.reload();
}, },
search : async () : Promise<boolean> => { search : async () : Promise<boolean> => {
const url = window.location.pathname.match(/\/tournament\/([^\/]+)(?=\/|$)/); const url = window.location.hash.match(/#\/(.*?)(?:\?|$)/);
// @ts-ignore // @ts-ignore
const id = url[1]; const id = url[1];
// @ts-ignore // @ts-ignore
...@@ -569,16 +568,23 @@ ...@@ -569,16 +568,23 @@
let page = reactive({ let page = reactive({
height : 0, height : 0,
loading : false, loading : false,
clear : async () : Promise<void>=> { clear : (chk = false) : void => {
tournament.this = undefined; const i = window.location.href.split('/?');
await (new Promise(resolve => setTimeout(resolve, 450))); if (chk)
window.location.replace(window.location.href.replace(window.location.pathname, '')) window.location.replace(`${window.location.origin}/#${i[1] ? `/?${i[1]}` : '/'}`);
else
emitter.emit(Const.changeUrl, `${window.location.origin}/#${i[1] ? `/?${i[1]}` : '/'}`);
},
show : () : void => {
emitter.emit(Const.show);
}, },
get : async () : Promise<void> => { get : async () : Promise<void> => {
if (await participant.search()) if (await participant.search()) {
await match.search(); await match.search();
else page.show();
page.clear(); }
else
page.clear(true);
}, },
reload : async () : Promise<void> => { reload : async () : Promise<void> => {
const query = uni.createSelectorQuery().in(this); const query = uni.createSelectorQuery().in(this);
...@@ -616,18 +622,24 @@ ...@@ -616,18 +622,24 @@
} }
}); });
onBeforeMount(() => { const loading = () : void => {
const url = window.location.pathname.match(/\/tournament\/([^\/]+)(?=\/|$)/); const url = window.location.hash.match(/#\/(.*?)(?:\?|$)/);
url && !isNaN(parseInt(url[1])) ? page.get() : page.clear(); url && !isNaN(parseInt(url[1])) ? page.get() : page.clear();
};
onBeforeMount(() => {
loading();
document.addEventListener("click", page.clickClear); document.addEventListener("click", page.clickClear);
// @ts-ignore // @ts-ignore
emitter.on(Const.updateTournament, participant.update); emitter.on(Const.updateTournament, participant.update);
emitter.on(Const.showTournament, loading);
}); });
onUnmounted(() => { onUnmounted(() => {
document.removeEventListener("click", page.clickClear); document.removeEventListener("click", page.clickClear);
// @ts-ignore // @ts-ignore
emitter.off(Const.updateTournament, participant.update); emitter.off(Const.updateTournament, participant.update);
emitter.off(Const.showTournament, loading);
}); });
watch(() => { return match.round; }, async () : Promise<void> => { watch(() => { return match.round; }, async () : Promise<void> => {
......
...@@ -7,6 +7,9 @@ class ConstData { ...@@ -7,6 +7,9 @@ class ConstData {
picsOpen = 'picsOpen'; picsOpen = 'picsOpen';
searcherInit = 'searcherInit'; searcherInit = 'searcherInit';
settingInit = 'settingInit'; settingInit = 'settingInit';
changeUrl = 'changeUrl';
show = 'show';
showTournament = 'showTournament';
} }
const Const = new ConstData(); const Const = new ConstData();
......
import { Buffer } from 'buffer'; import { Buffer } from 'buffer';
import emitter from './emitter.ts'
import Const from './const.ts'
interface MyCardSSOUser { interface MyCardSSOUser {
token : string; token : string;
...@@ -49,7 +51,7 @@ class MyCard { ...@@ -49,7 +51,7 @@ class MyCard {
logout() { logout() {
window.localStorage.removeItem('mycardLogin'); window.localStorage.removeItem('mycardLogin');
window.location.replace(window.location.href.replace(/\/\?.*/, '')) emitter.emit(Const.changeUrl, window.location.href.replace(/\/\?.*/, ''));
} }
} }
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
} }
} }
.move_left { .move_left, .move_left_slow {
&-enter-active, &-enter-active,
&-leave-active { &-leave-active {
transition: transform 0.5s ease; transition: transform 0.5s ease;
...@@ -49,9 +49,9 @@ ...@@ -49,9 +49,9 @@
} }
} }
.move_right_slow { .move_right_slow, .move_left_slow {
&-leave-active { &-leave-active {
transition: transform 2s ease; transition: transform 1s ease;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment