system.ts 834 B

1234567891011121314151617181920212223242526272829303132
  1. import { defineStore } from 'pinia'
  2. import storage from '@/utils/storage'
  3. import { getSiteInfo } from '@/app/api/system'
  4. interface System {
  5. lang: string,
  6. site: Record<string, any>
  7. }
  8. const useSystemStore = defineStore('system', {
  9. state: (): System => {
  10. return {
  11. lang: storage.get('lang') ?? 'zh-cn',
  12. site: {
  13. front_end_name: '',
  14. site_name: ''
  15. }
  16. }
  17. },
  18. actions: {
  19. async getSiteInfoFn() {
  20. await getSiteInfo().then((res: any) => {
  21. this.site = res.data
  22. if (this.site.status == 3) navigateTo('/site/close', { replace: true })
  23. }).catch((err) => {
  24. navigateTo('/site/nosite', { replace: true })
  25. })
  26. }
  27. }
  28. })
  29. export default useSystemStore