diff --git a/.env.example b/.env.example index f49aa59..a018ba8 100644 --- a/.env.example +++ b/.env.example @@ -14,4 +14,7 @@ NUXT_AVATAR_CACHE_TIME = 3600000 NUXT_LINKS = {"blog":"https://blog.example.com","forum":"https://forum.example.com"} NUXT_SOCIALS = {"github":{"link":"https://github.com/","icon":"fa-brands fa-github"},"bilibili":{"link":"https://www.bilibili.com/","icon":"fa-brands fa-bilibili"},"email":{"link":"mailto:example@example.com","icon":"fa-solid fa-envelope"}} -NUXT_KEYWORDS = ["main page"] \ No newline at end of file +NUXT_KEYWORDS = ["main page"] + +NUXT_IMAGE_HOSTING = false +NUXT_IMAGE_LINKS = [] \ No newline at end of file diff --git a/nuxt.config.ts b/nuxt.config.ts index 743590e..914bbfe 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -15,5 +15,7 @@ export default defineNuxtConfig({ links: {}, socials: {}, keywords: ["main page"], + imageHosting: false, + imageLinks: [], }, }); diff --git a/public/favicon.ico b/public/favicon.ico index 151f55f..a2b9b96 100644 Binary files a/public/favicon.ico and b/public/favicon.ico differ diff --git a/server/api/getRandomBackground.ts b/server/api/getRandomBackground.ts index 268967b..08068b0 100644 --- a/server/api/getRandomBackground.ts +++ b/server/api/getRandomBackground.ts @@ -1,8 +1,16 @@ import fs from "fs"; import { randomInt } from "crypto"; +const config = useRuntimeConfig(); + export default defineEventHandler((event) => { - const imgList = fs.readdirSync("public/backgrounds"); - const imgName = imgList[randomInt(imgList.length)]; - return sendRedirect(event, `/backgrounds/${imgName}`); + if (config.imageHosting) { + const imgList: string[] = config.imageLinks; + const imgLink = imgList[randomInt(imgList.length)]; + return sendRedirect(event, imgLink); + } else { + const imgList = fs.readdirSync("public/backgrounds"); + const imgName = imgList[randomInt(imgList.length)]; + return sendRedirect(event, `/backgrounds/${imgName}`); + } });