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