chore: bump version to 0.3.20 + metona-toast 迁移至 @metona-team 私有源
This commit is contained in:
@@ -96,12 +96,12 @@ function useConfig<T>(key: string, defaultValue: T): [T, (v: T) => void] {
|
||||
if (r && !r.success) {
|
||||
// 只有当没有后续 set 操作时才回滚,避免覆盖用户的新修改
|
||||
if (seqRef.current === seq) setValue(prev);
|
||||
import('metona-toast').then((mod) => mod.default.error(r.error ?? '配置保存失败')).catch(() => {});
|
||||
import('@metona-team/metona-toast').then((mod) => mod.default.error(r.error ?? '配置保存失败')).catch(() => {});
|
||||
}
|
||||
}).catch((err: unknown) => {
|
||||
console.error('[SettingsModal]', err);
|
||||
if (seqRef.current === seq) setValue(prev);
|
||||
import('metona-toast').then((mod) => mod.default.error('配置保存失败')).catch(() => {});
|
||||
import('@metona-team/metona-toast').then((mod) => mod.default.error('配置保存失败')).catch(() => {});
|
||||
});
|
||||
}, [key]);
|
||||
return [value, set];
|
||||
@@ -159,18 +159,18 @@ function WorkspaceSettings() {
|
||||
try {
|
||||
const integrityResult = await window.metona?.workspace?.checkDatabaseIntegrity(currentPath);
|
||||
if (!integrityResult?.success) {
|
||||
import('metona-toast').then((mod) => mod.default.error(`源数据库校验失败:${integrityResult?.error ?? '未知错误'}`)).catch(() => {});
|
||||
import('@metona-team/metona-toast').then((mod) => mod.default.error(`源数据库校验失败:${integrityResult?.error ?? '未知错误'}`)).catch(() => {});
|
||||
setApplying(false);
|
||||
return;
|
||||
}
|
||||
if (!integrityResult.ok) {
|
||||
import('metona-toast').then((mod) => mod.default.error(`源数据库损坏(${integrityResult.detail}),无法继承`)).catch(() => {});
|
||||
import('@metona-team/metona-toast').then((mod) => mod.default.error(`源数据库损坏(${integrityResult.detail}),无法继承`)).catch(() => {});
|
||||
setApplying(false);
|
||||
return;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('[SettingsModal] Database integrity check failed:', err);
|
||||
import('metona-toast').then((mod) => mod.default.error(`源数据库校验异常:${(err as Error).message}`)).catch(() => {});
|
||||
import('@metona-team/metona-toast').then((mod) => mod.default.error(`源数据库校验异常:${(err as Error).message}`)).catch(() => {});
|
||||
setApplying(false);
|
||||
return;
|
||||
}
|
||||
@@ -186,7 +186,7 @@ function WorkspaceSettings() {
|
||||
} catch (err) {
|
||||
// 用户勾选了继承文件,失败时必须告知,否则切到新空间才发现文件是空的,潜在数据丢失风险
|
||||
console.error('[SettingsModal] Inherit failed:', err);
|
||||
import('metona-toast').then((mod) => mod.default.warning(`部分文件继承失败:${(err as Error).message},请手动检查`)).catch(() => {});
|
||||
import('@metona-team/metona-toast').then((mod) => mod.default.warning(`部分文件继承失败:${(err as Error).message},请手动检查`)).catch(() => {});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ function WorkspaceSettings() {
|
||||
} catch (err) {
|
||||
console.error('[SettingsModal]', err);
|
||||
// 用户主动操作(切换工作空间)失败必须有反馈
|
||||
import('metona-toast').then((mod) => mod.default.error(`切换工作空间失败:${(err as Error).message}`)).catch(() => {});
|
||||
import('@metona-team/metona-toast').then((mod) => mod.default.error(`切换工作空间失败:${(err as Error).message}`)).catch(() => {});
|
||||
} finally {
|
||||
setApplying(false);
|
||||
}
|
||||
@@ -216,11 +216,11 @@ function WorkspaceSettings() {
|
||||
try {
|
||||
const r = await window.metona?.app?.showItemInFolder(workspacePath);
|
||||
if (r && !r.success) {
|
||||
import('metona-toast').then((mod) => mod.default.error(r.error ?? '打开文件夹失败')).catch(() => {});
|
||||
import('@metona-team/metona-toast').then((mod) => mod.default.error(r.error ?? '打开文件夹失败')).catch(() => {});
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('[SettingsModal]', err);
|
||||
import('metona-toast').then((mod) => mod.default.error('打开文件夹失败')).catch(() => {});
|
||||
import('@metona-team/metona-toast').then((mod) => mod.default.error('打开文件夹失败')).catch(() => {});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -466,14 +466,14 @@ function LLMSettings() {
|
||||
|
||||
const handleSave = async () => {
|
||||
if (hasBlockingError) {
|
||||
import('metona-toast').then((mod) => mod.default.error('请修正表单中的错误后再保存')).catch(() => {});
|
||||
import('@metona-team/metona-toast').then((mod) => mod.default.error('请修正表单中的错误后再保存')).catch(() => {});
|
||||
return;
|
||||
}
|
||||
setSaving(true);
|
||||
try {
|
||||
const setBatch = window.metona?.config?.setBatch;
|
||||
if (!setBatch) {
|
||||
import('metona-toast').then((mod) => mod.default.error('配置 API 不可用')).catch(() => {});
|
||||
import('@metona-team/metona-toast').then((mod) => mod.default.error('配置 API 不可用')).catch(() => {});
|
||||
return;
|
||||
}
|
||||
// v0.3.9: 批量保存,避免串行保存中间态触发 reloadAdapter 失败
|
||||
@@ -493,12 +493,12 @@ function LLMSettings() {
|
||||
];
|
||||
const r = await setBatch(entries);
|
||||
if (r && !r.success) {
|
||||
import('metona-toast').then((mod) => mod.default.error(r.error ?? '配置保存失败')).catch(() => {});
|
||||
import('@metona-team/metona-toast').then((mod) => mod.default.error(r.error ?? '配置保存失败')).catch(() => {});
|
||||
} else {
|
||||
import('metona-toast').then((mod) => mod.default.success('配置已保存')).catch(() => {});
|
||||
import('@metona-team/metona-toast').then((mod) => mod.default.success('配置已保存')).catch(() => {});
|
||||
}
|
||||
} catch (err) {
|
||||
import('metona-toast').then((mod) => mod.default.error(`保存失败:${(err as Error).message}`)).catch(() => {});
|
||||
import('@metona-team/metona-toast').then((mod) => mod.default.error(`保存失败:${(err as Error).message}`)).catch(() => {});
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
@@ -735,12 +735,12 @@ function ToolsSettings() {
|
||||
const r = await window.metona?.tools?.toggle(name, enabled);
|
||||
if (r && !r.success) {
|
||||
setTools((p) => p.map((t) => t.name === name ? { ...t, enabled: !enabled } : t));
|
||||
import('metona-toast').then((mod) => mod.default.error(r.error ?? '切换工具失败')).catch(() => {});
|
||||
import('@metona-team/metona-toast').then((mod) => mod.default.error(r.error ?? '切换工具失败')).catch(() => {});
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('[SettingsModal]', err);
|
||||
setTools((p) => p.map((t) => t.name === name ? { ...t, enabled: !enabled } : t));
|
||||
import('metona-toast').then((mod) => mod.default.error('切换工具失败')).catch(() => {});
|
||||
import('@metona-team/metona-toast').then((mod) => mod.default.error('切换工具失败')).catch(() => {});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -752,11 +752,11 @@ function ToolsSettings() {
|
||||
if (r.success) {
|
||||
setAutoExecList((p) => enabled ? [...p, name] : p.filter((n) => n !== name));
|
||||
} else {
|
||||
import('metona-toast').then((mod) => mod.default.error(r.error ?? '设置自动执行失败')).catch(() => {});
|
||||
import('@metona-team/metona-toast').then((mod) => mod.default.error(r.error ?? '设置自动执行失败')).catch(() => {});
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('[SettingsModal]', err);
|
||||
import('metona-toast').then((mod) => mod.default.error('设置自动执行失败')).catch(() => {});
|
||||
import('@metona-team/metona-toast').then((mod) => mod.default.error('设置自动执行失败')).catch(() => {});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -909,11 +909,11 @@ function MCPSettings() {
|
||||
if (r?.success) {
|
||||
setNewName(''); setNewCommand(''); setNewArgs(''); setShowAdd(false); loadServers();
|
||||
} else {
|
||||
import('metona-toast').then((mod) => mod.default.error(r?.error ?? '添加 MCP 服务失败')).catch(() => {});
|
||||
import('@metona-team/metona-toast').then((mod) => mod.default.error(r?.error ?? '添加 MCP 服务失败')).catch(() => {});
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('[SettingsModal]', err);
|
||||
import('metona-toast').then((mod) => mod.default.error(`添加 MCP 服务失败:${(err as Error).message}`)).catch(() => {});
|
||||
import('@metona-team/metona-toast').then((mod) => mod.default.error(`添加 MCP 服务失败:${(err as Error).message}`)).catch(() => {});
|
||||
}
|
||||
};
|
||||
const statusColors: Record<string, string> = { connected: 'success.main', connecting: 'warning.main', disconnected: 'text.secondary', error: 'error.main' };
|
||||
@@ -955,11 +955,11 @@ function MCPSettings() {
|
||||
if (r?.success) {
|
||||
loadServers();
|
||||
} else {
|
||||
import('metona-toast').then((mod) => mod.default.error(r?.error ?? '操作失败')).catch(() => {});
|
||||
import('@metona-team/metona-toast').then((mod) => mod.default.error(r?.error ?? '操作失败')).catch(() => {});
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('[SettingsModal]', err);
|
||||
import('metona-toast').then((mod) => mod.default.error(`操作失败:${(err as Error).message}`)).catch(() => {});
|
||||
import('@metona-team/metona-toast').then((mod) => mod.default.error(`操作失败:${(err as Error).message}`)).catch(() => {});
|
||||
}
|
||||
}}>{s.status === 'connected' ? '断开' : '连接'}</Button>
|
||||
{/* L-11 修复: 点击移除打开 MUI Dialog 二次确认,而非原生 confirm() */}
|
||||
@@ -1244,10 +1244,10 @@ function LogsSettings() {
|
||||
try {
|
||||
const r = await window.metona?.app?.showItemInFolder?.(logFilePath);
|
||||
if (r && !r.success) {
|
||||
import('metona-toast').then((mod) => mod.default.error(`打开失败: ${r.error ?? '未知错误'}`)).catch(() => {});
|
||||
import('@metona-team/metona-toast').then((mod) => mod.default.error(`打开失败: ${r.error ?? '未知错误'}`)).catch(() => {});
|
||||
}
|
||||
} catch (e) {
|
||||
import('metona-toast').then((mod) => mod.default.error(`打开失败: ${(e as Error).message}`)).catch(() => {});
|
||||
import('@metona-team/metona-toast').then((mod) => mod.default.error(`打开失败: ${(e as Error).message}`)).catch(() => {});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1260,7 +1260,7 @@ function LogsSettings() {
|
||||
} catch (e) {
|
||||
setCopyState('error');
|
||||
setTimeout(() => setCopyState('idle'), 1500);
|
||||
import('metona-toast').then((mod) => mod.default.error(`复制失败: ${(e as Error).message}`)).catch(() => {});
|
||||
import('@metona-team/metona-toast').then((mod) => mod.default.error(`复制失败: ${(e as Error).message}`)).catch(() => {});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1272,11 +1272,11 @@ function LogsSettings() {
|
||||
const b = new Blob([JSON.stringify(r.data, null, 2)], { type: 'application/json' });
|
||||
const a = document.createElement('a'); a.href = URL.createObjectURL(b); a.download = `metona-export-${Date.now()}.json`; a.click();
|
||||
} else {
|
||||
import('metona-toast').then((mod) => mod.default.error(`导出失败: ${r.error ?? '未知错误'}`)).catch(() => {});
|
||||
import('@metona-team/metona-toast').then((mod) => mod.default.error(`导出失败: ${r.error ?? '未知错误'}`)).catch(() => {});
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('[LogsSettings]', err);
|
||||
import('metona-toast').then((mod) => mod.default.error(`导出失败: ${(err as Error).message}`)).catch(() => {});
|
||||
import('@metona-team/metona-toast').then((mod) => mod.default.error(`导出失败: ${(err as Error).message}`)).catch(() => {});
|
||||
}
|
||||
};
|
||||
const labels: Record<string, string> = { sessions: '所有会话', memories: '所有记忆', auditLogs: '审计日志' };
|
||||
@@ -1293,7 +1293,7 @@ function LogsSettings() {
|
||||
else if (type === 'memories') r = await window.metona?.data?.clearMemories();
|
||||
else r = await window.metona?.data?.clearAuditLogs();
|
||||
if (r?.success) {
|
||||
import('metona-toast').then((mod) => mod.default.success(`${labels[type]}已清理`)).catch(() => {});
|
||||
import('@metona-team/metona-toast').then((mod) => mod.default.success(`${labels[type]}已清理`)).catch(() => {});
|
||||
// 修复: 清理会话后同步清空前端状态,无需重启应用
|
||||
if (type === 'sessions') {
|
||||
useSessionStore.getState().setSessions([]);
|
||||
@@ -1306,10 +1306,10 @@ function LogsSettings() {
|
||||
useUIStore.getState().bumpMemoryVersion();
|
||||
}
|
||||
} else {
|
||||
import('metona-toast').then((mod) => mod.default.error(`失败: ${r?.error ?? '未知错误'}`)).catch(() => {});
|
||||
import('@metona-team/metona-toast').then((mod) => mod.default.error(`失败: ${r?.error ?? '未知错误'}`)).catch(() => {});
|
||||
}
|
||||
} catch (e) {
|
||||
import('metona-toast').then((mod) => mod.default.error(`失败: ${(e as Error).message}`)).catch(() => {});
|
||||
import('@metona-team/metona-toast').then((mod) => mod.default.error(`失败: ${(e as Error).message}`)).catch(() => {});
|
||||
}
|
||||
setClearing(null);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user