24 lines
470 B
JavaScript
24 lines
470 B
JavaScript
import { ref } from "vue";
|
|
|
|
let count = 0;
|
|
|
|
const useList = () => {
|
|
const notificationList = ref([]);
|
|
|
|
const add = (optionProps) => {
|
|
notificationList.value.push({ id: count++, ...optionProps });
|
|
};
|
|
|
|
const remove = (id) => {
|
|
notificationList.value = notificationList.value.filter((item) => item.id !== id);
|
|
};
|
|
|
|
const clear = () => {
|
|
notificationList.value = [];
|
|
}
|
|
|
|
return { notificationList, add, remove, clear };
|
|
};
|
|
|
|
export default useList;
|