2
0
mirror of https://github.com/frappe/books.git synced 2024-11-14 09:24:04 +00:00

Merge pull request #395 from 18alantom/platform-specific-fixes

fix: platform specific, post build fixes
This commit is contained in:
Alan 2022-05-28 20:36:59 +05:30 committed by GitHub
commit 8d3dba7687
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 177 additions and 139 deletions

View File

@ -29,6 +29,8 @@ export async function setupDummyInstance(
baseCount: number = 1000, baseCount: number = 1000,
notifier?: Notifier notifier?: Notifier
) { ) {
fyo.store.skipTelemetryLogging = true;
fyo.purgeCache(); fyo.purgeCache();
notifier?.(fyo.t`Setting Up Instance`, -1); notifier?.(fyo.t`Setting Up Instance`, -1);
const options = { const options = {
@ -55,6 +57,8 @@ export async function setupDummyInstance(
ModelNameEnum.SystemSettings, ModelNameEnum.SystemSettings,
'instanceId' 'instanceId'
)) as string; )) as string;
fyo.store.skipTelemetryLogging = false;
return { companyName: options.companyName, instanceId }; return { companyName: options.companyName, instanceId };
} }

View File

@ -223,6 +223,7 @@ export class Fyo {
store = { store = {
isDevelopment: false, isDevelopment: false,
skipTelemetryLogging: false,
appVersion: '', appVersion: '',
}; };
} }

View File

@ -63,20 +63,16 @@ export class TelemetryManager {
} }
async start(openCount?: number) { async start(openCount?: number) {
this.#telemetryObject.country ||= getCountry(this.fyo); await this.#init();
this.#telemetryObject.language ??= getLanguage(this.fyo);
this.#telemetryObject.deviceId ||= getDeviceId(this.fyo);
this.#telemetryObject.instanceId ||= await getInstanceId(this.fyo);
this.#telemetryObject.version ||= await getVersion(this.fyo);
this.#started = true; this.#started = true;
await this.#setCreds(); await this.#setCreds();
if (typeof openCount === 'number') { if (typeof openCount === 'number') {
this.#telemetryObject.openCount = openCount; this.#telemetryObject.openCount = openCount;
this.log(Verb.Started, 'telemetry'); this.log(Verb.Opened, 'instance');
} else { } else {
this.log(Verb.Resumed, 'telemetry'); this.log(Verb.Resumed, 'instance');
} }
} }
@ -85,7 +81,7 @@ export class TelemetryManager {
return; return;
} }
this.log(Verb.Stopped, 'telemetry'); this.log(Verb.Closed, 'instance');
this.#started = false; this.#started = false;
this.#clear(); this.#clear();
} }
@ -99,8 +95,14 @@ export class TelemetryManager {
this.#sendBeacon(verb, noun, more); this.#sendBeacon(verb, noun, more);
} }
async logOpened() {
await this.#init();
await this.#setCreds();
this.#sendBeacon(Verb.Opened, 'app');
}
#sendBeacon(verb: Verb, noun: Noun, more?: Record<string, unknown>) { #sendBeacon(verb: Verb, noun: Noun, more?: Record<string, unknown>) {
if (!this.hasCreds) { if (!this.hasCreds || this.fyo.store.skipTelemetryLogging) {
return; return;
} }
@ -123,6 +125,21 @@ export class TelemetryManager {
this.#token = tokenString; this.#token = tokenString;
} }
async #init() {
this.#telemetryObject.language ??= getLanguage(this.fyo);
this.#telemetryObject.deviceId ||= getDeviceId(this.fyo);
this.#telemetryObject.version = this.fyo.store.appVersion;
if (this.fyo.db.dbPath) {
this.#telemetryObject.country ||= getCountry(this.fyo);
this.#telemetryObject.instanceId ||= await getInstanceId(this.fyo);
this.#telemetryObject.version = await getVersion(this.fyo);
} else {
this.#telemetryObject.country ||= '';
this.#telemetryObject.instanceId ||= '';
}
}
#getTelemtryData( #getTelemtryData(
verb: Verb, verb: Verb,
noun: Noun, noun: Noun,

View File

