add mount of menu
fix store usage add page loader
This commit is contained in:
+10
-4
@@ -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,
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user