build: prune admin bundle

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/900/head
Varun Patil 2023-10-30 01:01:27 -07:00
parent 664bbae0ca
commit ba473e6314
6 changed files with 48 additions and 40 deletions

View File

@ -3,7 +3,9 @@ import './bootstrap';
import Vue from 'vue'; import Vue from 'vue';
import App from '@components/admin/AdminMain.vue'; import App from '@components/admin/AdminMain.vue';
_m.mode = 'admin'; globalThis._m = {
mode: 'admin',
} as any;
export default new Vue({ export default new Vue({
el: '#vue-content', el: '#vue-content',

View File

@ -6,42 +6,15 @@ import { generateFilePath } from '@nextcloud/router';
import { getRequestToken } from '@nextcloud/auth'; import { getRequestToken } from '@nextcloud/auth';
// Global components // Global components
import XImg from '@components/frame/XImg.vue';
import XLoadingIcon from '@components/XLoadingIcon.vue'; import XLoadingIcon from '@components/XLoadingIcon.vue';
import VueVirtualScroller from 'vue-virtual-scroller';
// Locals // Locals
import router, { routes } from './router';
import { constants, initstate } from '@services/utils'; import { constants, initstate } from '@services/utils';
import { translate, translatePlural } from '@services/l10n'; import { translate, translatePlural } from '@services/l10n';
// CSS for components
import 'vue-virtual-scroller/dist/vue-virtual-scroller.css';
// Global CSS // Global CSS
import './styles/global.scss'; import './styles/global.scss';
// Initialize global memories object
globalThis._m = {
mode: 'user',
get route() {
return router.currentRoute;
},
router: router,
routes: routes,
modals: {} as any,
sidebar: {} as any,
viewer: {} as any,
video: {} as any,
window: {
innerWidth: window.innerWidth,
innerHeight: window.innerHeight,
},
};
// CSP config for webpack dynamic chunk loading // CSP config for webpack dynamic chunk loading
__webpack_nonce__ = window.btoa(getRequestToken() ?? ''); __webpack_nonce__ = window.btoa(getRequestToken() ?? '');
@ -51,20 +24,12 @@ __webpack_nonce__ = window.btoa(getRequestToken() ?? '');
// We do not want the index.php since we're loading files // We do not want the index.php since we're loading files
__webpack_public_path__ = generateFilePath('memories', '', 'js/'); __webpack_public_path__ = generateFilePath('memories', '', 'js/');
// Generate client id for this instance
// Does not need to be cryptographically secure
_m.video.clientId = Math.random().toString(36).substring(2, 15).padEnd(12, '0');
_m.video.clientIdPersistent = localStorage.getItem('videoClientIdPersistent') ?? _m.video.clientId;
localStorage.setItem('videoClientIdPersistent', _m.video.clientIdPersistent);
// Turn on virtual keyboard support // Turn on virtual keyboard support
if ('virtualKeyboard' in navigator) { if ('virtualKeyboard' in navigator) {
(<any>navigator.virtualKeyboard).overlaysContent = true; (<any>navigator.virtualKeyboard).overlaysContent = true;
} }
// Register global components and plugins // Register global components and plugins
Vue.use(VueVirtualScroller);
Vue.component('XImg', XImg);
Vue.component('XLoadingIcon', XLoadingIcon); Vue.component('XLoadingIcon', XLoadingIcon);
// Register global constants and functions // Register global constants and functions

View File

@ -78,7 +78,6 @@ export default defineComponent({
methods: { methods: {
async refreshSystemConfig() { async refreshSystemConfig() {
console.log(this.components);
try { try {
this.loading++; this.loading++;
const res = await axios.get<ISystemConfig>(API.SYSTEM_CONFIG(null)); const res = await axios.get<ISystemConfig>(API.SYSTEM_CONFIG(null));

5
src/globals.d.ts vendored
View File

@ -27,7 +27,10 @@ declare global {
}; };
}; };
/** Global Memories object. Initialized in src/bootstrap.ts */ /**
* Global Memories object. Initialized in main.ts
* Most of this is not available for admin.ts.
*/
var _m: { var _m: {
mode: 'admin' | 'user'; mode: 'admin' | 'user';
route: Route; route: Route;

View File

@ -2,9 +2,45 @@ import './bootstrap';
import Vue from 'vue'; import Vue from 'vue';
import App from './App.vue'; import App from './App.vue';
import router from './router'; import router, { routes } from './router';
_m.mode = 'user'; // Global components
import XImg from '@components/frame/XImg.vue';
import VueVirtualScroller from 'vue-virtual-scroller';
// CSS for components
import 'vue-virtual-scroller/dist/vue-virtual-scroller.css';
// Initialize global memories object
globalThis._m = {
mode: 'user',
get route() {
return router.currentRoute;
},
router: router,
routes: routes,
modals: {} as any,
sidebar: {} as any,
viewer: {} as any,
video: {} as any,
window: {
innerWidth: window.innerWidth,
innerHeight: window.innerHeight,
},
};
// Generate client id for this instance
// Does not need to be cryptographically secure
_m.video.clientId = Math.random().toString(36).substring(2, 15).padEnd(12, '0');
_m.video.clientIdPersistent = localStorage.getItem('videoClientIdPersistent') ?? _m.video.clientId;
localStorage.setItem('videoClientIdPersistent', _m.video.clientIdPersistent);
// Register global components and plugins
Vue.use(VueVirtualScroller);
Vue.component('XImg', XImg);
export default new Vue({ export default new Vue({
el: '#content', el: '#content',

View File

@ -190,6 +190,9 @@ export const fragment = {
}; };
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
// Skip unless in user mode
if (_m.mode !== 'user') return;
// Only contextual fragments should be present on page load // Only contextual fragments should be present on page load
if (fragment.list.length) { if (fragment.list.length) {
const contextual = fragment.list.filter((frag) => frag.type === FragmentType.viewer); const contextual = fragment.list.filter((frag) => frag.type === FragmentType.viewer);