diff --git a/server/assets/fonts/SourceHanSerifCN-VF.woff2 b/resources/font/FZB.ttf similarity index 55% rename from server/assets/fonts/SourceHanSerifCN-VF.woff2 rename to resources/font/FZB.ttf index 87e20c4..ddf1bdd 100644 Binary files a/server/assets/fonts/SourceHanSerifCN-VF.woff2 and b/resources/font/FZB.ttf differ diff --git a/resources/font/PermanentMarker.ttf b/resources/font/PermanentMarker.ttf deleted file mode 100644 index 6541e9d..0000000 Binary files a/resources/font/PermanentMarker.ttf and /dev/null differ diff --git a/server/app/r/api/commit/route.js b/server/app/r/api/commit/route.js new file mode 100644 index 0000000..4860c3e --- /dev/null +++ b/server/app/r/api/commit/route.js @@ -0,0 +1,30 @@ +async function getLatestCommit(platform = "github") { + // 构建 API URL + const baseUrl = + platform === "github" + ? `https://api.github.com/repos/zhiyu1998/rconsole-plugin/commits` + : `https://gitee.com/api/v5/repos/kyrzy0416/rconsole-plugin/commits`; + + try { + const response = await fetch(baseUrl); + if (!response.ok) throw new Error("获取提交信息失败"); + + const commits = await response.json(); + const latestCommit = commits[0]; // 最新提交 + const { sha, commit, html_url } = latestCommit; + + return { sha, author: commit.author.name, message: commit.message, url: html_url }; + } catch (error) { + console.error("无法获取最新的提交:", error.message); + return null; + } +} + +export async function GET(req, res) { + const latestCommit = await getLatestCommit(); + + return new Response(JSON.stringify(latestCommit), { + status: 200, + headers: { 'Content-Type': 'application/json' }, + }); +} diff --git a/server/app/r/api/version/route.js b/server/app/r/api/version/route.js new file mode 100644 index 0000000..de810b7 --- /dev/null +++ b/server/app/r/api/version/route.js @@ -0,0 +1,43 @@ +async function getLatestTag() { + // GitHub 和 Gitee 的 API URL + const githubUrl = `https://api.github.com/repos/zhiyu1998/rconsole-plugin/tags`; + const giteeUrl = `https://gitee.com/api/v5/repos/kyrzy0416/rconsole-plugin/tags`; + + // 定义 fetch 请求 + const fetchGitHub = fetch(githubUrl).then(async (response) => { + if (!response.ok) throw new Error("GitHub请求失败"); + const data = await response.json(); + return { source: "GitHub", tag: data }; + }); + + const fetchGitee = fetch(giteeUrl).then(async (response) => { + if (!response.ok) throw new Error("Gitee请求失败"); + const data = await response.json(); + return { source: "Gitee", tag: data }; + }); + + // 使用 Promise.race 竞速 + try { + return await Promise.race([fetchGitHub, fetchGitee]); + } catch (error) { + console.error("无法获取最新的标签:", error.message); + return null; + } +} + +export async function GET(req, res) { + const tags = await getLatestTag(); + console.log(tags); + + let latestTag; + if (tags.source === "Gitee") { + latestTag = tags.tag[tags.length - 1]; + } + latestTag = tags.tag[0]; + console.log(latestTag); + + return new Response(JSON.stringify(latestTag), { + status: 200, + headers: { 'Content-Type': 'application/json' }, + }); +} diff --git a/server/assets/fonts/FiraCode-VF.woff2 b/server/assets/fonts/FiraCode-VF.woff2 deleted file mode 100644 index e755a9d..0000000 Binary files a/server/assets/fonts/FiraCode-VF.woff2 and /dev/null differ diff --git a/server/components/home/bot-config.jsx b/server/components/home/bot-config.jsx index 5622e5d..a8a8058 100644 --- a/server/components/home/bot-config.jsx +++ b/server/components/home/bot-config.jsx @@ -1,32 +1,46 @@ +import { useEffect, useState } from "react"; +import { GIT_COMMIT_URL, GIT_VERSION_URL } from "../../constants/api.js"; + export function BotConfig() { + + const [version, setVersion] = useState("v0.0.0"); + + const [commit, setCommit] = useState(null); + + useEffect(() => { + fetch(GIT_VERSION_URL).then(response => response.json()).then(data => setVersion(data.name)); + fetch(GIT_COMMIT_URL).then(response => response.json()).then(data => setCommit(data)); + }, []); + return (
-

🔥快捷更新

+

🔥更新看板

-

检查更新

-

当前最新版本为:v0.0.0

+

最新版本

+

当前最新版本为:{ version }

+
+ +
+
+
+

手动更新

+

R 插件的自动选择更新 / 强制更新

-

非强制更新

-

R 插件的非强制更新,力度小

+

最近更新

+ [{ commit?.author }]{ commit?.message }
- -
-
-
-

强制更新

-

R 插件的强制更新,力度大

-
-
- ) + ); } diff --git a/server/components/home/bot-network.jsx b/server/components/home/bot-network.jsx index 65b7fe9..5d07ae0 100644 --- a/server/components/home/bot-network.jsx +++ b/server/components/home/bot-network.jsx @@ -7,28 +7,28 @@ const TESTING_LINKS = [ name: "bilibili", url: "https://bilibili.com/", icon: ( - + ) }, { name: "Github", url: "https://github.com/", icon: ( - + ) }, { name: "YouTube", url: "https://youtube.com/", icon: ( - + ) }, { name: "Tiktok", url: "https://tiktok.com/", icon: ( - + ) }, // ... 其他链接配置类似 diff --git a/server/constants/api.js b/server/constants/api.js index c9d2595..be7f14a 100644 --- a/server/constants/api.js +++ b/server/constants/api.js @@ -5,3 +5,7 @@ export const SYSTEM_BASE_URL = `${BASE_URL}/system`; export const NETWORK_BASE_URL = `${BASE_URL}/network?url=`; export const BOT_INFO_URL = `${ BASE_URL }/bot`; + +export const GIT_VERSION_URL = `${ BASE_URL }/version`; + +export const GIT_COMMIT_URL = `${ BASE_URL }/commit`; diff --git a/server/styles/global.css b/server/styles/global.css index d250bfb..1f09233 100644 --- a/server/styles/global.css +++ b/server/styles/global.css @@ -4,13 +4,17 @@ /** 代码字体 */ @font-face { - font-family: "FiraCode"; - src: url("../assets/fonts/FiraCode-VF.woff2"); + font-family: "FZB"; + src: url("../../resources/font/FZB.ttf"); } -/** 正文字体 */ -@font-face { - font-family: "SourceHanSerifCN"; - src: local("SourceHanSerifCN"), url("../assets/fonts/SourceHanSerifCN-VF.woff2"); + +* { + margin: 0; + font-family: "FZB", serif; + box-sizing: border-box; + -webkit-user-select: none; + -moz-user-select: none; + user-select: none; } /* 自定义滚动条 */