Commit 1a6d4ca7 authored by xiaoye's avatar xiaoye

fix

parent ab2c1ec2
......@@ -22,6 +22,7 @@
</uni-list-chat>
</uni-list>
</view>
<Pics></Pics>
<transition name = 'move_right'>
<uni-card
class = 'click'
......@@ -264,6 +265,7 @@
import Const from '../script/const.ts'
import PageTournament from './tournament.vue';
import Create from './drawer.vue';
import Pics from './pics.vue';
let page = reactive({
user : false,
......
<template>
<view class = 'Pics'>
<transition name = 'move_right'>
<view v-show = 'deck.participant >= 0'>
<uni-card :title = "deck.main.length > 0 ? '主卡组' : '暂无主卡组'">
<image class = 'deck_cards' v-for = '(i, v) in deck.main' :src = '`https://cdn.233.momobako.com/ygopro/pics/${i}.jpg!half`' mode = 'aspectFit' @error = 'changeImg.main(v)'></image>
</uni-card>
<uni-card :title = "deck.side.length > 0 ? '副卡组' : '暂无副卡组'">
<image class = 'deck_cards' v-for = '(i, v) in deck.side' :src = '`https://cdn.233.momobako.com/ygopro/pics/${i}.jpg!half`' mode = 'aspectFit' @error = 'changeImg.main(v)'></image>
</uni-card>
</view>
</transition>
</view>
</template>
<script setup lang = 'ts'>
import { ref, reactive, onMounted, onUnmounted, onBeforeMount, watch} from 'vue';
import emitter from '../script/emitter.ts'
import Const from '../script/const.ts'
import Participant from '../script/participant.ts';
const changeImg = {
main : (v : number) : void => {
deck.main[v] = 0;
},
side : (v : number) : void => {
deck.side[v] = 0;
}
};
let deck = reactive({
participant : -1 as number,
main : [] as Array<number>,
side : [] as Array<number>,
init : (i : Map<string, Array<number>>) : void => {
const participant = i.get('Participant')?.[0] ?? -1;
if (participant && deck.participant == participant) {
deck.off();
return
}
deck.main = i.get('main') ?? [];
deck.side = i.get('side') ?? [];
deck.participant = participant;
},
off : async () : Promise<void> => {
deck.participant = -1;
await (new Promise(resolve => setTimeout(resolve, 500)));
deck.main = [];
deck.side = [];
},
clickClear : (e) : void => {
let element = e.target;
while (element) {
if (['body'].includes(element.id) || element.classList.contains('Pics'))
return undefined;
element = element.parentElement;
}
deck.off();
}
});
onBeforeMount(() : void => {
// @ts-ignore
emitter.on(Const.picsOpen, deck.init);
document.addEventListener("click", deck.clickClear);
});
onUnmounted(() => {
// @ts-ignore
emitter.off(Const.picsOpen, deck.init);
document.removeEventListener("click", deck.clickClear);
});
</script>
<style scoped lang = 'scss'>
@import '../style/transition.scss';
</style>
\ No newline at end of file
......@@ -68,6 +68,7 @@
:title = "i.score ? `胜平负:${i.score.win + i.score.bye}-${i.score.draw}-${i.score.lose}` : ''"
:note = "i.score ? `小分:${i.score.score}` : ''"
:clickable = true
@click = 'participant.pics.on(i)'
>
<template v-slot:header>
<view id = 'header'>
......@@ -348,10 +349,10 @@
showCancel : false
});
},
upload : async (i : Participant) : Promise<void> => {
upload : async () : Promise<void> => {
const f = async (res : UniApp.ChooseFileSuccessCallbackResult) : Promise<void> => {
// @ts-ignore
if (await Tabulator.Participant.UpdateYdk(Mycard.token, tournament.this.id, res.tempFiles[0], i.name))
if (await Tabulator.Tournament.UpdateYdk(Mycard.token, tournament.this.id, res))
await participant.search();
};
await UniApp.selectFile(['.ydk', '.txt'], f);
......@@ -474,6 +475,13 @@
}
};
await UniApp.selectFile(['.ydk', '.txt'], f, 1);
},
pics : {
on : (i : Participant) => {
emitter.emit(Const.picsOpen, new Map([
['main', i.getDeck().main], ['side', i.getDeck().side], ['Participant', [i.id]]
]))
}
}
});
......
......@@ -4,6 +4,7 @@ class ConstData {
tournamentInfo = 'tournamentInfo';
tournamentReload = 'tournamentReload';
createOff = 'createOff';
picsOpen = 'picsOpen';
}
const Const = new ConstData();
......
......@@ -30,9 +30,9 @@ class Participant {
getDeck = () : Deck => {
return {
main : this.deck?.main ?? [],
extra : this.deck?.extra ?? [],
side : this.deck?.side ?? [],
main : this.deck?.main.slice() ?? [],
extra : this.deck?.extra.slice() ?? [],
side : this.deck?.side.slice() ?? [],
};
}
}
......
......@@ -81,4 +81,21 @@
border: 0.02px solid #409eff;
}
}
.Pics {
position: absolute;
z-index: 1;
right: 2%;
width: 50%;
:deep(.uni-card) {
// display: flex;
.deck_cards {
width: 10%;
height: 11.52vh;
aspect-ratio: 1 / 1.43;
display: inline-block;
vertical-align: top;
}
}
}
}
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