Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Vue Rewrite] Start More Routes #2024

Merged
merged 2 commits into from
Dec 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<NcContent app-name="news">
<Sidebar />
<NcAppContent>
<router-view />
<RouterView />
</NcAppContent>
</NcContent>
</template>
Expand Down
8 changes: 4 additions & 4 deletions src/components/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</ActionButton>
</template>
</NcAppNavigationItem>
<NcAppNavigationItem :title="t('news', 'Starred')" icon="icon-starred">
<NcAppNavigationItem :title="t('news', 'Starred')" icon="icon-starred" :to="{ name: ROUTES.STARRED }">
<template #counter>
<NcCounterBubble>35</NcCounterBubble>
</template>
Expand Down Expand Up @@ -118,7 +118,7 @@

<NcAppNavigationItem :title="t('news', 'Explore')"
icon="icon-link"
:to="{ name: 'explore' }">
:to="{ name: ROUTES.EXPLORE }">
<template #counter>
<NcCounterBubble>35</NcCounterBubble>
</template>
Expand All @@ -140,7 +140,7 @@ import NcAppNavigationNewItem from '@nextcloud/vue/dist/Components/NcAppNavigati
import NcCounterBubble from '@nextcloud/vue/dist/Components/NcCounterBubble.js'
import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'

// import { ROUTES } from '../routes.js'
import { ROUTES } from '../routes'
import { ACTIONS, AppState } from '../store'

import AddFeed from './AddFeed.vue'
Expand Down Expand Up @@ -174,7 +174,7 @@ export default Vue.extend({
data: () => {
return {
showAddFeed: false,
// ROUTES
ROUTES,
}
},
computed: {
Expand Down
25 changes: 25 additions & 0 deletions src/components/Starred.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<template>
<div id="starred">
Starred Items Here
</div>
</template>

<script>
// import axios from "@nextcloud/axios";
// import { generateUrl } from "@nextcloud/router";
export default {
components: {
},
props: {

},
created() {
// this.fetchStarred();
},
methods: {
async fetchStarred() {
// TODO
},
},
}
</script>
19 changes: 2 additions & 17 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@

import Vue from 'vue'
import App from './App.vue'
import VueRouter from 'vue-router'
import Explore from './components/Explore.vue'
import { generateUrl } from '@nextcloud/router'
import Vuex, { Store } from 'vuex'

import App from './App.vue'
import router from './routes'
import mainStore from './store'

import { Tooltip } from '@nextcloud/vue'
Expand All @@ -20,20 +19,6 @@ Vue.use(VueRouter)

Vue.directive('tooltip', Tooltip)

const routes = [
{
name: 'explore',
path: '#explore',
component: Explore,
},
]

const router = new VueRouter({
mode: 'history',
base: generateUrl('apps/news'),
routes,
})

const store = new Store(mainStore)

export default new Vue({
Expand Down
41 changes: 41 additions & 0 deletions src/routes/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import VueRouter from 'vue-router'

import ExplorePanel from '../components/Explore.vue'
import StarredPanel from '../components/Starred.vue'

export const ROUTES = {
EXPLORE: 'explore',
STARRED: 'starred',
}

const getInitialRoute = function() {
// TODO: Fetch Recent route from Browser Session?
return ROUTES.EXPLORE
}

const routes = [
// using
// { path: '/collections/all', component: CollectionGeneral, alias: '/' },
// instead of
{ path: '/', redirect: getInitialRoute() },
// would also be an option, but it currently does not work
// reliably with router-link due to
// https://github.com/vuejs/vue-router/issues/419
{
name: ROUTES.EXPLORE,
path: '/explore',
component: ExplorePanel,
props: true,
},
{
name: ROUTES.STARRED,
path: '/starred',
component: StarredPanel,
props: true,
},
]

export default new VueRouter({
linkActiveClass: 'active',
routes, // short for `routes: routes`
})