feat: split worker login device limits by type

This commit is contained in:
yml2213
2026-08-30 21:58:13 +08:00
parent ffb71f2276
commit b832279c1f
15 changed files with 537 additions and 14 deletions
@@ -662,7 +662,7 @@ export default function WorkerLoginPage() {
<Alert
showIcon
type="info"
message="验证账号密码后,可删除旧设备。所有 PC 和手机合计最多同时在线 3 台。"
message="验证账号密码后,可删除旧设备。PC 和手机分别最多同时在线 3 台。"
style={{ marginBottom: 16 }}
/>
<Table
@@ -38,6 +38,7 @@ export function WorkerProfileAccountModals({
setDevicesOpen,
devices,
maxDevices,
deviceCounts,
devicesLoading,
removeWorkerDevice,
passwordOpen,
@@ -60,6 +61,7 @@ export function WorkerProfileAccountModals({
setDevicesOpen: (open: boolean) => void
devices: WorkerSessionDevice[]
maxDevices: number
deviceCounts: { pc: number; mobile: number }
devicesLoading: boolean
removeWorkerDevice: (device: WorkerSessionDevice) => Promise<void>
passwordOpen: boolean
@@ -88,7 +90,7 @@ export function WorkerProfileAccountModals({
<Alert
showIcon
type="info"
message={`所有设备合计最多同时在线 ${maxDevices} 台,删除旧设备后才能在新设备登录。`}
message={`PC 和手机分别最多同时在线 ${maxDevices}(当前 PC ${deviceCounts.pc} 台、手机 ${deviceCounts.mobile} 台),删除对应旧设备后才能登录。`}
/>
<Table<WorkerSessionDevice>
size="small"
@@ -658,6 +658,7 @@ export default function WorkerProfilePage() {
setDevicesOpen={setDevicesOpen}
devices={devicesQuery.data?.data.items || []}
maxDevices={devicesQuery.data?.data.maxDevices || 3}
deviceCounts={devicesQuery.data?.data.deviceCounts || { pc: 0, mobile: 0 }}
devicesLoading={devicesQuery.isLoading || devicesQuery.isFetching}
removeWorkerDevice={removeWorkerDevice}
passwordOpen={passwordOpen}
+9 -5
View File
@@ -94,7 +94,7 @@ export function loginWorkerBySmsCode(payload: { phone: string; code: string }) {
}
export function fetchWorkerSessions() {
return apiGet<{ maxDevices: number; items: WorkerSessionDevice[] }>('/api/v1/worker/auth/devices')
return apiGet<WorkerDeviceLimitsResponse>('/api/v1/worker/auth/devices')
}
export function deleteWorkerSession(sessionId: string) {
@@ -102,10 +102,14 @@ export function deleteWorkerSession(sessionId: string) {
}
export function manageWorkerSessions(payload: { username: string; password: string }) {
return apiPost<{ maxDevices: number; items: WorkerSessionDevice[] }>(
'/api/v1/worker/auth/devices/manage/list',
payload,
)
return apiPost<WorkerDeviceLimitsResponse>('/api/v1/worker/auth/devices/manage/list', payload)
}
export type WorkerDeviceLimitsResponse = {
maxDevices: number
maxDevicesByType: { pc: number; mobile: number }
deviceCounts: { pc: number; mobile: number }
items: WorkerSessionDevice[]
}
export function deleteWorkerSessionWithCredentials(payload: {