main.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import './assets/main.css'
  2. import { createApp, computed } from 'vue'
  3. import { createPinia } from 'pinia'
  4. import { useUserStore } from '@/stores/user'
  5. import PrimeVue from 'primevue/config'
  6. import ToastService from 'primevue/toastservice'
  7. import ConfirmService from 'primevue/confirmationservice'
  8. import Aura from '@primeuix/themes/aura'
  9. import 'primeicons/primeicons.css'
  10. import App from './App.vue'
  11. import router from './router'
  12. const app = createApp(App)
  13. app.use(createPinia())
  14. app.use(router)
  15. app.use(PrimeVue, { ripple: true, theme: { preset: Aura } })
  16. app.use(ToastService)
  17. app.use(ConfirmService)
  18. app.provide(
  19. 'isAdmin',
  20. computed(() => {
  21. if (!(useUserStore().userInfo && useUserStore().userInfo.role)) return false
  22. return useUserStore().userInfo.role === 'admin'
  23. })
  24. )
  25. app.provide(
  26. 'isTeam',
  27. computed(() => {
  28. if (!(useUserStore().userInfo && useUserStore().userInfo.role)) return false
  29. return useUserStore().userInfo.role === 'team'
  30. })
  31. )
  32. app.provide(
  33. 'isPromoter',
  34. computed(() => {
  35. if (!(useUserStore().userInfo && useUserStore().userInfo.role)) return false
  36. return useUserStore().userInfo.role === 'promoter'
  37. })
  38. )
  39. app.provide(
  40. 'isUser',
  41. computed(() => {
  42. if (!(useUserStore().userInfo && useUserStore().userInfo.role)) return false
  43. return useUserStore().userInfo.role === 'user'
  44. })
  45. )
  46. app.mount('#app')