feat: 添加射箭声音
This commit is contained in:
68
src/App.vue
68
src/App.vue
@@ -1,13 +1,28 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { watch } from "vue";
|
import {
|
||||||
import { onShow, onHide } from "@dcloudio/uni-app";
|
watch
|
||||||
|
} from "vue";
|
||||||
|
import {
|
||||||
|
onShow,
|
||||||
|
onHide
|
||||||
|
} from "@dcloudio/uni-app";
|
||||||
import websocket from "@/websocket";
|
import websocket from "@/websocket";
|
||||||
import { getDeviceBatteryAPI } from "@/apis";
|
import {
|
||||||
|
getDeviceBatteryAPI
|
||||||
|
} from "@/apis";
|
||||||
import useStore from "@/store";
|
import useStore from "@/store";
|
||||||
import { storeToRefs } from "pinia";
|
import {
|
||||||
|
storeToRefs
|
||||||
|
} from "pinia";
|
||||||
|
import audioManager from "./audioManager";
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const { user } = storeToRefs(store);
|
const {
|
||||||
const { updateUser, updateOnline } = store;
|
user
|
||||||
|
} = storeToRefs(store);
|
||||||
|
const {
|
||||||
|
updateUser,
|
||||||
|
updateOnline
|
||||||
|
} = store;
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => user.value.id,
|
() => user.value.id,
|
||||||
@@ -16,15 +31,12 @@ watch(
|
|||||||
`${uni.getAccountInfoSync().miniProgram.envVersion}_token`
|
`${uni.getAccountInfoSync().miniProgram.envVersion}_token`
|
||||||
);
|
);
|
||||||
if (newVal && token) {
|
if (newVal && token) {
|
||||||
websocket.createWebSocket(token, (content) => {
|
websocket.createWebSocket(token, onShootWsMsg);
|
||||||
uni.$emit("socket-inbox", content);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if (!newVal) {
|
if (!newVal) {
|
||||||
websocket.closeWebSocket();
|
websocket.closeWebSocket();
|
||||||
}
|
}
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
deep: false, // 如果 user 是一个对象或数组,建议开启
|
deep: false, // 如果 user 是一个对象或数组,建议开启
|
||||||
immediate: false, // 若想在初始化时立即执行一次回调,可开启。
|
immediate: false, // 若想在初始化时立即执行一次回调,可开启。
|
||||||
}
|
}
|
||||||
@@ -39,6 +51,17 @@ async function emitUpdateOnline() {
|
|||||||
updateOnline(data.online);
|
updateOnline(data.online);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onDeviceShoot() {
|
||||||
|
audioManager.play("射箭声音")
|
||||||
|
}
|
||||||
|
|
||||||
|
function onShootWsMsg(content) {
|
||||||
|
if(content.type === 'shoot-trigger'){
|
||||||
|
onDeviceShoot()
|
||||||
|
}
|
||||||
|
uni.$emit("socket-inbox", content);
|
||||||
|
}
|
||||||
|
|
||||||
onShow(() => {
|
onShow(() => {
|
||||||
uni.$on("update-user", emitUpdateUser);
|
uni.$on("update-user", emitUpdateUser);
|
||||||
uni.$on("update-online", emitUpdateOnline);
|
uni.$on("update-online", emitUpdateOnline);
|
||||||
@@ -47,9 +70,7 @@ onShow(() => {
|
|||||||
);
|
);
|
||||||
if (user.value.id && token) {
|
if (user.value.id && token) {
|
||||||
console.log("回到前台,重新连接 websocket");
|
console.log("回到前台,重新连接 websocket");
|
||||||
websocket.createWebSocket(token, (content) => {
|
websocket.createWebSocket(token, onShootWsMsg);
|
||||||
uni.$emit("socket-inbox", content);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -93,9 +114,11 @@ button::after {
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.guide-tips>text:first-child {
|
.guide-tips>text:first-child {
|
||||||
color: #fed847;
|
color: #fed847;
|
||||||
}
|
}
|
||||||
|
|
||||||
.guide-tips>text:nth-child(2) {
|
.guide-tips>text:nth-child(2) {
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
}
|
}
|
||||||
@@ -105,13 +128,16 @@ button::after {
|
|||||||
transform: translateY(20px);
|
transform: translateY(20px);
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
30% {
|
30% {
|
||||||
transform: translateY(0);
|
transform: translateY(0);
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
80% {
|
80% {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
100% {
|
100% {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
@@ -126,6 +152,7 @@ button::after {
|
|||||||
transform: translateY(0);
|
transform: translateY(0);
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
to {
|
to {
|
||||||
transform: translateY(20px);
|
transform: translateY(20px);
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
@@ -141,6 +168,7 @@ button::after {
|
|||||||
transform: scale(0);
|
transform: scale(0);
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
to {
|
to {
|
||||||
transform: scale(1);
|
transform: scale(1);
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
@@ -157,6 +185,7 @@ button::after {
|
|||||||
transform: scale(1);
|
transform: scale(1);
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
to {
|
to {
|
||||||
transform: scale(0);
|
transform: scale(0);
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
@@ -172,6 +201,7 @@ button::after {
|
|||||||
from {
|
from {
|
||||||
transform: rotate(0deg);
|
transform: rotate(0deg);
|
||||||
}
|
}
|
||||||
|
|
||||||
to {
|
to {
|
||||||
transform: rotate(360deg);
|
transform: rotate(360deg);
|
||||||
}
|
}
|
||||||
@@ -181,6 +211,7 @@ button::after {
|
|||||||
from {
|
from {
|
||||||
transform: scale(2);
|
transform: scale(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
to {
|
to {
|
||||||
transform: scale(1);
|
transform: scale(1);
|
||||||
}
|
}
|
||||||
@@ -212,6 +243,7 @@ button::after {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.user-row {
|
.user-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -220,6 +252,7 @@ button::after {
|
|||||||
padding-top: 7px;
|
padding-top: 7px;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.half-time-tip {
|
.half-time-tip {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -227,28 +260,31 @@ button::after {
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.half-time-tip>text:last-child {
|
.half-time-tip>text:last-child {
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
color: #fff9;
|
color: #fff9;
|
||||||
}
|
}
|
||||||
|
|
||||||
.see-more {
|
.see-more {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
margin-top: 20rpx;
|
margin-top: 20rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.see-more>text {
|
.see-more>text {
|
||||||
color: #39a8ff;
|
color: #39a8ff;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.see-more>image {
|
.see-more>image {
|
||||||
width: 15px;
|
width: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@font-face {
|
@font-face {
|
||||||
font-family: "DINCondensed";
|
font-family: "DINCondensed";
|
||||||
src: url("https://static.shelingxingqiu.com/font/DIN-Condensed-Bold-2.ttf")
|
src: url("https://static.shelingxingqiu.com/font/DIN-Condensed-Bold-2.ttf") format("truetype");
|
||||||
format("truetype");
|
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
font-display: swap;
|
font-display: swap;
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ try {
|
|||||||
|
|
||||||
switch (envVersion) {
|
switch (envVersion) {
|
||||||
case "develop": // 开发版
|
case "develop": // 开发版
|
||||||
// BASE_URL = "http://192.168.1.30:8000/api/shoot";
|
BASE_URL = "http://localhost:8000/api/shoot";
|
||||||
BASE_URL = "https://apitest.shelingxingqiu.com/api/shoot";
|
// BASE_URL = "https://apitest.shelingxingqiu.com/api/shoot";
|
||||||
break;
|
break;
|
||||||
case "trial": // 体验版
|
case "trial": // 体验版
|
||||||
BASE_URL = "https://apitest.shelingxingqiu.com/api/shoot";
|
BASE_URL = "https://apitest.shelingxingqiu.com/api/shoot";
|
||||||
|
|||||||
@@ -40,25 +40,25 @@ export const audioFils = {
|
|||||||
未上靶:
|
未上靶:
|
||||||
"https://static.shelingxingqiu.com/attachment/2025-11-12/de6n45o3tsm1v4unam.mp3",
|
"https://static.shelingxingqiu.com/attachment/2025-11-12/de6n45o3tsm1v4unam.mp3",
|
||||||
"1环":
|
"1环":
|
||||||
"https://static.shelingxingqiu.com/attachment/2025-09-17/dcutxin1aq7gxjih5l.mp3",
|
"https://static.shelingxingqiu.com/shootaudio/1%E7%8E%AF.mp3",
|
||||||
"2环":
|
"2环":
|
||||||
"https://static.shelingxingqiu.com/attachment/2025-09-17/dcutxin64tdgx2s4at.mp3",
|
"https://static.shelingxingqiu.com/shootaudio/2%E7%8E%AF.mp3",
|
||||||
"3环":
|
"3环":
|
||||||
"https://static.shelingxingqiu.com/attachment/2025-09-17/dcutxinlmf87vt8z65.mp3",
|
"https://static.shelingxingqiu.com/shootaudio/3%E7%8E%AF.mp3",
|
||||||
"4环":
|
"4环":
|
||||||
"https://static.shelingxingqiu.com/attachment/2025-09-17/dcutxinniv97sx0q9u.mp3",
|
"https://static.shelingxingqiu.com/shootaudio/4%E7%8E%AF.mp3",
|
||||||
"5环":
|
"5环":
|
||||||
"https://static.shelingxingqiu.com/attachment/2025-09-17/dcutxin7j01kknpb7k.mp3",
|
"https://static.shelingxingqiu.com/shootaudio/5%E7%8E%AF.mp3",
|
||||||
"6环":
|
"6环":
|
||||||
"https://static.shelingxingqiu.com/attachment/2025-09-17/dcutxin4syy1015rtq.mp3",
|
"https://static.shelingxingqiu.com/shootaudio/6%E7%8E%AF.mp3",
|
||||||
"7环":
|
"7环":
|
||||||
"https://static.shelingxingqiu.com/attachment/2025-09-17/dcutxin3iz3dvmjdai.mp3",
|
"https://static.shelingxingqiu.com/shootaudio/7%E7%8E%AF.mp3",
|
||||||
"8环":
|
"8环":
|
||||||
"https://static.shelingxingqiu.com/attachment/2025-09-17/dcutxinnjd42lhpfiw.mp3",
|
"https://static.shelingxingqiu.com/shootaudio/8%E7%8E%AF.mp3",
|
||||||
"9环":
|
"9环":
|
||||||
"https://static.shelingxingqiu.com/attachment/2025-09-17/dcutxin69nj1xh7yfz.mp3",
|
"https://static.shelingxingqiu.com/shootaudio/9%E7%8E%AF.mp3",
|
||||||
"10环":
|
"10环":
|
||||||
"https://static.shelingxingqiu.com/attachment/2025-09-17/dcutxinnvsx0tt7ksa.mp3",
|
"https://static.shelingxingqiu.com/shootaudio/10%E7%8E%AF.mp3",
|
||||||
X环: "https://static.shelingxingqiu.com/attachment/2026-02-09/dga8puwekpe2gmtbu4.mp3",
|
X环: "https://static.shelingxingqiu.com/attachment/2026-02-09/dga8puwekpe2gmtbu4.mp3",
|
||||||
向上调整:
|
向上调整:
|
||||||
"https://static.shelingxingqiu.com/attachment/2025-11-12/de6ellf5pfvu3l8dhr.mp3",
|
"https://static.shelingxingqiu.com/attachment/2025-11-12/de6ellf5pfvu3l8dhr.mp3",
|
||||||
@@ -80,6 +80,10 @@ export const audioFils = {
|
|||||||
"https://static.shelingxingqiu.com/attachment/2025-11-13/de7kzzllq0futwynso.mp3",
|
"https://static.shelingxingqiu.com/attachment/2025-11-13/de7kzzllq0futwynso.mp3",
|
||||||
练习开始:
|
练习开始:
|
||||||
"https://static.shelingxingqiu.com/attachment/2025-11-14/de88w0lmmt43nnfmoi.mp3",
|
"https://static.shelingxingqiu.com/attachment/2025-11-14/de88w0lmmt43nnfmoi.mp3",
|
||||||
|
射箭声音:
|
||||||
|
"https://static.shelingxingqiu.com/shootaudio/%E6%9C%AA%E4%B8%8A%E9%9D%B6.mp3",
|
||||||
|
命中:
|
||||||
|
"https://static.shelingxingqiu.com/shootaudio/%E5%91%BD%E4%B8%AD.mp3"
|
||||||
};
|
};
|
||||||
|
|
||||||
// 版本控制日志函数
|
// 版本控制日志函数
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ function createWebSocket(token, onMessage) {
|
|||||||
|
|
||||||
switch (envVersion) {
|
switch (envVersion) {
|
||||||
case "develop": // 开发版
|
case "develop": // 开发版
|
||||||
// url = "ws://192.168.1.30:8000/socket";
|
url = "ws://localhost:8000/socket";
|
||||||
url = "wss://apitest.shelingxingqiu.com/socket";
|
// url = "wss://apitest.shelingxingqiu.com/socket";
|
||||||
break;
|
break;
|
||||||
case "trial": // 体验版
|
case "trial": // 体验版
|
||||||
url = "wss://apitest.shelingxingqiu.com/socket";
|
url = "wss://apitest.shelingxingqiu.com/socket";
|
||||||
|
|||||||
Reference in New Issue
Block a user