feat: admin config subscription

This commit is contained in:
shinya
2025-08-13 22:07:28 +08:00
parent 214aee1cb4
commit 6d4846d0b1
14 changed files with 227 additions and 259 deletions

View File

@@ -60,6 +60,13 @@ export async function POST(request: NextRequest) {
}
adminConfig.ConfigFile = configFile;
if (!adminConfig.ConfigSubscribtion) {
adminConfig.ConfigSubscribtion = {
URL: '',
AutoUpdate: false,
LastCheck: '',
};
}
// 更新订阅配置
if (subscriptionUrl !== undefined) {
@@ -68,7 +75,6 @@ export async function POST(request: NextRequest) {
if (autoUpdate !== undefined) {
adminConfig.ConfigSubscribtion.AutoUpdate = autoUpdate;
}
// 更新最后检查时间 - 使用前端传递的时间或当前时间
adminConfig.ConfigSubscribtion.LastCheck = lastCheckTime || '';
adminConfig = refineConfig(adminConfig);

View File

@@ -20,9 +20,20 @@ export async function POST(request: NextRequest) {
const configContent = await response.text();
// 对 configContent 进行 base58 解码
let decodedContent;
try {
const bs58 = (await import('bs58')).default;
const decodedBytes = bs58.decode(configContent);
decodedContent = new TextDecoder().decode(decodedBytes);
} catch (decodeError) {
console.warn('Base58 解码失败,返回原始内容:', decodeError);
throw decodeError;
}
return NextResponse.json({
success: true,
configContent,
configContent: decodedContent,
message: '配置拉取成功'
});