2023-01-05 13:57:47 +00:00
|
|
|
import { ref } from 'vue';
|
|
|
|
import { defineStore } from 'pinia';
|
|
|
|
|
|
|
|
export const useArrayDataStore = defineStore('arrayDataStore', () => {
|
2023-01-10 13:58:24 +00:00
|
|
|
const state = ref({});
|
2023-01-05 13:57:47 +00:00
|
|
|
|
|
|
|
function get(key) {
|
2023-01-10 13:58:24 +00:00
|
|
|
return state.value[key];
|
2023-01-05 13:57:47 +00:00
|
|
|
}
|
|
|
|
|
2023-01-10 13:58:24 +00:00
|
|
|
function set(key) {
|
|
|
|
state.value[key] = { data: ref([]) };
|
|
|
|
}
|
|
|
|
|
|
|
|
function clear(key) {
|
|
|
|
delete state.value[key];
|
2023-01-05 13:57:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
get,
|
|
|
|
set,
|
2023-01-10 13:58:24 +00:00
|
|
|
clear
|
2023-01-05 13:57:47 +00:00
|
|
|
};
|
|
|
|
});
|