mirror of
https://wget.la/https://github.com/leookun/cursor-byok
synced 2026-08-21 05:26:59 +08:00
feat(config): 支持完整配置导入导出
This commit is contained in:
@@ -3,11 +3,13 @@ import { Events } from "@wailsio/runtime";
|
||||
import dayjs from "dayjs";
|
||||
import {
|
||||
checkForUpdates,
|
||||
exportUserConfig as exportUserConfigFile,
|
||||
getAppVersion,
|
||||
getHomeMetricsSummary,
|
||||
getModelAdapterTestResults,
|
||||
installReadyUpdate,
|
||||
getProxyState,
|
||||
importUserConfig as importUserConfigFile,
|
||||
openConfigWindow as openConfig,
|
||||
loadUserConfig,
|
||||
openLogsDirectory,
|
||||
@@ -607,6 +609,9 @@ async function loadPersistedUserConfig() {
|
||||
}
|
||||
|
||||
async function persistConfigPayload(config, { modelAdaptersOnly = false } = {}) {
|
||||
if (appState.configSaving) {
|
||||
return { ok: false, error: "已有配置操作正在进行,请稍后再试" };
|
||||
}
|
||||
const payload = buildConfigPayload(config);
|
||||
const validationError = validateModelAdapters(payload.modelAdapters);
|
||||
if (validationError) {
|
||||
@@ -1119,6 +1124,27 @@ export async function persistUserConfig() {
|
||||
});
|
||||
}
|
||||
|
||||
export async function exportUserConfigToFile(path) {
|
||||
return exportUserConfigFile(path);
|
||||
}
|
||||
|
||||
export async function importUserConfigFromFile(path) {
|
||||
if (appState.serviceRunning || appState.backendRunning || appState.proxyRunning) {
|
||||
throw new Error("服务运行中不能导入完整配置,请先停止服务");
|
||||
}
|
||||
if (appState.configSaving) {
|
||||
throw new Error("已有配置操作正在进行,请稍后再试");
|
||||
}
|
||||
appState.configSaving = true;
|
||||
try {
|
||||
const imported = normalizeConfig(await importUserConfigFile(path));
|
||||
applyConfigToState(imported);
|
||||
return imported;
|
||||
} finally {
|
||||
appState.configSaving = false;
|
||||
}
|
||||
}
|
||||
|
||||
export async function saveIncludeCacheWriteInHitRate(value) {
|
||||
const currentConfig = await loadPersistedUserConfig();
|
||||
const previousValue = appState.includeCacheWriteInHitRate;
|
||||
|
||||
Reference in New Issue
Block a user