Did the needful

This commit is contained in:
2021-06-14 01:27:47 +02:00
parent 1506fe5f82
commit fd8d7a9ec6
10 changed files with 211 additions and 112 deletions

View File

@@ -1,32 +1,3 @@
<template>
<div id="app">
<div id="nav">
<router-link to="/">Home</router-link> |
<router-link to="/about">About</router-link>
</div>
<router-view/>
</div>
<router-view/>
</template>
<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
}
#nav {
padding: 30px;
}
#nav a {
font-weight: bold;
color: #2c3e50;
}
#nav a.router-link-exact-active {
color: #42b983;
}
</style>

BIN
src/assets/liba.wav Normal file

Binary file not shown.

View File

@@ -1,59 +0,0 @@
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<p>
For a guide and recipes on how to configure / customize this project,<br>
check out the
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
</p>
<h3>Installed CLI Plugins</h3>
<ul>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-router" target="_blank" rel="noopener">router</a></li>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint" target="_blank" rel="noopener">eslint</a></li>
</ul>
<h3>Essential Links</h3>
<ul>
<li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
<li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
<li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
<li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
<li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
</ul>
<h3>Ecosystem</h3>
<ul>
<li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
<li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
<li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
<li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
<li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
</ul>
</div>
</template>
<script>
export default {
name: 'HelloWorld',
props: {
msg: String
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>

View File

@@ -2,8 +2,16 @@ import Vue from 'vue'
import App from './App.vue'
import router from './router'
import { BootstrapVue, IconsPlugin } from 'bootstrap-vue'
import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'
Vue.config.productionTip = false
Vue.use(BootstrapVue)
Vue.use(IconsPlugin)
new Vue({
router,
render: h => h(App)

View File

@@ -9,14 +9,6 @@ const routes = [
path: '/',
name: 'Home',
component: Home
},
{
path: '/about',
name: 'About',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
}
]

View File

@@ -1,5 +0,0 @@
<template>
<div class="about">
<h1>This is an about page</h1>
</div>
</template>

View File

@@ -1,18 +1,89 @@
<template>
<div class="home">
<img alt="Vue logo" src="../assets/logo.png">
<HelloWorld msg="Welcome to Your Vue.js App"/>
</div>
<b-container fluid style="height: 100vh">
<b-row v-if="errorCondition">
{{ errorCondition }}
</b-row>
<b-row v-else class="mb-2 h-100">
<b-col v-for="(snd,id) in availableSounds" :key="id" class="my-2" :cols="columnWidth" align-v="stretch">
<b-button @click="play(id)" squared size="lg" class="bigBoyButton"
:variant="nowPlaying === id? 'success' : 'secondary'">
{{ snd.sampleName }}
</b-button>
</b-col>
</b-row>
</b-container>
</template>
<script>
// @ is an alias to /src
import HelloWorld from '@/components/HelloWorld.vue'
import {Howl} from 'howler'
import axios from 'axios'
export default {
name: 'Home',
components: {
HelloWorld
data() {
return {
nowPlaying: -1,
availableSounds: [],
columnWidth: 6,
errorCondition: false,
bgSound: null
}
},
methods: {
play(sampleId) {
const sample = this.availableSounds[sampleId].howl
if (sample.playing()) {
sample.stop()
this.nowPlaying = -1
this.bgSound.play() // Continue background sound
} else {
this.bgSound.pause() // the background sound must be paused
this.availableSounds.forEach((snd) => { // Stop all other effects
snd.howl.stop()
})
sample.play()
this.nowPlaying = sampleId
}
}
},
mounted() {
axios.get(process.env.VUE_APP_INDEX_URL).then((response) => {
this.columnWidth = response.data['columnWidth'] || 6
this.bgSound = new Howl({
src: response.data['bg'],
loop: true
})
response.data['availableSounds'].forEach((sndData) => {
this.availableSounds.push({
sampleName: sndData.sampleName,
howl: new Howl({
src: [sndData.url],
loop: false,
onend: () => {
this.nowPlaying = -1
this.bgSound.play() // Continue background sound
}
})
})
})
}).catch((err) => this.errorCondition = err)
}
}
</script>
<style scoped>
.bigBoyButton {
width: 100%;
height: 100%;
}
</style>