mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-13 00:10:27 +00:00
Introduces backend and frontend logic to fetch the latest NapCat version tag from multiple sources, exposes a new API endpoint, and adds a UI prompt to notify users of new versions with an update button. Also includes minor code style improvements in dialog context.
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
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 { getLatestTag } from 'napcat-common/src/helper';
|
|
|
|
export const GetNapCatVersion: RequestHandler = (_, res) => {
|
|
const data = WebUiDataRuntime.GetNapCatVersion();
|
|
sendSuccess(res, { version: data });
|
|
};
|
|
|
|
export const getLatestTagHandler: RequestHandler = async (_, res) => {
|
|
try {
|
|
const latestTag = await getLatestTag();
|
|
sendSuccess(res, latestTag);
|
|
} catch (error) {
|
|
res.status(500).json({ error: 'Failed to fetch latest tag' });
|
|
}
|
|
};
|
|
|
|
export const QQVersionHandler: RequestHandler = (_, res) => {
|
|
const data = WebUiDataRuntime.getQQVersion();
|
|
sendSuccess(res, data);
|
|
};
|
|
|
|
export const GetThemeConfigHandler: RequestHandler = async (_, res) => {
|
|
const data = await WebUiConfig.GetTheme();
|
|
sendSuccess(res, data);
|
|
};
|
|
|
|
export const SetThemeConfigHandler: RequestHandler = async (req, res) => {
|
|
const { theme } = req.body;
|
|
await WebUiConfig.UpdateTheme(theme);
|
|
sendSuccess(res, { message: '更新成功' });
|
|
};
|