This commit is contained in:
Baobhan Sith
2025-05-01 18:30:11 +08:00
parent 164cc343d7
commit 5c28ba4c76
@@ -60,13 +60,13 @@ export const useSshKeysStore = defineStore('sshKeys', () => {
sshKeys.value.push(response.data.key); sshKeys.value.push(response.data.key);
// Sort keys by name // Sort keys by name
sshKeys.value.sort((a, b) => a.name.localeCompare(b.name)); sshKeys.value.sort((a, b) => a.name.localeCompare(b.name));
uiNotificationsStore.addNotification({ message: response.data.message || 'SSH 密钥添加成功。', type: 'success' }); uiNotificationsStore.showSuccess(response.data.message || 'SSH 密钥添加成功。'); // 使用便捷方法,默认 3 秒超时
return true; return true;
} catch (err: any) { } catch (err: any) {
console.error('Failed to add SSH key:', err); console.error('Failed to add SSH key:', err);
error.value = err.response?.data?.message || err.message || '添加 SSH 密钥失败。'; error.value = err.response?.data?.message || err.message || '添加 SSH 密钥失败。';
// Ensure error.value is not null before passing // Ensure error.value is not null before passing
uiNotificationsStore.addNotification({ message: error.value ?? '未知错误', type: 'error' }); uiNotificationsStore.showError(error.value ?? '未知错误'); // 使用便捷方法,默认 5 秒超时
return false; return false;
} finally { } finally {
isLoading.value = false; isLoading.value = false;