diff options
Diffstat (limited to 'apps/files/src/main.ts')
-rw-r--r-- | apps/files/src/main.ts | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/apps/files/src/main.ts b/apps/files/src/main.ts index 97b3b2f9651..463ecaf6239 100644 --- a/apps/files/src/main.ts +++ b/apps/files/src/main.ts @@ -1,23 +1,28 @@ +/** + * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +import type { Pinia } from 'pinia' +import { getCSPNonce } from '@nextcloud/auth' import { PiniaVuePlugin } from 'pinia' -import { getNavigation } from '@nextcloud/files' -import { getRequestToken } from '@nextcloud/auth' import Vue from 'vue' -import { pinia } from './store/index.ts' +import { getPinia } from './store/index.ts' +import FilesApp from './FilesApp.vue' import router from './router/router' import RouterService from './services/RouterService' import SettingsModel from './models/Setting.js' import SettingsService from './services/Settings.js' -import FilesApp from './FilesApp.vue' -// @ts-expect-error __webpack_nonce__ is injected by webpack -__webpack_nonce__ = btoa(getRequestToken()) +__webpack_nonce__ = getCSPNonce() declare global { interface Window { - OC: any; - OCA: any; - OCP: any; + OC: Nextcloud.v29.OC + OCP: Nextcloud.v29.OCP + // eslint-disable-next-line @typescript-eslint/no-explicit-any + OCA: Record<string, any> + _nc_files_pinia: Pinia } } @@ -26,17 +31,14 @@ window.OCA.Files = window.OCA.Files ?? {} window.OCP.Files = window.OCP.Files ?? {} // Expose router -const Router = new RouterService(router) -Object.assign(window.OCP.Files, { Router }) +if (!window.OCP.Files.Router) { + const Router = new RouterService(router) + Object.assign(window.OCP.Files, { Router }) +} // Init Pinia store Vue.use(PiniaVuePlugin) -// Init Navigation Service -// This only works with Vue 2 - with Vue 3 this will not modify the source but return just a oberserver -const Navigation = Vue.observable(getNavigation()) -Vue.prototype.$navigation = Navigation - // Init Files App Settings Service const Settings = new SettingsService() Object.assign(window.OCA.Files, { Settings }) @@ -44,6 +46,6 @@ Object.assign(window.OCA.Files.Settings, { Setting: SettingsModel }) const FilesAppVue = Vue.extend(FilesApp) new FilesAppVue({ - router, - pinia, + router: (window.OCP.Files.Router as RouterService)._router, + pinia: getPinia(), }).$mount('#content') |