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 插件的强制更新,力度大
-