|
|
@@ -195,11 +195,17 @@
|
|
|
@visitor="onLoginChoiceVisitor"
|
|
|
@close="onLoginChoiceClose"
|
|
|
/>
|
|
|
+
|
|
|
+ <van-loading
|
|
|
+ v-show="isShowLoading"
|
|
|
+ class="loading"
|
|
|
+ type="spinner"
|
|
|
+ />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { ref, computed, watch, onMounted, onUnmounted } from "vue"
|
|
|
+import { ref, computed, watch, onMounted, onUnmounted, watchEffect } from "vue"
|
|
|
import { useRoute, useRouter } from "vue-router"
|
|
|
import { useStore } from "vuex"
|
|
|
import ClipboardJS from 'clipboard'
|
|
|
@@ -219,8 +225,21 @@ const {
|
|
|
const loginStatus = computed(() => {
|
|
|
return store.state.loginStatus
|
|
|
})
|
|
|
-watch(loginStatus, () => {
|
|
|
- if (loginStatus.value) {
|
|
|
+const gameRuleList = computed(() => {
|
|
|
+ return store.state.gameRuleList
|
|
|
+})
|
|
|
+const score = computed(() => {
|
|
|
+ return store.state.score
|
|
|
+})
|
|
|
+const ifScoreLimitReached = computed(() => {
|
|
|
+ return store.state.ifScoreLimitReached
|
|
|
+})
|
|
|
+const scoreLimit = computed(() => {
|
|
|
+ return store.state.scoreLimit
|
|
|
+})
|
|
|
+
|
|
|
+watch(loginStatus, (vNew) => {
|
|
|
+ if (vNew) {
|
|
|
getScore().then((res) => {
|
|
|
store.commit('setScore', res.total)
|
|
|
store.commit('setIfScoreLimitReached', res.hasOver)
|
|
|
@@ -230,6 +249,20 @@ watch(loginStatus, () => {
|
|
|
immediate: true,
|
|
|
})
|
|
|
|
|
|
+const isShowLoading = ref(true)
|
|
|
+let hideLoadingCallback = null
|
|
|
+watchEffect(() => {
|
|
|
+ if (
|
|
|
+ (loginStatus.value === false && gameRuleList.value.length > 0) ||
|
|
|
+ (loginStatus.value === true && gameRuleList.value.length > 0 && score.value !== undefined && ifScoreLimitReached.value !== undefined && !scoreLimit.value !== undefined)
|
|
|
+ ) {
|
|
|
+ isShowLoading.value = false
|
|
|
+ if (hideLoadingCallback) {
|
|
|
+ hideLoadingCallback()
|
|
|
+ }
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
|
|
|
function onClickLogin() {
|
|
|
router.push({
|
|
|
@@ -334,7 +367,13 @@ if (route.query.gameIdx) {
|
|
|
router.replace({
|
|
|
name: route.name
|
|
|
})
|
|
|
- onClickGameEntry(gameIdx)
|
|
|
+ if (isShowLoading.value) {
|
|
|
+ hideLoadingCallback = () => {
|
|
|
+ onClickGameEntry(gameIdx)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ onClickGameEntry(gameIdx)
|
|
|
+ }
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
@@ -477,5 +516,16 @@ if (route.query.gameIdx) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ >.loading{
|
|
|
+ position: absolute;
|
|
|
+ left: 0;
|
|
|
+ top: 0;
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ background-color: rgba(0, 0, 0, 0.5);
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ align-items: center;
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|