This commit is contained in:
Lyz Coote
2026-02-02 21:52:13 +01:00
parent d6a5cb8a67
commit 0f71cd3e0a
30 changed files with 3949 additions and 93 deletions

View File

@@ -49,10 +49,14 @@
<Sidebar.Root style="opacity: 0.8;">
<Sidebar.Header>
<div
class="sidebar-title"
class="sidebar-title items-center justify-center p-3 border-b border-white/10"
style="padding: 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); display: flex; justify-content: center;"
>
<img src="/logo.png" alt="Logo" />
<img src="/appicon.png" alt="Logo" width="64" height="64" />
<span
class="font-bold text-lg mt-2 pl-3"
style="font-family: system-ui, sans-serif;">EMLy by 3gIT</span
>
</div>
</Sidebar.Header>
<Sidebar.Content>

View File

@@ -1,6 +1,6 @@
<script lang="ts">
import { X, MailOpen, Image, FileText, File } from "@lucide/svelte";
import { ShowOpenFileDialog, ReadEML, OpenPDF, OpenImageWindow } from "$lib/wailsjs/go/main/App";
import { ShowOpenFileDialog, ReadEML, OpenPDF, OpenImageWindow, OpenPDFWindow, OpenImage } from "$lib/wailsjs/go/main/App";
import type { internal } from "$lib/wailsjs/go/models";
import { sidebarOpen } from "$lib/stores/app";
import { onDestroy, onMount } from "svelte";
@@ -23,6 +23,7 @@
if(mailState.currentEmail !== null) {
sidebarOpen.set(false);
}
console.log(mailState.currentEmail?.attachments)
})
onDestroy(() => {
@@ -55,13 +56,30 @@
async function openPDFHandler(base64Data: string, filename: string) {
try {
await OpenPDF(base64Data, filename);
if (settingsStore.settings.useBuiltinPDFViewer) {
await OpenPDFWindow(base64Data, filename);
} else {
await OpenPDF(base64Data, filename);
}
} catch (error) {
console.error("Failed to open PDF:", error);
toast.error(m.mail_error_pdf());
}
}
async function openImageHandler(base64Data: string, filename: string) {
try {
if (settingsStore.settings.useBuiltinPreview) {
await OpenImageWindow(base64Data, filename);
} else {
await OpenImage(base64Data, filename);
}
} catch (error) {
console.error("Failed to open image:", error);
toast.error(m.mail_error_image());
}
}
async function onOpenMail() {
isLoading = true;
const result = await ShowOpenFileDialog();
@@ -177,10 +195,10 @@
<div class="att-list">
{#if mailState.currentEmail.attachments && mailState.currentEmail.attachments.length > 0}
{#each mailState.currentEmail.attachments as att}
{#if att.contentType.startsWith("image/") && shouldPreview(att.filename)}
{#if att.contentType.startsWith("image/")}
<button
class="att-btn image"
onclick={() => OpenImageWindow(arrayBufferToBase64(att.data), att.filename)}
onclick={() => openImageHandler(arrayBufferToBase64(att.data), att.filename)}
>
<Image size="14" />
<span class="att-name">{att.filename}</span>

View File

@@ -1,8 +1,6 @@
import { writable } from "svelte/store";
import { browser } from "$app/environment";
export const telemetryEnabled = writable<boolean>(false);
const storedDebug = browser ? sessionStorage.getItem("debugWindowInSettings") === "true" : false;
export const dangerZoneEnabled = writable<boolean>(storedDebug);
export const unsavedChanges = writable<boolean>(false);

View File

@@ -5,6 +5,7 @@ type SupportedFileTypePreview = "jpg" | "jpeg" | "png";
interface EMLy_GUI_Settings {
selectedLanguage: SupportedLanguages = "en" | "it";
useBuiltinPreview: boolean;
useBuiltinPDFViewer?: boolean;
previewFileSupportedTypes?: SupportedFileTypePreview[];
}

View File

@@ -10,4 +10,4 @@ export type WithoutChild<T> = T extends { child?: any } ? Omit<T, "child"> : T;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type WithoutChildren<T> = T extends { children?: any } ? Omit<T, "children"> : T;
export type WithoutChildrenOrChild<T> = WithoutChildren<WithoutChild<T>>;
export type WithElementRef<T, U extends HTMLElement = HTMLElement> = T & { ref?: U | null };
export type WithElementRef<T, U extends HTMLElement = HTMLElement> = T & { ref?: U | null };

View File

@@ -12,14 +12,22 @@ export function GetImageViewerData():Promise<main.ImageViewerData>;
export function GetMachineData():Promise<utils.MachineInfo>;
export function GetPDFViewerData():Promise<main.PDFViewerData>;
export function GetStartupFile():Promise<string>;
export function GetViewerData():Promise<main.ViewerData>;
export function OpenDefaultAppsSettings():Promise<void>;
export function OpenImage(arg1:string,arg2:string):Promise<void>;
export function OpenImageWindow(arg1:string,arg2:string):Promise<void>;
export function OpenPDF(arg1:string,arg2:string):Promise<void>;
export function OpenPDFWindow(arg1:string,arg2:string):Promise<void>;
export function QuitApp():Promise<void>;
export function ReadEML(arg1:string):Promise<internal.EmailData>;

View File

@@ -18,14 +18,26 @@ export function GetMachineData() {
return window['go']['main']['App']['GetMachineData']();
}
export function GetPDFViewerData() {
return window['go']['main']['App']['GetPDFViewerData']();
}
export function GetStartupFile() {
return window['go']['main']['App']['GetStartupFile']();
}
export function GetViewerData() {
return window['go']['main']['App']['GetViewerData']();
}
export function OpenDefaultAppsSettings() {
return window['go']['main']['App']['OpenDefaultAppsSettings']();
}
export function OpenImage(arg1, arg2) {
return window['go']['main']['App']['OpenImage'](arg1, arg2);
}
export function OpenImageWindow(arg1, arg2) {
return window['go']['main']['App']['OpenImageWindow'](arg1, arg2);
}
@@ -34,6 +46,10 @@ export function OpenPDF(arg1, arg2) {
return window['go']['main']['App']['OpenPDF'](arg1, arg2);
}
export function OpenPDFWindow(arg1, arg2) {
return window['go']['main']['App']['OpenPDFWindow'](arg1, arg2);
}
export function QuitApp() {
return window['go']['main']['App']['QuitApp']();
}

View File

@@ -252,6 +252,52 @@ export namespace main {
this.filename = source["filename"];
}
}
export class PDFViewerData {
data: string;
filename: string;
static createFrom(source: any = {}) {
return new PDFViewerData(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.data = source["data"];
this.filename = source["filename"];
}
}
export class ViewerData {
imageData?: ImageViewerData;
pdfData?: PDFViewerData;
static createFrom(source: any = {}) {
return new ViewerData(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.imageData = this.convertValues(source["imageData"], ImageViewerData);
this.pdfData = this.convertValues(source["pdfData"], PDFViewerData);
}
convertValues(a: any, classs: any, asMap: boolean = false): any {
if (!a) {
return a;
}
if (a.slice && a.map) {
return (a as any[]).map(elem => this.convertValues(elem, classs));
} else if ("object" === typeof a) {
if (asMap) {
for (const key of Object.keys(a)) {
a[key] = new classs(a[key]);
}
return a;
}
return new classs(a);
}
return a;
}
}
}