修复PHP两个bug:1.land_api.php玩家端token验证兼容POST(changeVisitorRole等POST请求不再误报需要登录);2.player.php成员权限toggle检测逻辑修正(isCustom原本查span但自定义文字在div里,导致永远走无自定义分支只能给不能撤)

This commit is contained in:
ypsdf1
2026-07-10 22:51:04 +08:00
parent b67480d073
commit a28083f4ca
2 changed files with 10 additions and 5 deletions
+2 -2
View File
@@ -133,8 +133,8 @@ try {
$isAdmin = true; $isAdmin = true;
} }
} elseif (in_array($action, $playerActions) || in_array($action, $playerPermActions) || in_array($action, $memberPermActions) || in_array($action, $playerFieldActions)) { } elseif (in_array($action, $playerActions) || in_array($action, $playerPermActions) || in_array($action, $memberPermActions) || in_array($action, $playerFieldActions)) {
// 玩家端:需要token // 玩家端:需要token(兼容 GET 和 POST)
$token = $_GET['token'] ?? ''; $token = $_GET['token'] ?? $_POST['token'] ?? '';
if (empty($token)) { if (empty($token)) {
echo json_encode(['success' => false, 'error' => '需要登录', 'needLogin' => true]); echo json_encode(['success' => false, 'error' => '需要登录', 'needLogin' => true]);
exit; exit;
+8 -3
View File
@@ -3483,9 +3483,14 @@ async function toggleMemberPerm(landName, targetPlayer, permKey, el) {
body.set('perm', permKey); body.set('perm', permKey);
// 从元素中获取当前状态 // 从元素中获取当前状态
const statusSpan = el.querySelector('span:last-child'); // 状态文字在 flex div 的最后一个 span 里(✓ 启用 / ✗ 禁用 / 默认)
const isCustom = statusSpan.textContent.includes('自定义'); const spans = el.querySelectorAll('span');
const isEnabled = statusSpan.textContent.includes('启用'); const statusSpan = spans[spans.length - 1]; // 第二个 span 是状态
const statusText = statusSpan ? statusSpan.textContent : '';
const isEnabled = statusText.includes('启用');
// "★ 自定义" 在第二个 div 里
const divs = el.querySelectorAll('div');
const isCustom = divs.length > 1 && divs[divs.length - 1].textContent.includes('自定义');
if (isCustom) { if (isCustom) {
// 已有自定义:切换启用/禁用 // 已有自定义:切换启用/禁用