started implementing Vue Router; updated README.md; corrected an italian translation

This commit is contained in:
Roberto Tonino 2020-07-27 22:01:57 +02:00
parent b9a6b48f38
commit 35edbb7aa7
10 changed files with 67 additions and 18 deletions

View File

@ -6,9 +6,10 @@ This is just the WebUI for deemix, it should be used with deemix-pyweb or someth
- Use Vue as much as possible - Use Vue as much as possible
- First step: rewrite the app in Single File Components way ✅ - First step: rewrite the app in Single File Components way ✅
- Second step: Remove jQuery - Second step: Implement routing for the whole app using Vue Router
- Third step: Remove jQuery
- Make i18n async (https://kazupon.github.io/vue-i18n/guide/lazy-loading.html) - Make i18n async (https://kazupon.github.io/vue-i18n/guide/lazy-loading.html)
- Use ES2020 async imports - Use ES2020 async imports, if possible
- Make the UI look coherent - Make the UI look coherent
- Style buttons - Style buttons
- Style text inputs - Style text inputs
@ -19,6 +20,7 @@ This is just the WebUI for deemix, it should be used with deemix-pyweb or someth
- Better placeholer before analyzing and error feedback - Better placeholer before analyzing and error feedback
- Settings tab - Settings tab
- Maybe tabbing the section for easy navigation - Maybe tabbing the section for easy navigation
- Could use a carousel, but it's not worth adding a new dep
- Add Custom Context menu to objects - Add Custom Context menu to objects
- Copy Link where possible - Copy Link where possible
- Copy Image URL where possible - Copy Image URL where possible

5
package-lock.json generated
View File

@ -2804,6 +2804,11 @@
"resolved": "https://registry.npmjs.org/vue-i18n/-/vue-i18n-8.18.2.tgz", "resolved": "https://registry.npmjs.org/vue-i18n/-/vue-i18n-8.18.2.tgz",
"integrity": "sha512-0X5nBTCZAVjlwcrPaYJwNs3iipBBTv0AUHwQUOa8yP3XbQGWKbRHqBb3OhCYtum/IHDD21d/df5Xd2VgyxbxfA==" "integrity": "sha512-0X5nBTCZAVjlwcrPaYJwNs3iipBBTv0AUHwQUOa8yP3XbQGWKbRHqBb3OhCYtum/IHDD21d/df5Xd2VgyxbxfA=="
}, },
"vue-router": {
"version": "3.3.4",
"resolved": "https://registry.npmjs.org/vue-router/-/vue-router-3.3.4.tgz",
"integrity": "sha512-SdKRBeoXUjaZ9R/8AyxsdTqkOfMcI5tWxPZOUX5Ie1BTL5rPSZ0O++pbiZCeYeythiZIdLEfkDiQPKIaWk5hDg=="
},
"vue-template-compiler": { "vue-template-compiler": {
"version": "2.6.11", "version": "2.6.11",
"resolved": "https://registry.npmjs.org/vue-template-compiler/-/vue-template-compiler-2.6.11.tgz", "resolved": "https://registry.npmjs.org/vue-template-compiler/-/vue-template-compiler-2.6.11.tgz",

View File

@ -22,7 +22,8 @@
"svg-country-flags": "^1.2.7", "svg-country-flags": "^1.2.7",
"toastify-js": "^1.8.0", "toastify-js": "^1.8.0",
"vue": "^2.6.11", "vue": "^2.6.11",
"vue-i18n": "^8.18.2" "vue-i18n": "^8.18.2",
"vue-router": "^3.3.4"
}, },
"devDependencies": { "devDependencies": {
"@rollup/plugin-alias": "^3.1.0", "@rollup/plugin-alias": "^3.1.0",

File diff suppressed because one or more lines are too long

View File

@ -7,6 +7,7 @@ window.vol = {
import App from '@components/App.vue' import App from '@components/App.vue'
import i18n from '@/plugins/i18n' import i18n from '@/plugins/i18n'
// import router from '@/plugins/router'
import $ from 'jquery' import $ from 'jquery'
import { socket } from '@/utils/socket' import { socket } from '@/utils/socket'
@ -21,8 +22,8 @@ function startApp() {
} }
function mountApp() { function mountApp() {
// TODO Remove the App instance from the window when deemix will be a complete Vue App
new Vue({ new Vue({
// router,
i18n, i18n,
render: h => h(App) render: h => h(App)
}).$mount('#app') }).$mount('#app')
@ -148,10 +149,8 @@ socket.on('errorMessage', function(error) {
}) })
socket.on('queueError', function(queueItem) { socket.on('queueError', function(queueItem) {
if (queueItem.errid) if (queueItem.errid) toast(i18n.t(`errors.ids.${queueItem.errid}`), 'error')
toast(i18n.t(`errors.ids.${queueItem.errid}`), 'error') else toast(queueItem.error, 'error')
else
toast(queueItem.error, 'error')
}) })
socket.on('alreadyInQueue', function(data) { socket.on('alreadyInQueue', function(data) {

View File

@ -1,5 +1,7 @@
<template> <template>
<main id="main_content"> <main id="main_content">
<!-- <router-link to="/tracklist/132">Go to Foo</router-link> -->
<!-- <router-view></router-view> -->
<TheMiddleSection /> <TheMiddleSection />
<TheDownloadTab /> <TheDownloadTab />
</main> </main>
@ -13,6 +15,9 @@ export default {
components: { components: {
TheMiddleSection, TheMiddleSection,
TheDownloadTab TheDownloadTab
},
mounted() {
console.log(this.$route)
} }
} }
</script> </script>

View File

@ -131,7 +131,7 @@
</template> </template>
</tbody> </tbody>
</table> </table>
<span v-if="label" style="opacity: 0.40;margin-top: 8px;display: inline-block;font-size: 13px;">{{ label }}</span> <span v-if="label" style="opacity: 0.4; margin-top: 8px; display: inline-block; font-size: 13px;">{{ label }}</span>
<footer> <footer>
<button @contextmenu.prevent="openQualityModal" @click.stop="addToQueue" :data-link="link"> <button @contextmenu.prevent="openQualityModal" @click.stop="addToQueue" :data-link="link">
{{ `${$t('globals.download', [$tc(`globals.listTabs.${type}`, 1)])}` }} {{ `${$t('globals.download', [$tc(`globals.listTabs.${type}`, 1)])}` }}
@ -289,10 +289,11 @@ export default {
} }
}, },
selectRow(index, track) { selectRow(index, track) {
track.selected = !track.selected; track.selected = !track.selected
} }
}, },
mounted() { mounted() {
console.log('tracklist mounted')
EventBus.$on('tracklistTab:reset', this.reset) EventBus.$on('tracklistTab:reset', this.reset)
EventBus.$on('tracklistTab:selectRow', this.selectRow) EventBus.$on('tracklistTab:selectRow', this.selectRow)

View File

@ -106,7 +106,7 @@ const it = {
needTologin: 'Devi accedere al tuo account Deezer, fino a quel momento non potrai scaricare nulla.', needTologin: 'Devi accedere al tuo account Deezer, fino a quel momento non potrai scaricare nulla.',
openSettings: 'Apri le impostazioni', openSettings: 'Apri le impostazioni',
sections: { sections: {
popularPlaylists: 'Playlyst Popolari', popularPlaylists: 'Playlist Popolari',
popularAlbums: 'Album più riprodotti' popularAlbums: 'Album più riprodotti'
} }
}, },

36
src/plugins/router.js Normal file
View File

@ -0,0 +1,36 @@
import Vue from 'vue'
import VueRouter from 'vue-router'
import TracklistTab from '@components/TracklistTab.vue'
console.log(TracklistTab)
Vue.use(VueRouter)
const routes = [
{
path: '/tracklist/:id',
component: TracklistTab
},
// 404
{
path: '*',
component: TracklistTab
}
]
const router = new VueRouter({
mode: 'history',
// linkActiveClass: 'open',
routes,
scrollBehavior(to, from, savedPosition) {
return { x: 0, y: 0 }
}
})
router.beforeEach((to, from, next) => {
console.log({ from, to })
next()
})
export default router