genadmin/src/hooks/useState.ts
2022-01-10 10:40:05 +00:00

197 lines
4.0 KiB
TypeScript

import { ref } from 'vue'
import type { SideMenuItemType, UiPanelsType } from '~/typs/cmpnts'
import { DataLangsType, ShowInfoType, HtmlAttrsType, ModelType, ModelSelType, CVDataType } from '~/typs/cv'
import { VarsConfigType,ConfUrlsType } from '~/typs/config'
import { VarsUserType} from '~/typs/users'
const reqError = ref({ defs: '', lang: '', data: '', gql: '', api: '' })
const currentMapKey = ref('')
const isSidebarOpen = ref(false)
const toggleSidebar = () => {
isSidebarOpen.value = !isSidebarOpen.value
}
const showModal = ref(false)
const isAsidePanelOpen = ref(false)
const sideSettingButton = ref(false)
const isSettingsPanelOpen = ref(false)
const isSearchPanelOpen = ref(false)
const usideSettingButton = ref(false)
const isNotificationsPanelOpen = ref(false)
const useSettings = ref(false)
const useSearch = ref(false)
const search = ref('')
const isDevelmode = ref(false)
const bcPath = ref('')
const navTitle = ref({
text: '',
textclick: null as null | Function,
title: '',
cmpnt: '',
ops: [] as any[],
btntype: '',
cllbck: null as null | Function,
})
const dfltNavTitle = () => {
navTitle.value = {
text: '',
textclick: null as null | Function,
title: '',
cmpnt: '',
ops: [] as any[],
btntype: '',
cllbck: null as null | Function,
}
}
const bookCllbck = ref()
const bookSelec = (data: string) => {
if (data === '#') {
bcPath.value = ''
dfltNavTitle()
}
else {
if (bookCllbck.value)
bookCllbck.value(data)
// else ...
}
}
const sidebarMenuItems = ref([] as SideMenuItemType[])
const checkin = ref(false)
const connection = ref({
state: '',
})
const side_menu_click = ref()
const app_home_click = ref()
const backdrop_blur = ref(14)
const back_opacity = ref(60)
const panels = ref({} as UiPanelsType)
const show_profile = ref(false)
const cvdata = ref({} as CVDataType | any)
const datalang = ref({} as DataLangsType | any)
const showinfo = ref({} as ShowInfoType)
const authinfo = ref({ editable: false, viewchange: false, show: true })
const dataSections = ref([] as string[])
const htmlAttrs = ref({
bold: '', //'itm-title',
list: 'list-circle ml-5',
link: 'link',
text: '',
} as HtmlAttrsType)
const cv_model = ref({} as ModelType)
const models = ref({} as ModelType)
const selectOps = ref({} as ModelSelType)
const current_model = ref({} as ModelType)
const current_modelid = ref("")
const APPNAME = ref('')
const AUTHKEY = ref('auth')
const UUIDNONE = ref('none')
const TKNLIMIT = ref(20)
const REFRESHTIME = ref(5)
const ASSETS_PATH = ref("/assets")
const DATA_PATH = ref("/assets/data")
// const DATA_URL = ref("${DATA_PATH}/dist/info.json")
const MODEL_ID = ref("cv")
const URLKEY = ref("?k: ") // location.search.replace('?k: ','')
const AUTH_SEPCHAR = ref(";")
const PASSWD_ENC = ref("enc;")
const ALLOW_REGISTER = ref(false)
const RESET_PASSWORD = ref(false)
const CONFURLS = ref({} as ConfUrlsType)
const timeoutAuth = ref(0)
const allowView = ref(false)
const userID = ref('')
const sourceRoute = ref('')
const varsConfig = ref({} as VarsConfigType)
const varsUser = ref({} as VarsUserType)
export default function useState() {
return {
reqError,
currentMapKey,
isSidebarOpen,
toggleSidebar,
isAsidePanelOpen,
isSettingsPanelOpen,
isSearchPanelOpen,
isNotificationsPanelOpen,
useSettings,
usideSettingButton,
sideSettingButton,
bcPath,
bookSelec,
bookCllbck,
navTitle,
dfltNavTitle,
checkin,
connection,
sidebarMenuItems,
showModal,
side_menu_click,
app_home_click,
useSearch,
search,
back_opacity,
backdrop_blur,
panels,
show_profile,
cvdata,
datalang,
showinfo,
authinfo,
dataSections,
htmlAttrs,
selectOps,
models,
cv_model,
current_model,
current_modelid,
timeoutAuth,
isDevelmode,
allowView,
userID,
sourceRoute,
varsConfig,
varsUser,
// APP CONFIG VARS
APPNAME,
AUTHKEY,
UUIDNONE,
TKNLIMIT,
REFRESHTIME,
ASSETS_PATH,
DATA_PATH,
MODEL_ID,
URLKEY,
AUTH_SEPCHAR,
PASSWD_ENC,
ALLOW_REGISTER,
RESET_PASSWORD,
CONFURLS,
}
}