浏览代码

enh: 'notification' event type

Timothy Jaeryang Baek 3 月之前
父节点
当前提交
ed7db1dd41
共有 1 个文件被更改,包括 13 次插入0 次删除
  1. 13 0
      src/lib/components/chat/Chat.svelte

+ 13 - 0
src/lib/components/chat/Chat.svelte

@@ -321,6 +321,19 @@
 					eventConfirmationMessage = data.message;
 					eventConfirmationInputPlaceholder = data.placeholder;
 					eventConfirmationInputValue = data?.value ?? '';
+				} else if (type === 'notification') {
+					const toastType = data?.type ?? 'info';
+					const toastContent = data?.content ?? '';
+
+					if (toastType === 'success') {
+						toast.success(toastContent);
+					} else if (toastType === 'error') {
+						toast.error(toastContent);
+					} else if (toastType === 'warning') {
+						toast.warning(toastContent);
+					} else {
+						toast.info(toastContent);
+					}
 				} else {
 					console.log('Unknown message type', data);
 				}