@ -11,8 +11,8 @@ export enum Verb {
Cancelled = 'cancelled', Cancelled = 'cancelled',
Imported = 'imported', Imported = 'imported',
Exported = 'exported', Exported = 'exported',
Stopped = 'stopped', Closed = 'closed',
Started = 'started', Opened = 'opened',
Resumed = 'resumed', Resumed = 'resumed',
} }

12
main.ts
View File

@ -26,7 +26,7 @@ export class Main {
mainWindow: BrowserWindow | null = null; mainWindow: BrowserWindow | null = null;
WIDTH = 1200; WIDTH = 1200;
HEIGHT = 900; HEIGHT = process.platform === 'win32' ? 926 : 900;
constructor() { constructor() {
this.icon = this.isDevelopment this.icon = this.isDevelopment
@ -86,10 +86,18 @@ export class Main {
contextIsolation: false, // TODO: Switch this off contextIsolation: false, // TODO: Switch this off
nodeIntegration: true, nodeIntegration: true,
}, },
frame: this.isLinux, autoHideMenuBar: true,
frame: !this.isMac,
resizable: true, resizable: true,
}; };
if (!this.isMac) {
options.titleBarOverlay = {
color: '#FFFFFF',
height: 26,
};
}
if (this.isDevelopment || this.isLinux) { if (this.isDevelopment || this.isLinux) {
Object.assign(options, { icon: this.icon }); Object.assign(options, { icon: this.icon });
} }

View File

@ -16,17 +16,6 @@ import {
import { saveHtmlAsPdf } from './saveHtmlAsPdf'; import { saveHtmlAsPdf } from './saveHtmlAsPdf';
export default function registerIpcMainActionListeners(main: Main) { export default function registerIpcMainActionListeners(main: Main) {
ipcMain.handle(IPC_ACTIONS.TOGGLE_MAXIMIZE_CURRENT_WINDOW, (event) => {
const maximized = main.mainWindow!.isFullScreen();
if (maximized) {
main.mainWindow?.setFullScreen(false);
main.mainWindow?.setSize(main.WIDTH, main.HEIGHT, true);
} else {
main.mainWindow?.setFullScreen(true);
}
return maximized;
});
ipcMain.handle(IPC_ACTIONS.GET_OPEN_FILEPATH, async (event, options) => { ipcMain.handle(IPC_ACTIONS.GET_OPEN_FILEPATH, async (event, options) => {
return await dialog.showOpenDialog(main.mainWindow!, options); return await dialog.showOpenDialog(main.mainWindow!, options);
}); });

View File

@ -20,14 +20,6 @@ export default function registerIpcMainMessageListeners(main: Main) {
main.mainWindow!.reload(); main.mainWindow!.reload();
}); });
ipcMain.on(IPC_MESSAGES.CLOSE_CURRENT_WINDOW, () => {
main.mainWindow!.close();
});
ipcMain.on(IPC_MESSAGES.MINIMIZE_CURRENT_WINDOW, () => {
main.mainWindow!.minimize();
});
ipcMain.on(IPC_MESSAGES.OPEN_EXTERNAL, (_, link) => { ipcMain.on(IPC_MESSAGES.OPEN_EXTERNAL, (_, link) => {
shell.openExternal(link); shell.openExternal(link);
}); });

View File

