mirror of
https://github.com/LiuYuYang01/ThriveX-Blog.git
synced 2026-05-23 03:42:56 +08:00
大改动
This commit is contained in:
27
src/utils/index.ts
Normal file
27
src/utils/index.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
// 生成随机数
|
||||
export function getRandom(min: number, max: number): number {
|
||||
return Math.floor(Math.random() * (max - min + 1) + min);
|
||||
}
|
||||
|
||||
// 随机预览图
|
||||
export function randomImage() {
|
||||
const covers = [
|
||||
"https://bu.dusays.com/2023/11/10/654e2da1d80f8.jpg",
|
||||
"https://bu.dusays.com/2023/11/10/654e2d719d31c.jpg",
|
||||
"https://bu.dusays.com/2023/11/10/654e2cf92cd45.jpg",
|
||||
"https://bu.dusays.com/2023/11/10/654e2cf6055b0.jpg",
|
||||
"https://bu.dusays.com/2023/11/10/654e2db0889fe.jpg",
|
||||
"https://bu.dusays.com/2023/11/10/654e2d50015a9.jpg",
|
||||
"https://bu.dusays.com/2023/11/05/65473848ed863.jpg",
|
||||
"https://bu.dusays.com/2023/11/10/654e2c870e280.jpg",
|
||||
"https://bu.dusays.com/2023/11/10/654e2c717eb73.jpg",
|
||||
"https://bu.dusays.com/2023/11/10/654e2c5d75d5b.jpg",
|
||||
"https://bu.dusays.com/2023/11/10/654e2da27801e.jpg",
|
||||
"https://bu.dusays.com/2023/11/10/654e2d2a67517.jpg",
|
||||
"https://bu.dusays.com/2023/11/10/654e2cf47f17a.jpg",
|
||||
"https://bu.dusays.com/2023/11/05/65473848ed863.jpg"
|
||||
];
|
||||
|
||||
|
||||
return covers[getRandom(0, covers.length - 1)];
|
||||
}
|
||||
6
src/utils/request.ts
Normal file
6
src/utils/request.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
const url = "http://localhost:9999/api"
|
||||
|
||||
export default async (api: string) => {
|
||||
const res = await fetch(`${url}${api}`)
|
||||
return res.json()
|
||||
}
|
||||
Reference in New Issue
Block a user