mirror of
https://github.com/snowykami/neo-blog.git
synced 2025-09-03 15:56:22 +00:00
✨ feat: 添加设备检测功能,支持判断用户是否使用移动设备
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@ -10,5 +10,5 @@ configs/
|
||||
data/
|
||||
|
||||
# dist
|
||||
server
|
||||
./server
|
||||
main
|
7
web/src/utils/server/device.ts
Normal file
7
web/src/utils/server/device.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import { headers } from "next/headers";
|
||||
|
||||
export async function isMobileByUA() {
|
||||
const headerList = await headers();
|
||||
const ua = headerList.get("user-agent") || "";
|
||||
return /mobile|android|iphone|ipad|phone/i.test(ua);
|
||||
}
|
Reference in New Issue
Block a user