@ -3,8 +3,11 @@
id="app" id="app"
class="h-screen flex flex-col font-sans overflow-hidden antialiased" class="h-screen flex flex-col font-sans overflow-hidden antialiased"
> >
<WindowsTitleBar v-if="platform === 'Windows'" /> <WindowsTitleBar
v-if="platform === 'Windows'"
:db-path="dbPath"
:company-name="companyName"
/>
<!-- Main Contents --> <!-- Main Contents -->
<Desk <Desk
class="flex-1" class="flex-1"
@ -52,6 +55,8 @@ export default {
data() { data() {
return { return {
activeScreen: null, activeScreen: null,
dbPath: '',
companyName: '',
}; };
}, },
components: { components: {
@ -61,8 +66,6 @@ export default {
WindowsTitleBar, WindowsTitleBar,
}, },
async mounted() { async mounted() {
fyo.telemetry.platform = this.platform;
const lastSelectedFilePath = fyo.config.get( const lastSelectedFilePath = fyo.config.get(
ConfigKeys.LastSelectedFilePath, ConfigKeys.LastSelectedFilePath,
null null
@ -76,7 +79,7 @@ export default {
await this.fileSelected(lastSelectedFilePath, false); await this.fileSelected(lastSelectedFilePath, false);
} catch (err) { } catch (err) {
await handleErrorWithDialog(err, undefined, true, true); await handleErrorWithDialog(err, undefined, true, true);
await this.showDbSelector() await this.showDbSelector();
} }
}, },
methods: { methods: {
@ -86,6 +89,11 @@ export default {
const openCount = await incrementOpenCount(filePath); const openCount = await incrementOpenCount(filePath);
await fyo.telemetry.start(openCount); await fyo.telemetry.start(openCount);
await checkForUpdates(false); await checkForUpdates(false);
this.dbPath = filePath;
this.companyName = await fyo.getValue(
ModelNameEnum.AccountingSettings,
'companyName'
);
}, },
async fileSelected(filePath, isNew) { async fileSelected(filePath, isNew) {
fyo.config.set(ConfigKeys.LastSelectedFilePath, filePath); fyo.config.set(ConfigKeys.LastSelectedFilePath, filePath);
@ -130,6 +138,8 @@ export default {
fyo.telemetry.stop(); fyo.telemetry.stop();
fyo.purgeCache(); fyo.purgeCache();
this.activeScreen = 'DatabaseSelector'; this.activeScreen = 'DatabaseSelector';
this.dbPath = '';
this.companyName = '';
}, },
}, },
}; };

View File

@ -77,7 +77,8 @@
text-xs text-gray-600 text-xs text-gray-600
font-semibold font-semibold
whitespace-nowrap whitespace-nowrap
overflow-x-scroll overflow-x-auto
no-scrollbar
" "
> >
{{ {{

View File

@ -17,7 +17,7 @@
/> />
<div <div
v-show="!showInput" v-show="!showInput"
:class="[inputClasses, 'cursor-text whitespace-nowrap overflow-x-scroll']" :class="[inputClasses, 'cursor-text whitespace-nowrap overflow-x-auto']"
@click="activateInput" @click="activateInput"
@focus="activateInput" @focus="activateInput"
tabindex="0" tabindex="0"

View File

@ -0,0 +1,29 @@
<template>
<svg
width="19"
height="13"
viewBox="0 0 19 13"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M9.25935 12.128V0.727295H13.8241C14.6628 0.727295 15.3624 0.851619 15.9227 1.10027C16.4831 1.34892 16.9043 1.69405 17.1864 2.13568C17.4684 2.5736 17.6095 3.07832 17.6095 3.64984C17.6095 4.09518 17.5204 4.4867 17.3423 4.82442C17.1641 5.15843 16.9192 5.43305 16.6075 5.6483C16.2994 5.85984 15.9469 6.01014 15.5498 6.09921V6.21054C15.984 6.2291 16.3904 6.35156 16.7689 6.57795C17.1511 6.80433 17.461 7.12163 17.6985 7.52986C17.9361 7.93438 18.0548 8.41683 18.0548 8.97721C18.0548 9.58213 17.9045 10.1221 17.6039 10.5971C17.307 11.0685 16.8672 11.4414 16.2846 11.7161C15.7019 11.9907 14.9838 12.128 14.1303 12.128H9.25935ZM11.6698 10.1574H13.6348C14.3065 10.1574 14.7964 10.0293 15.1044 9.77326C15.4125 9.51348 15.5665 9.16834 15.5665 8.73784C15.5665 8.42239 15.4904 8.14406 15.3382 7.90283C15.1861 7.66161 14.969 7.47234 14.6869 7.33502C14.4086 7.19771 14.0764 7.12905 13.6905 7.12905H11.6698V10.1574ZM11.6698 5.498H13.4567C13.787 5.498 14.0802 5.44047 14.3362 5.32543C14.596 5.20667 14.8001 5.03967 14.9486 4.82442C15.1007 4.60917 15.1768 4.35125 15.1768 4.05064C15.1768 3.6387 15.0302 3.30655 14.737 3.05419C14.4476 2.80184 14.0356 2.67566 13.5012 2.67566H11.6698V5.498Z"
fill="#505A62"
/>
<path
d="M7.73114 2.75564V0.75855H0.0548096V2.75564H7.73114Z"
fill="#0089FF"
/>
<path
d="M2.48876 7.43646H7.35669V5.43935H0.0548096V12.1796H2.48876V7.43646Z"
fill="#0089FF"
/>
</svg>
</template>
<script>
import Base from '../base';
export default {
name: 'FB',
extends: Base,
};
</script>

View File

@ -16,7 +16,7 @@
text-gray-600 text-base text-gray-600 text-base
px-3 px-3
flex-shrink-0 flex-shrink-0
overflow-x-scroll overflow-x-auto
whitespace-nowrap whitespace-nowrap
" "
> >
@ -50,7 +50,7 @@
text-gray-900 text-base text-gray-900 text-base
px-3 px-3
flex-shrink-0 flex-shrink-0
overflow-x-scroll overflow-x-auto
whitespace-nowrap whitespace-nowrap
" "
> >

View File

@ -20,7 +20,7 @@
> >
<feather-icon name="search" class="w-4 h-4" /> <feather-icon name="search" class="w-4 h-4" />
<p>{{ t`Search` }}</p> <p>{{ t`Search` }}</p>
<div v-if="!inputValue" class="text-gray-500 ml-auto"> <div v-if="!inputValue" class="text-gray-400 ml-auto text-sm">
{{ modKey('k') }} {{ modKey('k') }}
</div> </div>
</button> </button>
@ -58,7 +58,7 @@
<hr v-if="suggestions.length" /> <hr v-if="suggestions.length" />
<!-- Search List --> <!-- Search List -->
<div :style="`max-height: ${49 * 6 - 1}px`" class="overflow-scroll"> <div :style="`max-height: ${49 * 6 - 1}px`" class="overflow-auto">
<div <div
v-for="(si, i) in suggestions" v-for="(si, i) in suggestions"
:key="`${i}-${si.key}`" :key="`${i}-${si.key}`"

View File

@ -7,13 +7,16 @@
> >
<div> <div>
<!-- Company name and DB Switcher --> <!-- Company name and DB Switcher -->
<div class="px-2 flex flex-row items-center justify-between mb-6 mt-12"> <div
class="px-2 flex flex-row items-center justify-between mb-4"
:class="platform === 'Mac' ? 'mt-10' : 'mt-2'"
>
<h6 <h6
class=" class="
text-xl text-xl
font-semibold font-semibold
whitespace-nowrap whitespace-nowrap
overflow-scroll overflow-auto
no-scrollbar no-scrollbar
select-none select-none
w-32 w-32

View File

@ -1,50 +1,24 @@
<template> <template>
<div class="bg-white text-base flex justify-between window-drag border-b">
<div <div
class="py-1 px-2 window-no-drag hover:bg-gray-100 cursor-pointer" class="window-drag flex items-center border-b text-gray-900 border-gray-100"
@click="openMenu" style="height: 28px"
> >
<feather-icon name="menu" class="w-4 h-4" /> <Fb class="ml-2" />
</div> <p class="mx-auto text-sm" v-if="companyName && dbPath">
<div class="flex window-no-drag"> {{ companyName }} - {{ dbPath }}
<div </p>
class="py-1 px-2 hover:bg-gray-100 cursor-pointer"
@click="action('minimize')"
>
<feather-icon name="minus" class="w-4 h-4" />
</div>
<div
class="flex-center py-1 px-2 hover:bg-gray-100 cursor-pointer"
@click="action('maximize')"
>
<feather-icon name="square" class="w-3 h-3" />
</div>
<div
class="py-1 px-2 hover:bg-red-500 hover:text-white cursor-pointer"
@click="action('close')"
>
<feather-icon name="x" class="w-4 h-4" />
</div>
</div>
</div> </div>
</template> </template>
<script> <script>
import { ipcRenderer } from 'electron'; import Fb from './Icons/18/fb.vue';
import { runWindowAction } from 'src/utils/ipcCalls';
import { IPC_MESSAGES } from 'utils/messages';
export default { export default {
name: 'WindowsTitleBar', name: 'WindowsTitleBar',
emits: ['close', 'minimize', 'maximize', 'unmaximize'], components: { Fb },
methods: { props: {
async action(name) { dbPath: String,
const actionRan = await runWindowAction(name); companyName: String,
this.$emit(actionRan);
},
openMenu() {
ipcRenderer.send(IPC_MESSAGES.OPEN_MENU);
},
}, },
}; };
</script> </script>

View File

@ -2,7 +2,7 @@
<div class="flex flex-col"> <div class="flex flex-col">
<PageHeader :title="t`Dashboard`" /> <PageHeader :title="t`Dashboard`" />
<div class="mx-4 overflow-y-scroll no-scrollbar flex flex-col gap-8"> <div class="mx-4 overflow-y-auto no-scrollbar flex flex-col gap-8">
<Cashflow class="" /> <Cashflow class="" />
<hr /> <hr />
<UnpaidInvoices /> <UnpaidInvoices />

View File

@ -18,7 +18,7 @@
@mouseleave="active = null" @mouseleave="active = null"
> >
<div class="w-3 h-3 rounded-sm flex-shrink-0" :class="d.class" /> <div class="w-3 h-3 rounded-sm flex-shrink-0" :class="d.class" />
<p class="ml-2 overflow-x-scroll whitespace-nowrap no-scrollbar w-28"> <p class="ml-2 overflow-x-auto whitespace-nowrap no-scrollbar w-28">
{{ d.account }} {{ d.account }}
</p> </p>
<p class="whitespace-nowrap flex-shrink-0 ml-auto"> <p class="whitespace-nowrap flex-shrink-0 ml-auto">

View File

@ -127,7 +127,7 @@
<div v-if="fileName" class="pb-4"> <div v-if="fileName" class="pb-4">
<h2 class="text-lg font-semibold">{{ t`Assign Imported Labels` }}</h2> <h2 class="text-lg font-semibold">{{ t`Assign Imported Labels` }}</h2>
<div <div
class="gap-2 mt-4 grid grid-flow-col overflow-x-scroll no-scrollbar" class="gap-2 mt-4 grid grid-flow-col overflow-x-auto no-scrollbar"
> >
<div <div
v-for="(f, k) in importer.assignableLabels" v-for="(f, k) in importer.assignableLabels"
@ -165,7 +165,7 @@
{{ t`Verify Imported Data` }} {{ t`Verify Imported Data` }}
</h2> </h2>
<div class="overflow-scroll mt-4 pb-4"> <div class="overflow-auto mt-4 pb-4">
<!-- Column Name Rows --> <!-- Column Name Rows -->
<div <div
class="grid grid-flow-col pb-4 border-b gap-2 sticky top-0 bg-white" class="grid grid-flow-col pb-4 border-b gap-2 sticky top-0 bg-white"
@ -280,7 +280,7 @@
<p class="text-lg text-center"> <p class="text-lg text-center">
{{ t`Successfully created the following ${names.length} entries:` }} {{ t`Successfully created the following ${names.length} entries:` }}
</p> </p>
<div class="max-h-96 overflow-y-scroll"> <div class="max-h-96 overflow-y-auto">
<div <div
v-for="(n, i) in names" v-for="(n, i) in names"
:key="'name-' + i" :key="'name-' + i"

View File

@ -65,7 +65,7 @@
<hr /> <hr />
<!-- File List --> <!-- File List -->
<div class="overflow-scroll" style="max-height: 340px"> <div class="overflow-y-auto" style="max-height: 340px">
<div <div
class="h-18 px-6 flex gap-4 items-center" class="h-18 px-6 flex gap-4 items-center"
:class="creatingDemo ? '' : 'hover:bg-gray-100 cursor-pointer'" :class="creatingDemo ? '' : 'hover:bg-gray-100 cursor-pointer'"
@ -84,18 +84,31 @@
bg-gray-200 bg-gray-200
text-gray-500 text-gray-500
font-semibold font-semibold
flex-shrink-0
text-base text-base
" "
> >
{{ i + 1 }} {{ i + 1 }}
</div> </div>
<div> <div class="w-full">
<p class="font-medium"> <p class="font-medium">
{{ file.companyName }} {{ file.companyName }}
</p> </p>
<p class="text-sm text-gray-600"> <div
class="
text-sm text-gray-600
flex
justify-between
overflow-x-scroll
"
>
<p class="whitespace-nowrap mr-2">
{{ formatDate(file.modified) }} {{ formatDate(file.modified) }}
</p> </p>
<p class="text-right" v-if="fyo.store.isDevelopment">
{{ file.dbPath }}
</p>
</div>
</div> </div>
<button <button
class=" class="
@ -230,7 +243,7 @@ export default {
} }
this.creatingDemo = true; this.creatingDemo = true;
const baseCount = fyo.store.isDevelopment ? 1000 : 150; const baseCount = fyo.store.isDevelopment ? 1000 : 100;
const { companyName, instanceId } = await setupDummyInstance( const { companyName, instanceId } = await setupDummyInstance(
filePath, filePath,

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="flex flex-col overflow-y-hidden"> <div class="flex flex-col overflow-y-hidden">
<PageHeader :title="t`Setup Your Workspace`" /> <PageHeader :title="t`Setup Your Workspace`" />
<div class="flex-1 mx-4 overflow-y-auto"> <div class="flex-1 mx-4 overflow-y-auto overflow-x-hidden">
<div class="my-4" v-for="section in sections" :key="section.label"> <div class="my-4" v-for="section in sections" :key="section.label">
<h2 class="font-medium">{{ section.label }}</h2> <h2 class="font-medium">{{ section.label }}</h2>
<div class="flex mt-4 -mx-2"> <div class="flex mt-4 -mx-2">
@ -14,7 +14,7 @@
class=" class="
flex flex-col flex flex-col
justify-between justify-between
h-full h-40
p-4 p-4
border border
rounded-lg rounded-lg

View File

@ -11,7 +11,7 @@
<div <div
v-for="(column, i) in columns" v-for="(column, i) in columns"
:key="column.label" :key="column.label"
class="py-4 overflow-x-scroll whitespace-nowrap" class="py-4 overflow-x-auto no-scrollbar whitespace-nowrap"
:class="{ :class="{
'text-right': isNumeric(column.fieldtype), 'text-right': isNumeric(column.fieldtype),
'pr-4': i === columns.length - 1, 'pr-4': i === columns.length - 1,

View File

@ -93,16 +93,13 @@ export default {
const html = document.createElement('html'); const html = document.createElement('html');
const head = document.createElement('head'); const head = document.createElement('head');
const body = document.createElement('body'); const body = document.createElement('body');
const style = document.getElementsByTagName('style'); const style = getAllCSSAsStyleElem();
const styleTags = Array.from(style)
.map((s) => s.outerHTML)
.join('\n');
head.innerHTML = [ head.innerHTML = [
'<meta charset="UTF-8">', '<meta charset="UTF-8">',
'<title>Print Window</title>', '<title>Print Window</title>',
styleTags,
].join('\n'); ].join('\n');
head.append(style);
body.innerHTML = this.$refs.printContainer.innerHTML; body.innerHTML = this.$refs.printContainer.innerHTML;
html.append(head, body); html.append(head, body);
@ -112,8 +109,7 @@ export default {
const savePath = await this.getSavePath(); const savePath = await this.getSavePath();
if (!savePath) return; if (!savePath) return;
const html = this.constructPrintDocument();
const html = this.constructPrintDocument()
await makePDF(html, savePath); await makePDF(html, savePath);
fyo.telemetry.log(Verb.Exported, 'SalesInvoice', { extension: 'pdf' }); fyo.telemetry.log(Verb.Exported, 'SalesInvoice', { extension: 'pdf' });
}, },
@ -138,4 +134,21 @@ export default {
}, },
}, },
}; };
function getAllCSSAsStyleElem() {
const cssTexts = [];
for (const sheet of document.styleSheets) {
for (const rule of sheet.cssRules) {
cssTexts.push(rule.cssText);
}
for (const rule of sheet.ownerRule ?? []) {
cssTexts.push(rule.cssText);
}
}
const styleElem = document.createElement('style');
styleElem.innerHTML = cssTexts.join('\n');
return styleElem;
}
</script> </script>

View File

@ -36,7 +36,7 @@
<div class="mt-2 text-xs">{{ tab.label }}</div> <div class="mt-2 text-xs">{{ tab.label }}</div>
</div> </div>
</div> </div>
<div class="flex-1 overflow-y-scroll"> <div class="flex-1 overflow-y-auto">
<component :is="activeTabComponent" @change="handleChange" /> <component :is="activeTabComponent" @change="handleChange" />
</div> </div>
</div> </div>

View File

@ -30,6 +30,7 @@ import { setLanguageMap } from './utils/language';
fyo.store.isDevelopment = isDevelopment; fyo.store.isDevelopment = isDevelopment;
fyo.store.appVersion = version; fyo.store.appVersion = version;
const platformName = getPlatformName(platform);
setOnWindow(isDevelopment); setOnWindow(isDevelopment);
@ -50,16 +51,7 @@ import { setLanguageMap } from './utils/language';
return fyo; return fyo;
}, },
platform() { platform() {
switch (platform) { return platformName;
case 'win32':
return 'Windows';
case 'darwin':
return 'Mac';
case 'linux':
return 'Linux';
default:
return 'Linux';
}
}, },
}, },
methods: { methods: {
@ -68,6 +60,8 @@ import { setLanguageMap } from './utils/language';
}, },
}); });
fyo.telemetry.platform = platformName;
await fyo.telemetry.logOpened();
app.mount('body'); app.mount('body');
})(); })();
@ -106,3 +100,16 @@ function setOnWindow(isDevelopment: boolean) {
// @ts-ignore // @ts-ignore
window.DateTime = DateTime; window.DateTime = DateTime;
} }
function getPlatformName(platform: string) {
switch (platform) {
case 'win32':
return 'Windows';
case 'darwin':
return 'Mac';
case 'linux':
return 'Linux';
default:
return 'Linux';
}
}

