2
0
mirror of https://github.com/frappe/books.git synced 2024-12-25 20:11:15 +00:00
books/src/main.js

80 lines
1.8 KiB
JavaScript
Raw Normal View History

// frappejs imports
import frappe from 'frappejs';
import common from 'frappejs/common';
import coreModels from 'frappejs/models';
import FeatherIcon from 'frappejs/ui/components/FeatherIcon';
import outsideClickDirective from 'frappejs/ui/plugins/outsideClickDirective';
import models from '../models';
import { ipcRenderer } from 'electron';
// vue imports
import Vue from 'vue';
import PortalVue from 'portal-vue';
import App from './App';
import router from './router';
(async () => {
frappe.isServer = true;
frappe.isElectron = true;
frappe.init();
frappe.registerLibs(common);
frappe.registerModels(coreModels);
frappe.registerModels(models);
frappe.fetch = window.fetch.bind();
frappe.events.on('reload-main-window', () => {
ipcRenderer.send('reload-main-window');
});
frappe.events.on('check-for-updates', () => {
let { autoUpdate } = frappe.AccountingSettings;
if (autoUpdate == null || autoUpdate === 1) {
ipcRenderer.send('check-for-updates');
}
});
window.frappe = frappe;
Vue.config.productionTip = false;
Vue.component('feather-icon', FeatherIcon);
Vue.directive('on-outside-click', outsideClickDirective);
Vue.use(PortalVue);
Vue.mixin({
computed: {
frappe() {
return frappe;
},
platform() {
return {
win32: 'Windows',
darwin: 'Mac',
linux: 'Linux'
}[process.platform];
}
},
methods: {
_(...args) {
return frappe._(...args);
}
}
});
2018-06-01 12:35:51 +00:00
Vue.config.errorHandler = (err, vm, info) => {
console.error(err, vm, info);
};
2018-06-26 11:13:05 +00:00
2021-08-18 18:00:35 +00:00
process.on('unhandledRejection', error => {
console.error(error);
});
2021-08-18 16:22:07 +00:00
/* eslint-disable no-new */
new Vue({
el: '#app',
router,
components: {
App
},
template: '<App/>'
});
})();