import { store } from '@/store'
import { defineStore } from 'pinia'

interface AppInfo {
  design: number,
  zoom: number
  mode: string,
  fixHeight: any
}

export const useAppStore = defineStore('app', {

  state: (): AppInfo => ({
    mode: '2D',
    design: 1920,
    zoom: 1,
    fixHeight: null
  }),

  getters: {

    getMode(): string {
      return this.mode
    },

    getZoom(): number {
      return this.zoom
    },

    getDesign(): number {
      return this.design
    },

    getFixHeight(): number {
      return this.fixHeight
    }

  },

  actions: {

    setFix () {
      this.zoom = document.documentElement.clientWidth / this.design
      this.fixHeight = window.innerHeight / this.zoom
    },

    setMode (e) {
      this.mode = e
    }
  }

})

export const useAppStoreWithOut = () => {
  return useAppStore(store)
}