fix get userlist issue

This commit is contained in:
Feng Yue
2025-09-02 18:40:16 +08:00
parent 7a9e4abdd5
commit 5ee98597e7
2 changed files with 27 additions and 15 deletions

View File

@@ -30,12 +30,13 @@ const router = express.Router()
router.get('/users', authenticateAdmin, async (req, res) => { router.get('/users', authenticateAdmin, async (req, res) => {
try { try {
const userService = require('../services/userService') const userService = require('../services/userService')
const allUsers = await userService.getAllUsers() const result = await userService.getAllUsers({ isActive: true, limit: 1000 }) // Get all active users
// 只返回活跃用户,并包含管理员选项 // Extract users array from the paginated result
const activeUsers = allUsers const allUsers = result.users || []
.filter((user) => user.isActive)
.map((user) => ({ // Map to the format needed for the dropdown
const activeUsers = allUsers.map((user) => ({
id: user.id, id: user.id,
username: user.username, username: user.username,
displayName: user.displayName || user.username, displayName: user.displayName || user.username,

View File

@@ -999,11 +999,22 @@ const loadUsers = async () => {
// 初始化表单数据 // 初始化表单数据
onMounted(async () => { onMounted(async () => {
try {
// 并行加载所有需要的数据 // 并行加载所有需要的数据
await Promise.all([clientsStore.loadSupportedClients(), apiKeysStore.fetchTags(), loadUsers()]) const [clients, tags] = await Promise.all([
clientsStore.loadSupportedClients(),
apiKeysStore.fetchTags(),
loadUsers()
])
supportedClients.value = clientsStore.supportedClients supportedClients.value = clients || []
availableTags.value = apiKeysStore.availableTags availableTags.value = tags || []
} catch (error) {
console.error('Error loading initial data:', error)
// Fallback to empty arrays if loading fails
supportedClients.value = []
availableTags.value = []
}
// 初始化账号数据 // 初始化账号数据
if (props.accounts) { if (props.accounts) {