2
0
mirror of https://github.com/frappe/books.git synced 2024-12-24 11:55:46 +00:00
books/src/App.vue

99 lines
2.6 KiB
Vue
Raw Normal View History

2018-06-01 12:35:51 +00:00
<template>
<div id="app" class="h-screen flex flex-col font-sans overflow-hidden">
<WindowsTitleBar
2019-12-17 07:04:49 +00:00
v-if="['Windows', 'Linux'].includes(platform)"
@close="reloadMainWindowOnSettingsClose"
/>
<Desk class="flex-1" v-if="activeScreen === 'Desk'" />
<DatabaseSelector
v-if="activeScreen === 'DatabaseSelector'"
@database-connect="showSetupWizardOrDesk"
/>
<SetupWizard
v-if="activeScreen === 'SetupWizard'"
@setup-complete="showSetupWizardOrDesk"
/>
<Settings v-if="activeScreen === 'Settings'" />
<portal-target name="popovers" multiple></portal-target>
2018-06-01 12:35:51 +00:00
</div>
</template>
<script>
import './styles/index.css';
import 'frappe-charts/dist/frappe-charts.min.css';
2018-10-22 18:02:47 +00:00
import frappe from 'frappejs';
2018-10-23 12:42:36 +00:00
import Desk from './pages/Desk';
2018-10-05 05:35:20 +00:00
import SetupWizard from './pages/SetupWizard/SetupWizard';
2018-10-23 12:42:36 +00:00
import DatabaseSelector from './pages/DatabaseSelector';
2019-11-19 17:50:00 +00:00
import Settings from '@/pages/Settings/Settings.vue';
import WindowsTitleBar from '@/components/WindowsTitleBar';
import { remote } from 'electron';
import { connectToLocalDatabase } from '@/utils';
2020-01-23 12:58:51 +00:00
import { getMainWindowSize } from '@/screenSize';
2018-06-01 12:35:51 +00:00
export default {
name: 'App',
data() {
return {
activeScreen: null
};
},
watch: {
activeScreen(value) {
if (!value) return;
2020-01-23 12:58:51 +00:00
let { width, height } = getMainWindowSize();
let size = {
2020-01-23 12:58:51 +00:00
Desk: [width, height],
DatabaseSelector: [600, 600],
SetupWizard: [600, 600],
Settings: [460, 577]
}[value];
let resizable = value === 'Desk';
let win = remote.getCurrentWindow();
if (size.length) {
win.setSize(...size);
win.setResizable(resizable);
}
2019-10-19 14:26:13 +00:00
}
},
2018-06-01 12:35:51 +00:00
components: {
2018-10-23 12:42:36 +00:00
Desk,
2018-10-22 18:10:22 +00:00
SetupWizard,
2019-10-19 14:26:13 +00:00
DatabaseSelector,
Settings,
WindowsTitleBar
},
async mounted() {
let dbPath = localStorage.dbPath;
if (!dbPath) {
this.activeScreen = 'DatabaseSelector';
2018-10-23 12:42:36 +00:00
} else {
await connectToLocalDatabase(dbPath);
this.showSetupWizardOrDesk();
2018-10-23 12:42:36 +00:00
}
},
methods: {
showSetupWizardOrDesk() {
const { setupComplete } = frappe.AccountingSettings;
if (!setupComplete) {
this.activeScreen = 'SetupWizard';
} else if (this.$route.path.startsWith('/settings')) {
this.activeScreen = 'Settings';
2019-10-24 10:39:57 +00:00
} else {
this.activeScreen = 'Desk';
this.checkForUpdates();
2019-10-24 10:39:57 +00:00
}
},
reloadMainWindowOnSettingsClose() {
if (this.activeScreen === 'Settings') {
frappe.events.trigger('reload-main-window');
}
},
checkForUpdates() {
frappe.events.trigger('check-for-updates');
2018-10-23 12:42:36 +00:00
}
2018-06-01 12:35:51 +00:00
}
};
2018-06-01 12:35:51 +00:00
</script>