add app orderer
This commit is contained in:
+22
-28
@@ -21,48 +21,42 @@ import axios from '@nextcloud/axios'
|
||||
import { generateUrl, generateOcsUrl } from '@nextcloud/router'
|
||||
|
||||
export const useNavStore = defineStore('nav', () => {
|
||||
const categories = ref(null)
|
||||
const apps = ref(null)
|
||||
const coreApps = ref(null)
|
||||
let categories = null
|
||||
let apps = null
|
||||
let coreApps = null
|
||||
|
||||
async function getApps() {
|
||||
if (apps.value !== null) {
|
||||
return apps.value
|
||||
if (apps === null) {
|
||||
apps = []
|
||||
const cats = await getCategories()
|
||||
|
||||
cats.forEach((category) => {
|
||||
Object.values(category.apps).forEach((app) => {
|
||||
apps.push(app)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
apps.value = []
|
||||
const cats = await getCategories()
|
||||
|
||||
cats.forEach((category) => {
|
||||
Object.values(category.apps).forEach((app) => {
|
||||
apps.value.push(app)
|
||||
})
|
||||
})
|
||||
|
||||
return apps.value
|
||||
return apps
|
||||
}
|
||||
|
||||
async function getCoreApps() {
|
||||
if (coreApps.value !== null) {
|
||||
return coreApps.value
|
||||
if (coreApps == null) {
|
||||
coreApps = await axios
|
||||
.get(generateOcsUrl('core/navigation', 2) + '/apps?format=json')
|
||||
.then((response) => response.data)
|
||||
.then((value) => value.ocs.data)
|
||||
}
|
||||
|
||||
coreApps.value = await axios
|
||||
.get(generateOcsUrl('core/navigation', 2) + '/apps?format=json')
|
||||
.then((response) => response.data)
|
||||
.then((value) => value.ocs.data)
|
||||
|
||||
return coreApps.value
|
||||
return coreApps
|
||||
}
|
||||
|
||||
async function getCategories() {
|
||||
if (categories.value !== null) {
|
||||
return categories.value
|
||||
if (categories === null) {
|
||||
categories = await axios.get(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 categories
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user