2018-06-01 12:35:51 +00:00
|
|
|
<template>
|
2019-12-16 11:34:22 +00:00
|
|
|
<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)"
|
2019-12-16 11:34:22 +00:00
|
|
|
@close="reloadMainWindowOnSettingsClose"
|
|
|
|
/>
|
2020-01-01 08:11:57 +00:00
|
|
|
<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'" />
|
2019-12-11 09:05:46 +00:00
|
|
|
<portal-target name="popovers" multiple></portal-target>
|
2018-06-01 12:35:51 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2019-10-03 13:46:12 +00:00
|
|
|
import './styles/index.css';
|
2019-12-12 17:40:34 +00:00
|
|
|
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';
|
2019-12-16 11:34:22 +00:00
|
|
|
import WindowsTitleBar from '@/components/WindowsTitleBar';
|
2019-10-13 12:03:01 +00:00
|
|
|
import { remote } from 'electron';
|
2020-01-01 08:11:57 +00:00
|
|
|
import { connectToLocalDatabase } from '@/utils';
|
2018-06-01 12:35:51 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'App',
|
2018-06-11 09:46:25 +00:00
|
|
|
data() {
|
|
|
|
return {
|
2020-01-01 08:11:57 +00:00
|
|
|
activeScreen: null
|
2019-08-20 08:57:27 +00:00
|
|
|
};
|
2018-06-11 09:46:25 +00:00
|
|
|
},
|
2019-10-13 12:03:01 +00:00
|
|
|
watch: {
|
2020-01-01 08:11:57 +00:00
|
|
|
activeScreen(value) {
|
|
|
|
if (!value) return;
|
|
|
|
let size = {
|
|
|
|
Desk: [1200, 907],
|
|
|
|
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-13 12:03:01 +00:00
|
|
|
}
|
2019-10-19 14:26:13 +00:00
|
|
|
}
|
2019-10-13 12:03:01 +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,
|
2019-12-16 11:34:22 +00:00
|
|
|
Settings,
|
|
|
|
WindowsTitleBar
|
2018-06-11 09:46:25 +00:00
|
|
|
},
|
2020-01-01 08:11:57 +00:00
|
|
|
async mounted() {
|
|
|
|
let dbPath = localStorage.dbPath;
|
|
|
|
if (!dbPath) {
|
|
|
|
this.activeScreen = 'DatabaseSelector';
|
2018-10-23 12:42:36 +00:00
|
|
|
} else {
|
2020-01-01 08:11:57 +00:00
|
|
|
await connectToLocalDatabase(dbPath);
|
|
|
|
this.showSetupWizardOrDesk();
|
2018-10-23 12:42:36 +00:00
|
|
|
}
|
2020-01-01 08:11:57 +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 {
|
2020-01-01 08:11:57 +00:00
|
|
|
this.activeScreen = 'Desk';
|
2019-12-27 06:37:39 +00:00
|
|
|
this.checkForUpdates();
|
2019-10-24 10:39:57 +00:00
|
|
|
}
|
2019-12-16 11:34:22 +00:00
|
|
|
},
|
|
|
|
reloadMainWindowOnSettingsClose() {
|
2020-01-01 08:11:57 +00:00
|
|
|
if (this.activeScreen === 'Settings') {
|
2019-12-16 11:34:22 +00:00
|
|
|
frappe.events.trigger('reload-main-window');
|
|
|
|
}
|
2019-12-27 06:37:39 +00:00
|
|
|
},
|
|
|
|
checkForUpdates() {
|
|
|
|
frappe.events.trigger('check-for-updates');
|
2018-10-23 12:42:36 +00:00
|
|
|
}
|
2018-06-01 12:35:51 +00:00
|
|
|
}
|
2019-08-20 08:57:27 +00:00
|
|
|
};
|
2018-06-01 12:35:51 +00:00
|
|
|
</script>
|