fix(import connect):修改导入时提示,而不是在连接时提示

This commit is contained in:
anyanfei
2026-04-15 09:53:29 +08:00
parent b6121fe1f8
commit 47235e1390
4 changed files with 9 additions and 12 deletions

View File

@@ -1709,7 +1709,11 @@ function App() {
try {
setPendingConnectionImportPayload(null);
const importedViews = await importConnectionsPayload(raw, '');
void message.success(`成功导入 ${importedViews.length} 个连接`);
if (importedViews.some(v => !v.hasPrimaryPassword)) {
void message.warning(`成功导入 ${importedViews.length} 个连接,部分连接未包含密码,请编辑对应连接并输入密码后保存`);
} else {
void message.success(`成功导入 ${importedViews.length} 个连接`);
}
} catch (e: any) {
if (isConnectionPackagePasswordRequiredError(e)) {
setPendingConnectionImportPayload(raw);

View File

@@ -25,7 +25,7 @@ describe('connectionModalPresentation', () => {
it('maps missing saved-connection errors to a secret-specific hint', () => {
expect(normalizeConnectionSecretErrorMessage('saved connection not found: conn-1')).toBe(
'未找到当前连接对应的已保存密文,请编辑当前连接,并输入密码保存',
'未找到当前连接对应的已保存密文,请重新填写密码保存后再试',
);
});

View File

@@ -41,7 +41,7 @@ export const normalizeConnectionSecretErrorMessage = (
const lower = text.toLowerCase();
if (lower.includes('saved connection not found:')) {
return '未找到当前连接对应的已保存密文,请编辑当前连接,并输入密码保存';
return '未找到当前连接对应的已保存密文,请重新填写密码保存后再试';
}
if (lower.includes('secret store unavailable')) {
return '系统密文存储当前不可用,请检查系统钥匙串或凭据管理器后再试';

View File

@@ -38,13 +38,6 @@ func (a *App) resolveConnectionSecrets(config connection.ConnectionConfig) (conn
resolved := mergeConnectionSecretBundleIntoConfig(base, bundle)
resolved.ID = view.ID
if !connectionConfigCarriesInlineSecrets(config) && !bundle.hasAny() {
_, dailyExists, _ := repo.dailySecrets().GetConnection(view.ID)
if !dailyExists {
return resolved, fmt.Errorf("未找到当前连接对应的已保存密文,请编辑当前连接,并输入密码后保存")
}
}
return resolved, nil
}
@@ -110,9 +103,9 @@ func normalizeConnectionSecretResolutionError(config connection.ConnectionConfig
if connectionMetadataLooksEmpty(config) {
return fmt.Errorf("未找到已保存连接,可能已被删除,请刷新后重试")
}
return fmt.Errorf("未找到当前连接对应的已保存密文,请编辑当前连接,并输入密码保存")
return fmt.Errorf("未找到当前连接对应的已保存密文,请重新填写密码保存后再试")
case errors.Is(err, os.ErrNotExist):
return fmt.Errorf("未找到当前连接对应的已保存密文,请编辑当前连接,并输入密码保存")
return fmt.Errorf("未找到当前连接对应的已保存密文,请重新填写密码保存后再试")
case strings.Contains(lower, "secret store unavailable"):
return fmt.Errorf("系统密文存储当前不可用,请检查系统钥匙串或凭据管理器后再试")
default: