mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Fetch lists on index page
This commit is contained in:
parent
4c2e70c95f
commit
fa16340a86
1 changed files with 43 additions and 3 deletions
|
|
@ -12,7 +12,7 @@
|
||||||
:app-list="allList"
|
:app-list="allList"
|
||||||
:quick-buttons="quickButtons"
|
:quick-buttons="quickButtons"
|
||||||
:initial-limit="200"
|
:initial-limit="200"
|
||||||
@update:query="query = $event"
|
@update:query="onQueryUpdate"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div class="flex flex-col md:flex-row space-x-0 space-y-4 md:space-y-0 md:space-x-4">
|
<div class="flex flex-col md:flex-row space-x-0 space-y-4 md:space-y-0 md:space-x-4">
|
||||||
|
|
@ -46,6 +46,8 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import axios from 'axios'
|
||||||
|
|
||||||
import Search from '~/components/search.vue'
|
import Search from '~/components/search.vue'
|
||||||
import LinkButton from '~/components/link-button.vue'
|
import LinkButton from '~/components/link-button.vue'
|
||||||
import AllUpdatesSubscribe from '~/components/all-updates-subscribe.vue'
|
import AllUpdatesSubscribe from '~/components/all-updates-subscribe.vue'
|
||||||
|
|
@ -55,11 +57,11 @@ export default {
|
||||||
// const { default: appList } = await import('~/static/app-list.json')
|
// const { default: appList } = await import('~/static/app-list.json')
|
||||||
// const { default: gamelist } = await import('~/static/game-list.json')
|
// const { default: gamelist } = await import('~/static/game-list.json')
|
||||||
|
|
||||||
const { allList } = await import('~/helpers/get-list.js')
|
const { sortedAppList } = await import('~/helpers/get-list.js')
|
||||||
|
|
||||||
return {
|
return {
|
||||||
// Filter app list to leave out data not needed for search
|
// Filter app list to leave out data not needed for search
|
||||||
allList: allList.map( app => {
|
initialAppList: sortedAppList.map( app => {
|
||||||
return {
|
return {
|
||||||
name: app.name,
|
name: app.name,
|
||||||
status: app.status,
|
status: app.status,
|
||||||
|
|
@ -80,6 +82,7 @@ export default {
|
||||||
data: function () {
|
data: function () {
|
||||||
return {
|
return {
|
||||||
query: '',
|
query: '',
|
||||||
|
fetchedAppList: [],
|
||||||
quickButtons: [
|
quickButtons: [
|
||||||
{
|
{
|
||||||
label: '✅ Full Native Support',
|
label: '✅ Full Native Support',
|
||||||
|
|
@ -123,6 +126,43 @@ export default {
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
allList () {
|
||||||
|
return [
|
||||||
|
...this.initialAppList,
|
||||||
|
...this.fetchedAppList
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
async onQueryUpdate ( $event ) {
|
||||||
|
console.log('$event', $event)
|
||||||
|
this.query = $event
|
||||||
|
|
||||||
|
|
||||||
|
if (this.fetchedAppList.length !== 0) return
|
||||||
|
|
||||||
|
const fetchedListUrls = [
|
||||||
|
'/game-list.json',
|
||||||
|
'/homebrew-list.json'
|
||||||
|
]
|
||||||
|
|
||||||
|
const fetchedLists = await Promise.all(fetchedListUrls.map( async listUrl => {
|
||||||
|
// Fetch List
|
||||||
|
const response = await axios.get(listUrl)
|
||||||
|
// Extract apps from response data
|
||||||
|
const fetchedApps = response.data
|
||||||
|
|
||||||
|
return fetchedApps
|
||||||
|
}))
|
||||||
|
|
||||||
|
console.log('fetchedLists', fetchedLists)
|
||||||
|
|
||||||
|
this.fetchedAppList = fetchedLists.flat(1)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue