A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
blob: 1cf2a5032c6e39b907526f3f15445b5d3c660d18 (1884 bytes)[doc][blame][raw]
1
import {http} from './utils.js';2
import VMenu from './component/menu.js';3
import VPlayer from './component/player.js';4
import VSearch from './page/search.js';5
import VFavorites from './page/favorites.js';6
import VAccount from './page/account.js';8
export const state = {9
app: null,10
tab: 'favorites',11
account: {12
username: '',13
language: 'en'14
},15
station: null16
};18
(async () => {19
state.locale = await http`get::/asset/json/locale.json`();21
new Vue({22
el: '#app',23
data: {24
state25
},26
components: {27
VMenu,28
VSearch,29
VFavorites,30
VAccount,31
VPlayer32
},33
mounted() {34
document.body.style.display = '';35
state.app = this;36
this.init();37
},38
methods: {39
async init() {40
window.app = this;41
state.account = await http`get::/api/account`();42
document.addEventListener('scroll', this.onScroll);43
document.addEventListener('wheel', this.onScroll);44
},45
onScroll() {46
if(state.tab === 'search') {47
if(window.innerHeight + window.pageYOffset >= document.body.offsetHeight - 200) {48
this.$refs.search.doSearchMore();49
}50
}51
}52
},53
template: `54
<div class="px-4 sm:px-10 pb-8 sm:pb-[100px] max-w-[800px] mx-auto flex flex-col">55
<v-menu :state="state"></v-menu>56
<v-player :station="state.station"></v-player>57
<v-search ref="search" :state="state"></v-search>58
<v-favorites ref="favorites" :state="state"></v-favorites>59
<v-account :state="state"></v-account>60
</div>61
`62
});63
})();