代码优化
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted } from "vue";
|
import { capsuleHeight } from "@/util";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
type: {
|
type: {
|
||||||
type: Number,
|
type: Number,
|
||||||
@@ -10,11 +11,6 @@ const props = defineProps({
|
|||||||
default: "#050b19",
|
default: "#050b19",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const capsuleHeight = ref(0);
|
|
||||||
onMounted(() => {
|
|
||||||
const menuBtnInfo = uni.getMenuButtonBoundingClientRect();
|
|
||||||
capsuleHeight.value = menuBtnInfo.top + 50 - 9;
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -35,7 +31,7 @@ onMounted(() => {
|
|||||||
class="bg-image"
|
class="bg-image"
|
||||||
v-if="type === 2"
|
v-if="type === 2"
|
||||||
src="../static/app-bg3.png"
|
src="../static/app-bg3.png"
|
||||||
:style="{ height: capsuleHeight + 'px' }"
|
:style="{ height: capsuleHeight + 50 + 'px' }"
|
||||||
/>
|
/>
|
||||||
<image
|
<image
|
||||||
class="bg-image"
|
class="bg-image"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted, onBeforeUnmount } from "vue";
|
import { ref, onMounted, onBeforeUnmount } from "vue";
|
||||||
import { getElementRect, calcRing } from "@/util";
|
import { getElementRect, calcRing, capsuleHeight } from "@/util";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
id: {
|
id: {
|
||||||
@@ -25,7 +25,6 @@ const rect = ref({});
|
|||||||
const arrow = ref(null);
|
const arrow = ref(null);
|
||||||
const isDragging = ref(false);
|
const isDragging = ref(false);
|
||||||
const dragStartPos = ref({ x: 0, y: 0 });
|
const dragStartPos = ref({ x: 0, y: 0 });
|
||||||
const capsuleHeight = ref(0);
|
|
||||||
const scale = ref(1);
|
const scale = ref(1);
|
||||||
const scrollTop = ref(0);
|
const scrollTop = ref(0);
|
||||||
const selected = ref(null);
|
const selected = ref(null);
|
||||||
@@ -59,7 +58,7 @@ const onClick = async (e) => {
|
|||||||
}
|
}
|
||||||
const newArrow = {
|
const newArrow = {
|
||||||
x: (e.detail.x - 6) * scale.value,
|
x: (e.detail.x - 6) * scale.value,
|
||||||
y: (e.detail.y - rect.value.top - capsuleHeight.value - 6) * scale.value,
|
y: (e.detail.y - rect.value.top - capsuleHeight - 6) * scale.value,
|
||||||
};
|
};
|
||||||
|
|
||||||
const side = rect.value.width;
|
const side = rect.value.width;
|
||||||
@@ -188,8 +187,6 @@ const setEditArrow = (data) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
const menuBtnInfo = uni.getMenuButtonBoundingClientRect();
|
|
||||||
capsuleHeight.value = menuBtnInfo.top - 9;
|
|
||||||
const result = await getElementRect(".container");
|
const result = await getElementRect(".container");
|
||||||
rect.value = result;
|
rect.value = result;
|
||||||
uni.$on("set-edit-arrow", setEditArrow);
|
uni.$on("set-edit-arrow", setEditArrow);
|
||||||
@@ -423,9 +420,17 @@ onBeforeUnmount(() => {
|
|||||||
animation: duang 0.35s ease-out;
|
animation: duang 0.35s ease-out;
|
||||||
}
|
}
|
||||||
@keyframes duang {
|
@keyframes duang {
|
||||||
0% { transform: translate(-50%, -50%) scale(0.7); }
|
0% {
|
||||||
45% { transform: translate(-50%, -50%) scale(1.4); }
|
transform: translate(-50%, -50%) scale(0.7);
|
||||||
70% { transform: translate(-50%, -50%) scale(0.9); }
|
}
|
||||||
100% { transform: translate(-50%, -50%) scale(1); }
|
45% {
|
||||||
|
transform: translate(-50%, -50%) scale(1.4);
|
||||||
|
}
|
||||||
|
70% {
|
||||||
|
transform: translate(-50%, -50%) scale(0.9);
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
transform: translate(-50%, -50%) scale(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import Header from "@/components/Header.vue";
|
|||||||
import ScreenHint from "@/components/ScreenHint.vue";
|
import ScreenHint from "@/components/ScreenHint.vue";
|
||||||
import BackToGame from "@/components/BackToGame.vue";
|
import BackToGame from "@/components/BackToGame.vue";
|
||||||
import { getCurrentGameAPI, laserAimAPI } from "@/apis";
|
import { getCurrentGameAPI, laserAimAPI } from "@/apis";
|
||||||
import { debounce } from "@/util";
|
import { capsuleHeight, debounce } from "@/util";
|
||||||
import AudioManager from "@/audioManager";
|
import AudioManager from "@/audioManager";
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
title: {
|
title: {
|
||||||
@@ -49,7 +49,6 @@ const props = defineProps({
|
|||||||
const isIOS = uni.getDeviceInfo().osName === "ios";
|
const isIOS = uni.getDeviceInfo().osName === "ios";
|
||||||
const showHint = ref(false);
|
const showHint = ref(false);
|
||||||
const hintType = ref(0);
|
const hintType = ref(0);
|
||||||
const capsuleHeight = ref(0);
|
|
||||||
const isLoading = ref(false);
|
const isLoading = ref(false);
|
||||||
const audioInitProgress = ref(1);
|
const audioInitProgress = ref(1);
|
||||||
const audioProgress = ref(0);
|
const audioProgress = ref(0);
|
||||||
@@ -96,11 +95,6 @@ const audioFinalProgress = computed(() => {
|
|||||||
return Math.max(0, (audioProgress.value - audioInitProgress.value) / left);
|
return Math.max(0, (audioProgress.value - audioInitProgress.value) / left);
|
||||||
});
|
});
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
const menuBtnInfo = uni.getMenuButtonBoundingClientRect();
|
|
||||||
capsuleHeight.value = menuBtnInfo.top - 9;
|
|
||||||
});
|
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
if (audioTimer.value) clearInterval(audioTimer.value);
|
if (audioTimer.value) clearInterval(audioTimer.value);
|
||||||
});
|
});
|
||||||
@@ -162,7 +156,7 @@ const goCalibration = async () => {
|
|||||||
:show-scrollbar="false"
|
:show-scrollbar="false"
|
||||||
:style="{
|
:style="{
|
||||||
height: `calc(100vh - ${capsuleHeight + (isHome ? 0 : 50)}px - ${
|
height: `calc(100vh - ${capsuleHeight + (isHome ? 0 : 50)}px - ${
|
||||||
$slots.bottom && showBottom ? (isIOS ? '85px' : '65px') : '0px'
|
$slots.bottom && showBottom ? (isIOS ? '75px' : '65px') : '0px'
|
||||||
})`,
|
})`,
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
@@ -171,7 +165,7 @@ const goCalibration = async () => {
|
|||||||
<view
|
<view
|
||||||
class="bottom-part"
|
class="bottom-part"
|
||||||
v-if="$slots.bottom && showBottom"
|
v-if="$slots.bottom && showBottom"
|
||||||
:style="{ height: isIOS ? '75px' : '55px', paddingTop: '10px' }"
|
:style="{ height: isIOS ? '65px' : '55px', paddingTop: '10px' }"
|
||||||
>
|
>
|
||||||
<slot name="bottom"></slot>
|
<slot name="bottom"></slot>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
import { ref, onMounted } from "vue";
|
import { ref, onMounted } from "vue";
|
||||||
import SButton from "@/components/SButton.vue";
|
import SButton from "@/components/SButton.vue";
|
||||||
|
|
||||||
|
import { capsuleHeight } from "@/util";
|
||||||
|
|
||||||
const images = [
|
const images = [
|
||||||
"https://static.shelingxingqiu.com/attachment/2025-09-04/dcjmxsmf6yitekatwe.jpg",
|
"https://static.shelingxingqiu.com/attachment/2025-09-04/dcjmxsmf6yitekatwe.jpg",
|
||||||
"https://static.shelingxingqiu.com/attachment/2025-09-04/dcjmxsmi475gqdtrvx.jpg",
|
"https://static.shelingxingqiu.com/attachment/2025-09-04/dcjmxsmi475gqdtrvx.jpg",
|
||||||
@@ -14,12 +16,7 @@ const images = [
|
|||||||
"https://static.shelingxingqiu.com/attachment/2025-10-14/ddht51a3hiyw7ueli4.jpg",
|
"https://static.shelingxingqiu.com/attachment/2025-10-14/ddht51a3hiyw7ueli4.jpg",
|
||||||
];
|
];
|
||||||
|
|
||||||
const addBg = ref("");
|
const addBg = ref(false);
|
||||||
const capsuleHeight = ref(0);
|
|
||||||
onMounted(async () => {
|
|
||||||
const menuBtnInfo = uni.getMenuButtonBoundingClientRect();
|
|
||||||
capsuleHeight.value = menuBtnInfo.top - 9;
|
|
||||||
});
|
|
||||||
|
|
||||||
const onScrollView = (e) => {
|
const onScrollView = (e) => {
|
||||||
addBg.value = e.detail.scrollTop > 100;
|
addBg.value = e.detail.scrollTop > 100;
|
||||||
@@ -35,8 +32,7 @@ const onScrollView = (e) => {
|
|||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<image
|
<image
|
||||||
v-if="addBg"
|
:style="{ opacity: addBg ? 1 : 0 }"
|
||||||
class="bg-image"
|
|
||||||
src="../static/app-bg.png"
|
src="../static/app-bg.png"
|
||||||
mode="widthFix"
|
mode="widthFix"
|
||||||
/>
|
/>
|
||||||
@@ -46,12 +42,17 @@ const onScrollView = (e) => {
|
|||||||
<text
|
<text
|
||||||
:style="{ opacity: addBg ? 1 : 0, color: '#fff', fontWeight: 'bold' }"
|
:style="{ opacity: addBg ? 1 : 0, color: '#fff', fontWeight: 'bold' }"
|
||||||
>
|
>
|
||||||
本赛季排行榜
|
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<scroll-view scroll-y @scroll="onScrollView" :style="{ height: '100vh' }">
|
<scroll-view scroll-y @scroll="onScrollView" :style="{ height: '100vh' }">
|
||||||
<view class="images">
|
<view class="images">
|
||||||
<image v-for="src in images" :key="src" :src="src" mode="widthFix" show-menu-by-longpress />
|
<image
|
||||||
|
v-for="src in images"
|
||||||
|
:key="src"
|
||||||
|
:src="src"
|
||||||
|
mode="widthFix"
|
||||||
|
show-menu-by-longpress
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
</view>
|
</view>
|
||||||
@@ -71,7 +72,6 @@ const onScrollView = (e) => {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
transition: all 0.3s ease;
|
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
@@ -82,12 +82,19 @@ const onScrollView = (e) => {
|
|||||||
margin-top: 5px;
|
margin-top: 5px;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
.bg-image {
|
.header > image:first-child {
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
|
transition: all 0.5s ease;
|
||||||
|
}
|
||||||
|
.header > text {
|
||||||
|
color: #fff;
|
||||||
|
font-weight: bold;
|
||||||
|
transition: all 0.5s ease;
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
.images {
|
.images {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -1,21 +1,19 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted } from "vue";
|
import { ref, onMounted } from "vue";
|
||||||
import Avatar from "@/components/Avatar.vue";
|
import Avatar from "@/components/Avatar.vue";
|
||||||
|
import { capsuleHeight } from "@/util";
|
||||||
import useStore from "@/store";
|
import useStore from "@/store";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const { user, rankData } = storeToRefs(store);
|
const { user, rankData } = storeToRefs(store);
|
||||||
const { getLvlName } = store;
|
const { getLvlName } = store;
|
||||||
|
|
||||||
const capsuleHeight = ref(0);
|
|
||||||
const selectedIndex = ref(0);
|
const selectedIndex = ref(0);
|
||||||
const currentList = ref([]);
|
const currentList = ref([]);
|
||||||
const myData = ref({});
|
const myData = ref({});
|
||||||
const addBg = ref("");
|
const addBg = ref(false);
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
const menuBtnInfo = uni.getMenuButtonBoundingClientRect();
|
|
||||||
capsuleHeight.value = menuBtnInfo.top - 9;
|
|
||||||
handleSelect(0);
|
handleSelect(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -66,19 +64,14 @@ const subTitles = ["排位赛积分", "MVP次数", "十环次数"];
|
|||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<image
|
<image
|
||||||
v-if="addBg"
|
:style="{ opacity: addBg ? 1 : 0 }"
|
||||||
class="bg-image"
|
|
||||||
src="../static/app-bg.png"
|
src="../static/app-bg.png"
|
||||||
mode="widthFix"
|
mode="widthFix"
|
||||||
/>
|
/>
|
||||||
<navigator open-type="navigateBack">
|
<navigator open-type="navigateBack">
|
||||||
<image class="header-back" src="../static/back.png" mode="widthFix" />
|
<image class="header-back" src="../static/back.png" mode="widthFix" />
|
||||||
</navigator>
|
</navigator>
|
||||||
<text
|
<text :style="{ opacity: addBg ? 1 : 0 }">本赛季排行榜</text>
|
||||||
:style="{ opacity: addBg ? 1 : 0, color: '#fff', fontWeight: 'bold' }"
|
|
||||||
>
|
|
||||||
本赛季排行榜
|
|
||||||
</text>
|
|
||||||
</view>
|
</view>
|
||||||
<scroll-view
|
<scroll-view
|
||||||
scroll-y
|
scroll-y
|
||||||
@@ -231,13 +224,28 @@ const subTitles = ["排位赛积分", "MVP次数", "十环次数"];
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
transition: all 0.3s ease;
|
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
.header text {
|
.header-back {
|
||||||
transition: all 0.3s ease;
|
width: 22px;
|
||||||
line-height: 50px;
|
height: 22px;
|
||||||
|
margin: 0px 15px;
|
||||||
|
margin-top: 5px;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.header > image:first-child {
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
transition: all 0.5s ease;
|
||||||
|
}
|
||||||
|
.header > text {
|
||||||
|
color: #fff;
|
||||||
|
font-weight: bold;
|
||||||
|
transition: all 0.5s ease;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
.rank-tabs {
|
.rank-tabs {
|
||||||
@@ -384,18 +392,4 @@ const subTitles = ["排位赛积分", "MVP次数", "十环次数"];
|
|||||||
color: #fff9;
|
color: #fff9;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
.header-back {
|
|
||||||
width: 22px;
|
|
||||||
height: 22px;
|
|
||||||
margin: 0px 15px;
|
|
||||||
margin-top: 5px;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
.bg-image {
|
|
||||||
width: 100vw;
|
|
||||||
height: 100vh;
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user