@@ -16,7 +16,7 @@
|
||||
<div class="flex flex-col overflow-hidden">
|
||||
<span class="text-white">设备: {{ getDeviceTypeInfo(device.user_agent)?.type }}</span>
|
||||
<span class="font-mono text-[11px] tracking-tighter uppercase"
|
||||
>SN: {{ device?.identifier?.slice(0, 4) }}{{ device.id }}
|
||||
>SN: {{ device.device_no }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -36,6 +36,7 @@ interface Device {
|
||||
name: string
|
||||
user_agent: string
|
||||
identifier: string
|
||||
device_no: string
|
||||
type: 'mobile' | 'desktop'
|
||||
deviceId: string
|
||||
}
|
||||
@@ -65,19 +66,18 @@ interface DeviceTypeInfo {
|
||||
* @param userAgent 浏览器代理字符串
|
||||
*/
|
||||
const getDeviceTypeInfo = (userAgent: string): DeviceTypeInfo => {
|
||||
// 转换为小写以便进行不区分大小写的匹配
|
||||
const ua = userAgent.toLowerCase()
|
||||
|
||||
if (ua.includes('ipad')) {
|
||||
return { type: 'iPad', iconComponent: Tablet }
|
||||
}
|
||||
if (ua.includes('iphone') || ua.includes('ios')) {
|
||||
return { type: 'iPhone', iconComponent: Smartphone }
|
||||
}
|
||||
if (ua.includes('android')) {
|
||||
return { type: 'Android', iconComponent: Smartphone }
|
||||
}
|
||||
if (ua.includes('mac') || ua.includes('macos')) {
|
||||
if (userAgent.includes('iPhone') || ua.includes('ios')) {
|
||||
return { type: 'iPhone', iconComponent: Smartphone }
|
||||
}
|
||||
if (userAgent.includes('iPad')) {
|
||||
return { type: 'iPad', iconComponent: Tablet }
|
||||
}
|
||||
if (ua.includes('mac')) {
|
||||
return { type: 'Mac', iconComponent: Laptop }
|
||||
}
|
||||
if (ua.includes('windows')) {
|
||||
@@ -87,6 +87,6 @@ const getDeviceTypeInfo = (userAgent: string): DeviceTypeInfo => {
|
||||
return { type: 'Linux', iconComponent: Cpu }
|
||||
}
|
||||
|
||||
return { type: 'Unknown', iconComponent: HelpCircle }
|
||||
return { type: '未知设备', iconComponent: HelpCircle }
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -334,6 +334,7 @@ async function init() {
|
||||
.get('/api/v1/public/user/info')
|
||||
.then((res: any) => {
|
||||
devices.value = res.user_devices
|
||||
console.log(res.user_devices)
|
||||
const emailInfo = res.auth_methods?.find((item: any) => item.auth_type === 'email')
|
||||
if (emailInfo) {
|
||||
userSubInfo.value.email = emailInfo.auth_identifier
|
||||
|
||||
Reference in New Issue
Block a user