add mount of menu

fix store usage

add page loader
This commit is contained in:
Simon Vieille
2025-04-06 14:09:06 +02:00
parent d8a622ce0f
commit b287b671be
15 changed files with 175 additions and 81 deletions
+10 -4
View File
@@ -1,20 +1,21 @@
import { defineStore } from 'pinia'
import { ref } from 'vue'
import { axios } from '@nextcloud/axios'
import axios from '@nextcloud/axios'
import { generateUrl } from '@nextcloud/router'
export const useNavStore = defineStore('nav', () => {
const categories = ref(null)
const apps = ref(null)
function getApps() {
async function getApps() {
if (apps.value !== null) {
return apps.value
}
apps.value = []
const cats = await getCategories()
getCategories().forEach((category) => {
cats.forEach((category) => {
Object.values(category.apps).forEach((app) => {
apps.value.push(app)
})
@@ -28,8 +29,13 @@ export const useNavStore = defineStore('nav', () => {
return categories.value
}
categories.value = await fetch(generateUrl('/apps/side_menu/nav/items')).then((response) => response.data.items)
categories.value = await axios.get(generateUrl('/apps/side_menu/nav/items')).then((response) => response.data.items)
return categories.value
}
return {
getApps,
getCategories,
}
})