This commit is contained in:
@ -1,6 +1,11 @@
|
||||
import {ref} from "vue";
|
||||
import {type Ref} from "vue";
|
||||
enum color {Red, Yellow, Blue, Green}
|
||||
import { ref, type Ref } from "vue";
|
||||
|
||||
enum color {
|
||||
Red,
|
||||
Yellow,
|
||||
Blue,
|
||||
Green,
|
||||
}
|
||||
|
||||
type ErrorMessageContent = {
|
||||
message: string;
|
||||
@ -11,23 +16,28 @@ type ErrorMessageContent = {
|
||||
|
||||
let id: number = 0;
|
||||
const getId = () => {
|
||||
id = id+1;
|
||||
id = id + 1;
|
||||
return id;
|
||||
}
|
||||
};
|
||||
|
||||
function addNewMessage(errorMessage: string, type?: color, timeout?: number){
|
||||
if (timeout == null){
|
||||
function addNewMessage(errorMessage: string, type?: color, timeout?: number) {
|
||||
if (timeout == null) {
|
||||
timeout = 5000;
|
||||
}
|
||||
if (type == null){
|
||||
if (type == null) {
|
||||
type = color.Red;
|
||||
}
|
||||
|
||||
const data: ErrorMessageContent = {message: errorMessage, timeout: timeout, color: type, id: getId()};
|
||||
errorList.value.push(data)
|
||||
setTimeout(() => errorList.value.slice(0, 1), timeout)
|
||||
const data: ErrorMessageContent = {
|
||||
message: errorMessage,
|
||||
timeout: timeout,
|
||||
color: type,
|
||||
id: getId(),
|
||||
};
|
||||
errorList.value.push(data);
|
||||
setTimeout(() => errorList.value.slice(0, 1), timeout);
|
||||
}
|
||||
|
||||
const errorList: Ref<ErrorMessageContent[]>= ref([])
|
||||
const errorList: Ref<ErrorMessageContent[]> = ref([]);
|
||||
|
||||
export {addNewMessage, errorList, color, type ErrorMessageContent}
|
||||
export { addNewMessage, errorList, color, type ErrorMessageContent };
|
||||
|
Reference in New Issue
Block a user