部分重型模块的原子化拆解

This commit is contained in:
2026-07-23 20:46:16 +08:00
parent 2afff129b9
commit 5fa1b99c5d
12 changed files with 1688 additions and 875 deletions
+35
View File
@@ -0,0 +1,35 @@
// modules/config.js
import { apiFetch } from './api.js';
const defaultConfig = {
serverAddr: 'frp.whitetop.xyz',
serverPort: 9358,
token: '',
logLevel: 'info',
logMaxDays: 3,
tcpMux: true,
tcpMuxKeepalive: 30,
heartbeatInterval: 15,
heartbeatTimeout: 70,
poolCount: 8,
};
export async function loadConfig() {
try {
const data = await apiFetch('/config');
if (data.code === 0) {
return { ...defaultConfig, ...data.data };
}
} catch (e) {
console.warn('加载配置失败', e);
}
return { ...defaultConfig };
}
export async function saveConfig(config) {
const data = await apiFetch('/config', {
method: 'PUT',
body: JSON.stringify(config),
});
return data;
}