2020-09-21 12:25:50 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020. The Nextcloud Bookmarks contributors.
|
2019-07-26 18:16:37 +00:00
|
|
|
*
|
2020-09-21 12:25:50 +00:00
|
|
|
* This file is licensed under the Affero General Public License version 3 or later. See the COPYING file.
|
2019-07-26 18:16:37 +00:00
|
|
|
*/
|
2019-09-24 15:18:29 +00:00
|
|
|
import Vue from 'vue'
|
2021-03-30 11:21:18 +00:00
|
|
|
import { Store } from 'vuex'
|
2020-03-05 11:35:05 +00:00
|
|
|
import Tooltip from '@nextcloud/vue/dist/Directives/Tooltip'
|
2019-09-24 15:18:29 +00:00
|
|
|
import App from './App'
|
|
|
|
import router from './router'
|
|
|
|
import store from './store/'
|
|
|
|
import AppGlobal from './mixins/AppGlobal'
|
2021-03-25 12:25:56 +00:00
|
|
|
import DropTarget from './directives/drop-target'
|
2021-01-22 13:11:32 +00:00
|
|
|
import { subscribe } from '@nextcloud/event-bus'
|
2021-02-19 09:59:12 +00:00
|
|
|
import { generateUrl } from '@nextcloud/router'
|
2019-07-26 18:16:37 +00:00
|
|
|
|
2019-09-24 15:18:29 +00:00
|
|
|
Vue.mixin(AppGlobal)
|
|
|
|
Vue.directive('tooltip', Tooltip)
|
2021-03-25 12:25:56 +00:00
|
|
|
Vue.directive('drop-target', DropTarget)
|
2019-07-26 18:16:37 +00:00
|
|
|
|
2020-08-02 13:53:33 +00:00
|
|
|
const BookmarksApp = (global.Bookmarks = new Vue({
|
2019-07-26 18:16:37 +00:00
|
|
|
el: '#content',
|
2021-03-30 11:21:18 +00:00
|
|
|
store: new Store(store),
|
2019-07-26 18:16:37 +00:00
|
|
|
router,
|
2021-01-22 13:11:32 +00:00
|
|
|
created() {
|
|
|
|
subscribe('nextcloud:unified-search.search', ({ query }) => {
|
|
|
|
this.$router.push({ name: this.routes.SEARCH, params: { search: query } })
|
|
|
|
})
|
|
|
|
subscribe('nextcloud:unified-search.reset', () => {
|
|
|
|
this.$router.push({ name: this.routes.HOME })
|
|
|
|
})
|
|
|
|
},
|
2019-12-10 21:33:54 +00:00
|
|
|
render: h => h(App),
|
2019-09-24 15:18:29 +00:00
|
|
|
}))
|
2019-08-04 21:49:07 +00:00
|
|
|
|
2021-02-19 09:59:12 +00:00
|
|
|
if ('serviceWorker' in navigator) {
|
2022-09-13 14:02:21 +00:00
|
|
|
navigator.serviceWorker.register(
|
|
|
|
generateUrl('/apps/bookmarks/service-worker', {}, {
|
|
|
|
noRewrite: true,
|
|
|
|
}) + '.js')
|
2020-06-07 14:57:19 +00:00
|
|
|
.then(() => {
|
|
|
|
console.info('ServiceWorker registered')
|
|
|
|
})
|
|
|
|
.catch(er => console.error(er))
|
|
|
|
|
|
|
|
window.caches.open('js').then(async cache => {
|
|
|
|
const url = generateUrl('/apps/bookmarks/js/bookmarks.main.js')
|
|
|
|
cache.put(url, await fetch(url))
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
console.warn('ServiceWorker not supported')
|
2021-02-19 09:59:12 +00:00
|
|
|
}
|
2020-06-07 14:57:19 +00:00
|
|
|
|
2019-09-24 15:18:29 +00:00
|
|
|
export default BookmarksApp
|