2024-11-15 19:35:11 +11:00
|
|
|
/*
|
|
|
|
DrCr: Web-based double-entry bookkeeping framework
|
|
|
|
Copyright (C) 2022–2024 Lee Yingtong Li (RunasSudo)
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Affero General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import { invoke } from '@tauri-apps/api/core';
|
2024-11-17 00:35:28 +11:00
|
|
|
import { WebviewWindow } from '@tauri-apps/api/webviewWindow';
|
2024-11-15 19:35:11 +11:00
|
|
|
|
|
|
|
import { createApp } from 'vue';
|
|
|
|
import { createRouter, createWebHistory } from 'vue-router';
|
|
|
|
|
|
|
|
import App from './App.vue';
|
|
|
|
|
|
|
|
import { db } from './db.ts';
|
|
|
|
|
|
|
|
async function initApp() {
|
|
|
|
// Init router
|
|
|
|
const routes = [
|
2024-11-16 15:39:44 +11:00
|
|
|
{ path: '/', name: 'index', component: () => import('./pages/HomeView.vue') },
|
2024-11-22 18:12:40 +11:00
|
|
|
{ path: '/balance-assertions', name: 'balance-assertions', component: () => import('./pages/BalanceAssertionsView.vue') },
|
2024-11-22 01:24:14 +11:00
|
|
|
{ path: '/chart-of-accounts', name: 'chart-of-accounts', component: () => import('./pages/ChartOfAccountsView.vue') },
|
2024-11-16 15:39:44 +11:00
|
|
|
{ path: '/general-ledger', name: 'general-ledger', component: () => import('./pages/GeneralLedgerView.vue') },
|
2024-11-16 21:35:39 +11:00
|
|
|
{ path: '/journal', name: 'journal', component: () => import('./pages/JournalView.vue') },
|
2024-11-17 00:35:28 +11:00
|
|
|
{ path: '/journal/edit-transaction/:id', name: 'journal-edit-transaction', component: () => import('./pages/EditTransactionView.vue') },
|
2024-11-17 02:24:20 +11:00
|
|
|
{ path: '/journal/new-transaction', name: 'journal-new-transaction', component: () => import('./pages/NewTransactionView.vue') },
|
2024-11-17 18:43:28 +11:00
|
|
|
{ path: '/statement-lines', name: 'statement-lines', component: () => import('./pages/StatementLinesView.vue') },
|
2024-11-18 16:54:50 +11:00
|
|
|
{ path: '/statement-lines/import', name: 'import-statement', component: () => import('./pages/ImportStatementView.vue') },
|
2024-11-16 15:39:44 +11:00
|
|
|
{ path: '/transactions/:account', name: 'transactions', component: () => import('./pages/TransactionsView.vue') },
|
|
|
|
{ path: '/trial-balance', name: 'trial-balance', component: () => import('./pages/TrialBalanceView.vue') },
|
2024-11-15 19:35:11 +11:00
|
|
|
];
|
|
|
|
const router = createRouter({
|
|
|
|
history: createWebHistory(),
|
|
|
|
routes,
|
|
|
|
});
|
|
|
|
|
|
|
|
// Init state
|
|
|
|
const dbFilename: string = await invoke('get_open_filename');
|
|
|
|
if (dbFilename !== null) {
|
2024-11-16 01:20:18 +11:00
|
|
|
await db.init(dbFilename); // Ensure all metadata cached before loading Vue
|
2024-11-15 19:35:11 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create Vue app
|
|
|
|
createApp(App).use(router).mount('#app');
|
|
|
|
}
|
|
|
|
|
2024-11-17 00:35:28 +11:00
|
|
|
(window as any).openLinkInNewWindow = function(link: HTMLAnchorElement) {
|
|
|
|
const webview = new WebviewWindow('dialog' + +new Date(), {
|
|
|
|
url: link.href,
|
|
|
|
});
|
|
|
|
webview.once('tauri://error', function(e) {
|
|
|
|
console.error(e);
|
|
|
|
});
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2024-11-15 19:35:11 +11:00
|
|
|
initApp();
|