From 379b08f691859d4e7839a2957d61c821110e8a9d Mon Sep 17 00:00:00 2001 From: CalciumIon <1808837298@qq.com> Date: Wed, 11 Dec 2024 21:25:50 +0800 Subject: [PATCH] feat: Update user group handling in Playground component - Enhanced the Playground component to prioritize the user's group by moving it to the front of the local group options if it exists. - Improved user experience by ensuring the default group selection reflects the user's current group, if available. --- web/src/pages/Playground/Playground.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/web/src/pages/Playground/Playground.js b/web/src/pages/Playground/Playground.js index 57bf11c1..00a2eded 100644 --- a/web/src/pages/Playground/Playground.js +++ b/web/src/pages/Playground/Playground.js @@ -103,11 +103,16 @@ const Playground = () => { // handleInputChange('group', localGroupOptions[0].value); if (localGroupOptions.length > 0) { - // set default group at first - localGroupOptions.unshift({ - label: '用户分组', - value: '', - }); + // set user group at first + if (userState.user && userState.user.group) { + let userGroup = userState.user.group; + // Find and move user's group to the front + const userGroupIndex = localGroupOptions.findIndex(g => g.value === userGroup); + if (userGroupIndex > -1) { + const userGroupOption = localGroupOptions.splice(userGroupIndex, 1)[0]; + localGroupOptions.unshift(userGroupOption); + } + } } else { localGroupOptions = [{ label: '用户分组',