tabby-ai-assistant 1.0.11 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -15,9 +15,79 @@ export class ToastService {
|
|
|
15
15
|
|
|
16
16
|
show(type: ToastMessage['type'], message: string, duration = 3000): void {
|
|
17
17
|
const id = `toast-${Date.now()}`;
|
|
18
|
+
|
|
19
|
+
// 确保容器存在
|
|
20
|
+
let container = document.getElementById('ai-toast-container');
|
|
21
|
+
if (!container) {
|
|
22
|
+
container = document.createElement('div');
|
|
23
|
+
container.id = 'ai-toast-container';
|
|
24
|
+
container.className = 'ai-toast-container';
|
|
25
|
+
container.style.cssText = `
|
|
26
|
+
position: fixed;
|
|
27
|
+
bottom: 20px;
|
|
28
|
+
right: 20px;
|
|
29
|
+
z-index: 99999;
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
gap: 10px;
|
|
33
|
+
pointer-events: none;
|
|
34
|
+
`;
|
|
35
|
+
document.body.appendChild(container);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// 创建 Toast 元素
|
|
39
|
+
const toast = document.createElement('div');
|
|
40
|
+
toast.id = id;
|
|
41
|
+
toast.className = `ai-toast ai-toast-${type}`;
|
|
42
|
+
toast.style.cssText = `
|
|
43
|
+
padding: 12px 16px;
|
|
44
|
+
border-radius: 8px;
|
|
45
|
+
color: white;
|
|
46
|
+
font-size: 14px;
|
|
47
|
+
display: flex;
|
|
48
|
+
align-items: center;
|
|
49
|
+
gap: 8px;
|
|
50
|
+
animation: toastSlideIn 0.3s ease;
|
|
51
|
+
cursor: pointer;
|
|
52
|
+
box-shadow: 0 4px 12px rgba(0,0,0,0.3);
|
|
53
|
+
pointer-events: auto;
|
|
54
|
+
min-width: 200px;
|
|
55
|
+
max-width: 350px;
|
|
56
|
+
${type === 'success' ? 'background: linear-gradient(135deg, #22c55e, #16a34a);' : ''}
|
|
57
|
+
${type === 'error' ? 'background: linear-gradient(135deg, #ef4444, #dc2626);' : ''}
|
|
58
|
+
${type === 'warning' ? 'background: linear-gradient(135deg, #f59e0b, #d97706);' : ''}
|
|
59
|
+
${type === 'info' ? 'background: linear-gradient(135deg, #3b82f6, #2563eb);' : ''}
|
|
60
|
+
`;
|
|
61
|
+
|
|
62
|
+
const icon = type === 'success' ? '✓' : type === 'error' ? '✗' : type === 'warning' ? '⚠' : 'ℹ';
|
|
63
|
+
toast.innerHTML = `<span style="font-size: 16px;">${icon}</span><span>${message}</span>`;
|
|
64
|
+
|
|
65
|
+
toast.onclick = () => {
|
|
66
|
+
this.removeToast(toast);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
container.appendChild(toast);
|
|
70
|
+
|
|
71
|
+
// 自动消失
|
|
72
|
+
setTimeout(() => {
|
|
73
|
+
this.removeToast(toast);
|
|
74
|
+
}, duration);
|
|
75
|
+
|
|
76
|
+
// 发射事件(兼容现有订阅)
|
|
18
77
|
this.toastSubject.next({ id, type, message, duration });
|
|
19
78
|
}
|
|
20
79
|
|
|
80
|
+
private removeToast(toast: HTMLElement): void {
|
|
81
|
+
if (toast && toast.parentNode) {
|
|
82
|
+
toast.style.animation = 'toastSlideOut 0.3s ease forwards';
|
|
83
|
+
setTimeout(() => {
|
|
84
|
+
if (toast.parentNode) {
|
|
85
|
+
toast.remove();
|
|
86
|
+
}
|
|
87
|
+
}, 300);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
21
91
|
success(message: string, duration = 3000): void {
|
|
22
92
|
this.show('success', message, duration);
|
|
23
93
|
}
|
|
@@ -438,4 +438,27 @@
|
|
|
438
438
|
.modal-backdrop {
|
|
439
439
|
background-color: rgba(0, 0, 0, 0.3) !important;
|
|
440
440
|
}
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// Toast 动画
|
|
444
|
+
@keyframes toastSlideIn {
|
|
445
|
+
from {
|
|
446
|
+
transform: translateX(100%);
|
|
447
|
+
opacity: 0;
|
|
448
|
+
}
|
|
449
|
+
to {
|
|
450
|
+
transform: translateX(0);
|
|
451
|
+
opacity: 1;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
@keyframes toastSlideOut {
|
|
456
|
+
from {
|
|
457
|
+
transform: translateX(0);
|
|
458
|
+
opacity: 1;
|
|
459
|
+
}
|
|
460
|
+
to {
|
|
461
|
+
transform: translateX(100%);
|
|
462
|
+
opacity: 0;
|
|
463
|
+
}
|
|
441
464
|
}
|