Add release hash script and NapCat file-hash UI
Add a new .github/scripts/publish-release-hash.mjs to compute SHA512 for Shell/Framework napcat.mjs, maintain a release.json (keep last 100 entries) and write it to a separate hash repo. Wire the script into .github/workflows/release.yml to clone NapNeko/napcat-release-hash and publish hashes on release. Backend: expose GET /base/GetNapCatFileHash to compute napcat.mjs SHA512. Frontend: add WebUIManager.GetNapCatFileHash and show a join-password snippet on About page by combining file hash and user UIN (hashed with CryptoJS); update About page links to QQ groups. Update README and localized docs to list community QQ groups. Error handling and basic logging added.
This commit is contained in:
1 parent
fbba3d5ade
commit
4c8419d5ab
13 files changed
+274
-13
No files matched your search
@@ -1,11 +1,14 @@
|
||||
import { RequestHandler } from 'express';
|
||||
import { WebUiDataRuntime } from '@/napcat-webui-backend/src/helper/Data';
|
||||
|
||||
import { sendSuccess } from '@/napcat-webui-backend/src/utils/response';
|
||||
import { WebUiConfig } from '@/napcat-webui-backend/index';
|
||||
import { sendSuccess, sendError } from '@/napcat-webui-backend/src/utils/response';
|
||||
import { WebUiConfig, webUiPathWrapper } from '@/napcat-webui-backend/index';
|
||||
import { getLatestTag, getAllTags, compareSemVer } from 'napcat-common/src/helper';
|
||||
import { getLatestActionArtifacts, getMirrorConfig } from '@/napcat-common/src/mirror';
|
||||
import { NapCatCoreWorkingEnv } from '@/napcat-webui-backend/src/types';
|
||||
import crypto from 'crypto';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
export const GetNapCatVersion: RequestHandler = (_, res) => {
|
||||
const data = WebUiDataRuntime.GetNapCatVersion();
|
||||
@@ -178,3 +181,14 @@ export const GetMirrorsHandler: RequestHandler = (_, res) => {
|
||||
const config = getMirrorConfig();
|
||||
sendSuccess(res, { mirrors: config.fileMirrors });
|
||||
};
|
||||
|
||||
export const GetNapCatFileHashHandler: RequestHandler = (_, res) => {
|
||||
try {
|
||||
const filePath = path.join(webUiPathWrapper.binaryPath, 'napcat.mjs');
|
||||
const fileBuffer = fs.readFileSync(filePath);
|
||||
const hash = crypto.createHash('sha512').update(fileBuffer).digest('hex');
|
||||
sendSuccess(res, { hash, file: 'napcat.mjs', algorithm: 'sha512' });
|
||||
} catch (error) {
|
||||
sendError(res, `无法计算 napcat.mjs 的 hash:${(error as Error).message}`);
|
||||
}
|
||||
};
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Router } from 'express';
|
||||
import { GetThemeConfigHandler, GetNapCatVersion, QQVersionHandler, SetThemeConfigHandler, getLatestTagHandler, getAllReleasesHandler, GetMirrorsHandler } from '../api/BaseInfo';
|
||||
import { GetThemeConfigHandler, GetNapCatVersion, QQVersionHandler, SetThemeConfigHandler, getLatestTagHandler, getAllReleasesHandler, GetMirrorsHandler, GetNapCatFileHashHandler } from '../api/BaseInfo';
|
||||
import { StatusRealTimeHandler } from '@/napcat-webui-backend/src/api/Status';
|
||||
import { GetProxyHandler } from '../api/Proxy';
|
||||
|
||||
@@ -14,5 +14,6 @@ router.get('/GetSysStatusRealTime', StatusRealTimeHandler);
|
||||
router.get('/proxy', GetProxyHandler);
|
||||
router.get('/Theme', GetThemeConfigHandler);
|
||||
router.post('/SetTheme', SetThemeConfigHandler);
|
||||
router.get('/GetNapCatFileHash', GetNapCatFileHashHandler);
|
||||
|
||||
export { router as BaseRouter };
|
||||
@@ -340,4 +340,11 @@ export default class WebUIManager {
|
||||
);
|
||||
return data.data;
|
||||
}
|
||||
|
||||
public static async GetNapCatFileHash () {
|
||||
const { data } = await serverRequest.get<ServerResponse<{ hash: string; file: string; algorithm: string; }>>(
|
||||
'/base/GetNapCatFileHash'
|
||||
);
|
||||
return data.data;
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,9 @@ import { Chip } from '@heroui/chip';
|
||||
import { Divider } from '@heroui/divider';
|
||||
import { Image } from '@heroui/image';
|
||||
import { Link } from '@heroui/link';
|
||||
import { Snippet } from '@heroui/snippet';
|
||||
import { Spinner } from '@heroui/spinner';
|
||||
import { Tooltip } from '@heroui/tooltip';
|
||||
import { useRequest } from 'ahooks';
|
||||
import {
|
||||
BsCodeSlash,
|
||||
@@ -16,7 +18,10 @@ import {
|
||||
} from 'react-icons/bs';
|
||||
import { IoDocument, IoRocketSharp } from 'react-icons/io5';
|
||||
|
||||
import CryptoJS from 'crypto-js';
|
||||
|
||||
import logo from '@/assets/images/logo.png';
|
||||
import QQManager from '@/controllers/qq_manager';
|
||||
import WebUIManager from '@/controllers/webui_manager';
|
||||
|
||||
function VersionInfo () {
|
||||
@@ -38,6 +43,41 @@ function VersionInfo () {
|
||||
);
|
||||
}
|
||||
|
||||
function NapCatFileHash () {
|
||||
const { data: hashData, loading: hashLoading, error: hashError } = useRequest(WebUIManager.GetNapCatFileHash);
|
||||
const { data: loginData, loading: loginLoading, error: loginError } = useRequest(QQManager.getQQLoginInfo);
|
||||
|
||||
const loading = hashLoading || loginLoading;
|
||||
const error = hashError || loginError;
|
||||
|
||||
const password = hashData && loginData?.uin
|
||||
? CryptoJS.SHA512(hashData.hash + loginData.uin).toString()
|
||||
: null;
|
||||
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center gap-2 text-sm font-medium text-default-700">
|
||||
<span>入群密码</span>
|
||||
{loading && <Spinner size="sm" color="default" />}
|
||||
</div>
|
||||
{error ? (
|
||||
<Chip color="warning" variant="flat" size="sm">无法计算:{(error as Error).message}</Chip>
|
||||
) : loading ? null : password ? (
|
||||
<Tooltip content="复制此值作为入群密码" placement="top">
|
||||
<Snippet
|
||||
size="sm"
|
||||
variant="flat"
|
||||
className="w-full text-xs"
|
||||
symbol=""
|
||||
>
|
||||
{password}
|
||||
</Snippet>
|
||||
</Tooltip>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default function AboutPage () {
|
||||
const features = [
|
||||
{
|
||||
@@ -69,8 +109,10 @@ export default function AboutPage () {
|
||||
const links = [
|
||||
{ icon: <BsGithub />, name: 'GitHub', href: 'https://github.com/NapNeko/NapCatQQ' },
|
||||
{ icon: <BsTelegram />, name: 'Telegram', href: 'https://t.me/napcatqq' },
|
||||
{ icon: <BsTencentQq />, name: 'QQ 群 1', href: 'https://qm.qq.com/q/F9cgs1N3Mc' },
|
||||
{ icon: <BsTencentQq />, name: 'QQ 群 2', href: 'https://qm.qq.com/q/hSt0u9PVn' },
|
||||
{ icon: <BsTencentQq />, name: '交流群 欢乐一家亲', href: 'https://qm.qq.com/q/VwpnklcXqo' },
|
||||
{ icon: <BsTencentQq />, name: '交流群 皇亲国戚', href: 'https://qm.qq.com/q/gq18RH7o7S' },
|
||||
{ icon: <BsTencentQq />, name: '交流群 相亲相爱一家人', href: 'https://qm.qq.com/q/XyiyGPqa42' },
|
||||
{ icon: <BsTencentQq />, name: '交流群 开心家族', href: 'https://qm.qq.com/q/E4nfkGD6oK' },
|
||||
{ icon: <IoDocument />, name: '文档', href: 'https://napcat.napneko.icu/' },
|
||||
];
|
||||
|
||||
@@ -139,7 +181,11 @@ export default function AboutPage () {
|
||||
<CardHeader className="pb-0 pt-4 px-4">
|
||||
<h2 className="text-lg font-bold">相关资源</h2>
|
||||
</CardHeader>
|
||||
<CardBody className="py-4">
|
||||
<CardBody className="py-4 space-y-4">
|
||||
<NapCatFileHash />
|
||||
<p className="text-xs text-default-400 px-1">
|
||||
复制上方密码,作为加入 QQ 群的入群密码。
|
||||
</p>
|
||||
<div className="flex flex-col gap-2">
|
||||
{links.map((link, idx) => (
|
||||
<Link
|
||||
|
||||
Reference in new issue
Block a user