2
0
mirror of https://github.com/frappe/books.git synced 2024-11-13 00:46:28 +00:00
books/src/App.vue
2019-11-19 23:20:00 +05:30

87 lines
2.1 KiB
Vue

<template>
<div id="app" class="h-screen flex flex-col font-sans">
<Desk class="flex-1" v-if="showDesk" />
<database-selector v-if="showDatabaseSelector" @file="connectToDBFile" />
<setup-wizard v-if="showSetupWizard" />
<Settings v-if="showSettings" />
</div>
</template>
<script>
import './styles/index.css';
import frappe from 'frappejs';
import Desk from './pages/Desk';
import SetupWizard from './pages/SetupWizard/SetupWizard';
import DatabaseSelector from './pages/DatabaseSelector';
import Settings from '@/pages/Settings/Settings.vue';
import { remote } from 'electron';
export default {
name: 'App',
data() {
return {
showDatabaseSelector: false,
showDesk: false,
showSetupWizard: false,
showSettings: false
};
},
watch: {
showDatabaseSelector(newValue) {
if (newValue) {
remote.getCurrentWindow().setSize(600, 600);
}
},
showSetupWizard(newValue) {
if (newValue) {
remote.getCurrentWindow().setSize(600, 600);
}
},
showSettings(newValue) {
if (newValue) {
remote.getCurrentWindow().setSize(460, 577);
}
},
showDesk(newValue) {
if (newValue) {
remote.getCurrentWindow().setSize(1200, 907);
}
}
},
components: {
Desk,
SetupWizard,
DatabaseSelector,
Settings
},
mounted() {
if (!localStorage.dbPath) {
this.showDatabaseSelector = true;
} else {
frappe.events.trigger('connect-database', localStorage.dbPath);
}
frappe.events.on('show-setup-wizard', () => {
this.showSetupWizard = true;
this.showDesk = false;
this.showDatabaseSelector = false;
});
frappe.events.on('show-desk', () => {
if (this.$route.path.startsWith('/settings')) {
this.showSettings = true;
} else {
this.showDesk = true;
}
this.showSetupWizard = false;
this.showDatabaseSelector = false;
});
},
methods: {
connectToDBFile(filePath) {
frappe.events.trigger('DatabaseSelector:file-selected', filePath);
}
}
};
</script>