| 123456789101112131415161718192021222324252627 |
- import { computed, ref } from 'vue'
- import { defineStore } from 'pinia'
- import { useAuthStore } from './auth';
- export const useCollectStore = defineStore('collect', () => {
- const collectableModules = ref<string[]>([]);
- const authStore = useAuthStore();
- function setCollectableModules(modules: string[]) {
- collectableModules.value = modules;
- }
- function canCollect(module: string) {
- if (authStore.isAdmin)
- return true;
- return collectableModules.value.includes(module);
- }
-
- const isEmpty = computed(() => collectableModules.value.length === 0);
- return {
- isEmpty,
- collectableModules,
- setCollectableModules,
- canCollect,
- }
- })
|