mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-23 19:09:15 +00:00
fix get userlist issue
This commit is contained in:
@@ -30,18 +30,19 @@ 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
|
||||||
id: user.id,
|
const activeUsers = allUsers.map((user) => ({
|
||||||
username: user.username,
|
id: user.id,
|
||||||
displayName: user.displayName || user.username,
|
username: user.username,
|
||||||
email: user.email,
|
displayName: user.displayName || user.username,
|
||||||
role: user.role
|
email: user.email,
|
||||||
}))
|
role: user.role
|
||||||
|
}))
|
||||||
|
|
||||||
// 添加Admin选项作为第一个
|
// 添加Admin选项作为第一个
|
||||||
const usersWithAdmin = [
|
const usersWithAdmin = [
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user