83d8035dc2
* root + server * frontend * frontend-2 * dui3 * dui3 * tailwind theme * ui-components * preview service * viewer * viewer-sandbox * fileimport-service * webhook service * objectloader * shared * ui-components-nuxt * WIP full config * WIP full linter * eslint projectwide util * minor fix * removing redundant ci * clean up test errors * fixed prettier formatting * CI improvements * TSC lint fix * 'buildBatch' needs to be async since some batch types (like Text) require it. Removed a disabled liniting rule from ObjLoader * removed unnecessary void --------- Co-authored-by: AlexandruPopovici <alexandrupopoviciioan@gmail.com>
35 lines
876 B
TypeScript
35 lines
876 B
TypeScript
import { defineStore } from 'pinia'
|
|
import type { Config } from 'lib/bindings/definitions/IConfigBinding'
|
|
|
|
export const useDocumentInfoStore = defineStore('documentInfoStore', () => {
|
|
const { $configBinding } = useNuxtApp()
|
|
|
|
const hasConfigBindings = ref(!!$configBinding)
|
|
const uiConfig = ref<Config>({ darkTheme: false })
|
|
|
|
watch(
|
|
uiConfig,
|
|
async (newValue) => {
|
|
if (!newValue || !$configBinding) return
|
|
await $configBinding.updateConfig(newValue)
|
|
},
|
|
{ deep: true }
|
|
)
|
|
|
|
const isDarkTheme = computed(() => {
|
|
return uiConfig.value?.darkTheme
|
|
})
|
|
|
|
const toggleTheme = () => {
|
|
uiConfig.value.darkTheme = !uiConfig.value.darkTheme
|
|
}
|
|
|
|
const init = async () => {
|
|
if (!$configBinding) return
|
|
uiConfig.value = await $configBinding.getConfig()
|
|
}
|
|
void init()
|
|
|
|
return { hasConfigBindings, isDarkTheme, toggleTheme }
|
|
})
|