fix:新增分享房间图片&2v2+3v3+大乱斗只有管理员房间才展示踢人按钮

This commit is contained in:
2026-05-14 10:05:50 +08:00
parent 34a32b108c
commit 1c75c06eaa
4 changed files with 33 additions and 8 deletions

View File

@@ -6,8 +6,8 @@ try {
switch (envVersion) {
case "develop": // 开发版
BASE_URL = "http://192.168.1.30:8000/api/shoot";
// BASE_URL = "https://apitest.shelingxingqiu.com/api/shoot";
// BASE_URL = "http://192.168.1.30:8000/api/shoot";
BASE_URL = "https://apitest.shelingxingqiu.com/api/shoot";
break;
case "trial": // 体验版
BASE_URL = "https://apitest.shelingxingqiu.com/api/shoot";

View File

@@ -14,6 +14,11 @@ const props = defineProps({
type: Function,
default: () => {},
},
/** 当前用户是否为房主;仅房主可见踢人按钮 */
isOwner: {
type: Boolean,
default: false,
},
});
const seats = new Array(props.total).fill(1);
</script>
@@ -45,8 +50,9 @@ const seats = new Array(props.total).fill(1);
mode="widthFix"
class="player-bg"
/> -->
<!-- 仅房主isOwner=true且非空座位时展示踢人按钮 -->
<button
v-if="index > 0 && players[index]"
v-if="index > 0 && players[index] && isOwner"
hover-class="none"
class="remove-player"
@click="() => removePlayer(players[index])"

View File

@@ -65,6 +65,7 @@ const goBattle = ref(false);
async function refreshRoomData() {
if (!roomNumber.value) return;
const result = await getRoomAPI(roomNumber.value);
console.log(result);
if (result.started) return;
room.value = result;
// 加入者通过 API 返回的 targetType 字段同步靶纸尺寸,并持久化到本地缓存
@@ -276,11 +277,27 @@ const shareTitle = computed(() => {
return '星球论箭,来一决高下敢否?';
});
/**
* 根据对战类型动态返回分享封面图路径
* battleType === 2多人乱斗→ melee_share.jpg
* 其余(好友约战 / 组队对战)→ contest_share.jpg
*
* 网络图片:
* https://static.shelingxingqiu.com/shootmini/static/share/melee_share.jpg
* https://static.shelingxingqiu.com/shootmini/static/share/contest_share.jpg
*/
const shareImage = computed(() => {
if (room.value.battleType === 2) {
return 'https://static.shelingxingqiu.com/shootmini/static/share/melee_share.jpg';
}
return 'https://static.shelingxingqiu.com/shootmini/static/share/contest_share.jpg';
});
onShareAppMessage(() => {
return {
title: shareTitle.value,
path: "/pages/friend-battle?roomID=" + roomNumber.value,
imageUrl: "",
imageUrl: shareImage.value,
};
});
@@ -385,7 +402,8 @@ onBeforeUnmount(() => {
<view v-for="(item, index) in players" :key="index">
<Avatar v-if="item.id" :src="item.avatar" :size="36" />
<text v-if="owner.id === item.id">管理员</text>
<button v-if="owner.id !== item.id && item.id" hover-class="none" class="remove-player"
<!-- 仅房主可见踢人按钮且不能踢自己 -->
<button v-if="owner.id !== item.id && item.id && owner.id === user.id" hover-class="none" class="remove-player"
@click="() => removePlayer(item)" :style="{ top: '-10rpx', right: '-10rpx' }">
<image src="../static/close-white.png" mode="widthFix" />
</button>
@@ -425,8 +443,9 @@ onBeforeUnmount(() => {
</view>
</view>
</block>
<!-- isOwner当前用户是房主时才展示踢人按钮 -->
<PlayerSeats v-if="room.battleType === 2" :total="room.count || 10" :players="players"
:removePlayer="removePlayer" />
:removePlayer="removePlayer" :isOwner="owner.id === user.id" />
<view>
<SButton :disabled="!canClick" :onClick="getReady">
{{

View File

@@ -14,8 +14,8 @@ function createWebSocket(token, onMessage) {
switch (envVersion) {
case "develop": // 开发版
url = "ws://192.168.1.30:8000/socket";
// url = "wss://apitest.shelingxingqiu.com/socket";
// url = "ws://192.168.1.30:8000/socket";
url = "wss://apitest.shelingxingqiu.com/socket";
break;
case "trial": // 体验版
url = "wss://apitest.shelingxingqiu.com/socket";