View File

@ -39,26 +39,6 @@ export async function makePDF(html: string, savePath: string) {
} }
} }
export async function runWindowAction(name: WindowAction) {
switch (name) {
case 'close':
ipcRenderer.send(IPC_MESSAGES.CLOSE_CURRENT_WINDOW);
break;
case 'minimize':
ipcRenderer.send(IPC_MESSAGES.MINIMIZE_CURRENT_WINDOW);
break;
case 'maximize':
const maximized = await ipcRenderer.invoke(
IPC_ACTIONS.TOGGLE_MAXIMIZE_CURRENT_WINDOW
);
name = maximized ? 'unmaximize' : name;
break;
default:
throw new Error(`invalid window action ${name}`);
}
return name;
}
export function showExportInFolder(message: string, filePath: string) { export function showExportInFolder(message: string, filePath: string) {
showToast({ showToast({
message, message,

View File

@ -5,13 +5,10 @@ export enum IPC_MESSAGES {
OPEN_EXTERNAL = 'open-external', OPEN_EXTERNAL = 'open-external',
SHOW_ITEM_IN_FOLDER = 'show-item-in-folder', SHOW_ITEM_IN_FOLDER = 'show-item-in-folder',
RELOAD_MAIN_WINDOW = 'reload-main-window', RELOAD_MAIN_WINDOW = 'reload-main-window',
CLOSE_CURRENT_WINDOW = 'close-current-window',
MINIMIZE_CURRENT_WINDOW = 'minimize-current-window',
} }
// ipcRenderer.invoke(...) // ipcRenderer.invoke(...)
export enum IPC_ACTIONS { export enum IPC_ACTIONS {
TOGGLE_MAXIMIZE_CURRENT_WINDOW = 'toggle-maximize-current-window',
GET_OPEN_FILEPATH = 'open-dialog', GET_OPEN_FILEPATH = 'open-dialog',
GET_SAVE_FILEPATH = 'save-dialog', GET_SAVE_FILEPATH = 'save-dialog',
GET_DIALOG_RESPONSE = 'show-message-box', GET_DIALOG_RESPONSE = 'show-message-box',