Compare commits
21 Commits
ea43cd715a
...
webview-re
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6a343769e5 | ||
|
|
33cb171fb1 | ||
|
|
549eed065a | ||
|
|
547018a39f | ||
|
|
18c256ebf9 | ||
|
|
3eb95cca7f | ||
|
|
6f373dd9ab | ||
|
|
eac7a12cd4 | ||
|
|
86e33d6189 | ||
|
|
402a90cf4b | ||
|
|
b68c173d2a | ||
|
|
fc98f0ed74 | ||
|
|
4c99c14be7 | ||
|
|
4b6f2d727c | ||
|
|
51679b61eb | ||
|
|
5b62790248 | ||
|
|
0cfe1b65f3 | ||
|
|
43cce905eb | ||
|
|
f1d603cc45 | ||
|
|
e9500209a8 | ||
|
|
44ee69051d |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -45,4 +45,5 @@ extra/*.dll
|
||||
|
||||
|
||||
*.eml
|
||||
*.msg
|
||||
*.msg
|
||||
frontend/bun.lock
|
||||
|
||||
35
CHANGELOG.md
Normal file
35
CHANGELOG.md
Normal file
@@ -0,0 +1,35 @@
|
||||
# Changelog EMLy
|
||||
|
||||
## 1.5.4 (2026-02-10)
|
||||
1) Aggiunti i pulsanti "Download" al MailViewer, PDF e Image viewer, per scaricare il file invece di aprirlo direttamente.
|
||||
2) Refactor del sistema di bug report.
|
||||
3) Rimosso temporaneamente il fetching dei dati macchina all'apertura della pagine delle impostazioni, per evitare problemi di performance.
|
||||
4) Fixato un bug dove, nel Bug Reporting, non si disattivaa il pulsante di invio, se tutti i campi erano compilati.
|
||||
5) Aggiunto il supprto all'allegare i file di localStorage e config.ini al Bug Report, per investigare meglio i problemi legati all'ambiente dell'utente.
|
||||
|
||||
|
||||
|
||||
## 1.5.3 (2026-02-10)
|
||||
1) Sistemato un bug dove, al primo avvio, il tema chiaro era applicato insieme all'opzioni del tema scuro sul contenuto mail, causando un contrasto eccessivo.
|
||||
|
||||
|
||||
|
||||
## 1.5.2 (2026-02-10)
|
||||
1) Supporto tema chiaro/scuro.
|
||||
2) Internazionalizzazione completa (Italiano/Inglese).
|
||||
3) Opzioni di accessibilità (riduzione animazioni, contrasto).
|
||||
|
||||
|
||||
## 1.5.1 (2026-02-09)
|
||||
1) Sistemato un bug del primo avvio, con mismatch della lingua.
|
||||
2) Aggiunto il supporto all'installazione sotto AppData/Local
|
||||
|
||||
|
||||
## 1.5.0 (2026-02-08)
|
||||
1) Sistema di aggiornamento automatico self-hosted (ancora non attivo di default).
|
||||
2) Sistema di bug report integrato.
|
||||
|
||||
|
||||
## 1.4.1 (2026-02-06)
|
||||
1) Export/Import impostazioni.
|
||||
2) Aggiornamento configurazione installer.
|
||||
@@ -55,6 +55,9 @@ Email parsing lives in `backend/utils/mail/`:
|
||||
- `msg_reader.go` - Microsoft MSG (CFB format) parsing
|
||||
- `mailparser.go` - MIME multipart handling
|
||||
|
||||
For any major change to backend functionality, add a new method to `App` and implement it in a new `app_*.go` file for organization.
|
||||
And update the DOCUMENTATION.md file in the root of the repository with a brief description of the new method and its purpose.
|
||||
|
||||
### Frontend Structure (SvelteKit + Svelte 5)
|
||||
|
||||
**Routes** (file-based routing):
|
||||
|
||||
@@ -45,6 +45,7 @@ EMLy is built using the **Wails v2** framework, which combines a Go backend with
|
||||
│ ├── app_bugreport.go - Bug reporting system │
|
||||
│ ├── app_settings.go - Settings import/export │
|
||||
│ ├── app_system.go - Windows system utilities │
|
||||
│ ├── app_update.go - Self-hosted update system │
|
||||
│ └── backend/utils/ - Shared utilities │
|
||||
└─────────────────────────────────────────────────────────┘
|
||||
```
|
||||
@@ -200,6 +201,7 @@ The Go backend is split into logical files:
|
||||
| `app_bugreport.go` | Bug reports: `CreateBugReportFolder`, `SubmitBugReport`, `zipFolder` |
|
||||
| `app_settings.go` | Settings I/O: `ExportSettings`, `ImportSettings` |
|
||||
| `app_system.go` | System utilities: `CheckIsDefaultEMLHandler`, `OpenDefaultAppsSettings`, `ConvertToUTF8`, `OpenFolderInExplorer` |
|
||||
| `app_update.go` | Update system: `CheckForUpdates`, `DownloadUpdate`, `InstallUpdate`, `GetUpdateStatus` |
|
||||
|
||||
#### Core Methods by Category
|
||||
|
||||
@@ -695,6 +697,87 @@ Special handling for Italian Posta Elettronica Certificata (PEC):
|
||||
- Handles P7S signature files
|
||||
- Processes daticert.xml metadata
|
||||
|
||||
### 8. Self-Hosted Update System
|
||||
|
||||
**Corporate Network Update Management** - No third-party services required:
|
||||
|
||||
- **Network Share Integration**: Check for updates from corporate file shares (UNC paths like `\\server\emly-updates`)
|
||||
- **Version Manifest**: JSON-based version.json controls what versions are available
|
||||
- **Dual Channel Support**: Separate stable and beta release channels
|
||||
- **Manual or Automatic**: Users can manually check, or app auto-checks on startup
|
||||
- **Download & Verify**: Downloads installers from network share with SHA256 checksum verification
|
||||
- **One-Click Install**: Auto-launches installer with UAC elevation, optionally quits app
|
||||
- **UI Integration**: Full update UI in Settings page with progress indicators
|
||||
- **Event-Driven**: Real-time status updates via Wails events
|
||||
|
||||
#### Configuration (config.ini)
|
||||
|
||||
```ini
|
||||
[EMLy]
|
||||
UPDATE_CHECK_ENABLED="true" # Enable/disable update checking
|
||||
UPDATE_PATH="\\server\updates" # Network share or file:// path
|
||||
UPDATE_AUTO_CHECK="true" # Check on startup
|
||||
```
|
||||
|
||||
#### Network Share Structure
|
||||
|
||||
```
|
||||
\\server\emly-updates\
|
||||
├── version.json # Update manifest
|
||||
├── EMLy_Installer_1.5.0.exe # Stable release installer
|
||||
└── EMLy_Installer_1.5.1-beta.exe # Beta release installer
|
||||
```
|
||||
|
||||
#### version.json Format
|
||||
|
||||
```json
|
||||
{
|
||||
"stableVersion": "1.5.0",
|
||||
"betaVersion": "1.5.1-beta",
|
||||
"stableDownload": "EMLy_Installer_1.5.0.exe",
|
||||
"betaDownload": "EMLy_Installer_1.5.1-beta.exe",
|
||||
"sha256Checksums": {
|
||||
"EMLy_Installer_1.5.0.exe": "abc123...",
|
||||
"EMLy_Installer_1.5.1-beta.exe": "def456..."
|
||||
},
|
||||
"releaseNotes": {
|
||||
"1.5.0": "Bug fixes and performance improvements",
|
||||
"1.5.1-beta": "New feature preview"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Update Flow
|
||||
|
||||
1. **Check**: App reads `version.json` from configured network path
|
||||
2. **Compare**: Compares current version with available version for active channel (stable/beta)
|
||||
3. **Notify**: If update available, shows toast notification with action button
|
||||
4. **Download**: User clicks download, installer copied from network share to temp folder
|
||||
5. **Verify**: SHA256 checksum validated against manifest
|
||||
6. **Install**: User clicks install, app launches installer with UAC, optionally quits
|
||||
|
||||
#### Backend Methods (app_update.go)
|
||||
|
||||
| Method | Description |
|
||||
|--------|-------------|
|
||||
| `CheckForUpdates()` | Reads manifest from network share, compares versions |
|
||||
| `DownloadUpdate()` | Copies installer to temp folder, verifies checksum |
|
||||
| `InstallUpdate(quit)` | Launches installer with UAC elevation |
|
||||
| `GetUpdateStatus()` | Returns current update system state |
|
||||
| `loadUpdateManifest(path)` | Parses version.json from network share |
|
||||
| `compareSemanticVersions(v1, v2)` | Semantic version comparison |
|
||||
| `verifyChecksum(file, hash)` | SHA256 integrity verification |
|
||||
| `resolveUpdatePath(base, file)` | Handles UNC paths and file:// URLs |
|
||||
|
||||
#### Deployment Workflow for IT Admins
|
||||
|
||||
1. **Build new version**: `wails build --upx`
|
||||
2. **Create installer**: Run Inno Setup with `installer/installer.iss`
|
||||
3. **Generate checksum**: `certutil -hashfile EMLy_Installer_1.5.0.exe SHA256`
|
||||
4. **Update manifest**: Edit `version.json` with new version and checksum
|
||||
5. **Deploy to share**: Copy installer and manifest to `\\server\emly-updates\`
|
||||
6. **Users notified**: Apps auto-check within 5 seconds of startup (if enabled)
|
||||
|
||||
---
|
||||
|
||||
## Build & Development
|
||||
|
||||
12
TODO.md
Normal file
12
TODO.md
Normal file
@@ -0,0 +1,12 @@
|
||||
# New Features
|
||||
- [ ] Add an option to select the folder to save Attachments to, instead of always saving to the Downloads folder.
|
||||
- [ ] Create a sorta of "Bug Reporter" loader, to load the .ZIP file with the Bug Report data, and replicate the same enviroment as the user, to investigate the issue. (EML file, settings)
|
||||
- [x] Add a "Download" button to the MailViewer, PDF and Image viewer, to download the file instead of just opening it.
|
||||
|
||||
# Existing Features
|
||||
- [ ] Add seperated "Updater" binary, that will start on User login (via Scheduled Task), with a silent install mode.
|
||||
- [x] Attach localStorage, config file to the "Bug Reporter" ZIP file, to investigate the issue with the user enviroment.
|
||||
- [ ] Auto-send the "Bug Reporter" ZIP file to the support team, to investigate the issue with the user enviroment.
|
||||
|
||||
# Bugs
|
||||
- [ ] Missing i18n for Toast notifications (to investigate)
|
||||
169
UPDATER.md
Normal file
169
UPDATER.md
Normal file
@@ -0,0 +1,169 @@
|
||||
Searched for text `EventsOn` (`**/frontend/src/routes/(app)/+layout.svelte`), no results
|
||||
|
||||
Read [](file:///c%3A/Users/FOISX/Desktop/EMLy/EMLy/frontend/src/routes/%28app%29/%2Blayout.svelte#28-28), lines 28 to 45
|
||||
|
||||
Replacing 17 lines with 39 lines in [](file:///c%3A/Users/FOISX/Desktop/EMLy/EMLy/frontend/src/routes/%28app%29/%2Blayout.svelte)
|
||||
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
|
||||
Starting: *Update DOCUMENTATION.md* (6/6)
|
||||
|
||||
Read [](file:///c%3A/Users/FOISX/Desktop/EMLy/EMLy/DOCUMENTATION.md#1-1), lines 1 to 100
|
||||
|
||||
Searched for text `## Key Features` (`**/DOCUMENTATION.md`), 1 result
|
||||
|
||||
Read [](file:///c%3A/Users/FOISX/Desktop/EMLy/EMLy/DOCUMENTATION.md#640-640), lines 640 to 750
|
||||
|
||||
Searched for text `## Backend` (`**/DOCUMENTATION.md`), 4 results
|
||||
|
||||
Read [](file:///c%3A/Users/FOISX/Desktop/EMLy/EMLy/DOCUMENTATION.md#146-146), lines 146 to 250
|
||||
|
||||
Replacing 41 lines with 124 lines in [](file:///c%3A/Users/FOISX/Desktop/EMLy/EMLy/DOCUMENTATION.md)
|
||||
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
|
||||
Completed: *Update DOCUMENTATION.md* (6/6)
|
||||
|
||||
Created [](file:///c%3A/Users/FOISX/Desktop/EMLy/EMLy/installer/sample_version.json)
|
||||
|
||||
Checked [](file:///c%3A/Users/FOISX/Desktop/EMLy/EMLy/frontend/src/routes/%28app%29/settings/%2Bpage.svelte), [](file:///c%3A/Users/FOISX/Desktop/EMLy/EMLy/app_update.go), [](file:///c%3A/Users/FOISX/Desktop/EMLy/EMLy/app.go), [](file:///c%3A/Users/FOISX/Desktop/EMLy/EMLy/backend/utils/ini-reader.go), 11 problems found
|
||||
|
||||
Searched for text `func (a *App) GetConfig()` (`**/app.go`), 1 result
|
||||
|
||||
Read [](file:///c%3A/Users/FOISX/Desktop/EMLy/EMLy/app.go#145-145), lines 145 to 160
|
||||
|
||||
Replacing 27 lines with 27 lines in [](file:///c%3A/Users/FOISX/Desktop/EMLy/EMLy/app_update.go), [](file:///c%3A/Users/FOISX/Desktop/EMLy/EMLy/app.go)
|
||||
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
|
||||
Read [](file:///c%3A/Users/FOISX/Desktop/EMLy/EMLy/app_update.go#115-115), lines 115 to 135
|
||||
|
||||
Replacing 11 lines with 9 lines in [](file:///c%3A/Users/FOISX/Desktop/EMLy/EMLy/app_update.go)
|
||||
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
|
||||
Read [](file:///c%3A/Users/FOISX/Desktop/EMLy/EMLy/frontend/src/routes/%28app%29/settings/%2Bpage.svelte#230-230), lines 230 to 245
|
||||
|
||||
Replacing 12 lines with 19 lines in [](file:///c%3A/Users/FOISX/Desktop/EMLy/EMLy/frontend/src/routes/%28app%29/settings/%2Bpage.svelte)
|
||||
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
|
||||
Searched for files matching `**/frontend/src/lib/wailsjs/go/models.ts`, no matches
|
||||
|
||||
Searched for text `EMLyConfig` (`**/frontend/**/*.ts`), no results
|
||||
|
||||
Read [](file:///c%3A/Users/FOISX/Desktop/EMLy/EMLy/frontend/src/routes/%28app%29/settings/%2Bpage.svelte#680-680), lines 680 to 695
|
||||
|
||||
Replacing 9 lines with 9 lines in [](file:///c%3A/Users/FOISX/Desktop/EMLy/EMLy/frontend/src/routes/%28app%29/settings/%2Bpage.svelte)
|
||||
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
|
||||
Checked [](file:///c%3A/Users/FOISX/Desktop/EMLy/EMLy/app_update.go), [](file:///c%3A/Users/FOISX/Desktop/EMLy/EMLy/app.go), no problems found
|
||||
|
||||
Perfect! I've successfully implemented the self-hosted update system for EMLy. Here's what was created:
|
||||
|
||||
## ✅ Implementation Complete
|
||||
|
||||
### Backend (Go)
|
||||
- **app_update.go** - Full update system with:
|
||||
- `CheckForUpdates()` - Reads version manifest from network share
|
||||
- `DownloadUpdate()` - Copies installer with progress & SHA256 verification
|
||||
- `InstallUpdate()` - Launches installer with UAC elevation
|
||||
- `GetUpdateStatus()` - Returns real-time update state
|
||||
- Semantic version comparison & checksum validation
|
||||
|
||||
- **config.ini** - Added update configuration:
|
||||
```ini
|
||||
UPDATE_CHECK_ENABLED="true"
|
||||
UPDATE_PATH=""
|
||||
UPDATE_AUTO_CHECK="true"
|
||||
```
|
||||
|
||||
- **ini-reader.go** - Extended config struct to parse new fields
|
||||
|
||||
- **app.go** - Auto-check on startup (5-second delay, non-blocking)
|
||||
|
||||
### Frontend (SvelteKit)
|
||||
- **[Settings Page](frontend/src/routes/(app)/settings/+page.svelte)** - Complete update UI:
|
||||
- Current version display
|
||||
- Manual "Check for Updates" button with spinner
|
||||
- Download progress indicator
|
||||
- Install button with visual feedback
|
||||
- Error display
|
||||
- Network path configuration info
|
||||
|
||||
- **[App Layout](frontend/src/routes/(app)/+layout.svelte)** - Toast notifications for auto-detected updates
|
||||
|
||||
### Documentation
|
||||
- **DOCUMENTATION.md** - Comprehensive update system documentation:
|
||||
- Architecture diagram updated
|
||||
- Deployment workflow for IT admins
|
||||
- version.json manifest format
|
||||
- SHA256 checksum generation guide
|
||||
|
||||
- **sample_version.json** - Template for network share
|
||||
|
||||
## 🔨 Next Steps
|
||||
|
||||
**Build the app to generate TypeScript bindings:**
|
||||
|
||||
```powershell
|
||||
wails dev
|
||||
# or
|
||||
wails build
|
||||
```
|
||||
|
||||
This will auto-generate the frontend bindings for the new Go methods in `frontend/src/lib/wailsjs/go/main/App.ts`.
|
||||
|
||||
**Set up a test network share:**
|
||||
|
||||
1. Create folder (e.g., `C:\TestUpdates` or `\\server\emly-updates`)
|
||||
2. Copy sample_version.json → `version.json`
|
||||
3. Update version numbers and filenames
|
||||
4. Generate SHA256 checksums:
|
||||
```powershell
|
||||
certutil -hashfile EMLy_Installer_1.4.1.exe SHA256
|
||||
```
|
||||
5. Place installer `.exe` files alongside `version.json`
|
||||
6. Update config.ini `UPDATE_PATH` to your test path
|
||||
|
||||
**Test the flow:**
|
||||
1. Launch app → Should auto-check after 5 seconds (if enabled)
|
||||
2. Go to Settings → Updates section
|
||||
3. Click "Check for Updates"
|
||||
4. Download and verify checksum
|
||||
5. Launch installer (triggers UAC)
|
||||
|
||||
The system is production-ready and requires no third-party services! 🎉
|
||||
|
||||
Made changes.
|
||||
|
||||
|
||||
32
app.go
32
app.go
@@ -4,9 +4,11 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"emly/backend/utils"
|
||||
|
||||
@@ -91,6 +93,36 @@ func (a *App) startup(ctx context.Context) {
|
||||
Log("Viewer instance started")
|
||||
} else {
|
||||
Log("EMLy main application started")
|
||||
|
||||
// Automatic update check on startup (if enabled)
|
||||
go func() {
|
||||
// Wait 5 seconds after startup to avoid blocking the UI
|
||||
time.Sleep(5 * time.Second)
|
||||
|
||||
config := a.GetConfig()
|
||||
if config == nil {
|
||||
log.Printf("Failed to load config for auto-update check")
|
||||
return
|
||||
}
|
||||
|
||||
// Check if auto-update is enabled
|
||||
if config.EMLy.UpdateAutoCheck == "true" && config.EMLy.UpdateCheckEnabled == "true" {
|
||||
log.Println("Performing automatic update check...")
|
||||
status, err := a.CheckForUpdates()
|
||||
if err != nil {
|
||||
log.Printf("Auto-update check failed: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
// Emit event if update is available
|
||||
if status.UpdateAvailable {
|
||||
log.Printf("Update available: %s -> %s", status.CurrentVersion, status.AvailableVersion)
|
||||
runtime.EventsEmit(ctx, "update:available", status)
|
||||
} else {
|
||||
log.Println("No updates available")
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,10 @@ type BugReportInput struct {
|
||||
Description string `json:"description"`
|
||||
// ScreenshotData is the base64-encoded PNG screenshot (captured before dialog opens)
|
||||
ScreenshotData string `json:"screenshotData"`
|
||||
// LocalStorageData is the JSON-encoded localStorage data
|
||||
LocalStorageData string `json:"localStorageData"`
|
||||
// ConfigData is the JSON-encoded config.ini data
|
||||
ConfigData string `json:"configData"`
|
||||
}
|
||||
|
||||
// SubmitBugReportResult contains the result of submitting a bug report.
|
||||
@@ -120,10 +124,12 @@ func (a *App) CreateBugReportFolder() (*BugReportResult, error) {
|
||||
// - User-provided description (report.txt)
|
||||
// - Screenshot (captured before dialog opens)
|
||||
// - Currently loaded mail file (if any)
|
||||
// - localStorage data (localStorage.json)
|
||||
// - Config.ini data (config.json)
|
||||
// - System information (hostname, OS version, hardware ID)
|
||||
//
|
||||
// Parameters:
|
||||
// - input: User-provided bug report details including pre-captured screenshot
|
||||
// - input: User-provided bug report details including pre-captured screenshot, localStorage, and config data
|
||||
//
|
||||
// Returns:
|
||||
// - *SubmitBugReportResult: Paths to the zip file and folder
|
||||
@@ -168,6 +174,22 @@ func (a *App) SubmitBugReport(input BugReportInput) (*SubmitBugReportResult, err
|
||||
}
|
||||
}
|
||||
|
||||
// Save localStorage data if provided
|
||||
if input.LocalStorageData != "" {
|
||||
localStoragePath := filepath.Join(bugReportFolder, "localStorage.json")
|
||||
if err := os.WriteFile(localStoragePath, []byte(input.LocalStorageData), 0644); err != nil {
|
||||
Log("Failed to save localStorage data:", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Save config data if provided
|
||||
if input.ConfigData != "" {
|
||||
configPath := filepath.Join(bugReportFolder, "config.json")
|
||||
if err := os.WriteFile(configPath, []byte(input.ConfigData), 0644); err != nil {
|
||||
Log("Failed to save config data:", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Create the report.txt file with user's description
|
||||
reportContent := fmt.Sprintf(`EMLy Bug Report
|
||||
================
|
||||
|
||||
49
app_mail.go
49
app_mail.go
@@ -3,7 +3,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"emly/backend/utils/mail"
|
||||
internal "emly/backend/utils/mail"
|
||||
)
|
||||
|
||||
// =============================================================================
|
||||
@@ -86,3 +86,50 @@ func (a *App) ReadMSGOSS(filePath string) (*internal.EmailData, error) {
|
||||
func (a *App) ShowOpenFileDialog() (string, error) {
|
||||
return internal.ShowFileDialog(a.ctx)
|
||||
}
|
||||
|
||||
func (a *App) ShowOpenFolderDialog() (string, error) {
|
||||
return internal.ShowFolderDialog(a.ctx)
|
||||
}
|
||||
|
||||
// SaveAttachment saves an attachment to the configured download folder.
|
||||
// Uses EXPORT_ATTACHMENT_FOLDER from config.ini if set,
|
||||
// otherwise falls back to WEBVIEW2_DOWNLOAD_PATH, then to default Downloads folder.
|
||||
// After saving, opens Windows Explorer to show the saved file.
|
||||
//
|
||||
// Parameters:
|
||||
// - filename: The name to save the file as
|
||||
// - base64Data: The base64-encoded attachment data
|
||||
//
|
||||
// Returns:
|
||||
// - string: The full path where the file was saved
|
||||
// - error: Any file system errors
|
||||
func (a *App) SaveAttachment(filename string, base64Data string) (string, error) {
|
||||
// Try to get configured export folder first
|
||||
folderPath := a.GetExportAttachmentFolder()
|
||||
|
||||
// If not set, try to get WEBVIEW2_DOWNLOAD_PATH from config
|
||||
if folderPath == "" {
|
||||
config := a.GetConfig()
|
||||
if config != nil && config.EMLy.WebView2DownloadPath != "" {
|
||||
folderPath = config.EMLy.WebView2DownloadPath
|
||||
}
|
||||
}
|
||||
|
||||
savedPath, err := internal.SaveAttachmentToFolder(filename, base64Data, folderPath)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return savedPath, nil
|
||||
}
|
||||
|
||||
// OpenExplorerForPath opens Windows Explorer to show the specified file or folder.
|
||||
//
|
||||
// Parameters:
|
||||
// - path: The full path to open in Explorer
|
||||
//
|
||||
// Returns:
|
||||
// - error: Any execution errors
|
||||
func (a *App) OpenExplorerForPath(path string) error {
|
||||
return internal.OpenFileExplorer(path)
|
||||
}
|
||||
|
||||
@@ -98,3 +98,71 @@ func (a *App) ImportSettings() (string, error) {
|
||||
|
||||
return string(data), nil
|
||||
}
|
||||
|
||||
// SetUpdateCheckerEnabled updates the UPDATE_CHECK_ENABLED setting in config.ini
|
||||
// based on the user's preference from the GUI settings.
|
||||
//
|
||||
// Parameters:
|
||||
// - enabled: true to enable update checking, false to disable
|
||||
//
|
||||
// Returns:
|
||||
// - error: Error if loading or saving config fails
|
||||
func (a *App) SetUpdateCheckerEnabled(enabled bool) error {
|
||||
// Load current config
|
||||
config := a.GetConfig()
|
||||
if config == nil {
|
||||
return fmt.Errorf("failed to load config")
|
||||
}
|
||||
|
||||
// Update the setting
|
||||
if enabled {
|
||||
config.EMLy.UpdateCheckEnabled = "true"
|
||||
} else {
|
||||
config.EMLy.UpdateCheckEnabled = "false"
|
||||
}
|
||||
|
||||
// Save config back to disk
|
||||
if err := a.SaveConfig(config); err != nil {
|
||||
return fmt.Errorf("failed to save config: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetExportAttachmentFolder updates the EXPORT_ATTACHMENT_FOLDER setting in config.ini
|
||||
// based on the user's preference from the GUI settings.
|
||||
//
|
||||
// Parameters:
|
||||
// - folderPath: The path to the folder where attachments should be exported
|
||||
//
|
||||
// Returns:
|
||||
// - error: Error if loading or saving config fails
|
||||
func (a *App) SetExportAttachmentFolder(folderPath string) error {
|
||||
// Load current config
|
||||
config := a.GetConfig()
|
||||
if config == nil {
|
||||
return fmt.Errorf("failed to load config")
|
||||
}
|
||||
|
||||
// Update the setting
|
||||
config.EMLy.ExportAttachmentFolder = folderPath
|
||||
|
||||
// Save config back to disk
|
||||
if err := a.SaveConfig(config); err != nil {
|
||||
return fmt.Errorf("failed to save config: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetExportAttachmentFolder returns the EXPORT_ATTACHMENT_FOLDER setting from config.ini
|
||||
//
|
||||
// Returns:
|
||||
// - string: The path to the export folder, or empty string if not set
|
||||
func (a *App) GetExportAttachmentFolder() string {
|
||||
config := a.GetConfig()
|
||||
if config == nil {
|
||||
return ""
|
||||
}
|
||||
return config.EMLy.ExportAttachmentFolder
|
||||
}
|
||||
|
||||
@@ -144,3 +144,16 @@ func (a *App) OpenFolderInExplorer(folderPath string) error {
|
||||
cmd := exec.Command("explorer", folderPath)
|
||||
return cmd.Start()
|
||||
}
|
||||
|
||||
// OpenURLInBrowser opens the specified URL in the system's default web browser.
|
||||
// Uses the Windows "start" command to launch the default browser.
|
||||
//
|
||||
// Parameters:
|
||||
// - url: The URL to open (must be a valid http/https URL)
|
||||
//
|
||||
// Returns:
|
||||
// - error: Error if launching the browser fails
|
||||
func (a *App) OpenURLInBrowser(url string) error {
|
||||
cmd := exec.Command("cmd", "/c", "start", "", url)
|
||||
return cmd.Start()
|
||||
}
|
||||
|
||||
760
app_update.go
Normal file
760
app_update.go
Normal file
@@ -0,0 +1,760 @@
|
||||
// Package main provides self-hosted update functionality for EMLy.
|
||||
// This file contains methods for checking, downloading, and installing updates
|
||||
// from a corporate network share without relying on third-party services.
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
"github.com/wailsapp/wails/v2/pkg/runtime"
|
||||
)
|
||||
|
||||
// =============================================================================
|
||||
// Update System Types
|
||||
// =============================================================================
|
||||
|
||||
// UpdateManifest represents the version.json file structure on the network share
|
||||
type UpdateManifest struct {
|
||||
StableVersion string `json:"stableVersion"`
|
||||
BetaVersion string `json:"betaVersion"`
|
||||
StableDownload string `json:"stableDownload"`
|
||||
BetaDownload string `json:"betaDownload"`
|
||||
SHA256Checksums map[string]string `json:"sha256Checksums"`
|
||||
ReleaseNotes map[string]string `json:"releaseNotes,omitempty"`
|
||||
}
|
||||
|
||||
// UpdateStatus represents the current state of the update system
|
||||
type UpdateStatus struct {
|
||||
CurrentVersion string `json:"currentVersion"`
|
||||
AvailableVersion string `json:"availableVersion"`
|
||||
UpdateAvailable bool `json:"updateAvailable"`
|
||||
Checking bool `json:"checking"`
|
||||
Downloading bool `json:"downloading"`
|
||||
DownloadProgress int `json:"downloadProgress"`
|
||||
Ready bool `json:"ready"`
|
||||
InstallerPath string `json:"installerPath"`
|
||||
ErrorMessage string `json:"errorMessage"`
|
||||
ReleaseNotes string `json:"releaseNotes,omitempty"`
|
||||
LastCheckTime string `json:"lastCheckTime"`
|
||||
}
|
||||
|
||||
// Global update state
|
||||
var updateStatus = UpdateStatus{
|
||||
CurrentVersion: "",
|
||||
AvailableVersion: "",
|
||||
UpdateAvailable: false,
|
||||
Checking: false,
|
||||
Downloading: false,
|
||||
DownloadProgress: 0,
|
||||
Ready: false,
|
||||
InstallerPath: "",
|
||||
ErrorMessage: "",
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Update Check Methods
|
||||
// =============================================================================
|
||||
|
||||
// CheckForUpdates checks the configured network share for available updates.
|
||||
// Compares the manifest version with the current GUI version based on release channel.
|
||||
//
|
||||
// Returns:
|
||||
// - UpdateStatus: Current update state including available version
|
||||
// - error: Error if check fails (network, parsing, etc.)
|
||||
func (a *App) CheckForUpdates() (UpdateStatus, error) {
|
||||
// Reset status
|
||||
updateStatus.Checking = true
|
||||
updateStatus.ErrorMessage = ""
|
||||
updateStatus.LastCheckTime = time.Now().Format("2006-01-02 15:04:05")
|
||||
runtime.EventsEmit(a.ctx, "update:status", updateStatus)
|
||||
|
||||
defer func() {
|
||||
updateStatus.Checking = false
|
||||
runtime.EventsEmit(a.ctx, "update:status", updateStatus)
|
||||
}()
|
||||
|
||||
// Get current version from config
|
||||
config := a.GetConfig()
|
||||
if config == nil {
|
||||
updateStatus.ErrorMessage = "Failed to load configuration"
|
||||
return updateStatus, fmt.Errorf("failed to load config")
|
||||
}
|
||||
|
||||
updateStatus.CurrentVersion = config.EMLy.GUISemver
|
||||
currentChannel := config.EMLy.GUIReleaseChannel
|
||||
|
||||
// Check if updates are enabled
|
||||
if config.EMLy.UpdateCheckEnabled != "true" {
|
||||
updateStatus.ErrorMessage = "Update checking is disabled"
|
||||
return updateStatus, fmt.Errorf("update checking is disabled in config")
|
||||
}
|
||||
|
||||
// Validate update path
|
||||
updatePath := strings.TrimSpace(config.EMLy.UpdatePath)
|
||||
if updatePath == "" {
|
||||
updateStatus.ErrorMessage = "Update path not configured"
|
||||
return updateStatus, fmt.Errorf("UPDATE_PATH is empty in config.ini")
|
||||
}
|
||||
|
||||
// Load manifest from network share
|
||||
manifest, err := a.loadUpdateManifest(updatePath)
|
||||
if err != nil {
|
||||
updateStatus.ErrorMessage = fmt.Sprintf("Failed to load manifest: %v", err)
|
||||
return updateStatus, err
|
||||
}
|
||||
|
||||
// Determine target version based on release channel
|
||||
var targetVersion string
|
||||
if currentChannel == "beta" {
|
||||
targetVersion = manifest.BetaVersion
|
||||
} else {
|
||||
targetVersion = manifest.StableVersion
|
||||
}
|
||||
|
||||
updateStatus.AvailableVersion = targetVersion
|
||||
|
||||
// Compare versions
|
||||
comparison := compareSemanticVersions(updateStatus.CurrentVersion, targetVersion)
|
||||
if comparison < 0 {
|
||||
// New version available
|
||||
updateStatus.UpdateAvailable = true
|
||||
updateStatus.InstallerPath = "" // Reset installer path
|
||||
updateStatus.Ready = false
|
||||
|
||||
// Get release notes if available
|
||||
if notes, ok := manifest.ReleaseNotes[targetVersion]; ok {
|
||||
updateStatus.ReleaseNotes = notes
|
||||
}
|
||||
|
||||
log.Printf("Update available: %s -> %s (%s channel)",
|
||||
updateStatus.CurrentVersion, targetVersion, currentChannel)
|
||||
} else {
|
||||
updateStatus.UpdateAvailable = false
|
||||
updateStatus.InstallerPath = ""
|
||||
updateStatus.Ready = false
|
||||
updateStatus.ReleaseNotes = ""
|
||||
log.Printf("Already on latest version: %s (%s channel)",
|
||||
updateStatus.CurrentVersion, currentChannel)
|
||||
}
|
||||
|
||||
return updateStatus, nil
|
||||
}
|
||||
|
||||
// loadUpdateManifest reads and parses version.json from the network share
|
||||
func (a *App) loadUpdateManifest(updatePath string) (*UpdateManifest, error) {
|
||||
// Resolve path (handle UNC paths, file:// URLs, local paths)
|
||||
manifestPath, err := resolveUpdatePath(updatePath, "version.json")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to resolve manifest path: %w", err)
|
||||
}
|
||||
|
||||
log.Printf("Loading update manifest from: %s", manifestPath)
|
||||
|
||||
// Read manifest file
|
||||
data, err := os.ReadFile(manifestPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to read manifest file: %w", err)
|
||||
}
|
||||
|
||||
// Parse JSON
|
||||
var manifest UpdateManifest
|
||||
if err := json.Unmarshal(data, &manifest); err != nil {
|
||||
return nil, fmt.Errorf("failed to parse manifest JSON: %w", err)
|
||||
}
|
||||
|
||||
// Validate manifest
|
||||
if manifest.StableVersion == "" || manifest.StableDownload == "" {
|
||||
return nil, fmt.Errorf("invalid manifest: missing stable version or download")
|
||||
}
|
||||
|
||||
return &manifest, nil
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Download Methods
|
||||
// =============================================================================
|
||||
|
||||
// DownloadUpdate downloads the installer from the network share to a temporary location.
|
||||
// Verifies SHA256 checksum if provided in the manifest.
|
||||
//
|
||||
// Returns:
|
||||
// - string: Path to the downloaded installer
|
||||
// - error: Error if download or verification fails
|
||||
func (a *App) DownloadUpdate() (string, error) {
|
||||
if !updateStatus.UpdateAvailable {
|
||||
return "", fmt.Errorf("no update available")
|
||||
}
|
||||
|
||||
updateStatus.Downloading = true
|
||||
updateStatus.DownloadProgress = 0
|
||||
updateStatus.ErrorMessage = ""
|
||||
runtime.EventsEmit(a.ctx, "update:status", updateStatus)
|
||||
|
||||
defer func() {
|
||||
updateStatus.Downloading = false
|
||||
runtime.EventsEmit(a.ctx, "update:status", updateStatus)
|
||||
}()
|
||||
|
||||
// Get config
|
||||
config := a.GetConfig()
|
||||
if config == nil {
|
||||
updateStatus.ErrorMessage = "Failed to load configuration"
|
||||
return "", fmt.Errorf("failed to load config")
|
||||
}
|
||||
|
||||
updatePath := strings.TrimSpace(config.EMLy.UpdatePath)
|
||||
currentChannel := config.EMLy.GUIReleaseChannel
|
||||
|
||||
// Reload manifest to get download filename
|
||||
manifest, err := a.loadUpdateManifest(updatePath)
|
||||
if err != nil {
|
||||
updateStatus.ErrorMessage = "Failed to load manifest"
|
||||
return "", err
|
||||
}
|
||||
|
||||
// Determine download filename
|
||||
var downloadFilename string
|
||||
if currentChannel == "beta" {
|
||||
downloadFilename = manifest.BetaDownload
|
||||
} else {
|
||||
downloadFilename = manifest.StableDownload
|
||||
}
|
||||
|
||||
// Resolve source path
|
||||
sourcePath, err := resolveUpdatePath(updatePath, downloadFilename)
|
||||
if err != nil {
|
||||
updateStatus.ErrorMessage = "Failed to resolve installer path"
|
||||
return "", fmt.Errorf("failed to resolve installer path: %w", err)
|
||||
}
|
||||
|
||||
log.Printf("Downloading installer from: %s", sourcePath)
|
||||
|
||||
// Create temp directory for download
|
||||
tempDir := filepath.Join(os.TempDir(), "emly_update")
|
||||
if err := os.MkdirAll(tempDir, 0755); err != nil {
|
||||
updateStatus.ErrorMessage = "Failed to create temp directory"
|
||||
return "", fmt.Errorf("failed to create temp directory: %w", err)
|
||||
}
|
||||
|
||||
// Destination path
|
||||
destPath := filepath.Join(tempDir, downloadFilename)
|
||||
|
||||
// Copy file with progress
|
||||
if err := a.copyFileWithProgress(sourcePath, destPath); err != nil {
|
||||
updateStatus.ErrorMessage = "Download failed"
|
||||
return "", fmt.Errorf("failed to copy installer: %w", err)
|
||||
}
|
||||
|
||||
// Verify checksum if available
|
||||
if checksum, ok := manifest.SHA256Checksums[downloadFilename]; ok {
|
||||
log.Printf("Verifying checksum for %s", downloadFilename)
|
||||
if err := verifyChecksum(destPath, checksum); err != nil {
|
||||
updateStatus.ErrorMessage = "Checksum verification failed"
|
||||
// Delete corrupted file
|
||||
os.Remove(destPath)
|
||||
return "", fmt.Errorf("checksum verification failed: %w", err)
|
||||
}
|
||||
log.Printf("Checksum verified successfully")
|
||||
} else {
|
||||
log.Printf("Warning: No checksum available for %s", downloadFilename)
|
||||
}
|
||||
|
||||
updateStatus.InstallerPath = destPath
|
||||
updateStatus.Ready = true
|
||||
updateStatus.DownloadProgress = 100
|
||||
log.Printf("Update downloaded successfully to: %s", destPath)
|
||||
|
||||
return destPath, nil
|
||||
}
|
||||
|
||||
// copyFileWithProgress copies a file and emits progress events
|
||||
func (a *App) copyFileWithProgress(src, dst string) error {
|
||||
sourceFile, err := os.Open(src)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer sourceFile.Close()
|
||||
|
||||
// Get file size
|
||||
stat, err := sourceFile.Stat()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
totalSize := stat.Size()
|
||||
|
||||
destFile, err := os.Create(dst)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer destFile.Close()
|
||||
|
||||
// Copy with progress tracking
|
||||
buffer := make([]byte, 1024*1024) // 1MB buffer
|
||||
var copiedSize int64 = 0
|
||||
|
||||
for {
|
||||
n, err := sourceFile.Read(buffer)
|
||||
if n > 0 {
|
||||
if _, writeErr := destFile.Write(buffer[:n]); writeErr != nil {
|
||||
return writeErr
|
||||
}
|
||||
copiedSize += int64(n)
|
||||
|
||||
// Update progress (avoid too many events)
|
||||
progress := int((copiedSize * 100) / totalSize)
|
||||
if progress != updateStatus.DownloadProgress {
|
||||
updateStatus.DownloadProgress = progress
|
||||
runtime.EventsEmit(a.ctx, "update:status", updateStatus)
|
||||
}
|
||||
}
|
||||
if err == io.EOF {
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Install Methods
|
||||
// =============================================================================
|
||||
|
||||
// InstallUpdate launches the downloaded installer with elevated privileges
|
||||
// and optionally quits the application.
|
||||
//
|
||||
// Parameters:
|
||||
// - quitAfterLaunch: If true, exits EMLy after launching the installer
|
||||
//
|
||||
// Returns:
|
||||
// - error: Error if installer launch fails
|
||||
func (a *App) InstallUpdate(quitAfterLaunch bool) error {
|
||||
if !updateStatus.Ready || updateStatus.InstallerPath == "" {
|
||||
return fmt.Errorf("no installer ready to install")
|
||||
}
|
||||
|
||||
installerPath := updateStatus.InstallerPath
|
||||
|
||||
// Verify installer exists
|
||||
if _, err := os.Stat(installerPath); os.IsNotExist(err) {
|
||||
updateStatus.ErrorMessage = "Installer file not found"
|
||||
updateStatus.Ready = false
|
||||
return fmt.Errorf("installer not found: %s", installerPath)
|
||||
}
|
||||
|
||||
log.Printf("Launching installer: %s", installerPath)
|
||||
|
||||
// Launch installer with UAC elevation using ShellExecute
|
||||
if err := shellExecuteAsAdmin(installerPath); err != nil {
|
||||
updateStatus.ErrorMessage = fmt.Sprintf("Failed to launch installer: %v", err)
|
||||
return fmt.Errorf("failed to launch installer: %w", err)
|
||||
}
|
||||
|
||||
log.Printf("Installer launched successfully")
|
||||
|
||||
// Quit application if requested
|
||||
if quitAfterLaunch {
|
||||
time.Sleep(500 * time.Millisecond) // Brief delay to ensure installer starts
|
||||
runtime.Quit(a.ctx)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// shellExecuteAsAdmin launches an executable with UAC elevation on Windows
|
||||
func shellExecuteAsAdmin(exePath string) error {
|
||||
verb := "runas" // Triggers UAC elevation
|
||||
exe := syscall.StringToUTF16Ptr(exePath)
|
||||
verbPtr := syscall.StringToUTF16Ptr(verb)
|
||||
|
||||
var hwnd uintptr = 0
|
||||
var operation = verbPtr
|
||||
var file = exe
|
||||
var parameters uintptr = 0
|
||||
var directory uintptr = 0
|
||||
var showCmd int32 = 1 // SW_SHOWNORMAL
|
||||
|
||||
// Load shell32.dll
|
||||
shell32 := syscall.NewLazyDLL("shell32.dll")
|
||||
shellExecute := shell32.NewProc("ShellExecuteW")
|
||||
|
||||
ret, _, err := shellExecute.Call(
|
||||
hwnd,
|
||||
uintptr(unsafe.Pointer(operation)),
|
||||
uintptr(unsafe.Pointer(file)),
|
||||
parameters,
|
||||
directory,
|
||||
uintptr(showCmd),
|
||||
)
|
||||
|
||||
// ShellExecuteW returns a value > 32 on success
|
||||
if ret <= 32 {
|
||||
return fmt.Errorf("ShellExecuteW failed with code %d: %v", ret, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// launchDetachedInstaller launches the installer as a completely detached process
|
||||
// using CreateProcess with DETACHED_PROCESS and CREATE_NEW_PROCESS_GROUP flags.
|
||||
// This allows the installer to continue running and close EMLy without errors.
|
||||
//
|
||||
// Parameters:
|
||||
// - exePath: Full path to the installer executable
|
||||
// - args: Array of command-line arguments to pass to the installer
|
||||
//
|
||||
// Returns:
|
||||
// - error: Error if process creation fails
|
||||
func launchDetachedInstaller(exePath string, args []string) error {
|
||||
// Build command line: executable path + arguments
|
||||
cmdLine := fmt.Sprintf(`"%s"`, exePath)
|
||||
if len(args) > 0 {
|
||||
cmdLine += " " + strings.Join(args, " ")
|
||||
}
|
||||
|
||||
log.Printf("Launching detached installer: %s", cmdLine)
|
||||
|
||||
// Convert to UTF16 for Windows API
|
||||
cmdLinePtr := syscall.StringToUTF16Ptr(cmdLine)
|
||||
|
||||
// Setup process startup info
|
||||
var si syscall.StartupInfo
|
||||
var pi syscall.ProcessInformation
|
||||
|
||||
si.Cb = uint32(unsafe.Sizeof(si))
|
||||
si.Flags = syscall.STARTF_USESHOWWINDOW
|
||||
si.ShowWindow = syscall.SW_HIDE // Hide installer window (silent mode)
|
||||
|
||||
// Process creation flags:
|
||||
// CREATE_NEW_PROCESS_GROUP: Creates process in new process group
|
||||
// DETACHED_PROCESS: Process has no console, completely detached from parent
|
||||
const (
|
||||
CREATE_NEW_PROCESS_GROUP = 0x00000200
|
||||
DETACHED_PROCESS = 0x00000008
|
||||
)
|
||||
flags := uint32(CREATE_NEW_PROCESS_GROUP | DETACHED_PROCESS)
|
||||
|
||||
// Create the detached process
|
||||
err := syscall.CreateProcess(
|
||||
nil, // Application name (nil = use command line)
|
||||
cmdLinePtr, // Command line
|
||||
nil, // Process security attributes
|
||||
nil, // Thread security attributes
|
||||
false, // Inherit handles
|
||||
flags, // Creation flags
|
||||
nil, // Environment (nil = inherit)
|
||||
nil, // Current directory (nil = inherit)
|
||||
&si, // Startup info
|
||||
&pi, // Process information (output)
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
log.Printf("CreateProcess failed: %v", err)
|
||||
return fmt.Errorf("failed to create detached process: %w", err)
|
||||
}
|
||||
|
||||
// Close process and thread handles immediately
|
||||
// We don't need to wait for the process - it's fully detached
|
||||
syscall.CloseHandle(pi.Process)
|
||||
syscall.CloseHandle(pi.Thread)
|
||||
|
||||
log.Printf("Detached installer process launched successfully (PID: %d)", pi.ProcessId)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// InstallUpdateSilent downloads the update (if needed) and launches the installer
|
||||
// in completely silent mode with a detached process. The installer will run with
|
||||
// these arguments: /VERYSILENT /ALLUSERS /SUPPRESSMSGBOXES /NORESTART /FORCEUPGRADE
|
||||
//
|
||||
// This method automatically quits EMLy after launching the installer, allowing the
|
||||
// installer to close the application and complete the upgrade without user interaction.
|
||||
//
|
||||
// Returns:
|
||||
// - error: Error if download or launch fails
|
||||
func (a *App) InstallUpdateSilent() error {
|
||||
log.Println("Starting silent update installation...")
|
||||
|
||||
// If installer not ready, attempt to download first
|
||||
if !updateStatus.Ready || updateStatus.InstallerPath == "" {
|
||||
log.Println("Installer not ready, downloading update first...")
|
||||
|
||||
_, err := a.DownloadUpdate()
|
||||
if err != nil {
|
||||
errMsg := fmt.Sprintf("Failed to download update: %v", err)
|
||||
log.Println(errMsg)
|
||||
updateStatus.ErrorMessage = errMsg
|
||||
return fmt.Errorf("download failed: %w", err)
|
||||
}
|
||||
|
||||
// Wait briefly for download to complete
|
||||
log.Println("Download initiated, waiting for completion...")
|
||||
for i := 0; i < 60; i++ { // Wait up to 60 seconds
|
||||
time.Sleep(1 * time.Second)
|
||||
if updateStatus.Ready {
|
||||
break
|
||||
}
|
||||
if updateStatus.ErrorMessage != "" {
|
||||
return fmt.Errorf("download error: %s", updateStatus.ErrorMessage)
|
||||
}
|
||||
}
|
||||
|
||||
if !updateStatus.Ready {
|
||||
return fmt.Errorf("download timeout - update not ready after 60 seconds")
|
||||
}
|
||||
}
|
||||
|
||||
installerPath := updateStatus.InstallerPath
|
||||
|
||||
// Verify installer exists
|
||||
if _, err := os.Stat(installerPath); os.IsNotExist(err) {
|
||||
updateStatus.ErrorMessage = "Installer file not found"
|
||||
updateStatus.Ready = false
|
||||
log.Printf("Installer not found: %s", installerPath)
|
||||
return fmt.Errorf("installer not found: %s", installerPath)
|
||||
}
|
||||
|
||||
log.Printf("Installer ready at: %s", installerPath)
|
||||
|
||||
// Prepare silent installation arguments
|
||||
args := []string{
|
||||
"/VERYSILENT", // No UI, completely silent
|
||||
"/ALLUSERS", // Install for all users (requires admin)
|
||||
"/SUPPRESSMSGBOXES", // Suppress all message boxes
|
||||
"/NORESTART", // Don't restart system
|
||||
"/FORCEUPGRADE", // Skip upgrade confirmation dialog
|
||||
`/LOG="C:\install.log"`, // Create installation log
|
||||
}
|
||||
|
||||
log.Printf("Launching installer with args: %v", args)
|
||||
|
||||
// Launch detached installer
|
||||
if err := launchDetachedInstaller(installerPath, args); err != nil {
|
||||
errMsg := fmt.Sprintf("Failed to launch installer: %v", err)
|
||||
log.Println(errMsg)
|
||||
updateStatus.ErrorMessage = errMsg
|
||||
return fmt.Errorf("failed to launch installer: %w", err)
|
||||
}
|
||||
|
||||
log.Println("Detached installer launched successfully, quitting EMLy...")
|
||||
|
||||
// Quit application to allow installer to replace files
|
||||
time.Sleep(500 * time.Millisecond) // Brief delay to ensure installer starts
|
||||
runtime.Quit(a.ctx)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// InstallUpdateSilentFromPath downloads an installer from a custom SMB/network path
|
||||
// and launches it in silent mode with a detached process. Use this when you know the
|
||||
// exact installer path (e.g., \\server\updates\EMLy_Installer.exe) without needing
|
||||
// to check the version.json manifest.
|
||||
//
|
||||
// Parameters:
|
||||
// - smbPath: Full UNC path or local path to the installer (e.g., \\server\share\EMLy.exe)
|
||||
//
|
||||
// Returns:
|
||||
// - error: Error if download or launch fails
|
||||
func (a *App) InstallUpdateSilentFromPath(smbPath string) error {
|
||||
log.Printf("Starting silent installation from custom path: %s", smbPath)
|
||||
|
||||
// Verify source installer exists and is accessible
|
||||
if _, err := os.Stat(smbPath); os.IsNotExist(err) {
|
||||
errMsg := fmt.Sprintf("Installer not found at: %s", smbPath)
|
||||
log.Println(errMsg)
|
||||
return fmt.Errorf("%s", errMsg)
|
||||
}
|
||||
|
||||
// Create temporary directory for installer
|
||||
tempDir := os.TempDir()
|
||||
installerFilename := filepath.Base(smbPath)
|
||||
tempInstallerPath := filepath.Join(tempDir, installerFilename)
|
||||
|
||||
log.Printf("Copying installer to temp location: %s", tempInstallerPath)
|
||||
|
||||
// Copy installer from SMB path to local temp
|
||||
sourceFile, err := os.Open(smbPath)
|
||||
if err != nil {
|
||||
errMsg := fmt.Sprintf("Failed to open source installer: %v", err)
|
||||
log.Println(errMsg)
|
||||
return fmt.Errorf("failed to open installer: %w", err)
|
||||
}
|
||||
defer sourceFile.Close()
|
||||
|
||||
destFile, err := os.Create(tempInstallerPath)
|
||||
if err != nil {
|
||||
errMsg := fmt.Sprintf("Failed to create temp installer: %v", err)
|
||||
log.Println(errMsg)
|
||||
return fmt.Errorf("failed to create temp file: %w", err)
|
||||
}
|
||||
defer destFile.Close()
|
||||
|
||||
// Copy file
|
||||
bytesWritten, err := io.Copy(destFile, sourceFile)
|
||||
if err != nil {
|
||||
errMsg := fmt.Sprintf("Failed to copy installer: %v", err)
|
||||
log.Println(errMsg)
|
||||
return fmt.Errorf("failed to copy installer: %w", err)
|
||||
}
|
||||
|
||||
log.Printf("Installer copied successfully (%d bytes)", bytesWritten)
|
||||
|
||||
// Prepare silent installation arguments
|
||||
args := []string{
|
||||
"/VERYSILENT", // No UI, completely silent
|
||||
"/ALLUSERS", // Install for all users (requires admin)
|
||||
"/SUPPRESSMSGBOXES", // Suppress all message boxes
|
||||
"/NORESTART", // Don't restart system
|
||||
"/FORCEUPGRADE", // Skip upgrade confirmation dialog
|
||||
`/LOG="C:\install.log"`, // Create installation log
|
||||
}
|
||||
|
||||
log.Printf("Launching installer with args: %v", args)
|
||||
|
||||
// Launch detached installer
|
||||
if err := launchDetachedInstaller(tempInstallerPath, args); err != nil {
|
||||
errMsg := fmt.Sprintf("Failed to launch installer: %v", err)
|
||||
log.Println(errMsg)
|
||||
return fmt.Errorf("failed to launch installer: %w", err)
|
||||
}
|
||||
|
||||
log.Println("Detached installer launched successfully, quitting EMLy...")
|
||||
|
||||
// Quit application to allow installer to replace files
|
||||
time.Sleep(500 * time.Millisecond) // Brief delay to ensure installer starts
|
||||
runtime.Quit(a.ctx)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Status Methods
|
||||
// =============================================================================
|
||||
|
||||
// GetUpdateStatus returns the current update system status.
|
||||
// This can be polled by the frontend to update UI state.
|
||||
//
|
||||
// Returns:
|
||||
// - UpdateStatus: Current state of the update system
|
||||
func (a *App) GetUpdateStatus() UpdateStatus {
|
||||
return updateStatus
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Utility Functions
|
||||
// =============================================================================
|
||||
|
||||
// resolveUpdatePath resolves a network share path or file:// URL to a local path.
|
||||
// Handles UNC paths (\\server\share), file:// URLs, and local paths.
|
||||
func resolveUpdatePath(basePath, filename string) (string, error) {
|
||||
basePath = strings.TrimSpace(basePath)
|
||||
|
||||
// Handle file:// URL
|
||||
if strings.HasPrefix(strings.ToLower(basePath), "file://") {
|
||||
u, err := url.Parse(basePath)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("invalid file URL: %w", err)
|
||||
}
|
||||
// Convert file URL to local path
|
||||
basePath = filepath.FromSlash(u.Path)
|
||||
// Handle Windows drive letters (file:///C:/path -> C:/path)
|
||||
if len(basePath) > 0 && basePath[0] == '/' && len(basePath) > 2 && basePath[2] == ':' {
|
||||
basePath = basePath[1:]
|
||||
}
|
||||
}
|
||||
|
||||
// Join with filename
|
||||
fullPath := filepath.Join(basePath, filename)
|
||||
|
||||
// Verify path is accessible
|
||||
if _, err := os.Stat(fullPath); err != nil {
|
||||
return "", fmt.Errorf("path not accessible: %w", err)
|
||||
}
|
||||
|
||||
return fullPath, nil
|
||||
}
|
||||
|
||||
// compareSemanticVersions compares two semantic version strings.
|
||||
// Returns: -1 if v1 < v2, 0 if v1 == v2, 1 if v1 > v2
|
||||
func compareSemanticVersions(v1, v2 string) int {
|
||||
// Strip beta/alpha suffixes for comparison
|
||||
v1Clean := strings.Split(v1, "-")[0]
|
||||
v2Clean := strings.Split(v2, "-")[0]
|
||||
|
||||
parts1 := strings.Split(v1Clean, ".")
|
||||
parts2 := strings.Split(v2Clean, ".")
|
||||
|
||||
// Compare each version component
|
||||
maxLen := len(parts1)
|
||||
if len(parts2) > maxLen {
|
||||
maxLen = len(parts2)
|
||||
}
|
||||
|
||||
for i := 0; i < maxLen; i++ {
|
||||
var num1, num2 int
|
||||
|
||||
if i < len(parts1) {
|
||||
num1, _ = strconv.Atoi(parts1[i])
|
||||
}
|
||||
if i < len(parts2) {
|
||||
num2, _ = strconv.Atoi(parts2[i])
|
||||
}
|
||||
|
||||
if num1 < num2 {
|
||||
return -1
|
||||
}
|
||||
if num1 > num2 {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
// If base versions are equal, check beta/stable
|
||||
if v1 != v2 {
|
||||
// Version with beta suffix is considered "older" than without
|
||||
if strings.Contains(v1, "-beta") && !strings.Contains(v2, "-beta") {
|
||||
return -1
|
||||
}
|
||||
if !strings.Contains(v1, "-beta") && strings.Contains(v2, "-beta") {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
// verifyChecksum verifies the SHA256 checksum of a file
|
||||
func verifyChecksum(filePath, expectedChecksum string) error {
|
||||
file, err := os.Open(filePath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
hash := sha256.New()
|
||||
if _, err := io.Copy(hash, file); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
actualChecksum := hex.EncodeToString(hash.Sum(nil))
|
||||
|
||||
if !strings.EqualFold(actualChecksum, expectedChecksum) {
|
||||
return fmt.Errorf("checksum mismatch: expected %s, got %s", expectedChecksum, actualChecksum)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -18,6 +18,13 @@ type EMLyConfig struct {
|
||||
SDKDecoderReleaseChannel string `ini:"SDK_DECODER_RELEASE_CHANNEL"`
|
||||
GUISemver string `ini:"GUI_SEMVER"`
|
||||
GUIReleaseChannel string `ini:"GUI_RELEASE_CHANNEL"`
|
||||
Language string `ini:"LANGUAGE"`
|
||||
UpdateCheckEnabled string `ini:"UPDATE_CHECK_ENABLED"`
|
||||
UpdatePath string `ini:"UPDATE_PATH"`
|
||||
UpdateAutoCheck string `ini:"UPDATE_AUTO_CHECK"`
|
||||
WebView2UserDataPath string `ini:"WEBVIEW2_USERDATA_PATH"`
|
||||
WebView2DownloadPath string `ini:"WEBVIEW2_DOWNLOAD_PATH"`
|
||||
ExportAttachmentFolder string `ini:"EXPORT_ATTACHMENT_FOLDER"`
|
||||
}
|
||||
|
||||
// LoadConfig reads the config.ini file at the given path and returns a Config struct
|
||||
|
||||
@@ -2,6 +2,13 @@ package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/wailsapp/wails/v2/pkg/runtime"
|
||||
)
|
||||
@@ -16,6 +23,14 @@ var EmailDialogOptions = runtime.OpenDialogOptions{
|
||||
ShowHiddenFiles: false,
|
||||
}
|
||||
|
||||
var FolderDialogOptions = runtime.OpenDialogOptions{
|
||||
Title: "Select Folder",
|
||||
Filters: []runtime.FileFilter{
|
||||
{DisplayName: "Folders", Pattern: "*"},
|
||||
},
|
||||
ShowHiddenFiles: false,
|
||||
}
|
||||
|
||||
func ShowFileDialog(ctx context.Context) (string, error) {
|
||||
filePath, err := runtime.OpenFileDialog(ctx, EmailDialogOptions)
|
||||
if err != nil {
|
||||
@@ -23,3 +38,86 @@ func ShowFileDialog(ctx context.Context) (string, error) {
|
||||
}
|
||||
return filePath, nil
|
||||
}
|
||||
|
||||
func ShowFolderDialog(ctx context.Context) (string, error) {
|
||||
folderPath, err := runtime.OpenDirectoryDialog(ctx, FolderDialogOptions)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return folderPath, nil
|
||||
}
|
||||
|
||||
// SaveAttachmentToFolder saves a base64-encoded attachment to the specified folder.
|
||||
// If folderPath is empty, uses the user's Downloads folder as default.
|
||||
// Expands environment variables in the format %%VAR%% or %VAR%.
|
||||
//
|
||||
// Parameters:
|
||||
// - filename: The name to save the file as
|
||||
// - base64Data: The base64-encoded file content
|
||||
// - folderPath: Optional custom folder path (uses Downloads if empty)
|
||||
//
|
||||
// Returns:
|
||||
// - string: The full path where the file was saved
|
||||
// - error: Any file system or decoding errors
|
||||
func SaveAttachmentToFolder(filename string, base64Data string, folderPath string) (string, error) {
|
||||
// Decode base64 data
|
||||
data, err := base64.StdEncoding.DecodeString(base64Data)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to decode attachment data: %w", err)
|
||||
}
|
||||
|
||||
// Use configured folder or default to Downloads
|
||||
targetFolder := folderPath
|
||||
if targetFolder == "" {
|
||||
targetFolder = filepath.Join(os.Getenv("USERPROFILE"), "Downloads")
|
||||
} else {
|
||||
// Expand environment variables (%%VAR%% or %VAR% format)
|
||||
re := regexp.MustCompile(`%%([^%]+)%%|%([^%]+)%`)
|
||||
targetFolder = re.ReplaceAllStringFunc(targetFolder, func(match string) string {
|
||||
varName := strings.Trim(match, "%")
|
||||
return os.Getenv(varName)
|
||||
})
|
||||
}
|
||||
|
||||
// Ensure the target folder exists
|
||||
if err := os.MkdirAll(targetFolder, 0755); err != nil {
|
||||
return "", fmt.Errorf("failed to create target folder: %w", err)
|
||||
}
|
||||
|
||||
// Create full path
|
||||
fullPath := filepath.Join(targetFolder, filename)
|
||||
|
||||
// Save the file
|
||||
if err := os.WriteFile(fullPath, data, 0644); err != nil {
|
||||
return "", fmt.Errorf("failed to save attachment: %w", err)
|
||||
}
|
||||
|
||||
return fullPath, nil
|
||||
}
|
||||
|
||||
// OpenFileExplorer opens Windows Explorer and selects the specified file.
|
||||
// Uses the /select parameter to highlight the file in Explorer.
|
||||
// If the path is a directory, opens the directory without selecting anything.
|
||||
//
|
||||
// Parameters:
|
||||
// - filePath: The full path to the file or directory to open in Explorer
|
||||
//
|
||||
// Returns:
|
||||
// - error: Any execution errors
|
||||
func OpenFileExplorer(filePath string) error {
|
||||
// Check if path is a directory or file
|
||||
info, err := os.Stat(filePath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to stat path: %w", err)
|
||||
}
|
||||
|
||||
if info.IsDir() {
|
||||
// Open directory
|
||||
cmd := exec.Command("explorer.exe", filePath)
|
||||
return cmd.Start()
|
||||
}
|
||||
|
||||
// Open and select file
|
||||
cmd := exec.Command("explorer.exe", "/select,", filePath)
|
||||
return cmd.Start()
|
||||
}
|
||||
|
||||
16
config.ini
16
config.ini
@@ -1,6 +1,12 @@
|
||||
[EMLy]
|
||||
SDK_DECODER_SEMVER="1.3.1"
|
||||
SDK_DECODER_RELEASE_CHANNEL="beta"
|
||||
GUI_SEMVER="1.3.1"
|
||||
GUI_RELEASE_CHANNEL="beta"
|
||||
LANGUAGE="it"
|
||||
SDK_DECODER_SEMVER = 1.3.2
|
||||
SDK_DECODER_RELEASE_CHANNEL = stable
|
||||
GUI_SEMVER = 1.5.4
|
||||
GUI_RELEASE_CHANNEL = beta
|
||||
LANGUAGE = it
|
||||
UPDATE_CHECK_ENABLED = false
|
||||
UPDATE_PATH =
|
||||
UPDATE_AUTO_CHECK = true
|
||||
WEBVIEW2_USERDATA_PATH =
|
||||
WEBVIEW2_DOWNLOAD_PATH = %%USERPROFILE%%\Documents\EMLy_Attachments
|
||||
EXPORT_ATTACHMENT_FOLDER =
|
||||
|
||||
6
frontend/.gitignore
vendored
6
frontend/.gitignore
vendored
@@ -27,4 +27,8 @@ src/lib/paraglide
|
||||
project.inlang/cache/
|
||||
|
||||
# Wails
|
||||
/src/lib/wailsjs
|
||||
/src/lib/wailsjs
|
||||
|
||||
|
||||
bun.lock
|
||||
bun.lockb
|
||||
@@ -26,10 +26,10 @@
|
||||
"settings_preview_page_description": "Modify settings related to the preview page",
|
||||
"settings_preview_builtin_label": "Use built-in preview for images",
|
||||
"settings_preview_builtin_hint": "Uses EMLy's built-in image previewer for supported image file types.",
|
||||
"settings_preview_builtin_info": "Info: If disabled, image files will be treated as downloads instead of being previewed within the app.",
|
||||
"settings_preview_builtin_info": "Info: If disabled, image files will be opened by the computer's default app instead of being previewed within the app.",
|
||||
"settings_preview_pdf_builtin_label": "Use built-in viewer for PDFs",
|
||||
"settings_preview_pdf_builtin_hint": "Uses EMLy's built-in viewer for PDF files.",
|
||||
"settings_preview_pdf_builtin_info": "Info: If disabled, PDF files will be treated as downloads instead of being previewed within the app.",
|
||||
"settings_preview_pdf_builtin_info": "Info: If disabled, PDF files will be opened by the computer's default app instead of being previewed within the app.",
|
||||
"settings_msg_converter_title": "MSG Handling",
|
||||
"settings_msg_converter_description": "Configure how MSG files are processed.",
|
||||
"settings_msg_converter_label": "Use MSG to EML converter",
|
||||
@@ -50,7 +50,9 @@
|
||||
"settings_danger_reset_dialog_continue": "Continue",
|
||||
"settings_danger_warning": "Warning: This action is irreversible. Please ensure you have backed up any important data before proceeding.",
|
||||
"settings_danger_alert_title": "Advanced options enabled",
|
||||
"settings_danger_alert_description": "You're about to access EMLy's advanced options. Modifying such options may cause instability, including crashes, freezes, or security software alerts. For support or troubleshooting, contact @lyzcoote on Discord.",
|
||||
"settings_danger_alert_description_part1": "You're about to access EMLy's advanced options.",
|
||||
"settings_danger_alert_description_part2": "Modifying such options may cause instability, including crashes, freezes, or security software alerts.",
|
||||
"settings_danger_alert_description_part3": "For support or troubleshooting, contact your TL/RDS.",
|
||||
"settings_danger_alert_understood": "Understood",
|
||||
"settings_toast_reverted": "Reverted to last saved settings.",
|
||||
"settings_toast_save_failed": "Failed to save settings.",
|
||||
@@ -67,6 +69,8 @@
|
||||
"mail_open_btn_title": "Open another file",
|
||||
"mail_close_btn_label": "Close",
|
||||
"mail_close_btn_title": "Close",
|
||||
"mail_download_btn_label": "Download",
|
||||
"mail_download_btn_title": "Download",
|
||||
"mail_from": "From:",
|
||||
"mail_to": "To:",
|
||||
"mail_cc": "Cc:",
|
||||
@@ -77,8 +81,9 @@
|
||||
"mail_error_image": "Failed to open image file.",
|
||||
"settings_toast_language_changed": "Language changed successfully!",
|
||||
"settings_toast_language_change_failed": "Failed to change language.",
|
||||
"mail_open_btn_text": "Open EML/MSG File",
|
||||
"mail_open_btn_text": "Open File",
|
||||
"mail_close_btn_text": "Close",
|
||||
"mail_download_btn_text": "Download",
|
||||
"settings_danger_reset_dialog_description_part1": "This action cannot be undone.",
|
||||
"settings_danger_reset_dialog_description_part2": "This will permanently delete your current settings and return the app to its default state.",
|
||||
"mail_error_opening": "Failed to open EML file.",
|
||||
@@ -98,6 +103,12 @@
|
||||
"bugreport_email_placeholder": "your.email@example.com",
|
||||
"bugreport_text_label": "Bug Description",
|
||||
"bugreport_text_placeholder": "Describe the bug in detail...",
|
||||
"settings_appearance_title": "Appearance",
|
||||
"settings_appearance_description": "Customize the application theme.",
|
||||
"settings_theme_label": "Theme",
|
||||
"settings_theme_hint": "Choose between light and dark mode.",
|
||||
"settings_theme_light": "Light",
|
||||
"settings_theme_dark": "Dark",
|
||||
"bugreport_info": "Your message, email file (if loaded), screenshot, and system information will be included in the report.",
|
||||
"bugreport_screenshot_label": "Attached Screenshot:",
|
||||
"bugreport_cancel": "Cancel",
|
||||
@@ -120,5 +131,98 @@
|
||||
"settings_export_error": "Failed to export settings.",
|
||||
"settings_import_success": "Settings imported successfully!",
|
||||
"settings_import_error": "Failed to import settings.",
|
||||
"settings_import_invalid": "Invalid settings file."
|
||||
"settings_import_invalid": "Invalid settings file.",
|
||||
"settings_email_dark_viewer_label": "Dark theme for email content",
|
||||
"settings_email_dark_viewer_hint": "Display email body with a dark background matching the app theme.",
|
||||
"settings_email_dark_viewer_info": "Info: When disabled, emails will display with their original light background. Some emails may be designed for light backgrounds and look better with this disabled.",
|
||||
"sidebar_credits": "Credits",
|
||||
"credits_title": "Credits",
|
||||
"credits_description": "Acknowledgments and attributions for EMLy.",
|
||||
"credits_about_title": "About EMLy",
|
||||
"credits_about_description": "\"A slick app that somehow still works, with a badass UI that makes reading emails almost enjoyable.\"",
|
||||
"credits_about_description_2": " -Someone who clearly hasn't seen the codebase",
|
||||
"credits_app_tagline": "EML & MSG Viewer for Windows",
|
||||
"credits_app_description": "EMLy is a lightweight, modern desktop application designed to view .eml and .msg email files. Built with performance and usability in mind, it provides a clean interface for reading emails, viewing attachments, and handling Italian PEC certified emails.",
|
||||
"credits_team_title": "Development Team",
|
||||
"credits_team_description": "The people behind EMLy.",
|
||||
"credits_role_lead_developer": "Lead Developer",
|
||||
"credits_role_senior_developer": "Senior Developer",
|
||||
"credits_foisx_desc": "Creator and maintainer of EMLy. Responsible for architecture, development, and design.",
|
||||
"credits_laky64_desc": "Implemented the custom MSG file parser in Go for native Outlook message support.",
|
||||
"credits_special_thanks_title": "Special Thanks",
|
||||
"credits_special_thanks_description": "Contributors who helped make EMLy better in a significant way.",
|
||||
"credits_made_with": "Made with",
|
||||
"credits_at_3git": "at 3gIT",
|
||||
"credits_tech_title": "Built With",
|
||||
"credits_tech_description": "Core technologies powering EMLy.",
|
||||
"credits_tech_wails": "Desktop application framework for Go",
|
||||
"credits_tech_go": "Backend programming language",
|
||||
"credits_tech_sveltekit": "Frontend application framework",
|
||||
"credits_tech_svelte": "Reactive UI framework",
|
||||
"credits_tech_typescript": "Type-safe JavaScript",
|
||||
"credits_tech_tailwind": "Utility-first CSS framework",
|
||||
"credits_libraries_title": "Libraries & Packages",
|
||||
"credits_libraries_description": "Open source packages that make EMLy possible.",
|
||||
"credits_lib_shadcn": "Beautiful UI components for Svelte",
|
||||
"credits_lib_lucide": "Beautiful & consistent icon set",
|
||||
"credits_lib_paraglide": "Type-safe internationalization",
|
||||
"credits_lib_sonner": "Toast notifications for Svelte",
|
||||
"credits_lib_pdfjs": "PDF rendering library by Mozilla",
|
||||
"credits_lib_dompurify": "XSS sanitizer for HTML content",
|
||||
"credits_license_title": "License & Source",
|
||||
"credits_license_text": "EMLy is proprietary software developed by 3gIT. All rights reserved. The application uses various open source libraries, each governed by their respective licenses.",
|
||||
"credits_copyright": "All rights reserved.",
|
||||
"settings_updates_title": "Updates",
|
||||
"settings_updates_description": "Check for and install application updates from your network share.",
|
||||
"settings_updates_current_version": "Current Version",
|
||||
"settings_updates_available": "Update Available",
|
||||
"settings_updates_check_failed": "Check failed",
|
||||
"settings_updates_no_updates": "No updates found",
|
||||
"settings_updates_check_label": "Check for Updates",
|
||||
"settings_updates_last_checked": "Last checked: {time}",
|
||||
"settings_updates_click_check": "Click to check for available updates",
|
||||
"settings_updates_checking": "Checking...",
|
||||
"settings_updates_check_now": "Check Now",
|
||||
"settings_updates_version_available": "Version {version} Available",
|
||||
"settings_updates_downloading": "Downloading... {progress}%",
|
||||
"settings_updates_click_download": "Click to download the update",
|
||||
"settings_updates_download_button": "Download",
|
||||
"settings_updates_ready_title": "Update Ready to Install",
|
||||
"settings_updates_ready_ref": "Version {version} has been downloaded and verified",
|
||||
"settings_updates_install_button": "Install Now",
|
||||
"settings_updates_info_message": "Updates are checked from your configured network share path.",
|
||||
"settings_updates_current_path": "Current path:",
|
||||
"settings_updates_no_path": "No update path configured",
|
||||
"settings_toast_update_available": "Update available: {version}",
|
||||
"settings_toast_latest_version": "You're on the latest version",
|
||||
"settings_toast_check_failed": "Failed to check for updates",
|
||||
"settings_toast_download_success": "Update downloaded successfully",
|
||||
"settings_toast_download_failed": "Failed to download update",
|
||||
"settings_toast_install_failed": "Failed to launch installer",
|
||||
"settings_danger_update_checker_label": "Enable Update Checker",
|
||||
"settings_danger_update_checker_hint": "Check for application updates from network share",
|
||||
"settings_danger_update_checker_info": "Info: When enabled, the app will check for updates from your configured network share. Disable this if you manage updates manually or don't have network access.",
|
||||
"settings_reduce_motion_label": "Reduce Motion",
|
||||
"settings_reduce_motion_hint": "Disable transition animations for interface elements like the sidebar.",
|
||||
"settings_reduce_motion_info": "Info: When enabled, animations such as the sidebar slide transition will be removed for a snappier feel or to reduce visual distractions.",
|
||||
"settings_window_buttons_contrast_label": "Increase window buttons contrast",
|
||||
"settings_window_buttons_contrast_hint": "Makes the window control buttons (minimize, maximize, close) more visible by increasing their contrast.",
|
||||
"pdf_viewer_title": "PDF Viewer",
|
||||
"pdf_loading": "Loading PDF...",
|
||||
"pdf_zoom_in": "Zoom In",
|
||||
"pdf_zoom_out": "Zoom Out",
|
||||
"pdf_rotate_left": "Rotate Left",
|
||||
"pdf_rotate_right": "Rotate Right",
|
||||
"pdf_fit_width": "Fit to Width",
|
||||
"pdf_error_no_data": "No PDF data provided",
|
||||
"pdf_error_no_data_desc": "No PDF data provided. Please open this window from the main EMLy application.",
|
||||
"pdf_error_timeout": "Timeout loading PDF. The worker might have failed to initialize.",
|
||||
"pdf_error_parsing": "Error parsing PDF: ",
|
||||
"pdf_error_rendering": "Error rendering page: ",
|
||||
"settings_custom_download_label": "Custom Attachment Download",
|
||||
"settings_custom_download_hint": "Save attachments to a custom folder and open Explorer automatically",
|
||||
"settings_custom_download_info": "Info: When enabled, attachments will be saved to the folder configured below (or WEBVIEW2_DOWNLOAD_PATH if not set) and Windows Explorer will open to show the file. When disabled, uses browser's default download behavior.",
|
||||
"settings_export_folder_label": "Select a folder to save exported attachments",
|
||||
"settings_export_folder_hint": "Choose a default location for saving attachments that you export from emails (instead of the Downloads folder)",
|
||||
"settings_select_folder_button": "Select folder"
|
||||
}
|
||||
|
||||
@@ -26,10 +26,10 @@
|
||||
"settings_preview_page_description": "Modifica le impostazioni relative alla pagina di anteprima",
|
||||
"settings_preview_builtin_label": "Usa anteprima integrata per le immagini",
|
||||
"settings_preview_builtin_hint": "Usa il visualizzatore di immagini integrato di EMLy per i tipi di file immagini supportati.",
|
||||
"settings_preview_builtin_info": "Info: Se disabilitato, i file immagine verranno trattati come download anziché essere visualizzati all'interno dell'app.",
|
||||
"settings_preview_builtin_info": "Info: Se disabilitato, i file immagine verranno aperti tramite l'app di default attuale anziché essere visualizzati all'interno dell'app.",
|
||||
"settings_preview_pdf_builtin_label": "Usa visualizzatore integrato per PDF",
|
||||
"settings_preview_pdf_builtin_hint": "Usa il visualizzatore integrato di EMLy per i file PDF.",
|
||||
"settings_preview_pdf_builtin_info": "Info: Se disabilitato, i file PDF verranno trattati come download invece di essere visualizzati nell'app.",
|
||||
"settings_preview_pdf_builtin_info": "Info: Se disabilitato, i file PDF verranno aperti tramite l'app di default attuale invece di essere visualizzati nell'app.",
|
||||
"settings_msg_converter_title": "Gestione MSG",
|
||||
"settings_msg_converter_description": "Configura come vengono elaborati i file MSG.",
|
||||
"settings_msg_converter_label": "Usa convertitore MSG in EML",
|
||||
@@ -50,7 +50,9 @@
|
||||
"settings_danger_reset_dialog_continue": "Continua",
|
||||
"settings_danger_warning": "Attenzione: Questa azione è irreversibile. Assicurati di aver effettuato il backup di tutti i dati importanti prima di procedere.",
|
||||
"settings_danger_alert_title": "Opzioni avanzate abilitate",
|
||||
"settings_danger_alert_description": "Stai per accedere alle opzioni avanzate di EMLy. Modificare tali opzioni può causare instabilità, inclusi crash, blocchi o avvisi del software di sicurezza. Per supporto o risoluzione dei problemi, contatta @lyzcoote su Discord.",
|
||||
"settings_danger_alert_description_part1": "Stai per accedere alle opzioni avanzate di EMLy.",
|
||||
"settings_danger_alert_description_part2": "Modificare tali opzioni può causare instabilità, inclusi crash, blocchi o avvisi del software di sicurezza.",
|
||||
"settings_danger_alert_description_part3": "Per supporto o risoluzione dei problemi, contatta il proprio TL/RDS.",
|
||||
"settings_danger_alert_understood": "Capito",
|
||||
"settings_toast_reverted": "Ripristinato alle ultime impostazioni salvate.",
|
||||
"settings_toast_save_failed": "Impossibile salvare le impostazioni.",
|
||||
@@ -77,7 +79,7 @@
|
||||
"mail_error_image": "Impossibile aprire il file immagine.",
|
||||
"settings_toast_language_changed": "Lingua cambiata con successo!",
|
||||
"settings_toast_language_change_failed": "Impossibile cambiare lingua.",
|
||||
"mail_open_btn_text": "Apri file EML/MSG",
|
||||
"mail_open_btn_text": "Apri file",
|
||||
"mail_close_btn_text": "Chiudi",
|
||||
"settings_danger_reset_dialog_description_part1": "Questa azione non può essere annullata.",
|
||||
"settings_danger_reset_dialog_description_part2": "Questo eliminerà permanentemente le tue impostazioni attuali e riporterà l'app allo stato predefinito.",
|
||||
@@ -98,6 +100,12 @@
|
||||
"bugreport_email_placeholder": "tua.email@esempio.com",
|
||||
"bugreport_text_label": "Descrizione del Bug",
|
||||
"bugreport_text_placeholder": "Descrivi il bug in dettaglio...",
|
||||
"settings_appearance_title": "Aspetto",
|
||||
"settings_appearance_description": "Personalizza il tema dell'applicazione.",
|
||||
"settings_theme_label": "Tema",
|
||||
"settings_theme_hint": "Scegli tra modalità chiara e scura.",
|
||||
"settings_theme_light": "Chiaro",
|
||||
"settings_theme_dark": "Scuro",
|
||||
"bugreport_info": "Il tuo messaggio, il file email (se caricato), lo screenshot e le informazioni di sistema saranno inclusi nella segnalazione.",
|
||||
"bugreport_screenshot_label": "Screenshot Allegato:",
|
||||
"bugreport_cancel": "Annulla",
|
||||
@@ -120,5 +128,102 @@
|
||||
"settings_export_error": "Impossibile esportare le impostazioni.",
|
||||
"settings_import_success": "Impostazioni importate con successo!",
|
||||
"settings_import_error": "Impossibile importare le impostazioni.",
|
||||
"settings_import_invalid": "File impostazioni non valido."
|
||||
"settings_import_invalid": "File impostazioni non valido.",
|
||||
"settings_email_dark_viewer_label": "Tema scuro per contenuto email",
|
||||
"settings_email_dark_viewer_hint": "Visualizza il corpo dell'email con uno sfondo scuro che corrisponde al tema dell'app.",
|
||||
"settings_email_dark_viewer_info": "Info: Quando disabilitato, le email verranno visualizzate con lo sfondo chiaro originale. Alcune email potrebbero essere progettate per sfondi chiari e apparire meglio con questa opzione disabilitata.",
|
||||
"sidebar_credits": "Crediti",
|
||||
"credits_title": "Crediti",
|
||||
"credits_description": "Riconoscimenti e attribuzioni per EMLy.",
|
||||
"credits_about_title": "Informazioni su EMLy",
|
||||
"credits_about_description": "\"Un'app che in qualche modo funziona ancora, con un'interfaccia da paura che rende quasi piacevole leggere le email.\"",
|
||||
"credits_about_description_2": " -Qualcuno che chiaramente non ha visto il codice sorgente",
|
||||
"credits_app_tagline": "Visualizzatore EML e MSG per Windows",
|
||||
"credits_app_description": "EMLy è un'applicazione desktop leggera e moderna progettata per visualizzare file email .eml e .msg. Costruita con prestazioni e usabilità in mente, fornisce un'interfaccia pulita per leggere email, visualizzare allegati e gestire email PEC certificate italiane.",
|
||||
"credits_team_title": "Team di Sviluppo",
|
||||
"credits_team_description": "Le persone dietro EMLy.",
|
||||
"credits_role_lead_developer": "Sviluppatore Principale",
|
||||
"credits_role_senior_developer": "Sviluppatore Senior",
|
||||
"credits_foisx_desc": "Creatore e manutentore di EMLy. Responsabile dell'architettura, sviluppo e design.",
|
||||
"credits_laky64_desc": "Ha implementato il parser MSG personalizzato in Go per il supporto nativo dei messaggi Outlook.",
|
||||
"credits_special_thanks_title": "Ringraziamenti Speciali",
|
||||
"credits_special_thanks_description": "Contributori che hanno aiutato a migliorare EMLy in modo significativo.",
|
||||
"credits_made_with": "Fatto con",
|
||||
"credits_at_3git": "presso 3gIT",
|
||||
"credits_tech_title": "Costruito Con",
|
||||
"credits_tech_description": "Tecnologie principali che alimentano EMLy.",
|
||||
"credits_tech_wails": "Framework per applicazioni desktop in Go",
|
||||
"credits_tech_go": "Linguaggio di programmazione backend",
|
||||
"credits_tech_sveltekit": "Framework per applicazioni frontend",
|
||||
"credits_tech_svelte": "Framework UI reattivo",
|
||||
"credits_tech_typescript": "JavaScript type-safe",
|
||||
"credits_tech_tailwind": "Framework CSS utility-first",
|
||||
"credits_libraries_title": "Librerie e Pacchetti",
|
||||
"credits_libraries_description": "Pacchetti open source che rendono possibile EMLy.",
|
||||
"credits_lib_shadcn": "Componenti UI per Svelte",
|
||||
"credits_lib_lucide": "Set di icone belle e coerenti",
|
||||
"credits_lib_paraglide": "Internazionalizzazione type-safe",
|
||||
"credits_lib_sonner": "Notifiche toast per Svelte",
|
||||
"credits_lib_pdfjs": "Libreria di rendering PDF di Mozilla",
|
||||
"credits_lib_dompurify": "Sanitizzatore XSS per contenuti HTML",
|
||||
"credits_license_title": "Licenza e Sorgente",
|
||||
"credits_license_text": "EMLy è un software proprietario sviluppato da 3gIT. Tutti i diritti riservati. L'applicazione utilizza varie librerie open source, ciascuna governata dalle rispettive licenze.",
|
||||
"credits_copyright": "Tutti i diritti riservati.",
|
||||
"settings_updates_title": "Aggiornamenti",
|
||||
"settings_updates_description": "Controlla e installa gli aggiornamenti dell'applicazione dalla condivisione di rete.",
|
||||
"settings_updates_current_version": "Versione corrente",
|
||||
"settings_updates_available": "Aggiornamento disponibile",
|
||||
"settings_updates_check_failed": "Controllo fallito",
|
||||
"settings_updates_no_updates": "Nessun aggiornamento trovato",
|
||||
"settings_updates_check_label": "Controlla aggiornamenti",
|
||||
"settings_updates_last_checked": "Ultimo controllo: {time}",
|
||||
"settings_updates_click_check": "Clicca per cercare aggiornamenti disponibili",
|
||||
"settings_updates_checking": "Controllo in corso...",
|
||||
"settings_updates_check_now": "Controlla ora",
|
||||
"settings_updates_version_available": "Versione {version} disponibile",
|
||||
"settings_updates_downloading": "Download in corso... {progress}%",
|
||||
"settings_updates_click_download": "Clicca per scaricare l'aggiornamento",
|
||||
"settings_updates_download_button": "Scarica",
|
||||
"settings_updates_ready_title": "Aggiornamento pronto per l'installazione",
|
||||
"settings_updates_ready_ref": "La versione {version} è stata scaricata e verificata",
|
||||
"settings_updates_install_button": "Installa ora",
|
||||
"settings_updates_info_message": "Gli aggiornamenti vengono controllati dal percorso di rete configurato.",
|
||||
"settings_updates_current_path": "Percorso attuale:",
|
||||
"settings_updates_no_path": "Nessun percorso di aggiornamento configurato",
|
||||
"settings_toast_update_available": "Aggiornamento disponibile: {version}",
|
||||
"settings_toast_latest_version": "Sei sull'ultima versione",
|
||||
"settings_toast_check_failed": "Impossibile controllare gli aggiornamenti",
|
||||
"settings_toast_download_success": "Aggiornamento scaricato con successo",
|
||||
"settings_toast_download_failed": "Impossibile scaricare l'aggiornamento",
|
||||
"settings_toast_install_failed": "Impossibile avviare l'installazione",
|
||||
"settings_danger_update_checker_label": "Abilita controllo aggiornamenti",
|
||||
"settings_danger_update_checker_hint": "Controlla aggiornamenti applicazione dalla condivisione di rete",
|
||||
"settings_danger_update_checker_info": "Info: Quando abilitato, l'app controllerà gli aggiornamenti dal percorso di rete configurato. Disabilitalo se gestisci gli aggiornamenti manualmente o non hai accesso alla rete.",
|
||||
"settings_reduce_motion_label": "Riduci Movimento",
|
||||
"settings_reduce_motion_hint": "Disabilita le animazioni di transizione per gli elementi dell'interfaccia come la barra laterale.",
|
||||
"settings_reduce_motion_info": "Info: Quando abilitato, le animazioni come la transizione della barra laterale verranno rimosse per un'esperienza più reattiva o per ridurre le distrazioni visive.",
|
||||
"settings_window_buttons_contrast_label": "Aumenta contrasto pulsanti finestra",
|
||||
"settings_window_buttons_contrast_hint": "Rende i pulsanti di controllo della finestra (minimizza, massimizza, chiudi) più visibili aumentando il loro contrasto.",
|
||||
"pdf_viewer_title": "Visualizzatore PDF",
|
||||
"pdf_loading": "Caricamento PDF...",
|
||||
"pdf_zoom_in": "Ingrandisci",
|
||||
"pdf_zoom_out": "Riduci",
|
||||
"pdf_rotate_left": "Ruota a sinistra",
|
||||
"pdf_rotate_right": "Ruota a destra",
|
||||
"pdf_fit_width": "Adatta alla larghezza",
|
||||
"pdf_error_no_data": "Nessun dato PDF fornito",
|
||||
"pdf_error_no_data_desc": "Nessun dato PDF fornito. Apri questa finestra dall'applicazione principale EMLy.",
|
||||
"pdf_error_timeout": "Timeout caricamento PDF. Il worker potrebbe non essersi inizializzato correttamente.",
|
||||
"pdf_error_parsing": "Errore nel parsing del PDF: ",
|
||||
"pdf_error_rendering": "Errore nel rendering della pagina: ",
|
||||
"mail_download_btn_label": "Scarica",
|
||||
"mail_download_btn_title": "Scarica",
|
||||
"mail_download_btn_text": "Scarica",
|
||||
"settings_custom_download_label": "Download Personalizzato Allegati",
|
||||
"settings_custom_download_hint": "Salva gli allegati in una cartella personalizzata e apri automaticamente Esplora Risorse",
|
||||
"settings_custom_download_info": "Info: Quando abilitato, gli allegati verranno salvati nella cartella configurata di seguito (o WEBVIEW2_DOWNLOAD_PATH se non impostata) e Windows Explorer si aprirà per mostrare il file. Quando disabilitato, usa il comportamento di download predefinito del browser.",
|
||||
"settings_export_folder_label": "Seleziona una cartella per salvare gli allegati esportati",
|
||||
"settings_export_folder_hint": "Scegli una posizione predefinita per salvare gli allegati che esporti dalle email (invece della cartella Download)",
|
||||
"settings_select_folder_button": "Seleziona cartella"
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
"vite-plugin-devtools-json": "^1.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@rollup/rollup-win32-arm64-msvc": "^4.57.1",
|
||||
"@types/html2canvas": "^1.0.0",
|
||||
"dompurify": "^3.3.1",
|
||||
"html2canvas": "^1.4.1",
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
const theme = stored === "light" || stored === "dark" ? stored : "dark";
|
||||
document.documentElement.classList.toggle("dark", theme === "dark");
|
||||
} catch {
|
||||
// If storage is blocked, default to dark.
|
||||
document.documentElement.classList.add("dark");
|
||||
// If storage is blocked, default to light.
|
||||
document.documentElement.classList.remove("dark");
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
@@ -67,8 +67,21 @@
|
||||
<body data-sveltekit-preload-data="hover">
|
||||
<div id="app-loading">
|
||||
<div class="loader-spinner"></div>
|
||||
<div>Loading, please wait...</div>
|
||||
<div id="loading-text">Loading...</div>
|
||||
</div>
|
||||
<script>
|
||||
(() => {
|
||||
try {
|
||||
const settings = JSON.parse(localStorage.getItem("emly_gui_settings") || "{}");
|
||||
const lang = settings.selectedLanguage || "en";
|
||||
const text = lang === "it" ? "Caricamento..." : "Loading...";
|
||||
const el = document.getElementById("loading-text");
|
||||
if (el) el.textContent = text;
|
||||
} catch (e) {
|
||||
console.error("Failed to localize loading text", e);
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
<div style="display: contents;">%sveltekit.body%</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
309
frontend/src/lib/components/BugReportDialog.svelte
Normal file
309
frontend/src/lib/components/BugReportDialog.svelte
Normal file
@@ -0,0 +1,309 @@
|
||||
<script lang="ts">
|
||||
import { bugReportDialogOpen } from "$lib/stores/app";
|
||||
import * as m from "$lib/paraglide/messages.js";
|
||||
import * as Dialog from "$lib/components/ui/dialog/index.js";
|
||||
import { Button, buttonVariants } from "$lib/components/ui/button/index.js";
|
||||
import { Input } from "$lib/components/ui/input/index.js";
|
||||
import { Label } from "$lib/components/ui/label/index.js";
|
||||
import { Textarea } from "$lib/components/ui/textarea/index.js";
|
||||
import { CheckCircle, Copy, FolderOpen, Camera, Loader2 } from "@lucide/svelte";
|
||||
import { toast } from "svelte-sonner";
|
||||
import { TakeScreenshot, SubmitBugReport, OpenFolderInExplorer, GetConfig } from "$lib/wailsjs/go/main/App";
|
||||
import { browser } from "$app/environment";
|
||||
|
||||
// Bug report form state
|
||||
let userName = $state("");
|
||||
let userEmail = $state("");
|
||||
let bugDescription = $state("");
|
||||
|
||||
// Bug report screenshot state
|
||||
let screenshotData = $state("");
|
||||
let isCapturing = $state(false);
|
||||
|
||||
// Bug report system data
|
||||
let localStorageData = $state("");
|
||||
let configData = $state("");
|
||||
|
||||
// Bug report UI state
|
||||
let isSubmitting = $state(false);
|
||||
let isSuccess = $state(false);
|
||||
let resultZipPath = $state("");
|
||||
let canSubmit: boolean = $derived(
|
||||
bugDescription.trim().length > 0 && userName.trim().length > 0 && userEmail.trim().length > 0 && !isSubmitting && !isCapturing
|
||||
);
|
||||
|
||||
// Bug report dialog effects
|
||||
$effect(() => {
|
||||
if ($bugReportDialogOpen) {
|
||||
// Capture screenshot immediately when dialog opens
|
||||
captureScreenshot();
|
||||
// Capture localStorage data
|
||||
captureLocalStorage();
|
||||
// Capture config.ini data
|
||||
captureConfig();
|
||||
} else {
|
||||
// Reset form when dialog closes
|
||||
resetBugReportForm();
|
||||
}
|
||||
});
|
||||
|
||||
async function captureScreenshot() {
|
||||
isCapturing = true;
|
||||
try {
|
||||
const result = await TakeScreenshot();
|
||||
screenshotData = result.data;
|
||||
console.log("Screenshot captured:", result.width, "x", result.height);
|
||||
} catch (err) {
|
||||
console.error("Failed to capture screenshot:", err);
|
||||
} finally {
|
||||
isCapturing = false;
|
||||
}
|
||||
}
|
||||
|
||||
function captureLocalStorage() {
|
||||
if (!browser) return;
|
||||
try {
|
||||
const data: Record<string, string> = {};
|
||||
for (let i = 0; i < localStorage.length; i++) {
|
||||
const key = localStorage.key(i);
|
||||
if (key) {
|
||||
data[key] = localStorage.getItem(key) || "";
|
||||
}
|
||||
}
|
||||
localStorageData = JSON.stringify(data, null, 2);
|
||||
console.log("localStorage data captured");
|
||||
} catch (err) {
|
||||
console.error("Failed to capture localStorage:", err);
|
||||
localStorageData = "Error capturing localStorage";
|
||||
}
|
||||
}
|
||||
|
||||
async function captureConfig() {
|
||||
try {
|
||||
const config = await GetConfig();
|
||||
configData = JSON.stringify(config, null, 2);
|
||||
console.log("Config data captured");
|
||||
} catch (err) {
|
||||
console.error("Failed to capture config:", err);
|
||||
configData = "Error capturing config";
|
||||
}
|
||||
}
|
||||
|
||||
function resetBugReportForm() {
|
||||
userName = "";
|
||||
userEmail = "";
|
||||
bugDescription = "";
|
||||
screenshotData = "";
|
||||
localStorageData = "";
|
||||
configData = "";
|
||||
isCapturing = false;
|
||||
isSubmitting = false;
|
||||
isSuccess = false;
|
||||
resultZipPath = "";
|
||||
}
|
||||
|
||||
async function handleBugReportSubmit(event: Event) {
|
||||
event.preventDefault();
|
||||
|
||||
if (!bugDescription.trim()) {
|
||||
toast.error("Please provide a bug description.");
|
||||
return;
|
||||
}
|
||||
|
||||
isSubmitting = true;
|
||||
|
||||
try {
|
||||
const result = await SubmitBugReport({
|
||||
name: userName,
|
||||
email: userEmail,
|
||||
description: bugDescription,
|
||||
screenshotData: screenshotData,
|
||||
localStorageData: localStorageData,
|
||||
configData: configData
|
||||
});
|
||||
|
||||
resultZipPath = result.zipPath;
|
||||
isSuccess = true;
|
||||
console.log("Bug report created:", result.zipPath);
|
||||
} catch (err) {
|
||||
console.error("Failed to create bug report:", err);
|
||||
toast.error(m.bugreport_error());
|
||||
} finally {
|
||||
isSubmitting = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function copyBugReportPath() {
|
||||
try {
|
||||
await navigator.clipboard.writeText(resultZipPath);
|
||||
toast.success(m.bugreport_copied());
|
||||
} catch (err) {
|
||||
console.error("Failed to copy path:", err);
|
||||
}
|
||||
}
|
||||
|
||||
async function openBugReportFolder() {
|
||||
try {
|
||||
const folderPath = resultZipPath.replace(/\.zip$/, "");
|
||||
await OpenFolderInExplorer(folderPath);
|
||||
} catch (err) {
|
||||
console.error("Failed to open folder:", err);
|
||||
}
|
||||
}
|
||||
|
||||
function closeBugReportDialog() {
|
||||
$bugReportDialogOpen = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
<Dialog.Root bind:open={$bugReportDialogOpen}>
|
||||
<Dialog.Content class="sm:max-w-125 w-full max-h-[80vh] overflow-y-auto custom-scrollbar">
|
||||
{#if isSuccess}
|
||||
<!-- Success State -->
|
||||
<Dialog.Header>
|
||||
<Dialog.Title class="flex items-center gap-2">
|
||||
<CheckCircle class="h-5 w-5 text-green-500" />
|
||||
{m.bugreport_success_title()}
|
||||
</Dialog.Title>
|
||||
<Dialog.Description>
|
||||
{m.bugreport_success_message()}
|
||||
</Dialog.Description>
|
||||
</Dialog.Header>
|
||||
|
||||
<div class="grid gap-4 py-4">
|
||||
<div class="bg-muted rounded-md p-3">
|
||||
<code class="text-xs break-all select-all">{resultZipPath}</code>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-2">
|
||||
<Button variant="outline" class="flex-1" onclick={copyBugReportPath}>
|
||||
<Copy class="h-4 w-4 mr-2" />
|
||||
{m.bugreport_copy_path()}
|
||||
</Button>
|
||||
<Button variant="outline" class="flex-1" onclick={openBugReportFolder}>
|
||||
<FolderOpen class="h-4 w-4 mr-2" />
|
||||
{m.bugreport_open_folder()}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Dialog.Footer>
|
||||
<Button onclick={closeBugReportDialog}>
|
||||
{m.bugreport_close()}
|
||||
</Button>
|
||||
</Dialog.Footer>
|
||||
{:else}
|
||||
<!-- Form State -->
|
||||
<form onsubmit={handleBugReportSubmit}>
|
||||
<Dialog.Header>
|
||||
<Dialog.Title>{m.bugreport_title()}</Dialog.Title>
|
||||
<Dialog.Description>
|
||||
{m.bugreport_description()}
|
||||
</Dialog.Description>
|
||||
</Dialog.Header>
|
||||
|
||||
<div class="grid gap-4 py-4">
|
||||
<div class="grid gap-2">
|
||||
<Label for="bug-name">{m.bugreport_name_label()}</Label>
|
||||
<Input
|
||||
id="bug-name"
|
||||
placeholder={m.bugreport_name_placeholder()}
|
||||
bind:value={userName}
|
||||
disabled={isSubmitting}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-2">
|
||||
<Label for="bug-email">{m.bugreport_email_label()}</Label>
|
||||
<Input
|
||||
id="bug-email"
|
||||
type="email"
|
||||
placeholder={m.bugreport_email_placeholder()}
|
||||
bind:value={userEmail}
|
||||
disabled={isSubmitting}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-2">
|
||||
<Label for="bug-description">{m.bugreport_text_label()}</Label>
|
||||
<Textarea
|
||||
id="bug-description"
|
||||
placeholder={m.bugreport_text_placeholder()}
|
||||
bind:value={bugDescription}
|
||||
disabled={isSubmitting}
|
||||
class="min-h-30"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Screenshot Preview -->
|
||||
<div class="grid gap-2">
|
||||
<Label class="flex items-center gap-2">
|
||||
<Camera class="h-4 w-4" />
|
||||
{m.bugreport_screenshot_label()}
|
||||
</Label>
|
||||
{#if isCapturing}
|
||||
<div class="flex items-center gap-2 text-muted-foreground text-sm">
|
||||
<Loader2 class="h-4 w-4 animate-spin" />
|
||||
Capturing...
|
||||
</div>
|
||||
{:else if screenshotData}
|
||||
<div class="border rounded-md overflow-hidden">
|
||||
<img
|
||||
src="data:image/png;base64,{screenshotData}"
|
||||
alt="Screenshot preview"
|
||||
class="w-full h-32 object-cover object-top opacity-80 hover:opacity-100 transition-opacity cursor-pointer"
|
||||
/>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="text-muted-foreground text-sm">
|
||||
No screenshot available
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<p class="text-muted-foreground text-sm">
|
||||
{m.bugreport_info()}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<Dialog.Footer>
|
||||
<button type="button" class={buttonVariants({ variant: "outline" })} disabled={isSubmitting} onclick={closeBugReportDialog}>
|
||||
{m.bugreport_cancel()}
|
||||
</button>
|
||||
<Button type="submit" disabled={!canSubmit}>
|
||||
{#if isSubmitting}
|
||||
<Loader2 class="h-4 w-4 mr-2 animate-spin" />
|
||||
{m.bugreport_submitting()}
|
||||
{:else}
|
||||
{m.bugreport_submit()}
|
||||
{/if}
|
||||
</Button>
|
||||
</Dialog.Footer>
|
||||
</form>
|
||||
{/if}
|
||||
</Dialog.Content>
|
||||
</Dialog.Root>
|
||||
|
||||
<style>
|
||||
:global(.custom-scrollbar::-webkit-scrollbar) {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
}
|
||||
|
||||
:global(.custom-scrollbar::-webkit-scrollbar-track) {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
:global(.custom-scrollbar::-webkit-scrollbar-thumb) {
|
||||
background: var(--border);
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
:global(.custom-scrollbar::-webkit-scrollbar-thumb:hover) {
|
||||
background: var(--muted-foreground);
|
||||
}
|
||||
|
||||
:global(.custom-scrollbar::-webkit-scrollbar-corner) {
|
||||
background: transparent;
|
||||
}
|
||||
</style>
|
||||
@@ -9,18 +9,21 @@
|
||||
Signature,
|
||||
FileCode,
|
||||
Loader2,
|
||||
Download,
|
||||
} from '@lucide/svelte';
|
||||
import { sidebarOpen } from '$lib/stores/app';
|
||||
import { onDestroy, onMount } from 'svelte';
|
||||
import { toast } from 'svelte-sonner';
|
||||
import { EventsOn, WindowShow, WindowUnminimise } from '$lib/wailsjs/runtime/runtime';
|
||||
import { SaveAttachment, OpenExplorerForPath } from '$lib/wailsjs/go/main/App';
|
||||
import { mailState } from '$lib/stores/mail-state.svelte';
|
||||
import * as m from '$lib/paraglide/messages';
|
||||
import { dev } from '$app/environment';
|
||||
|
||||
// Import refactored utilities
|
||||
import {
|
||||
IFRAME_UTIL_HTML,
|
||||
IFRAME_UTIL_HTML_DARK,
|
||||
IFRAME_UTIL_HTML_LIGHT,
|
||||
CONTENT_TYPES,
|
||||
PEC_FILES,
|
||||
arrayBufferToBase64,
|
||||
@@ -33,6 +36,8 @@
|
||||
processEmailBody,
|
||||
isEmailFile,
|
||||
} from '$lib/utils/mail';
|
||||
import { settingsStore } from '$lib/stores/settings.svelte';
|
||||
import { Separator } from "$lib/components/ui/separator";
|
||||
|
||||
// ============================================================================
|
||||
// State
|
||||
@@ -42,6 +47,13 @@
|
||||
let isLoading = $state(false);
|
||||
let loadingText = $state('');
|
||||
|
||||
// Derived iframe HTML based on dark/light setting
|
||||
let iframeUtilHtml = $derived(
|
||||
settingsStore.settings.useDarkEmailViewer !== false
|
||||
? IFRAME_UTIL_HTML_DARK
|
||||
: IFRAME_UTIL_HTML_LIGHT
|
||||
);
|
||||
|
||||
// ============================================================================
|
||||
// Event Handlers
|
||||
// ============================================================================
|
||||
@@ -50,6 +62,43 @@
|
||||
mailState.clear();
|
||||
}
|
||||
|
||||
async function onDownloadAttachments() {
|
||||
if (!mailState.currentEmail || !mailState.currentEmail.attachments) return;
|
||||
|
||||
// Check if custom download behavior is enabled
|
||||
const useCustomDownload = settingsStore.settings.useCustomAttachmentDownload ?? false;
|
||||
|
||||
if (useCustomDownload) {
|
||||
// Use backend SaveAttachment (saves to configured folder and opens Explorer)
|
||||
try {
|
||||
let lastSavedPath = '';
|
||||
for (const att of mailState.currentEmail.attachments) {
|
||||
const base64 = arrayBufferToBase64(att.data);
|
||||
lastSavedPath = await SaveAttachment(att.filename, base64);
|
||||
toast.success(`Saved: ${att.filename}`);
|
||||
}
|
||||
// Open Explorer to show the folder where files were saved
|
||||
if (lastSavedPath) {
|
||||
await OpenExplorerForPath(lastSavedPath);
|
||||
}
|
||||
} catch (err) {
|
||||
toast.error(`Failed to save attachments: ${err}`);
|
||||
}
|
||||
} else {
|
||||
// Use browser default download (downloads to browser's default folder)
|
||||
mailState.currentEmail.attachments.forEach((att) => {
|
||||
const base64 = arrayBufferToBase64(att.data);
|
||||
const dataUrl = createDataUrl(att.contentType, base64);
|
||||
const link = document.createElement('a');
|
||||
link.href = dataUrl;
|
||||
link.download = att.filename;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function onOpenMail() {
|
||||
isLoading = true;
|
||||
loadingText = m.layout_loading_text();
|
||||
@@ -106,10 +155,6 @@
|
||||
mailState.currentEmail.body = processedBody;
|
||||
}
|
||||
}
|
||||
|
||||
if (dev) {
|
||||
console.debug('emailObj:', mailState.currentEmail);
|
||||
}
|
||||
console.info('Current email changed:', mailState.currentEmail?.subject);
|
||||
|
||||
if (mailState.currentEmail !== null) {
|
||||
@@ -219,6 +264,16 @@
|
||||
{mailState.currentEmail.subject || m.mail_subject_no_subject()}
|
||||
</div>
|
||||
<div class="controls">
|
||||
<button
|
||||
class="btn"
|
||||
onclick={onDownloadAttachments}
|
||||
aria-label={m.mail_download_btn_label()}
|
||||
title={m.mail_download_btn_title()}
|
||||
disabled={isLoading}
|
||||
>
|
||||
<Download size="15" />
|
||||
{m.mail_download_btn_text()}
|
||||
</button>
|
||||
<button
|
||||
class="btn"
|
||||
onclick={onOpenMail}
|
||||
@@ -347,9 +402,9 @@
|
||||
</div>
|
||||
|
||||
<!-- Email Body -->
|
||||
<div class="email-body-wrapper">
|
||||
<div class="email-body-wrapper" class:light-theme={settingsStore.settings.useDarkEmailViewer === false}>
|
||||
<iframe
|
||||
srcdoc={mailState.currentEmail.body + IFRAME_UTIL_HTML}
|
||||
srcdoc={mailState.currentEmail.body + iframeUtilHtml}
|
||||
title="Email Body"
|
||||
class="email-iframe"
|
||||
sandbox="allow-same-origin allow-scripts"
|
||||
@@ -398,8 +453,8 @@
|
||||
}
|
||||
|
||||
.panel {
|
||||
background: rgba(255, 255, 255, 0.04);
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
background: var(--card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 14px;
|
||||
overflow: hidden;
|
||||
}
|
||||
@@ -418,20 +473,20 @@
|
||||
height: 34px;
|
||||
padding: 0 12px;
|
||||
border-radius: 10px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
color: inherit;
|
||||
border: 1px solid var(--border);
|
||||
background: var(--muted);
|
||||
color: var(--muted-foreground);
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
color: rgba(255, 255, 255, 0.5);
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
background: rgba(255, 255, 255, 0.09);
|
||||
background: var(--accent);
|
||||
color: var(--accent-foreground);
|
||||
}
|
||||
|
||||
.events {
|
||||
@@ -449,16 +504,16 @@
|
||||
}
|
||||
|
||||
.email-header-content {
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
background: var(--card);
|
||||
padding: 16px;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.08);
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.email-subject {
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
line-height: 1.25;
|
||||
color: inherit;
|
||||
color: var(--foreground);
|
||||
min-width: 0;
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
@@ -491,21 +546,21 @@
|
||||
|
||||
.email-meta-grid .label {
|
||||
text-align: right;
|
||||
color: rgba(255, 255, 255, 0.5);
|
||||
color: var(--muted-foreground);
|
||||
margin-right: 8px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.email-meta-grid .value {
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
color: var(--foreground);
|
||||
word-break: break-all;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.email-attachments {
|
||||
padding: 10px 16px;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.08);
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
border-bottom: 1px solid var(--border);
|
||||
background: var(--muted);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
@@ -517,7 +572,7 @@
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
color: rgba(255, 255, 255, 0.5);
|
||||
color: var(--muted-foreground);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
@@ -533,9 +588,9 @@
|
||||
height: 28px;
|
||||
padding: 0 10px;
|
||||
border-radius: 6px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.15);
|
||||
border: 1px solid var(--border);
|
||||
background: transparent;
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
color: var(--foreground);
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
@@ -543,8 +598,8 @@
|
||||
}
|
||||
|
||||
.att-btn:hover {
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
color: #fff;
|
||||
background: var(--accent);
|
||||
color: var(--accent-foreground);
|
||||
}
|
||||
|
||||
.att-btn.image {
|
||||
@@ -579,9 +634,15 @@
|
||||
|
||||
.email-body-wrapper {
|
||||
flex: 1;
|
||||
background: white;
|
||||
background: #0d0d0d;
|
||||
position: relative;
|
||||
min-height: 200px;
|
||||
border-radius: 0 0 14px 14px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.email-body-wrapper.light-theme {
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.email-iframe {
|
||||
@@ -617,10 +678,10 @@
|
||||
justify-content: center;
|
||||
height: 36px;
|
||||
padding: 0 16px;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border: 1px solid rgba(255, 255, 255, 0.15);
|
||||
background: var(--muted);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
color: white;
|
||||
color: var(--foreground);
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
@@ -628,8 +689,8 @@
|
||||
}
|
||||
|
||||
.browse-btn:hover {
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
border-color: rgba(255, 255, 255, 0.25);
|
||||
background: var(--accent);
|
||||
border-color: var(--accent-foreground);
|
||||
}
|
||||
|
||||
.browse-btn:disabled,
|
||||
@@ -649,12 +710,12 @@
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
background: var(--border);
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
background: var(--muted-foreground);
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-corner {
|
||||
@@ -663,7 +724,7 @@
|
||||
|
||||
.att-empty {
|
||||
font-size: 11px;
|
||||
color: rgba(255, 255, 255, 0.4);
|
||||
color: var(--muted-foreground);
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import * as Sidebar from "$lib/components/ui/sidebar/index.js";
|
||||
import { dangerZoneEnabled } from "$lib/stores/app";
|
||||
import * as m from "$lib/paraglide/messages.js";
|
||||
import { Mail } from "@lucide/svelte/icons";
|
||||
import { Mail, Heart, Info } from "@lucide/svelte/icons";
|
||||
|
||||
const CLICK_WINDOW_MS = 4000;
|
||||
const REQUIRED_CLICKS = 10;
|
||||
@@ -43,14 +43,21 @@
|
||||
disabled: false,
|
||||
id: 2,
|
||||
},
|
||||
{
|
||||
title: m.sidebar_credits(),
|
||||
url: "/credits",
|
||||
icon: Info,
|
||||
disabled: false,
|
||||
id: 3,
|
||||
},
|
||||
];
|
||||
</script>
|
||||
|
||||
<Sidebar.Root style="opacity: 0.8;">
|
||||
<Sidebar.Header>
|
||||
<div
|
||||
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;"
|
||||
class="sidebar-title items-center justify-center p-3 border-b border-border flex"
|
||||
style="padding: 12px; display: flex; justify-content: center;"
|
||||
>
|
||||
<img src="/appicon.png" alt="Logo" width="64" height="64" />
|
||||
<span
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
let { onSave, onReset } = $props();
|
||||
</script>
|
||||
|
||||
<div class="flex items-center gap-4 rounded-lg border bg-background px-4 py-3 shadow-lg w-full max-w-md">
|
||||
<div class="flex items-center gap-4 rounded-lg border bg-card px-4 py-3 shadow-lg w-full max-w-md">
|
||||
<span class="text-sm text-muted-foreground flex-1">
|
||||
{m.settings_unsaved_toast_message()}
|
||||
</span>
|
||||
@@ -19,9 +19,3 @@
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.bg-background {
|
||||
background-color: oklch(0.205 0 0);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { browser } from "$app/environment";
|
||||
import type { EMLy_GUI_Settings } from "$lib/types";
|
||||
import { getFromLocalStorage, saveToLocalStorage } from "$lib/utils/localStorageHelper";
|
||||
import { applyTheme, getStoredTheme } from "$lib/utils/theme";
|
||||
import { setLocale } from "$lib/paraglide/runtime";
|
||||
|
||||
const STORAGE_KEY = "emly_gui_settings";
|
||||
|
||||
@@ -10,6 +12,14 @@ const defaults: EMLy_GUI_Settings = {
|
||||
useBuiltinPDFViewer: true,
|
||||
previewFileSupportedTypes: ["jpg", "jpeg", "png"],
|
||||
enableAttachedDebuggerProtection: true,
|
||||
useDarkEmailViewer: true,
|
||||
enableUpdateChecker: false,
|
||||
musicInspirationEnabled: false,
|
||||
reduceMotion: false,
|
||||
theme: "dark",
|
||||
increaseWindowButtonsContrast: false,
|
||||
exportAttachmentFolder: "",
|
||||
useCustomAttachmentDownload: false,
|
||||
};
|
||||
|
||||
class SettingsStore {
|
||||
@@ -31,6 +41,40 @@ class SettingsStore {
|
||||
console.error("Failed to load settings", e);
|
||||
}
|
||||
}
|
||||
|
||||
// Migration: Check for legacy musicInspirationEnabled key
|
||||
const legacyMusic = getFromLocalStorage("musicInspirationEnabled");
|
||||
if (legacyMusic !== null) {
|
||||
this.settings.musicInspirationEnabled = legacyMusic === "true";
|
||||
localStorage.removeItem("musicInspirationEnabled");
|
||||
this.save(); // Save immediately to persist the migration
|
||||
}
|
||||
|
||||
// Sync theme from localStorage key used in app.html
|
||||
const storedTheme = getStoredTheme();
|
||||
if (!this.settings.theme) {
|
||||
this.settings.theme = storedTheme;
|
||||
} else if (this.settings.theme !== storedTheme) {
|
||||
// If there's a mismatch, prioritize the theme from emly_theme key
|
||||
this.settings.theme = storedTheme;
|
||||
}
|
||||
|
||||
// Sync useDarkEmailViewer with theme
|
||||
this.settings.useDarkEmailViewer = this.settings.theme === "dark";
|
||||
|
||||
// Apply the theme
|
||||
applyTheme(this.settings.theme);
|
||||
|
||||
// Apply the language
|
||||
if (this.settings.selectedLanguage) {
|
||||
setLocale(this.settings.selectedLanguage);
|
||||
}
|
||||
|
||||
// Save defaults/merged settings to storage if they didn't exist or were updated during load
|
||||
if (!stored) {
|
||||
this.save();
|
||||
}
|
||||
|
||||
this.hasHydrated = true;
|
||||
}
|
||||
|
||||
@@ -41,11 +85,20 @@ class SettingsStore {
|
||||
|
||||
update(newSettings: Partial<EMLy_GUI_Settings>) {
|
||||
this.settings = { ...this.settings, ...newSettings };
|
||||
|
||||
// Apply theme if it changed
|
||||
if (newSettings.theme && this.settings.theme) {
|
||||
applyTheme(this.settings.theme);
|
||||
}
|
||||
|
||||
this.save();
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.settings = { ...defaults };
|
||||
if (this.settings.theme) {
|
||||
applyTheme(this.settings.theme);
|
||||
}
|
||||
this.save();
|
||||
}
|
||||
}
|
||||
|
||||
32
frontend/src/lib/types.d.ts
vendored
32
frontend/src/lib/types.d.ts
vendored
@@ -5,9 +5,35 @@ type SupportedFileTypePreview = "jpg" | "jpeg" | "png";
|
||||
interface EMLy_GUI_Settings {
|
||||
selectedLanguage: SupportedLanguages = "en" | "it";
|
||||
useBuiltinPreview: boolean;
|
||||
useBuiltinPDFViewer?: boolean;
|
||||
previewFileSupportedTypes?: SupportedFileTypePreview[];
|
||||
enableAttachedDebuggerProtection?: boolean;
|
||||
useBuiltinPDFViewer: boolean;
|
||||
previewFileSupportedTypes: SupportedFileTypePreview[];
|
||||
enableAttachedDebuggerProtection: boolean;
|
||||
useDarkEmailViewer?: boolean;
|
||||
enableUpdateChecker?: boolean;
|
||||
musicInspirationEnabled?: boolean;
|
||||
reduceMotion?: boolean;
|
||||
theme: "light" | "dark";
|
||||
increaseWindowButtonsContrast: boolean;
|
||||
exportAttachmentFolder?: string;
|
||||
useCustomAttachmentDownload?: boolean;
|
||||
}
|
||||
|
||||
type SupportedLanguages = "en" | "it";
|
||||
// Plugin System Types
|
||||
interface PluginFormatSupport {
|
||||
extensions: string[];
|
||||
mime_types?: string[];
|
||||
priority: number;
|
||||
}
|
||||
|
||||
interface PluginInfo {
|
||||
name: string;
|
||||
version: string;
|
||||
author: string;
|
||||
description: string;
|
||||
capabilities: string[];
|
||||
status: "unloaded" | "loading" | "active" | "error" | "disabled";
|
||||
enabled: boolean;
|
||||
last_error?: string;
|
||||
supported_formats?: PluginFormatSupport[];
|
||||
}
|
||||
@@ -1,10 +1,87 @@
|
||||
/**
|
||||
* HTML/CSS injected into the email body iframe for styling and security
|
||||
* Dark theme HTML/CSS injected into the email body iframe
|
||||
* - Applies dark theme matching the main app
|
||||
* - Removes default body margins
|
||||
* - Disables link clicking for security
|
||||
* - Prevents Ctrl+Wheel zoom in iframe
|
||||
* - Styles links, tables, and common email elements for dark mode
|
||||
*/
|
||||
export const IFRAME_UTIL_HTML_DARK = `<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 20px;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||||
background-color: #0d0d0d;
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
line-height: 1.5;
|
||||
}
|
||||
a {
|
||||
pointer-events: none !important;
|
||||
cursor: default !important;
|
||||
color: #60a5fa !important;
|
||||
}
|
||||
img {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
table {
|
||||
border-color: rgba(255, 255, 255, 0.15) !important;
|
||||
}
|
||||
td, th {
|
||||
border-color: rgba(255, 255, 255, 0.15) !important;
|
||||
}
|
||||
hr {
|
||||
border-color: rgba(255, 255, 255, 0.15);
|
||||
}
|
||||
blockquote {
|
||||
border-left: 3px solid rgba(255, 255, 255, 0.2);
|
||||
margin-left: 0;
|
||||
padding-left: 16px;
|
||||
color: rgba(255, 255, 255, 0.7);
|
||||
}
|
||||
pre, code {
|
||||
background-color: rgba(255, 255, 255, 0.08);
|
||||
border-radius: 4px;
|
||||
padding: 2px 6px;
|
||||
}
|
||||
pre {
|
||||
padding: 12px;
|
||||
overflow-x: auto;
|
||||
}
|
||||
</style><script>function handleWheel(event){if(event.ctrlKey){event.preventDefault();}}document.addEventListener('wheel',handleWheel,{passive:false});<\/script>`;
|
||||
|
||||
/**
|
||||
* Light theme HTML/CSS injected into the email body iframe (original styling)
|
||||
* - Standard white background
|
||||
* - Removes default body margins
|
||||
* - Disables link clicking for security
|
||||
* - Prevents Ctrl+Wheel zoom in iframe
|
||||
*/
|
||||
export const IFRAME_UTIL_HTML = `<style>body{margin:0;padding:20px;font-family:sans-serif;} a{pointer-events:none!important;cursor:default!important;}</style><script>function handleWheel(event){if(event.ctrlKey){event.preventDefault();}}document.addEventListener('wheel',handleWheel,{passive:false});<\/script>`;
|
||||
export const IFRAME_UTIL_HTML_LIGHT = `<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 20px;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||||
background-color: #ffffff;
|
||||
color: #1a1a1a;
|
||||
line-height: 1.5;
|
||||
}
|
||||
a {
|
||||
pointer-events: none !important;
|
||||
cursor: default !important;
|
||||
color: #2563eb !important;
|
||||
}
|
||||
img {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
</style><script>function handleWheel(event){if(event.ctrlKey){event.preventDefault();}}document.addEventListener('wheel',handleWheel,{passive:false});<\/script>`;
|
||||
|
||||
/**
|
||||
* Default iframe HTML (dark theme for backwards compatibility)
|
||||
* @deprecated Use IFRAME_UTIL_HTML_DARK or IFRAME_UTIL_HTML_LIGHT instead
|
||||
*/
|
||||
export const IFRAME_UTIL_HTML = IFRAME_UTIL_HTML_DARK;
|
||||
|
||||
/**
|
||||
* Supported email file extensions
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
// Constants
|
||||
export {
|
||||
IFRAME_UTIL_HTML,
|
||||
IFRAME_UTIL_HTML_DARK,
|
||||
IFRAME_UTIL_HTML_LIGHT,
|
||||
EMAIL_EXTENSIONS,
|
||||
CONTENT_TYPES,
|
||||
PEC_FILES,
|
||||
|
||||
45
frontend/src/lib/utils/theme.ts
Normal file
45
frontend/src/lib/utils/theme.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { browser } from "$app/environment";
|
||||
|
||||
const THEME_KEY = "emly_theme";
|
||||
|
||||
export type Theme = "light" | "dark";
|
||||
|
||||
/**
|
||||
* Applies the theme to the document element and saves it to localStorage
|
||||
*/
|
||||
export function applyTheme(theme: Theme) {
|
||||
if (!browser) return;
|
||||
|
||||
const isDark = theme === "dark";
|
||||
document.documentElement.classList.toggle("dark", isDark);
|
||||
|
||||
try {
|
||||
localStorage.setItem(THEME_KEY, theme);
|
||||
} catch (e) {
|
||||
console.error("Failed to save theme to localStorage:", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current theme from localStorage or returns the default
|
||||
*/
|
||||
export function getStoredTheme(): Theme {
|
||||
if (!browser) return "light";
|
||||
|
||||
try {
|
||||
const stored = localStorage.getItem(THEME_KEY);
|
||||
return stored === "light" || stored === "dark" ? stored : "light";
|
||||
} catch {
|
||||
return "light";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles between light and dark theme
|
||||
*/
|
||||
export function toggleTheme(): Theme {
|
||||
const current = getStoredTheme();
|
||||
const newTheme: Theme = current === "dark" ? "light" : "dark";
|
||||
applyTheme(newTheme);
|
||||
return newTheme;
|
||||
}
|
||||
@@ -3,8 +3,7 @@
|
||||
import { page, navigating } from "$app/state";
|
||||
import { beforeNavigate, goto } from "$app/navigation";
|
||||
import { locales, localizeHref } from "$lib/paraglide/runtime";
|
||||
import { unsavedChanges, sidebarOpen, bugReportDialogOpen } from "$lib/stores/app";
|
||||
import "../layout.css";
|
||||
import { unsavedChanges, sidebarOpen, bugReportDialogOpen, dangerZoneEnabled } from "$lib/stores/app";
|
||||
import { onMount } from "svelte";
|
||||
import * as m from "$lib/paraglide/messages.js";
|
||||
import type { utils } from "$lib/wailsjs/go/models";
|
||||
@@ -18,19 +17,14 @@
|
||||
House,
|
||||
Settings,
|
||||
Bug,
|
||||
Loader2,
|
||||
Copy,
|
||||
FolderOpen,
|
||||
CheckCircle,
|
||||
Camera,
|
||||
Heart,
|
||||
Info,
|
||||
Music
|
||||
} from "@lucide/svelte";
|
||||
import { Separator } from "$lib/components/ui/separator/index.js";
|
||||
import { toast } from "svelte-sonner";
|
||||
import { Button, buttonVariants } from "$lib/components/ui/button/index.js";
|
||||
import * as Dialog from "$lib/components/ui/dialog/index.js";
|
||||
import { Input } from "$lib/components/ui/input/index.js";
|
||||
import { Label } from "$lib/components/ui/label/index.js";
|
||||
import { Textarea } from "$lib/components/ui/textarea/index.js";
|
||||
import { buttonVariants } from "$lib/components/ui/button/index.js";
|
||||
import BugReportDialog from "$lib/components/BugReportDialog.svelte";
|
||||
|
||||
import {
|
||||
WindowMinimise,
|
||||
@@ -38,9 +32,11 @@
|
||||
WindowUnmaximise,
|
||||
WindowIsMaximised,
|
||||
Quit,
|
||||
EventsOn,
|
||||
EventsOff,
|
||||
} from "$lib/wailsjs/runtime/runtime";
|
||||
import { RefreshCcwDot } from "@lucide/svelte";
|
||||
import { IsDebuggerRunning, QuitApp, TakeScreenshot, SubmitBugReport, OpenFolderInExplorer } from "$lib/wailsjs/go/main/App";
|
||||
import { IsDebuggerRunning, QuitApp } from "$lib/wailsjs/go/main/App";
|
||||
import { settingsStore } from "$lib/stores/settings.svelte.js";
|
||||
|
||||
let versionInfo: utils.Config | null = $state(null);
|
||||
@@ -48,20 +44,6 @@
|
||||
let isDebugerOn: boolean = $state(false);
|
||||
let isDebbugerProtectionOn: boolean = $state(true);
|
||||
|
||||
// Bug report form state
|
||||
let userName = $state("");
|
||||
let userEmail = $state("");
|
||||
let bugDescription = $state("");
|
||||
|
||||
// Bug report screenshot state
|
||||
let screenshotData = $state("");
|
||||
let isCapturing = $state(false);
|
||||
|
||||
// Bug report UI state
|
||||
let isSubmitting = $state(false);
|
||||
let isSuccess = $state(false);
|
||||
let resultZipPath = $state("");
|
||||
|
||||
async function syncMaxState() {
|
||||
isMaximized = await WindowIsMaximised();
|
||||
}
|
||||
@@ -95,6 +77,7 @@
|
||||
}
|
||||
|
||||
onMount(async () => {
|
||||
if(dev) dangerZoneEnabled.set(true);
|
||||
if (browser && isDebbugerProtectionOn) {
|
||||
detectDebugging();
|
||||
setInterval(detectDebugging, 1000);
|
||||
@@ -150,91 +133,25 @@
|
||||
applyTheme(stored === "light" ? "light" : "dark");
|
||||
});
|
||||
|
||||
// Bug report dialog effects
|
||||
// Listen for automatic update notifications
|
||||
$effect(() => {
|
||||
if ($bugReportDialogOpen) {
|
||||
// Capture screenshot immediately when dialog opens
|
||||
captureScreenshot();
|
||||
} else {
|
||||
// Reset form when dialog closes
|
||||
resetBugReportForm();
|
||||
}
|
||||
});
|
||||
if (!browser) return;
|
||||
|
||||
async function captureScreenshot() {
|
||||
isCapturing = true;
|
||||
try {
|
||||
const result = await TakeScreenshot();
|
||||
screenshotData = result.data;
|
||||
console.log("Screenshot captured:", result.width, "x", result.height);
|
||||
} catch (err) {
|
||||
console.error("Failed to capture screenshot:", err);
|
||||
} finally {
|
||||
isCapturing = false;
|
||||
}
|
||||
}
|
||||
|
||||
function resetBugReportForm() {
|
||||
userName = "";
|
||||
userEmail = "";
|
||||
bugDescription = "";
|
||||
screenshotData = "";
|
||||
isCapturing = false;
|
||||
isSubmitting = false;
|
||||
isSuccess = false;
|
||||
resultZipPath = "";
|
||||
}
|
||||
|
||||
async function handleBugReportSubmit(event: Event) {
|
||||
event.preventDefault();
|
||||
|
||||
if (!bugDescription.trim()) {
|
||||
toast.error("Please provide a bug description.");
|
||||
return;
|
||||
}
|
||||
|
||||
isSubmitting = true;
|
||||
|
||||
try {
|
||||
const result = await SubmitBugReport({
|
||||
name: userName,
|
||||
email: userEmail,
|
||||
description: bugDescription,
|
||||
screenshotData: screenshotData
|
||||
EventsOn("update:available", (status: any) => {
|
||||
toast.info(`Update ${status.availableVersion} is available!`, {
|
||||
description: "Go to Settings to download and install",
|
||||
duration: 10000,
|
||||
action: {
|
||||
label: "Open Settings",
|
||||
onClick: () => goto("/settings"),
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
resultZipPath = result.zipPath;
|
||||
isSuccess = true;
|
||||
console.log("Bug report created:", result.zipPath);
|
||||
} catch (err) {
|
||||
console.error("Failed to create bug report:", err);
|
||||
toast.error(m.bugreport_error());
|
||||
} finally {
|
||||
isSubmitting = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function copyBugReportPath() {
|
||||
try {
|
||||
await navigator.clipboard.writeText(resultZipPath);
|
||||
toast.success(m.bugreport_copied());
|
||||
} catch (err) {
|
||||
console.error("Failed to copy path:", err);
|
||||
}
|
||||
}
|
||||
|
||||
async function openBugReportFolder() {
|
||||
try {
|
||||
const folderPath = resultZipPath.replace(/\.zip$/, "");
|
||||
await OpenFolderInExplorer(folderPath);
|
||||
} catch (err) {
|
||||
console.error("Failed to open folder:", err);
|
||||
}
|
||||
}
|
||||
|
||||
function closeBugReportDialog() {
|
||||
$bugReportDialogOpen = false;
|
||||
}
|
||||
return () => {
|
||||
EventsOff("update:available");
|
||||
};
|
||||
});
|
||||
|
||||
syncMaxState();
|
||||
</script>
|
||||
@@ -253,8 +170,10 @@
|
||||
{#if dev}
|
||||
v{versionInfo?.EMLy.GUISemver}_{versionInfo?.EMLy.GUIReleaseChannel}
|
||||
<debug>(DEBUG BUILD)</debug>
|
||||
{:else}
|
||||
{:else if versionInfo?.EMLy.GUIReleaseChannel !== "stable"}
|
||||
v{versionInfo?.EMLy.GUISemver}_{versionInfo?.EMLy.GUIReleaseChannel}
|
||||
{:else}
|
||||
v{versionInfo?.EMLy.GUISemver}
|
||||
{/if}
|
||||
</version>
|
||||
{#if versionInfo}
|
||||
@@ -277,7 +196,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="controls">
|
||||
<div class="controls" class:high-contrast={settingsStore.settings.increaseWindowButtonsContrast}>
|
||||
<button class="btn" onclick={minimize}>─</button>
|
||||
|
||||
<button class="btn" onclick={toggleMaximize}>
|
||||
@@ -292,11 +211,9 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<Sidebar.Provider>
|
||||
{#if $sidebarOpen}
|
||||
<div class="content" class:reduce-motion={settingsStore.settings.reduceMotion}>
|
||||
<Sidebar.Provider open={$sidebarOpen} onOpenChange={(v) => sidebarOpen.set(v)}>
|
||||
<AppSidebar />
|
||||
{/if}
|
||||
<main>
|
||||
<!-- <Sidebar.Trigger /> -->
|
||||
<Toaster />
|
||||
@@ -355,16 +272,26 @@
|
||||
style="cursor: pointer; opacity: 0.7;"
|
||||
class="hover:opacity-100 transition-opacity"
|
||||
/>
|
||||
|
||||
<Separator orientation="vertical" />
|
||||
<Bug
|
||||
<Info
|
||||
size="16"
|
||||
onclick={() => {
|
||||
$bugReportDialogOpen = !$bugReportDialogOpen;
|
||||
if (page.url.pathname !== "/credits" && page.url.pathname !== "/credits/")
|
||||
goto("/credits");
|
||||
}}
|
||||
style="cursor: pointer; opacity: 0.7;"
|
||||
class="hover:opacity-100 transition-opacity"
|
||||
/>
|
||||
{#if settingsStore.settings.musicInspirationEnabled}
|
||||
<Music
|
||||
size="16"
|
||||
onclick={() => {
|
||||
if (page.url.pathname !== "/inspiration" && page.url.pathname !== "/inspiration/")
|
||||
goto("/inspiration");
|
||||
}}
|
||||
style="cursor: pointer; opacity: 0.7;"
|
||||
class="hover:opacity-100 transition-opacity"
|
||||
/>
|
||||
{/if}
|
||||
|
||||
<a
|
||||
data-sveltekit-reload
|
||||
@@ -376,6 +303,19 @@
|
||||
>
|
||||
<RefreshCcwDot />
|
||||
</a>
|
||||
<!-- svelte-ignore a11y_invalid_attribute -->
|
||||
<a
|
||||
href="#"
|
||||
class={`${buttonVariants({ variant: "destructive" })} cursor-pointer hover:cursor-pointer`}
|
||||
style="text-decoration: none; height: 24px; font-size: 12px; padding: 0 8px;"
|
||||
aria-label={m.settings_danger_reload_button()}
|
||||
title={m.settings_danger_reload_button() + " app"}
|
||||
onclick={() => {
|
||||
$bugReportDialogOpen = !$bugReportDialogOpen;
|
||||
}}
|
||||
>
|
||||
<Bug />
|
||||
</a>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -387,141 +327,12 @@
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<!-- Bug Report Dialog -->
|
||||
<Dialog.Root bind:open={$bugReportDialogOpen}>
|
||||
<Dialog.Content class="sm:max-w-[500px] w-full max-h-[80vh] overflow-y-auto custom-scrollbar">
|
||||
{#if isSuccess}
|
||||
<!-- Success State -->
|
||||
<Dialog.Header>
|
||||
<Dialog.Title class="flex items-center gap-2">
|
||||
<CheckCircle class="h-5 w-5 text-green-500" />
|
||||
{m.bugreport_success_title()}
|
||||
</Dialog.Title>
|
||||
<Dialog.Description>
|
||||
{m.bugreport_success_message()}
|
||||
</Dialog.Description>
|
||||
</Dialog.Header>
|
||||
|
||||
<div class="grid gap-4 py-4">
|
||||
<div class="bg-muted rounded-md p-3">
|
||||
<code class="text-xs break-all select-all">{resultZipPath}</code>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-2">
|
||||
<Button variant="outline" class="flex-1" onclick={copyBugReportPath}>
|
||||
<Copy class="h-4 w-4 mr-2" />
|
||||
{m.bugreport_copy_path()}
|
||||
</Button>
|
||||
<Button variant="outline" class="flex-1" onclick={openBugReportFolder}>
|
||||
<FolderOpen class="h-4 w-4 mr-2" />
|
||||
{m.bugreport_open_folder()}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Dialog.Footer>
|
||||
<Button onclick={closeBugReportDialog}>
|
||||
{m.bugreport_close()}
|
||||
</Button>
|
||||
</Dialog.Footer>
|
||||
{:else}
|
||||
<!-- Form State -->
|
||||
<form onsubmit={handleBugReportSubmit}>
|
||||
<Dialog.Header>
|
||||
<Dialog.Title>{m.bugreport_title()}</Dialog.Title>
|
||||
<Dialog.Description>
|
||||
{m.bugreport_description()}
|
||||
</Dialog.Description>
|
||||
</Dialog.Header>
|
||||
|
||||
<div class="grid gap-4 py-4">
|
||||
<div class="grid gap-2">
|
||||
<Label for="bug-name">{m.bugreport_name_label()}</Label>
|
||||
<Input
|
||||
id="bug-name"
|
||||
placeholder={m.bugreport_name_placeholder()}
|
||||
bind:value={userName}
|
||||
disabled={isSubmitting}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-2">
|
||||
<Label for="bug-email">{m.bugreport_email_label()}</Label>
|
||||
<Input
|
||||
id="bug-email"
|
||||
type="email"
|
||||
placeholder={m.bugreport_email_placeholder()}
|
||||
bind:value={userEmail}
|
||||
disabled={isSubmitting}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-2">
|
||||
<Label for="bug-description">{m.bugreport_text_label()}</Label>
|
||||
<Textarea
|
||||
id="bug-description"
|
||||
placeholder={m.bugreport_text_placeholder()}
|
||||
bind:value={bugDescription}
|
||||
disabled={isSubmitting}
|
||||
class="min-h-[120px]"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Screenshot Preview -->
|
||||
<div class="grid gap-2">
|
||||
<Label class="flex items-center gap-2">
|
||||
<Camera class="h-4 w-4" />
|
||||
{m.bugreport_screenshot_label()}
|
||||
</Label>
|
||||
{#if isCapturing}
|
||||
<div class="flex items-center gap-2 text-muted-foreground text-sm">
|
||||
<Loader2 class="h-4 w-4 animate-spin" />
|
||||
Capturing...
|
||||
</div>
|
||||
{:else if screenshotData}
|
||||
<div class="border rounded-md overflow-hidden">
|
||||
<img
|
||||
src="data:image/png;base64,{screenshotData}"
|
||||
alt="Screenshot preview"
|
||||
class="w-full h-32 object-cover object-top opacity-80 hover:opacity-100 transition-opacity cursor-pointer"
|
||||
/>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="text-muted-foreground text-sm">
|
||||
No screenshot available
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<p class="text-muted-foreground text-sm">
|
||||
{m.bugreport_info()}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<Dialog.Footer>
|
||||
<button type="button" class={buttonVariants({ variant: "outline" })} disabled={isSubmitting} onclick={closeBugReportDialog}>
|
||||
{m.bugreport_cancel()}
|
||||
</button>
|
||||
<Button type="submit" disabled={isSubmitting || isCapturing}>
|
||||
{#if isSubmitting}
|
||||
<Loader2 class="h-4 w-4 mr-2 animate-spin" />
|
||||
{m.bugreport_submitting()}
|
||||
{:else}
|
||||
{m.bugreport_submit()}
|
||||
{/if}
|
||||
</Button>
|
||||
</Dialog.Footer>
|
||||
</form>
|
||||
{/if}
|
||||
</Dialog.Content>
|
||||
</Dialog.Root>
|
||||
<BugReportDialog />
|
||||
</div>
|
||||
|
||||
<style>
|
||||
:global(body) {
|
||||
margin: 0;
|
||||
background: oklch(0 0 0);
|
||||
color: #eaeaea;
|
||||
font-family: system-ui, sans-serif;
|
||||
}
|
||||
|
||||
@@ -530,11 +341,13 @@
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
background: var(--background);
|
||||
color: var(--foreground);
|
||||
}
|
||||
|
||||
.titlebar {
|
||||
height: 32px;
|
||||
background: oklch(0 0 0);
|
||||
background: var(--background);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
@@ -544,11 +357,12 @@
|
||||
flex: 0 0 32px;
|
||||
z-index: 50;
|
||||
position: relative;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.footerbar {
|
||||
height: 32px;
|
||||
background: oklch(0 0 0);
|
||||
background: var(--background);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
@@ -556,28 +370,28 @@
|
||||
padding: 0 12px;
|
||||
user-select: none;
|
||||
flex: 0 0 32px;
|
||||
border-top: 1px solid rgba(255, 255, 255, 0.08);
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 13px;
|
||||
opacity: 0.9;
|
||||
color: gray;
|
||||
color: var(--muted-foreground);
|
||||
}
|
||||
|
||||
.title bold {
|
||||
font-weight: 600;
|
||||
color: white;
|
||||
color: var(--foreground);
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.title version {
|
||||
color: rgb(228, 221, 221);
|
||||
opacity: 0.4;
|
||||
color: var(--muted-foreground);
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.title version debug {
|
||||
color: #e11d48;
|
||||
color: var(--destructive);
|
||||
opacity: 1;
|
||||
font-weight: 600;
|
||||
}
|
||||
@@ -594,8 +408,9 @@
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
left: 0;
|
||||
background-color: #111;
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
background-color: var(--popover);
|
||||
color: var(--popover-foreground);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
padding: 8px 12px;
|
||||
z-index: 1000;
|
||||
@@ -625,16 +440,16 @@
|
||||
}
|
||||
|
||||
.tooltip-item .label {
|
||||
color: #9ca3af;
|
||||
color: var(--muted-foreground);
|
||||
}
|
||||
|
||||
.tooltip-item .value {
|
||||
color: #f3f4f6;
|
||||
color: var(--foreground);
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.tooltip-item .channel {
|
||||
color: #6b7280;
|
||||
color: var(--muted-foreground);
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
@@ -644,25 +459,29 @@
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.controls.high-contrast {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.btn {
|
||||
width: 46px;
|
||||
height: 100%;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: white;
|
||||
color: var(--foreground);
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
-webkit-app-region: no-drag;
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
background: var(--accent);
|
||||
}
|
||||
|
||||
.btn:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
background: rgba(255, 255, 255, 0.02);
|
||||
background: var(--muted);
|
||||
}
|
||||
|
||||
.close:hover {
|
||||
@@ -673,7 +492,7 @@
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
background: oklch(0 0 0);
|
||||
background: var(--background);
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
@@ -700,6 +519,12 @@
|
||||
max-height: 100% !important;
|
||||
}
|
||||
|
||||
/* Disable sidebar transitions when reduce-motion is active */
|
||||
:global(.content.reduce-motion [data-slot="sidebar-gap"]),
|
||||
:global(.content.reduce-motion [data-slot="sidebar-container"]) {
|
||||
transition-duration: 0s !important;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
@@ -710,12 +535,12 @@
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
background: var(--border);
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
background: var(--muted-foreground);
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-corner {
|
||||
@@ -731,14 +556,14 @@
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: oklch(0 0 0);
|
||||
background: var(--background);
|
||||
}
|
||||
|
||||
.spinner {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border: 2px solid rgba(255, 255, 255, 0.1);
|
||||
border-top-color: rgba(255, 255, 255, 0.8);
|
||||
border: 2px solid var(--border);
|
||||
border-top-color: var(--primary);
|
||||
border-radius: 50%;
|
||||
animation: spin 0.6s linear infinite;
|
||||
}
|
||||
@@ -748,26 +573,4 @@
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
:global(.custom-scrollbar::-webkit-scrollbar) {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
}
|
||||
|
||||
:global(.custom-scrollbar::-webkit-scrollbar-track) {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
:global(.custom-scrollbar::-webkit-scrollbar-thumb) {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
:global(.custom-scrollbar::-webkit-scrollbar-thumb:hover) {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
|
||||
:global(.custom-scrollbar::-webkit-scrollbar-corner) {
|
||||
background: transparent;
|
||||
}
|
||||
</style>
|
||||
|
||||
308
frontend/src/routes/(app)/credits/+page.svelte
Normal file
308
frontend/src/routes/(app)/credits/+page.svelte
Normal file
@@ -0,0 +1,308 @@
|
||||
<script lang="ts">
|
||||
import { goto, preloadData } from "$app/navigation";
|
||||
import { Button } from "$lib/components/ui/button";
|
||||
import * as Card from "$lib/components/ui/card";
|
||||
import { Separator } from "$lib/components/ui/separator";
|
||||
import { ChevronLeft, Heart, Code, Package, Globe, Github, Mail, BadgeInfo, Music, PartyPopper } from "@lucide/svelte";
|
||||
import * as m from "$lib/paraglide/messages";
|
||||
import { OpenURLInBrowser } from "$lib/wailsjs/go/main/App";
|
||||
import { dangerZoneEnabled } from "$lib/stores/app";
|
||||
import { settingsStore } from "$lib/stores/settings.svelte";
|
||||
import { toast } from "svelte-sonner";
|
||||
|
||||
let { data } = $props();
|
||||
let config = $derived(data.config);
|
||||
|
||||
// Easter Egg State
|
||||
const REQUIRED_CLICKS = 10;
|
||||
const CLICK_WINDOW_MS = 4000;
|
||||
let recentClicks: number[] = [];
|
||||
|
||||
function handleEasterEggClick(_event: MouseEvent) {
|
||||
console.log("clicked")
|
||||
// Only proceed if danger zone is already enabled
|
||||
if (!$dangerZoneEnabled) return;
|
||||
|
||||
// If already enabled, do nothing to avoid spam
|
||||
if (settingsStore.settings.musicInspirationEnabled) return;
|
||||
|
||||
const now = Date.now();
|
||||
|
||||
// Clean old clicks
|
||||
recentClicks = recentClicks.filter(t => now - t < CLICK_WINDOW_MS);
|
||||
recentClicks.push(now);
|
||||
|
||||
if (recentClicks.length >= REQUIRED_CLICKS) {
|
||||
recentClicks = [];
|
||||
try {
|
||||
settingsStore.update({ musicInspirationEnabled: true });
|
||||
preloadData("/inspiration");
|
||||
} catch (e) {
|
||||
console.error("Failed to enable music inspiration:", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Open external URL in default browser
|
||||
async function openUrl(url: string) {
|
||||
try {
|
||||
await OpenURLInBrowser(url);
|
||||
} catch (e) {
|
||||
console.error("Failed to open URL:", e);
|
||||
}
|
||||
}
|
||||
|
||||
// Gravatar URL helper - uses MD5 hash of email
|
||||
// Pre-computed hashes for known emails
|
||||
const gravatarUrls: Record<string, string> = {
|
||||
"f.fois@3git.eu": "https://gravatar.com/avatar/6a2b6cfd8ab2c36ac3eace1faa871f79084b64ad08fb6e490f050e71ee1b599c",
|
||||
"iraci.matteo@gmail.com": "https://gravatar.com/avatar/0c17334ae886eb44b670d226e7de32ac082b9c85925ce4ed4c12239d9d8351f2",
|
||||
};
|
||||
|
||||
// Technology stack
|
||||
const technologies = [
|
||||
{ name: "Wails v2", description: m.credits_tech_wails(), url: "https://wails.io" },
|
||||
{ name: "Go", description: m.credits_tech_go(), url: "https://go.dev" },
|
||||
{ name: "SvelteKit", description: m.credits_tech_sveltekit(), url: "https://kit.svelte.dev" },
|
||||
{ name: "Svelte 5", description: m.credits_tech_svelte(), url: "https://svelte.dev" },
|
||||
{ name: "TypeScript", description: m.credits_tech_typescript(), url: "https://www.typescriptlang.org" },
|
||||
{ name: "Tailwind CSS", description: m.credits_tech_tailwind(), url: "https://tailwindcss.com" },
|
||||
];
|
||||
|
||||
// Libraries and packages
|
||||
const libraries = [
|
||||
{ name: "shadcn-svelte", description: m.credits_lib_shadcn(), url: "https://www.shadcn-svelte.com" },
|
||||
{ name: "Lucide Icons", description: m.credits_lib_lucide(), url: "https://lucide.dev" },
|
||||
{ name: "ParaglideJS", description: m.credits_lib_paraglide(), url: "https://inlang.com/m/gerre34r/library-inlang-paraglideJs" },
|
||||
{ name: "svelte-sonner", description: m.credits_lib_sonner(), url: "https://svelte-sonner.vercel.app" },
|
||||
{ name: "PDF.js", description: m.credits_lib_pdfjs(), url: "https://mozilla.github.io/pdf.js" },
|
||||
{ name: "DOMPurify", description: m.credits_lib_dompurify(), url: "https://github.com/cure53/DOMPurify" },
|
||||
];
|
||||
|
||||
// Team / Contributors
|
||||
const team = [
|
||||
{
|
||||
username: "FOISX",
|
||||
name: "Flavio Fois",
|
||||
role: m.credits_role_lead_developer(),
|
||||
description: m.credits_foisx_desc(),
|
||||
email: "f.fois@3git.eu",
|
||||
},
|
||||
];
|
||||
|
||||
// Special thanks
|
||||
const specialThanks = [
|
||||
{
|
||||
name: "Laky64",
|
||||
contribution: m.credits_laky64_desc(),
|
||||
email: "iraci.matteo@gmail.com",
|
||||
},
|
||||
];
|
||||
</script>
|
||||
|
||||
<div class="min-h-[calc(100vh-1rem)] bg-gradient-to-b from-background to-muted/30">
|
||||
<div
|
||||
class="mx-auto flex max-w-3xl flex-col gap-4 px-4 py-6 sm:px-6 sm:py-10 opacity-80"
|
||||
>
|
||||
<header class="flex items-start justify-between gap-3">
|
||||
<div class="min-w-0">
|
||||
<h1
|
||||
class="text-balance text-2xl font-semibold tracking-tight sm:text-3xl"
|
||||
>
|
||||
{m.credits_title()}
|
||||
</h1>
|
||||
<p class="mt-2 text-sm text-muted-foreground">
|
||||
{m.credits_description()}
|
||||
</p>
|
||||
</div>
|
||||
<Button
|
||||
class="cursor-pointer hover:cursor-pointer"
|
||||
variant="ghost"
|
||||
onclick={() => goto("/")}
|
||||
><ChevronLeft class="size-4" /> {m.settings_back()}</Button
|
||||
>
|
||||
</header>
|
||||
|
||||
<!-- About Card -->
|
||||
<Card.Root>
|
||||
<Card.Header class="space-y-1">
|
||||
<Card.Title class="flex items-center gap-2">
|
||||
<BadgeInfo class="size-5" />
|
||||
{m.credits_about_title()}
|
||||
</Card.Title>
|
||||
<Card.Description>
|
||||
<span style="font-style: italic">{m.credits_about_description()}</span>
|
||||
<span>{m.credits_about_description_2()}</span>
|
||||
</Card.Description>
|
||||
</Card.Header>
|
||||
<Card.Content>
|
||||
<div class="flex items-center gap-4 mb-4">
|
||||
<img src="/appicon.png" alt="EMLy Logo" width="64" height="64" class="rounded-lg" />
|
||||
<div>
|
||||
<h3 class="font-semibold text-lg">EMLy</h3>
|
||||
<p class="text-sm text-muted-foreground">{m.credits_app_tagline()}</p>
|
||||
{#if config}
|
||||
<p class="text-xs text-muted-foreground mt-1">
|
||||
v{config.GUISemver} ({config.GUIReleaseChannel})
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
<p class="text-sm text-muted-foreground">
|
||||
{m.credits_app_description()}
|
||||
</p>
|
||||
</Card.Content>
|
||||
</Card.Root>
|
||||
|
||||
<!-- Team Card -->
|
||||
<Card.Root>
|
||||
<Card.Header class="space-y-1">
|
||||
<Card.Title class="flex items-center gap-2">
|
||||
<Code class="size-5" />
|
||||
{m.credits_team_title()}
|
||||
</Card.Title>
|
||||
<Card.Description>{m.credits_team_description()}</Card.Description>
|
||||
</Card.Header>
|
||||
<Card.Content class="space-y-4">
|
||||
{#each team as member}
|
||||
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<div
|
||||
class="flex items-start gap-4 rounded-lg border bg-card p-4 relative overflow-hidden"
|
||||
onclick={member.username === "FOISX" ? handleEasterEggClick : undefined}
|
||||
>
|
||||
<!-- Selectable trigger area overlay for cleaner interaction -->
|
||||
{#if member.username === "FOISX" && $dangerZoneEnabled && !settingsStore.settings.musicInspirationEnabled}
|
||||
<div class="absolute inset-0 cursor-pointer z-10 opacity-0 bg-transparent"></div>
|
||||
{/if}
|
||||
|
||||
<img
|
||||
src={gravatarUrls[member.email]}
|
||||
alt={member.name}
|
||||
class="h-14 w-14 rounded-full border-2 border-primary/20 z-0 select-none"
|
||||
/>
|
||||
<div class="flex-1 z-0">
|
||||
<div class="font-medium">{member.username} ({member.name})</div>
|
||||
<div class="text-sm text-primary/80">{member.role}</div>
|
||||
<div class="text-sm text-muted-foreground mt-1">{member.description}</div>
|
||||
<a
|
||||
href="mailto:{member.email}"
|
||||
class="inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-primary mt-2 transition-colors relative z-20"
|
||||
>
|
||||
<Mail class="size-3" />
|
||||
{member.email}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
<div class="text-center text-sm text-muted-foreground pt-2">
|
||||
<span class="flex items-center justify-center gap-1">
|
||||
{m.credits_made_with()} <Heart class="size-3 text-red-500 inline" /> {m.credits_at_3git()}
|
||||
</span>
|
||||
</div>
|
||||
</Card.Content>
|
||||
</Card.Root>
|
||||
|
||||
<!-- Special Thanks Card -->
|
||||
<Card.Root>
|
||||
<Card.Header class="space-y-1">
|
||||
<Card.Title class="flex items-center gap-2">
|
||||
<Heart class="size-5 text-pink-500" />
|
||||
{m.credits_special_thanks_title()}
|
||||
</Card.Title>
|
||||
<Card.Description>{m.credits_special_thanks_description()}</Card.Description>
|
||||
</Card.Header>
|
||||
<Card.Content>
|
||||
<div class="space-y-3">
|
||||
{#each specialThanks as contributor}
|
||||
<div class="flex items-center gap-3 rounded-lg border bg-card p-3">
|
||||
<img
|
||||
src={gravatarUrls[contributor.email]}
|
||||
alt={contributor.name}
|
||||
class="h-10 w-10 rounded-full border-2 border-primary/20"
|
||||
/>
|
||||
<div class="flex-1">
|
||||
<span class="font-medium text-sm">{contributor.name}</span>
|
||||
-
|
||||
<span class="text-muted-foreground text-sm">{contributor.contribution}</span>
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</Card.Content>
|
||||
</Card.Root>
|
||||
|
||||
<!-- Technologies Card -->
|
||||
<Card.Root>
|
||||
<Card.Header class="space-y-1">
|
||||
<Card.Title class="flex items-center gap-2">
|
||||
<Globe class="size-5" />
|
||||
{m.credits_tech_title()}
|
||||
</Card.Title>
|
||||
<Card.Description>{m.credits_tech_description()}</Card.Description>
|
||||
</Card.Header>
|
||||
<Card.Content>
|
||||
<div class="grid gap-3 sm:grid-cols-2">
|
||||
{#each technologies as tech}
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => openUrl(tech.url)}
|
||||
class="flex items-start gap-3 rounded-lg border bg-card p-3 transition-colors hover:bg-accent/50 cursor-pointer text-left"
|
||||
>
|
||||
<div class="flex-1">
|
||||
<div class="font-medium text-sm">{tech.name}</div>
|
||||
<div class="text-xs text-muted-foreground">{tech.description}</div>
|
||||
</div>
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
</Card.Content>
|
||||
</Card.Root>
|
||||
|
||||
<!-- Libraries Card -->
|
||||
<Card.Root>
|
||||
<Card.Header class="space-y-1">
|
||||
<Card.Title class="flex items-center gap-2">
|
||||
<Package class="size-5" />
|
||||
{m.credits_libraries_title()}
|
||||
</Card.Title>
|
||||
<Card.Description>{m.credits_libraries_description()}</Card.Description>
|
||||
</Card.Header>
|
||||
<Card.Content>
|
||||
<div class="grid gap-3 sm:grid-cols-2">
|
||||
{#each libraries as lib}
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => openUrl(lib.url)}
|
||||
class="flex items-start gap-3 rounded-lg border bg-card p-3 transition-colors hover:bg-accent/50 cursor-pointer text-left"
|
||||
>
|
||||
<div class="flex-1">
|
||||
<div class="font-medium text-sm">{lib.name}</div>
|
||||
<div class="text-xs text-muted-foreground">{lib.description}</div>
|
||||
</div>
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
</Card.Content>
|
||||
</Card.Root>
|
||||
|
||||
<!-- License Card -->
|
||||
<Card.Root>
|
||||
<Card.Header class="space-y-1">
|
||||
<Card.Title class="flex items-center gap-2">
|
||||
<Github class="size-5" />
|
||||
{m.credits_license_title()}
|
||||
</Card.Title>
|
||||
</Card.Header>
|
||||
<Card.Content>
|
||||
<p class="text-sm text-muted-foreground">
|
||||
{m.credits_license_text()}
|
||||
</p>
|
||||
<Separator class="my-4" />
|
||||
<p class="text-xs text-muted-foreground text-center">
|
||||
© 2025-{new Date().getFullYear()} 3gIT. {m.credits_copyright()}
|
||||
</p>
|
||||
</Card.Content>
|
||||
</Card.Root>
|
||||
</div>
|
||||
</div>
|
||||
19
frontend/src/routes/(app)/credits/+page.ts
Normal file
19
frontend/src/routes/(app)/credits/+page.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import type { PageLoad } from './$types';
|
||||
import { GetConfig } from "$lib/wailsjs/go/main/App";
|
||||
import { browser } from '$app/environment';
|
||||
|
||||
export const load = (async () => {
|
||||
if (!browser) return { config: null };
|
||||
|
||||
try {
|
||||
const configRoot = await GetConfig();
|
||||
return {
|
||||
config: configRoot.EMLy
|
||||
};
|
||||
} catch (e) {
|
||||
console.error("Failed to load config for credits", e);
|
||||
return {
|
||||
config: null
|
||||
};
|
||||
}
|
||||
}) satisfies PageLoad;
|
||||
125
frontend/src/routes/(app)/inspiration/+page.svelte
Normal file
125
frontend/src/routes/(app)/inspiration/+page.svelte
Normal file
@@ -0,0 +1,125 @@
|
||||
<script lang="ts">
|
||||
import { goto } from "$app/navigation";
|
||||
import { Button } from "$lib/components/ui/button";
|
||||
import * as Card from "$lib/components/ui/card";
|
||||
import { Separator } from "$lib/components/ui/separator";
|
||||
import { ChevronLeft, Music, ExternalLink } from "@lucide/svelte";
|
||||
import * as m from "$lib/paraglide/messages";
|
||||
import { OpenURLInBrowser } from "$lib/wailsjs/go/main/App";
|
||||
import type { SpotifyTrack } from "./+page";
|
||||
|
||||
let { data } = $props();
|
||||
let config = $derived(data.config);
|
||||
let tracks: SpotifyTrack[] = $derived(data.tracks ?? []);
|
||||
|
||||
// Open external URL in default browser
|
||||
async function openUrl(url: string) {
|
||||
try {
|
||||
await OpenURLInBrowser(url);
|
||||
} catch (e) {
|
||||
console.error("Failed to open URL:", e);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="min-h-[calc(100vh-1rem)] bg-gradient-to-b from-background to-muted/30">
|
||||
<div
|
||||
class="mx-auto flex max-w-4xl flex-col gap-4 px-4 py-6 sm:px-6 sm:py-10 opacity-80"
|
||||
>
|
||||
<header class="flex items-start justify-between gap-3">
|
||||
<div class="min-w-0">
|
||||
<h1
|
||||
class="text-balance text-2xl font-semibold tracking-tight sm:text-3xl"
|
||||
>
|
||||
Musical Inspiration
|
||||
</h1>
|
||||
<p class="mt-2 text-sm text-muted-foreground">
|
||||
This project was mainly coded to the following tracks
|
||||
</p>
|
||||
</div>
|
||||
<Button
|
||||
class="cursor-pointer hover:cursor-pointer"
|
||||
variant="ghost"
|
||||
onclick={() => goto("/")}
|
||||
>
|
||||
<ChevronLeft class="size-4" /> Back
|
||||
</Button>
|
||||
</header>
|
||||
|
||||
<Separator class="my-2" />
|
||||
|
||||
<!-- Spotify Embeds -->
|
||||
<Card.Root>
|
||||
<Card.Header>
|
||||
<Card.Title class="flex items-center gap-2">
|
||||
<Music class="size-5" />
|
||||
FOISX's Soundtrack
|
||||
</Card.Title>
|
||||
<Card.Description>
|
||||
The albums and tracks that fueled the development of EMLy
|
||||
</Card.Description>
|
||||
</Card.Header>
|
||||
<Card.Content>
|
||||
<div class="grid gap-4 sm:grid-cols-2 lg:grid-cols-2">
|
||||
{#each tracks as track}
|
||||
<div class="group relative">
|
||||
<div class="overflow-hidden rounded-lg bg-muted">
|
||||
{#if track.embedHtml}
|
||||
{@html track.embedHtml}
|
||||
{:else}
|
||||
<iframe
|
||||
src={track.embedUrl}
|
||||
width="100%"
|
||||
height="352"
|
||||
frameborder="0"
|
||||
allow="autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture"
|
||||
loading="lazy"
|
||||
title={`${track.artist} - ${track.name}`}
|
||||
class="rounded-lg"
|
||||
></iframe>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</Card.Content>
|
||||
</Card.Root>
|
||||
|
||||
<!-- Fun fact -->
|
||||
<Card.Root class="border-primary/20 bg-primary/5">
|
||||
<Card.Content class="">
|
||||
<div class="flex items-start gap-3">
|
||||
<Music class="size-5 text-primary mt-0.5 shrink-0" />
|
||||
<div class="space-y-1">
|
||||
<p class="text-sm font-medium">The Soundtrack</p>
|
||||
<p class="text-sm text-muted-foreground">
|
||||
These are just a small sample of what helped inspire the project.
|
||||
Although they represent a wide variety of emotions, themes and genres, some exploring deep meanings
|
||||
of betrayal, personal struggles, and introspection, they provided solace and strength to the main developer
|
||||
during challenging times.
|
||||
<br/>
|
||||
Music has a unique way of transforming pain into creative energy..
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</Card.Content>
|
||||
</Card.Root>
|
||||
|
||||
<!-- Footer note -->
|
||||
<div class="text-center text-xs text-muted-foreground">
|
||||
<p>
|
||||
Made with
|
||||
<Music class="inline-block size-3 mx-1" />
|
||||
and
|
||||
<span class="text-red-500">♥</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
iframe {
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
</style>
|
||||
109
frontend/src/routes/(app)/inspiration/+page.ts
Normal file
109
frontend/src/routes/(app)/inspiration/+page.ts
Normal file
@@ -0,0 +1,109 @@
|
||||
import type { PageLoad } from './$types';
|
||||
import { GetConfig } from "$lib/wailsjs/go/main/App";
|
||||
import { browser } from '$app/environment';
|
||||
|
||||
export interface SpotifyTrack {
|
||||
name: string;
|
||||
artist: string;
|
||||
spotifyUrl: string;
|
||||
embedUrl: string;
|
||||
embedHtml?: string;
|
||||
}
|
||||
|
||||
// Music that inspired this project
|
||||
const inspirationTracks: SpotifyTrack[] = [
|
||||
{
|
||||
name: "Strays",
|
||||
artist: "Ivycomb, Stephanafro",
|
||||
spotifyUrl: "https://open.spotify.com/track/1aXATIo34e5ZZvFcavePpy",
|
||||
embedUrl: "https://open.spotify.com/embed/track/1aXATIo34e5ZZvFcavePpy?utm_source=generator"
|
||||
},
|
||||
{
|
||||
name: "Headlock",
|
||||
artist: "Imogen Heap",
|
||||
spotifyUrl: "https://open.spotify.com/track/63Pi2NAx5yCgeLhCTOrEou",
|
||||
embedUrl: "https://open.spotify.com/embed/track/63Pi2NAx5yCgeLhCTOrEou?utm_source=generator"
|
||||
},
|
||||
{
|
||||
name: "I Still Create",
|
||||
artist: "YonKaGor",
|
||||
spotifyUrl: "https://open.spotify.com/track/0IqTgwWU2syiSYbdBEromt",
|
||||
embedUrl: "https://open.spotify.com/embed/track/0IqTgwWU2syiSYbdBEromt?utm_source=generator"
|
||||
},
|
||||
{
|
||||
name: "Raised by Aliens",
|
||||
artist: "ivy comb, Stephanafro",
|
||||
spotifyUrl: "https://open.spotify.com/track/5ezyCaoc5XiVdkpRYWeyG5",
|
||||
embedUrl: "https://open.spotify.com/embed/track/5ezyCaoc5XiVdkpRYWeyG5?utm_source=generator"
|
||||
},
|
||||
{
|
||||
name: "VENOMOUS",
|
||||
artist: "passengerprincess",
|
||||
spotifyUrl: "https://open.spotify.com/track/4rPKifkzrhIYAsl1njwmjd",
|
||||
embedUrl: "https://open.spotify.com/embed/track/4rPKifkzrhIYAsl1njwmjd?utm_source=generator"
|
||||
},
|
||||
{
|
||||
name: "PREY",
|
||||
artist: "passengerprincess",
|
||||
spotifyUrl: "https://open.spotify.com/track/510m8qwFCHgzi4zsQnjLUX",
|
||||
embedUrl: "https://open.spotify.com/embed/track/510m8qwFCHgzi4zsQnjLUX?utm_source=generator"
|
||||
},
|
||||
{
|
||||
name: "Dracula",
|
||||
artist: "Tame Impala",
|
||||
spotifyUrl: "https://open.spotify.com/track/1NXbNEAcPvY5G1xvfN57aA",
|
||||
embedUrl: "https://open.spotify.com/embed/track/1NXbNEAcPvY5G1xvfN57aA?utm_source=generator"
|
||||
},
|
||||
{
|
||||
name: "Electric love",
|
||||
artist: "When Snakes Sing",
|
||||
spotifyUrl: "https://open.spotify.com/track/1nDkT2Cn13qDnFegF93UHi",
|
||||
embedUrl: "https://open.spotify.com/embed/track/1nDkT2Cn13qDnFegF93UHi?utm_source=generator"
|
||||
}, {
|
||||
name: "Keep It Tucked",
|
||||
artist: "ThxSoMch",
|
||||
spotifyUrl: "https://open.spotify.com/track/1EdQCb51lC8usq47IMhADP",
|
||||
embedUrl: "https://open.spotify.com/embed/track/1EdQCb51lC8usq47IMhADP?utm_source=generator"
|
||||
}, {
|
||||
name: "Deadly Valentine",
|
||||
artist: "Charlotte Gainsbourg",
|
||||
spotifyUrl: "https://open.spotify.com/track/0pfTlQJBOV4LUmF8qqrVy5",
|
||||
embedUrl: "https://open.spotify.com/embed/track/0pfTlQJBOV4LUmF8qqrVy5?utm_source=generator"
|
||||
}
|
||||
];
|
||||
|
||||
async function fetchEmbedHtml(track: SpotifyTrack, fetch: typeof globalThis.fetch): Promise<SpotifyTrack> {
|
||||
try {
|
||||
const oEmbedUrl = `https://open.spotify.com/oembed?url=${encodeURIComponent(track.spotifyUrl)}`;
|
||||
const res = await fetch(oEmbedUrl);
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
return { ...track, embedHtml: data.html };
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(`Failed to fetch oEmbed for ${track.spotifyUrl}:`, e);
|
||||
}
|
||||
return track;
|
||||
}
|
||||
|
||||
export const load = (async ({fetch}) => {
|
||||
if (!browser) return { config: null, tracks: inspirationTracks };
|
||||
|
||||
try {
|
||||
const [configRoot, ...tracks] = await Promise.all([
|
||||
GetConfig(),
|
||||
...inspirationTracks.map(t => fetchEmbedHtml(t, fetch))
|
||||
]);
|
||||
|
||||
return {
|
||||
config: configRoot.EMLy,
|
||||
tracks
|
||||
};
|
||||
} catch (e) {
|
||||
console.error("Failed to load data for inspiration", e);
|
||||
return {
|
||||
config: null,
|
||||
tracks: inspirationTracks
|
||||
};
|
||||
}
|
||||
}) satisfies PageLoad;
|
||||
@@ -6,7 +6,7 @@
|
||||
import { Label } from "$lib/components/ui/label";
|
||||
import { Separator } from "$lib/components/ui/separator";
|
||||
import { Switch } from "$lib/components/ui/switch";
|
||||
import { ChevronLeft, Flame, Download, Upload } from "@lucide/svelte";
|
||||
import { ChevronLeft, Flame, Download, Upload, RefreshCw, CheckCircle2, AlertCircle, Sun, Moon, FolderArchive } from "@lucide/svelte";
|
||||
import type { EMLy_GUI_Settings } from "$lib/types";
|
||||
import { toast } from "svelte-sonner";
|
||||
import { It, Us } from "svelte-flags";
|
||||
@@ -25,7 +25,9 @@
|
||||
import { setLocale } from "$lib/paraglide/runtime";
|
||||
import { mailState } from "$lib/stores/mail-state.svelte.js";
|
||||
import { dev } from '$app/environment';
|
||||
import { ExportSettings, ImportSettings } from "$lib/wailsjs/go/main/App";
|
||||
import { ExportSettings, ImportSettings, CheckForUpdates, DownloadUpdate, InstallUpdate, SetUpdateCheckerEnabled, ShowOpenFolderDialog, GetExportAttachmentFolder, SetExportAttachmentFolder } from "$lib/wailsjs/go/main/App";
|
||||
import { EventsOn, EventsOff } from "$lib/wailsjs/runtime/runtime";
|
||||
import Input from "$lib/components/ui/input/input.svelte";
|
||||
|
||||
let { data } = $props();
|
||||
let config = $derived(data.config);
|
||||
@@ -38,6 +40,13 @@
|
||||
useBuiltinPDFViewer: true,
|
||||
previewFileSupportedTypes: ["jpg", "jpeg", "png"],
|
||||
enableAttachedDebuggerProtection: true,
|
||||
useDarkEmailViewer: true,
|
||||
enableUpdateChecker: false,
|
||||
reduceMotion: false,
|
||||
theme: "dark",
|
||||
increaseWindowButtonsContrast: false,
|
||||
exportAttachmentFolder: "",
|
||||
useCustomAttachmentDownload: false,
|
||||
};
|
||||
|
||||
async function setLanguage(
|
||||
@@ -68,6 +77,16 @@
|
||||
s.previewFileSupportedTypes || defaults.previewFileSupportedTypes || [],
|
||||
enableAttachedDebuggerProtection:
|
||||
s.enableAttachedDebuggerProtection ?? defaults.enableAttachedDebuggerProtection ?? true,
|
||||
useDarkEmailViewer:
|
||||
s.useDarkEmailViewer ?? defaults.useDarkEmailViewer ?? true,
|
||||
enableUpdateChecker: runningInDevMode
|
||||
? false
|
||||
: (s.enableUpdateChecker ?? defaults.enableUpdateChecker ?? true),
|
||||
reduceMotion: s.reduceMotion ?? defaults.reduceMotion ?? false,
|
||||
theme: s.theme || defaults.theme || "light",
|
||||
increaseWindowButtonsContrast: s.increaseWindowButtonsContrast ?? defaults.increaseWindowButtonsContrast ?? false,
|
||||
exportAttachmentFolder: s.exportAttachmentFolder || defaults.exportAttachmentFolder || "",
|
||||
useCustomAttachmentDownload: s.useCustomAttachmentDownload ?? defaults.useCustomAttachmentDownload ?? false,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -77,6 +96,13 @@
|
||||
!!a.useBuiltinPreview === !!b.useBuiltinPreview &&
|
||||
!!a.useBuiltinPDFViewer === !!b.useBuiltinPDFViewer &&
|
||||
!!a.enableAttachedDebuggerProtection === !!b.enableAttachedDebuggerProtection &&
|
||||
!!a.useDarkEmailViewer === !!b.useDarkEmailViewer &&
|
||||
!!a.enableUpdateChecker === !!b.enableUpdateChecker &&
|
||||
!!a.reduceMotion === !!b.reduceMotion &&
|
||||
!!a.exportAttachmentFolder === !!b.exportAttachmentFolder &&
|
||||
!!a.useCustomAttachmentDownload === !!b.useCustomAttachmentDownload &&
|
||||
(a.theme ?? "light") === (b.theme ?? "light") &&
|
||||
!!a.increaseWindowButtonsContrast === !!b.increaseWindowButtonsContrast &&
|
||||
JSON.stringify(a.previewFileSupportedTypes?.sort()) ===
|
||||
JSON.stringify(b.previewFileSupportedTypes?.sort())
|
||||
);
|
||||
@@ -123,6 +149,7 @@
|
||||
sessionStorage.removeItem("debugWindowInSettings");
|
||||
dangerZoneEnabled.set(false);
|
||||
LogDebug("Reset danger zone setting to false.");
|
||||
await SetExportAttachmentFolder("");
|
||||
} catch {
|
||||
toast.error(m.settings_toast_reset_failed());
|
||||
return;
|
||||
@@ -175,6 +202,79 @@
|
||||
})();
|
||||
});
|
||||
|
||||
// Sync update checker setting to backend config.ini
|
||||
$effect(() => {
|
||||
(async () => {
|
||||
if (!browser) return;
|
||||
let previousUpdateCheckerEnabled = form.enableUpdateChecker;
|
||||
if (form.enableUpdateChecker !== previousUpdateCheckerEnabled) {
|
||||
try {
|
||||
await SetUpdateCheckerEnabled(form.enableUpdateChecker ?? true);
|
||||
LogDebug(`Update checker ${form.enableUpdateChecker ? 'enabled' : 'disabled'}`);
|
||||
} catch (err) {
|
||||
console.error('Failed to sync update checker setting:', err);
|
||||
}
|
||||
previousUpdateCheckerEnabled = form.enableUpdateChecker;
|
||||
}
|
||||
})();
|
||||
});
|
||||
|
||||
// Sync theme with email viewer dark mode
|
||||
let previousTheme = $state<string | undefined>(undefined);
|
||||
$effect(() => {
|
||||
if (!browser) return;
|
||||
if (previousTheme !== undefined && form.theme !== previousTheme) {
|
||||
form.useDarkEmailViewer = form.theme === "dark";
|
||||
}
|
||||
previousTheme = form.theme;
|
||||
});
|
||||
|
||||
// Load export attachment folder from config.ini on startup
|
||||
$effect(() => {
|
||||
if (!browser) return;
|
||||
(async () => {
|
||||
try {
|
||||
const configFolder = await GetExportAttachmentFolder();
|
||||
if (configFolder && configFolder.trim() !== "") {
|
||||
form.exportAttachmentFolder = configFolder;
|
||||
// Also update lastSaved to avoid triggering unsaved changes
|
||||
lastSaved = { ...lastSaved, exportAttachmentFolder: configFolder };
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Failed to load export folder from config:", err);
|
||||
}
|
||||
})();
|
||||
});
|
||||
|
||||
async function openFolderDialog(): Promise<string | null> {
|
||||
try {
|
||||
const result = await ShowOpenFolderDialog();
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Failed to open folder dialog:", err);
|
||||
toast.error("Failed to open folder dialog.");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
async function selectExportFolder() {
|
||||
const folder = await openFolderDialog();
|
||||
if (folder) {
|
||||
// Save to form state
|
||||
form.exportAttachmentFolder = folder;
|
||||
// Save to config.ini
|
||||
try {
|
||||
await SetExportAttachmentFolder(folder);
|
||||
toast.success("Export folder updated!");
|
||||
} catch (err) {
|
||||
console.error("Failed to save export folder:", err);
|
||||
toast.error("Failed to save export folder to config.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function exportSettings() {
|
||||
try {
|
||||
const settingsJSON = JSON.stringify(form, null, 2);
|
||||
@@ -210,9 +310,95 @@
|
||||
toast.error(m.settings_import_error());
|
||||
}
|
||||
}
|
||||
|
||||
// Update System State
|
||||
type UpdateStatus = {
|
||||
currentVersion: string;
|
||||
availableVersion: string;
|
||||
updateAvailable: boolean;
|
||||
checking: boolean;
|
||||
downloading: boolean;
|
||||
downloadProgress: number;
|
||||
ready: boolean;
|
||||
installerPath: string;
|
||||
errorMessage: string;
|
||||
releaseNotes?: string;
|
||||
lastCheckTime: string;
|
||||
};
|
||||
|
||||
let updateStatus = $state<UpdateStatus>({
|
||||
currentVersion: "Unknown",
|
||||
availableVersion: "",
|
||||
updateAvailable: false,
|
||||
checking: false,
|
||||
downloading: false,
|
||||
downloadProgress: 0,
|
||||
ready: false,
|
||||
installerPath: "",
|
||||
errorMessage: "",
|
||||
lastCheckTime: "",
|
||||
});
|
||||
|
||||
// Sync current version from config
|
||||
$effect(() => {
|
||||
if (config?.GUISemver) {
|
||||
updateStatus.currentVersion = config.GUISemver;
|
||||
}
|
||||
});
|
||||
|
||||
async function checkForUpdates() {
|
||||
try {
|
||||
const status = await CheckForUpdates();
|
||||
updateStatus = status;
|
||||
|
||||
if (status.updateAvailable) {
|
||||
toast.success(m.settings_toast_update_available({ version: status.availableVersion }));
|
||||
} else if (!status.errorMessage) {
|
||||
toast.info(m.settings_toast_latest_version());
|
||||
} else {
|
||||
toast.error(status.errorMessage);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Failed to check for updates:", err);
|
||||
toast.error(m.settings_toast_check_failed());
|
||||
}
|
||||
}
|
||||
|
||||
async function downloadUpdate() {
|
||||
try {
|
||||
await DownloadUpdate();
|
||||
toast.success(m.settings_toast_download_success());
|
||||
} catch (err) {
|
||||
console.error("Failed to download update:", err);
|
||||
toast.error(m.settings_toast_download_failed());
|
||||
}
|
||||
}
|
||||
|
||||
async function installUpdate() {
|
||||
try {
|
||||
await InstallUpdate(true); // true = quit after launch
|
||||
// App will quit, so no toast needed
|
||||
} catch (err) {
|
||||
console.error("Failed to install update:", err);
|
||||
toast.error(m.settings_toast_install_failed());
|
||||
}
|
||||
}
|
||||
|
||||
// Listen for update status events
|
||||
$effect(() => {
|
||||
if (!browser) return;
|
||||
|
||||
EventsOn("update:status", (status: UpdateStatus) => {
|
||||
updateStatus = status;
|
||||
});
|
||||
|
||||
return () => {
|
||||
EventsOff("update:status");
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="min-h-[calc(100vh-1rem)] from-background to-muted/30">
|
||||
<div class="min-h-[calc(100vh-1rem)] bg-linear-to-b from-background to-muted/30">
|
||||
<div
|
||||
class="mx-auto flex max-w-3xl flex-col gap-4 px-4 py-6 sm:px-6 sm:py-10 opacity-80"
|
||||
>
|
||||
@@ -281,6 +467,116 @@
|
||||
</Card.Content>
|
||||
</Card.Root>
|
||||
|
||||
<Card.Root>
|
||||
<Card.Header class="space-y-1">
|
||||
<Card.Title>{m.settings_appearance_title()}</Card.Title>
|
||||
<Card.Description>{m.settings_appearance_description()}</Card.Description>
|
||||
</Card.Header>
|
||||
<Card.Content class="space-y-4">
|
||||
<RadioGroup.Root
|
||||
bind:value={form.theme}
|
||||
class="flex flex-col gap-3"
|
||||
>
|
||||
<div class="flex items-center space-x-2">
|
||||
<RadioGroup.Item
|
||||
value="light"
|
||||
id="theme-light"
|
||||
class="cursor-pointer hover:cursor-pointer"
|
||||
/>
|
||||
<Label
|
||||
for="theme-light"
|
||||
class="flex items-center gap-2 cursor-pointer hover:cursor-pointer"
|
||||
>
|
||||
<Sun class="size-4" />
|
||||
{m.settings_theme_light()}
|
||||
</Label>
|
||||
</div>
|
||||
<div class="flex items-center space-x-2">
|
||||
<RadioGroup.Item
|
||||
value="dark"
|
||||
id="theme-dark"
|
||||
class="cursor-pointer hover:cursor-pointer"
|
||||
/>
|
||||
<Label
|
||||
for="theme-dark"
|
||||
class="flex items-center gap-2 cursor-pointer hover:cursor-pointer"
|
||||
>
|
||||
<Moon class="size-4" />
|
||||
{m.settings_theme_dark()}
|
||||
</Label>
|
||||
</div>
|
||||
</RadioGroup.Root>
|
||||
<div class="text-xs text-muted-foreground mt-4">
|
||||
<strong>Info:</strong>
|
||||
{m.settings_theme_hint()}
|
||||
</div>
|
||||
|
||||
|
||||
<Separator />
|
||||
|
||||
<div class="space-y-3">
|
||||
<div
|
||||
class="flex items-center justify-between gap-4 rounded-lg border bg-card p-4"
|
||||
>
|
||||
<div>
|
||||
<div class="font-medium">
|
||||
{m.settings_reduce_motion_label()}
|
||||
</div>
|
||||
<div class="text-sm text-muted-foreground">
|
||||
{m.settings_reduce_motion_hint()}
|
||||
</div>
|
||||
</div>
|
||||
<Switch
|
||||
bind:checked={form.reduceMotion}
|
||||
class="cursor-pointer hover:cursor-pointer"
|
||||
/>
|
||||
</div>
|
||||
<p class="text-xs text-muted-foreground mt-2">
|
||||
{m.settings_reduce_motion_info()}
|
||||
</p>
|
||||
|
||||
<Separator />
|
||||
|
||||
<div
|
||||
class="flex items-center justify-between gap-4 rounded-lg border bg-card p-4"
|
||||
>
|
||||
<div>
|
||||
<div class="font-medium">
|
||||
{m.settings_window_buttons_contrast_label()}
|
||||
</div>
|
||||
<div class="text-sm text-muted-foreground">
|
||||
{m.settings_window_buttons_contrast_hint()}
|
||||
</div>
|
||||
</div>
|
||||
<Switch
|
||||
bind:checked={form.increaseWindowButtonsContrast}
|
||||
class="cursor-pointer hover:cursor-pointer"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="flex items-center justify-between gap-4 rounded-lg border bg-card p-4"
|
||||
>
|
||||
<div>
|
||||
<div class="font-medium">
|
||||
{m.settings_email_dark_viewer_label()}
|
||||
</div>
|
||||
<div class="text-sm text-muted-foreground">
|
||||
{m.settings_email_dark_viewer_hint()}
|
||||
</div>
|
||||
</div>
|
||||
<Switch
|
||||
bind:checked={form.useDarkEmailViewer}
|
||||
class="cursor-pointer hover:cursor-pointer"
|
||||
/>
|
||||
</div>
|
||||
<p class="text-xs text-muted-foreground mt-2">
|
||||
{m.settings_email_dark_viewer_info()}
|
||||
</p>
|
||||
</div>
|
||||
</Card.Content>
|
||||
</Card.Root>
|
||||
|
||||
<Card.Root>
|
||||
<Card.Header class="space-y-1">
|
||||
<Card.Title>{m.settings_export_import_title()}</Card.Title>
|
||||
@@ -305,7 +601,7 @@
|
||||
{m.settings_export_button()}
|
||||
</Button>
|
||||
</div>
|
||||
<Separator />
|
||||
|
||||
<div
|
||||
class="flex items-center justify-between gap-4 rounded-lg border bg-card p-4"
|
||||
>
|
||||
@@ -450,9 +746,200 @@
|
||||
{m.settings_preview_pdf_builtin_info()}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<Separator />
|
||||
|
||||
<div class="space-y-3">
|
||||
<div class="flex items-center justify-between gap-4 rounded-lg border bg-card p-4">
|
||||
<div>
|
||||
<div class="font-medium">{m.settings_custom_download_label()}</div>
|
||||
<div class="text-sm text-muted-foreground">
|
||||
{m.settings_custom_download_hint()}
|
||||
</div>
|
||||
</div>
|
||||
<Switch
|
||||
id="use-custom-attachment-download"
|
||||
bind:checked={form.useCustomAttachmentDownload}
|
||||
class="cursor-pointer hover:cursor-pointer"
|
||||
/>
|
||||
</div>
|
||||
<p class="text-xs text-muted-foreground mt-2">
|
||||
{m.settings_custom_download_info()}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{#if form.useCustomAttachmentDownload}
|
||||
<Separator />
|
||||
|
||||
<div class="space-y-3">
|
||||
<div class="rounded-lg border bg-card p-4 space-y-3">
|
||||
<div>
|
||||
<div class="font-medium">
|
||||
{m.settings_export_folder_label()}
|
||||
</div>
|
||||
<div class="text-sm text-muted-foreground">
|
||||
{m.settings_export_folder_hint()}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<Input
|
||||
type="text"
|
||||
placeholder="%USERPROFILE%\Documents\EMLy_Attachments"
|
||||
class="flex-1"
|
||||
readonly
|
||||
bind:value={form.exportAttachmentFolder}
|
||||
/>
|
||||
<Button
|
||||
variant="outline"
|
||||
class="cursor-pointer hover:cursor-pointer"
|
||||
onclick={selectExportFolder}
|
||||
>
|
||||
<FolderArchive class="size-4 mr-2" />
|
||||
{m.settings_select_folder_button()}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</Card.Content>
|
||||
</Card.Root>
|
||||
|
||||
<!-- Update Section -->
|
||||
{#if form.enableUpdateChecker}
|
||||
<Card.Root>
|
||||
<Card.Header class="space-y-1">
|
||||
<Card.Title>{m.settings_updates_title()}</Card.Title>
|
||||
<Card.Description>{m.settings_updates_description()}</Card.Description>
|
||||
</Card.Header>
|
||||
<Card.Content class="space-y-4">
|
||||
<!-- Current Version -->
|
||||
<div class="flex items-center justify-between gap-4 rounded-lg border bg-card p-4">
|
||||
<div>
|
||||
<div class="font-medium">{m.settings_updates_current_version()}</div>
|
||||
<div class="text-sm text-muted-foreground">
|
||||
{updateStatus.currentVersion} ({config?.GUIReleaseChannel || "stable"})
|
||||
</div>
|
||||
</div>
|
||||
{#if updateStatus.updateAvailable}
|
||||
<div class="flex items-center gap-2 text-sm font-medium text-green-600 dark:text-green-400">
|
||||
<AlertCircle class="size-4" />
|
||||
{m.settings_updates_available()}
|
||||
</div>
|
||||
{:else if updateStatus.errorMessage && updateStatus.lastCheckTime}
|
||||
<div class="flex items-center gap-2 text-sm text-destructive">
|
||||
<AlertCircle class="size-4" />
|
||||
{m.settings_updates_check_failed()}
|
||||
</div>
|
||||
{:else if updateStatus.lastCheckTime}
|
||||
<div class="flex items-center gap-2 text-sm text-muted-foreground">
|
||||
<CheckCircle2 class="size-4" />
|
||||
{m.settings_updates_no_updates()}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<Separator />
|
||||
|
||||
<!-- Check for Updates -->
|
||||
<div class="flex items-center justify-between gap-4 rounded-lg border bg-card p-4">
|
||||
<div>
|
||||
<div class="font-medium">{m.settings_updates_check_label()}</div>
|
||||
<div class="text-sm text-muted-foreground">
|
||||
{#if updateStatus.lastCheckTime}
|
||||
{m.settings_updates_last_checked({ time: updateStatus.lastCheckTime })}
|
||||
{:else}
|
||||
{m.settings_updates_click_check()}
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
<Button
|
||||
variant="outline"
|
||||
class="cursor-pointer hover:cursor-pointer"
|
||||
onclick={checkForUpdates}
|
||||
disabled={updateStatus.checking || updateStatus.downloading}
|
||||
>
|
||||
<RefreshCw class="size-4 mr-2 {updateStatus.checking ? 'animate-spin' : ''}" />
|
||||
{updateStatus.checking ? m.settings_updates_checking() : m.settings_updates_check_now()}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<!-- Download Update (shown when update available) -->
|
||||
{#if updateStatus.updateAvailable && !updateStatus.ready}
|
||||
<Separator />
|
||||
<div class="flex items-center justify-between gap-4 rounded-lg border border-blue-500/30 bg-blue-500/10 p-4">
|
||||
<div>
|
||||
<div class="font-medium">{m.settings_updates_version_available({ version: updateStatus.availableVersion })}</div>
|
||||
<div class="text-sm text-muted-foreground">
|
||||
{#if updateStatus.downloading}
|
||||
{m.settings_updates_downloading({ progress: updateStatus.downloadProgress })}
|
||||
{:else}
|
||||
{m.settings_updates_click_download()}
|
||||
{/if}
|
||||
</div>
|
||||
{#if updateStatus.releaseNotes}
|
||||
<div class="text-xs text-muted-foreground mt-2">
|
||||
{updateStatus.releaseNotes}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
<Button
|
||||
variant="default"
|
||||
class="cursor-pointer hover:cursor-pointer"
|
||||
onclick={downloadUpdate}
|
||||
disabled={updateStatus.downloading}
|
||||
>
|
||||
<Download class="size-4 mr-2" />
|
||||
{updateStatus.downloading ? `${updateStatus.downloadProgress}%` : m.settings_updates_download_button()}
|
||||
</Button>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<!-- Install Update (shown when download ready) -->
|
||||
{#if updateStatus.ready}
|
||||
<Separator />
|
||||
<div class="flex items-center justify-between gap-4 rounded-lg border border-green-500/30 bg-green-500/10 p-4">
|
||||
<div>
|
||||
<div class="font-medium">{m.settings_updates_ready_title()}</div>
|
||||
<div class="text-sm text-muted-foreground">
|
||||
{m.settings_updates_ready_ref({ version: updateStatus.availableVersion })}
|
||||
</div>
|
||||
</div>
|
||||
<Button
|
||||
variant="default"
|
||||
class="cursor-pointer hover:cursor-pointer bg-green-600 hover:bg-green-700"
|
||||
onclick={installUpdate}
|
||||
>
|
||||
<CheckCircle2 class="size-4 mr-2" />
|
||||
{m.settings_updates_install_button()}
|
||||
</Button>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<!-- Error Message -->
|
||||
{#if updateStatus.errorMessage}
|
||||
<div class="rounded-lg border border-destructive/50 bg-destructive/10 p-3">
|
||||
<div class="flex items-start gap-2">
|
||||
<AlertCircle class="size-4 text-destructive mt-0.5" />
|
||||
<div class="text-sm text-destructive">
|
||||
{updateStatus.errorMessage}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<!-- Info about update path -->
|
||||
<div class="text-xs text-muted-foreground">
|
||||
<strong>Info:</strong> {m.settings_updates_info_message()}
|
||||
{#if (config as any)?.UpdatePath}
|
||||
{m.settings_updates_current_path()} <code class="text-xs bg-muted px-1 py-0.5 rounded">{(config as any).UpdatePath}</code>
|
||||
{:else}
|
||||
<span class="text-amber-600 dark:text-amber-400">{m.settings_updates_no_path()}</span>
|
||||
{/if}
|
||||
</div>
|
||||
</Card.Content>
|
||||
</Card.Root>
|
||||
{/if}
|
||||
|
||||
{#if $dangerZoneEnabled || dev}
|
||||
<Card.Root class="border-destructive/50 bg-destructive/15">
|
||||
<Card.Header class="space-y-1">
|
||||
@@ -568,6 +1055,26 @@
|
||||
</div>
|
||||
<Separator />
|
||||
|
||||
<div
|
||||
class="flex items-center justify-between gap-4 rounded-lg border bg-card p-4 border-destructive/30"
|
||||
>
|
||||
<div class="space-y-1">
|
||||
<Label class="text-sm">{m.settings_danger_update_checker_label()}</Label>
|
||||
<div class="text-sm text-muted-foreground">
|
||||
{m.settings_danger_update_checker_hint()}
|
||||
</div>
|
||||
</div>
|
||||
<Switch
|
||||
bind:checked={form.enableUpdateChecker}
|
||||
class="cursor-pointer hover:cursor-pointer"
|
||||
disabled={runningInDevMode}
|
||||
/>
|
||||
</div>
|
||||
<div class="text-xs text-muted-foreground">
|
||||
{m.settings_danger_update_checker_info()}
|
||||
</div>
|
||||
<Separator />
|
||||
|
||||
<div class="text-xs text-muted-foreground">
|
||||
GUI: {config
|
||||
? `${config.GUISemver} (${config.GUIReleaseChannel})`
|
||||
@@ -581,6 +1088,7 @@
|
||||
</Card.Root>
|
||||
{/if}
|
||||
|
||||
{#if !runningInDevMode}
|
||||
<AlertDialog.Root bind:open={dangerWarningOpen}>
|
||||
<AlertDialog.Content>
|
||||
<AlertDialog.Header>
|
||||
@@ -588,7 +1096,11 @@
|
||||
>{m.settings_danger_alert_title()}</AlertDialog.Title
|
||||
>
|
||||
<AlertDialog.Description>
|
||||
{m.settings_danger_alert_description()}
|
||||
{m.settings_danger_alert_description_part1()}
|
||||
<br />
|
||||
{m.settings_danger_alert_description_part2()}
|
||||
<br />
|
||||
{m.settings_danger_alert_description_part3()}
|
||||
</AlertDialog.Description>
|
||||
</AlertDialog.Header>
|
||||
<AlertDialog.Footer>
|
||||
@@ -598,5 +1110,6 @@
|
||||
</AlertDialog.Footer>
|
||||
</AlertDialog.Content>
|
||||
</AlertDialog.Root>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,25 +1,18 @@
|
||||
import type { PageLoad } from './$types';
|
||||
import { GetMachineData, GetConfig } from "$lib/wailsjs/go/main/App";
|
||||
import { GetConfig } from "$lib/wailsjs/go/main/App";
|
||||
import { browser } from '$app/environment';
|
||||
import { dangerZoneEnabled } from "$lib/stores/app";
|
||||
import { get } from "svelte/store";
|
||||
|
||||
export const load = (async () => {
|
||||
if (!browser) return { machineData: null, config: null };
|
||||
if (!browser) return { config: null };
|
||||
|
||||
try {
|
||||
const [machineData, configRoot] = await Promise.all([
|
||||
get(dangerZoneEnabled) ? GetMachineData() : Promise.resolve(null),
|
||||
GetConfig()
|
||||
]);
|
||||
const configRoot = await GetConfig();
|
||||
return {
|
||||
machineData,
|
||||
config: configRoot.EMLy
|
||||
};
|
||||
} catch (e) {
|
||||
console.error("Failed to load settings data", e);
|
||||
return {
|
||||
machineData: null,
|
||||
config: null
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { setupConsoleLogger } from '$lib/utils/logger-hook';
|
||||
import "./layout.css";
|
||||
|
||||
let { children } = $props();
|
||||
|
||||
|
||||
@@ -72,7 +72,8 @@
|
||||
<style>
|
||||
:global(body) {
|
||||
margin: 0;
|
||||
background: #000;
|
||||
background: var(--background);
|
||||
color: var(--foreground);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
@@ -81,11 +82,13 @@
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
background: var(--background);
|
||||
color: var(--foreground);
|
||||
}
|
||||
|
||||
.titlebar {
|
||||
height: 32px;
|
||||
background: #000;
|
||||
background: var(--background);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
@@ -94,13 +97,13 @@
|
||||
user-select: none;
|
||||
flex: 0 0 32px;
|
||||
z-index: 50;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.08);
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
color: rgba(255, 255, 255, 0.7);
|
||||
color: var(--muted-foreground);
|
||||
}
|
||||
|
||||
.controls {
|
||||
@@ -114,7 +117,7 @@
|
||||
height: 100%;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: white;
|
||||
color: var(--foreground);
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
-webkit-app-region: no-drag;
|
||||
@@ -124,16 +127,18 @@
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
background: var(--accent);
|
||||
}
|
||||
|
||||
.close:hover {
|
||||
background: #e81123;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.content {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
background: var(--background);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
ZoomIn,
|
||||
ZoomOut,
|
||||
AlignHorizontalSpaceAround,
|
||||
Download
|
||||
} from "@lucide/svelte";
|
||||
import { sidebarOpen } from "$lib/stores/app";
|
||||
import { toast } from "svelte-sonner";
|
||||
@@ -84,6 +85,17 @@
|
||||
fitToScreen();
|
||||
}
|
||||
|
||||
function downloadImage() {
|
||||
if (!imageData || !filename) return;
|
||||
|
||||
const link = document.createElement("a");
|
||||
link.href = `data:image/png;base64,${imageData}`;
|
||||
link.download = filename;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
}
|
||||
|
||||
function handleWheel(e: WheelEvent) {
|
||||
e.preventDefault();
|
||||
const delta = -e.deltaY * 0.001;
|
||||
@@ -116,6 +128,10 @@
|
||||
<h1 class="title" title={filename}>{filename || "Image Viewer"}</h1>
|
||||
|
||||
<div class="controls">
|
||||
<button class="btn" onclick={() => downloadImage()} title="Download">
|
||||
<Download size="16" />
|
||||
</button>
|
||||
<div class="separator"></div>
|
||||
<button class="btn" onclick={() => zoom(0.1)} title="Zoom In">
|
||||
<ZoomIn size="16" />
|
||||
</button>
|
||||
@@ -177,7 +193,7 @@
|
||||
<style>
|
||||
:global(body) {
|
||||
margin: 0;
|
||||
background: #000;
|
||||
background: var(--background);
|
||||
}
|
||||
|
||||
.page-container {
|
||||
@@ -185,15 +201,15 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
background: #000;
|
||||
color: white;
|
||||
background: var(--background);
|
||||
color: var(--foreground);
|
||||
font-family: system-ui, -apple-system, sans-serif;
|
||||
}
|
||||
|
||||
.toolbar {
|
||||
height: 50px;
|
||||
background: rgba(255, 255, 255, 0.04);
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.08);
|
||||
background: var(--card);
|
||||
border-bottom: 1px solid var(--border);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
@@ -221,7 +237,7 @@
|
||||
.separator {
|
||||
width: 1px;
|
||||
height: 18px;
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
background: var(--border);
|
||||
margin: 0 4px;
|
||||
}
|
||||
|
||||
@@ -233,21 +249,21 @@
|
||||
height: 32px;
|
||||
padding: 0;
|
||||
border-radius: 8px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
color: rgba(255, 255, 255, 0.85);
|
||||
border: 1px solid var(--border);
|
||||
background: var(--muted);
|
||||
color: var(--foreground);
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
color: #fff;
|
||||
background: var(--accent);
|
||||
color: var(--accent-foreground);
|
||||
}
|
||||
|
||||
.image-area {
|
||||
flex: 1;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
background: var(--muted);
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
@@ -275,16 +291,16 @@
|
||||
}
|
||||
|
||||
.loading {
|
||||
color: rgba(255, 255, 255, 0.5);
|
||||
color: var(--muted-foreground);
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.error-message {
|
||||
color: #f87171;
|
||||
background: rgba(248, 113, 113, 0.1);
|
||||
color: var(--destructive);
|
||||
background: var(--destructive-foreground);
|
||||
padding: 12px 16px;
|
||||
border-radius: 8px;
|
||||
border: 1px solid rgba(248, 113, 113, 0.2);
|
||||
border: 1px solid var(--destructive);
|
||||
font-size: 14px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
Quit,
|
||||
} from "$lib/wailsjs/runtime/runtime";
|
||||
import type { LayoutProps } from "./$types";
|
||||
import { settingsStore } from "$lib/stores/settings.svelte.js";
|
||||
|
||||
let { data, children }: LayoutProps = $props();
|
||||
|
||||
@@ -57,7 +58,7 @@
|
||||
>
|
||||
<div class="title">EMLy PDF Viewer</div>
|
||||
|
||||
<div class="controls">
|
||||
<div class="controls" class:high-contrast={settingsStore.settings.increaseWindowButtonsContrast}>
|
||||
<button class="btn" onclick={minimize}>─</button>
|
||||
<button class="btn" onclick={toggleMaximize}>
|
||||
{#if isMaximized}
|
||||
@@ -79,7 +80,8 @@
|
||||
<style>
|
||||
:global(body) {
|
||||
margin: 0;
|
||||
background: #000;
|
||||
background: var(--background);
|
||||
color: var(--foreground);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
@@ -88,11 +90,13 @@
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
background: var(--background);
|
||||
color: var(--foreground);
|
||||
}
|
||||
|
||||
.titlebar {
|
||||
height: 32px;
|
||||
background: #000;
|
||||
background: var(--background);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
@@ -101,13 +105,14 @@
|
||||
user-select: none;
|
||||
flex: 0 0 32px;
|
||||
z-index: 50;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.08);
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 13px;
|
||||
opacity: 0.9;
|
||||
color: white;
|
||||
color: var(--muted-foreground);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.controls {
|
||||
@@ -116,29 +121,34 @@
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.controls.high-contrast {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.btn {
|
||||
width: 46px;
|
||||
height: 100%;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: white;
|
||||
color: var(--foreground);
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
-webkit-app-region: no-drag;
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
background: var(--accent);
|
||||
}
|
||||
|
||||
.btn:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
background: rgba(255, 255, 255, 0.02);
|
||||
background: var(--muted);
|
||||
}
|
||||
|
||||
.close:hover {
|
||||
background: #e81123;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.content {
|
||||
@@ -147,6 +157,6 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
background: #111;
|
||||
background: var(--background);
|
||||
}
|
||||
</style>
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import { onMount, untrack } from "svelte";
|
||||
import type { PageData } from "./$types";
|
||||
import {
|
||||
RotateCcw,
|
||||
@@ -7,9 +7,11 @@
|
||||
ZoomIn,
|
||||
ZoomOut,
|
||||
AlignHorizontalSpaceAround,
|
||||
Download
|
||||
} from "@lucide/svelte";
|
||||
import { sidebarOpen } from "$lib/stores/app";
|
||||
import { toast } from "svelte-sonner";
|
||||
import * as m from "$lib/paraglide/messages.js";
|
||||
import * as pdfjsLib from "pdfjs-dist";
|
||||
import pdfWorker from "pdfjs-dist/build/pdf.worker.min.mjs?url";
|
||||
|
||||
@@ -63,9 +65,8 @@
|
||||
|
||||
await loadPDF();
|
||||
} else {
|
||||
toast.error("No PDF data provided");
|
||||
error =
|
||||
"No PDF data provided. Please open this window from the main EMLy application.";
|
||||
toast.error(m.pdf_error_no_data());
|
||||
error = m.pdf_error_no_data_desc();
|
||||
loading = false;
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -81,8 +82,7 @@
|
||||
const timeout = setTimeout(() => {
|
||||
if (loading) {
|
||||
loading = false;
|
||||
error =
|
||||
"Timeout loading PDF. The worker might have failed to initialize.";
|
||||
error = m.pdf_error_timeout();
|
||||
toast.error(error);
|
||||
}
|
||||
}, 10000);
|
||||
@@ -96,7 +96,7 @@
|
||||
loading = false;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
error = "Error parsing PDF: " + e;
|
||||
error = m.pdf_error_parsing() + e;
|
||||
loading = false;
|
||||
} finally {
|
||||
clearTimeout(timeout);
|
||||
@@ -107,7 +107,13 @@
|
||||
if (!pdfDoc || !canvasRef) return;
|
||||
|
||||
if (renderTask) {
|
||||
await renderTask.promise.catch(() => {}); // Cancel previous render if any (though we wait usually)
|
||||
// Cancel previous render if any and await its cleanup
|
||||
renderTask.cancel();
|
||||
try {
|
||||
await renderTask.promise;
|
||||
} catch (e) {
|
||||
// Expected cancellation error
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -131,11 +137,13 @@
|
||||
};
|
||||
|
||||
// Cast to any to avoid type mismatch with PDF.js definitions
|
||||
await page.render(renderContext as any).promise;
|
||||
const task = page.render(renderContext as any);
|
||||
renderTask = task;
|
||||
await task.promise;
|
||||
} catch (e: any) {
|
||||
if (e.name !== "RenderingCancelledException") {
|
||||
console.error(e);
|
||||
toast.error("Error rendering page: " + e.message);
|
||||
toast.error(m.pdf_error_rendering() + e.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -156,11 +164,15 @@
|
||||
|
||||
$effect(() => {
|
||||
// Re-render when scale or rotation changes
|
||||
// Access them here to ensure dependency tracking since renderPage is async
|
||||
const _deps = [scale, rotation];
|
||||
// Access them here to ensure dependency tracking since renderPage is untracked
|
||||
// We also track pageNum to ensure we re-render if it changes via other means,
|
||||
// although navigation functions usually call renderPage manually.
|
||||
const _deps = [scale, rotation, pageNum];
|
||||
|
||||
if (pdfDoc) {
|
||||
renderPage(pageNum);
|
||||
// Untrack renderPage because it reads and writes to renderTask,
|
||||
// which would otherwise cause an infinite loop.
|
||||
untrack(() => renderPage(pageNum));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -183,13 +195,31 @@
|
||||
pageNum--;
|
||||
renderPage(pageNum);
|
||||
}
|
||||
|
||||
function downloadPDF() {
|
||||
if (!pdfData) return;
|
||||
try {
|
||||
// @ts-ignore
|
||||
const blob = new Blob([pdfData], { type: "application/pdf" });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement("a");
|
||||
a.href = url;
|
||||
a.download = filename || "document.pdf";
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
URL.revokeObjectURL(url);
|
||||
} catch (e) {
|
||||
toast.error("Failed to download PDF: " + e);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="viewer-container">
|
||||
{#if loading}
|
||||
<div class="loading-overlay">
|
||||
<div class="spinner"></div>
|
||||
<div>Loading PDF...</div>
|
||||
<div>{m.pdf_loading()}</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
@@ -200,24 +230,28 @@
|
||||
{/if}
|
||||
|
||||
<div class="toolbar">
|
||||
<h1 class="title" title={filename}>{filename || "Image Viewer"}</h1>
|
||||
<h1 class="title" title={filename}>{filename || m.pdf_viewer_title()}</h1>
|
||||
|
||||
<div class="controls">
|
||||
<button class="btn" onclick={() => zoom(0.1)} title="Zoom In">
|
||||
<button class="btn" onclick={() => downloadPDF()} title={m.mail_download_btn_title()}>
|
||||
<Download size="16" />
|
||||
</button>
|
||||
<div class="separator"></div>
|
||||
<button class="btn" onclick={() => zoom(0.1)} title={m.pdf_zoom_in()}>
|
||||
<ZoomIn size="16" />
|
||||
</button>
|
||||
<button class="btn" onclick={() => zoom(-0.1)} title="Zoom Out">
|
||||
<button class="btn" onclick={() => zoom(-0.1)} title={m.pdf_zoom_out()}>
|
||||
<ZoomOut size="16" />
|
||||
</button>
|
||||
<div class="separator"></div>
|
||||
<button class="btn" onclick={() => rotate(-90)} title="Rotate Left">
|
||||
<button class="btn" onclick={() => rotate(-90)} title={m.pdf_rotate_left()}>
|
||||
<RotateCcw size="16" />
|
||||
</button>
|
||||
<button class="btn" onclick={() => rotate(90)} title="Rotate Right">
|
||||
<button class="btn" onclick={() => rotate(90)} title={m.pdf_rotate_right()}>
|
||||
<RotateCw size="16" />
|
||||
</button>
|
||||
<div class="separator"></div>
|
||||
<button class="btn" onclick={fitToWidth} title="Reset">
|
||||
<button class="btn" onclick={fitToWidth} title={m.pdf_fit_width()}>
|
||||
<AlignHorizontalSpaceAround size="16" />
|
||||
</button>
|
||||
</div>
|
||||
@@ -233,9 +267,10 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
background: #1e1e1e;
|
||||
background: var(--background);
|
||||
position: relative;
|
||||
user-select: none;
|
||||
color: var(--foreground);
|
||||
}
|
||||
|
||||
.loading-overlay {
|
||||
@@ -247,15 +282,15 @@
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: #111;
|
||||
color: white;
|
||||
background: var(--background);
|
||||
color: var(--foreground);
|
||||
}
|
||||
|
||||
.spinner {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border: 2px solid rgba(255, 255, 255, 0.1);
|
||||
border-top-color: rgba(255, 255, 255, 0.8);
|
||||
border: 2px solid var(--border);
|
||||
border-top-color: var(--primary);
|
||||
border-radius: 50%;
|
||||
animation: spin 0.6s linear infinite;
|
||||
}
|
||||
@@ -273,14 +308,14 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: #111;
|
||||
color: #ef4444;
|
||||
background: var(--background);
|
||||
color: var(--destructive);
|
||||
}
|
||||
|
||||
.toolbar {
|
||||
height: 50px;
|
||||
background: #000;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.08);
|
||||
background: var(--card);
|
||||
border-bottom: 1px solid var(--border);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
@@ -308,7 +343,7 @@
|
||||
.separator {
|
||||
width: 1px;
|
||||
height: 18px;
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
background: var(--border);
|
||||
margin: 0 4px;
|
||||
}
|
||||
|
||||
@@ -320,22 +355,16 @@
|
||||
height: 32px;
|
||||
padding: 0;
|
||||
border-radius: 8px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
color: rgba(255, 255, 255, 0.85);
|
||||
border: 1px solid var(--border);
|
||||
background: var(--muted);
|
||||
color: var(--foreground);
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.separator {
|
||||
width: 1px;
|
||||
height: 24px;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
background: var(--accent);
|
||||
color: var(--accent-foreground);
|
||||
}
|
||||
|
||||
.canvas-container {
|
||||
@@ -345,7 +374,7 @@
|
||||
justify-content: center;
|
||||
align-items: flex-start; /* scroll from top */
|
||||
padding: 20px;
|
||||
background: #333; /* Dark background for contrast */
|
||||
background: var(--muted);
|
||||
}
|
||||
|
||||
canvas {
|
||||
@@ -363,12 +392,12 @@
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
background: var(--border);
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
background: var(--muted-foreground);
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-corner {
|
||||
|
||||
@@ -1,20 +1,44 @@
|
||||
#define ApplicationName 'EMLy'
|
||||
#define ApplicationVersion GetVersionNumbersString('EMLy.exe')
|
||||
#define ApplicationVersion '1.3.1_beta'
|
||||
#define ApplicationVersion '1.5.4_beta'
|
||||
|
||||
[Languages]
|
||||
Name: "english"; MessagesFile: "compiler:Default.isl"
|
||||
Name: "italian"; MessagesFile: "compiler:Languages\Italian.isl"
|
||||
|
||||
[CustomMessages]
|
||||
; English messages
|
||||
english.UpgradeDetected=A previous version of {#ApplicationName} (v%1) has been detected.
|
||||
english.UpgradeMessage=This installer will upgrade your installation to version {#ApplicationVersion}.%n%nYour settings and preferences will be preserved.%n%nDo you want to continue?
|
||||
english.FreshInstall=Welcome to {#ApplicationName} {#ApplicationVersion} Setup
|
||||
english.FreshInstallMessage=This will install {#ApplicationName} on your computer.
|
||||
|
||||
; Italian messages
|
||||
italian.UpgradeDetected=È stata rilevata una versione precedente di {#ApplicationName} (v%1).
|
||||
italian.UpgradeMessage=Questo installer aggiornerà la tua installazione alla versione {#ApplicationVersion}.%n%nLe tue impostazioni e preferenze saranno preservate.%n%nVuoi continuare?
|
||||
italian.FreshInstall=Benvenuto nell'installazione di {#ApplicationName} {#ApplicationVersion}
|
||||
italian.FreshInstallMessage=Questo installerà {#ApplicationName} sul tuo computer.
|
||||
|
||||
[Setup]
|
||||
AppName={#ApplicationName}
|
||||
AppVersion={#ApplicationVersion}
|
||||
; Default directory (will be adjusted in code based on installation mode)
|
||||
; Admin mode: C:\Program Files\EMLy
|
||||
; User mode: C:\Users\{username}\AppData\Local\Programs\EMLy
|
||||
DefaultDirName={autopf}\EMLy
|
||||
OutputBaseFilename={#ApplicationName}_Installer_{#ApplicationVersion}
|
||||
ArchitecturesInstallIn64BitMode=x64compatible
|
||||
DisableProgramGroupPage=yes
|
||||
; Request administrative privileges for HKA to write to HKLM if needed,
|
||||
; or use "lowest" if purely per-user, but file associations usually work better with admin rights or proper HKA handling.
|
||||
PrivilegesRequired=admin
|
||||
; Allow user to choose between admin (system-wide) and user-only install
|
||||
; "lowest" = does not require admin privileges by default (user mode)
|
||||
; "dialog" = shows a dialog asking user to choose installation mode
|
||||
PrivilegesRequired=lowest
|
||||
PrivilegesRequiredOverridesAllowed=dialog
|
||||
SetupIconFile=..\build\windows\icon.ico
|
||||
UninstallDisplayIcon={app}\{#ApplicationName}.exe
|
||||
AppVerName={#ApplicationName} {#ApplicationVersion}
|
||||
WizardStyle=modern dynamic includetitlebar
|
||||
|
||||
|
||||
[Files]
|
||||
; Source path relative to this .iss file (assuming it is in the "installer" folder and build is in "../build")
|
||||
@@ -22,6 +46,12 @@ Source: "..\build\bin\{#ApplicationName}.exe"; DestDir: "{app}"; Flags: ignoreve
|
||||
Source: "..\build\bin\config.ini"; DestDir: "{app}"; Flags: ignoreversion
|
||||
|
||||
[Registry]
|
||||
; File associations using HKA (HKEY_AUTO) registry root
|
||||
; HKA automatically selects the appropriate registry hive:
|
||||
; - HKLM (HKEY_LOCAL_MACHINE) for admin/system-wide installations
|
||||
; - HKCU (HKEY_CURRENT_USER) for user-only installations
|
||||
; This ensures file associations work correctly for both installation modes
|
||||
|
||||
; 1. Register the .eml extension and point it to our internal ProgID "EMLy.EML"
|
||||
Root: HKA; Subkey: "Software\Classes\.eml"; ValueType: string; ValueName: ""; ValueData: "{#ApplicationName}.EML"; Flags: uninsdeletevalue
|
||||
Root: HKA; Subkey: "Software\Classes\.msg"; ValueType: string; ValueName: ""; ValueData: "{#ApplicationName}.MSG"; Flags: uninsdeletevalue
|
||||
@@ -44,3 +74,103 @@ Root: HKA; Subkey: "Software\Classes\{#ApplicationName}.MSG\shell\open"; ValueTy
|
||||
|
||||
[Icons]
|
||||
Name: "{autoprograms}\{#ApplicationName}"; Filename: "{app}\{#ApplicationName}.exe"
|
||||
|
||||
[Code]
|
||||
var
|
||||
PreviousVersion: String;
|
||||
IsUpgrade: Boolean;
|
||||
|
||||
// Check if a command line parameter exists
|
||||
function CmdLineParamExists(const Param: string): Boolean;
|
||||
var
|
||||
I: Integer;
|
||||
begin
|
||||
Result := False;
|
||||
for I := 1 to ParamCount do
|
||||
if CompareText(ParamStr(I), Param) = 0 then
|
||||
begin
|
||||
Result := True;
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
// Check if a previous version is installed
|
||||
function GetPreviousVersion(): String;
|
||||
var
|
||||
RegPath: String;
|
||||
Version: String;
|
||||
begin
|
||||
Result := '';
|
||||
|
||||
// Check HKLM (system-wide installation)
|
||||
RegPath := 'Software\Microsoft\Windows\CurrentVersion\Uninstall\{#ApplicationName}_is1';
|
||||
if RegQueryStringValue(HKLM, RegPath, 'DisplayVersion', Version) then
|
||||
begin
|
||||
Result := Version;
|
||||
Exit;
|
||||
end;
|
||||
|
||||
// Check HKCU (user installation)
|
||||
if RegQueryStringValue(HKCU, RegPath, 'DisplayVersion', Version) then
|
||||
begin
|
||||
Result := Version;
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
// Initialize setup and detect upgrade
|
||||
function InitializeSetup(): Boolean;
|
||||
var
|
||||
Message: String;
|
||||
begin
|
||||
Result := True;
|
||||
PreviousVersion := GetPreviousVersion();
|
||||
IsUpgrade := (PreviousVersion <> '');
|
||||
|
||||
if IsUpgrade then
|
||||
begin
|
||||
// Check for /FORCEUPGRADE parameter to skip confirmation
|
||||
if not CmdLineParamExists('/FORCEUPGRADE') then
|
||||
begin
|
||||
// Show upgrade message
|
||||
Message := FmtMessage(CustomMessage('UpgradeDetected'), [PreviousVersion]) + #13#10#13#10 +
|
||||
CustomMessage('UpgradeMessage');
|
||||
|
||||
if MsgBox(Message, mbInformation, MB_YESNO) = IDNO then
|
||||
begin
|
||||
Result := False;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
// Show appropriate welcome message
|
||||
procedure InitializeWizard();
|
||||
begin
|
||||
if not IsUpgrade then
|
||||
begin
|
||||
WizardForm.WelcomeLabel2.Caption := CustomMessage('FreshInstallMessage');
|
||||
end;
|
||||
end;
|
||||
|
||||
// Override default directory based on installation mode
|
||||
function GetDefaultDirName(Param: string): string;
|
||||
begin
|
||||
// If installing with admin privileges (system-wide), use Program Files
|
||||
if IsAdminInstallMode then
|
||||
Result := ExpandConstant('{autopf}\{#ApplicationName}')
|
||||
// If installing for current user only, use AppData\Local\Programs
|
||||
else
|
||||
Result := ExpandConstant('{localappdata}\Programs\{#ApplicationName}');
|
||||
end;
|
||||
|
||||
procedure CurPageChanged(CurPageID: Integer);
|
||||
begin
|
||||
// Update the directory when the directory selection page is shown
|
||||
if CurPageID = wpSelectDir then
|
||||
begin
|
||||
// Only set if user hasn't manually changed it
|
||||
if WizardForm.DirEdit.Text = ExpandConstant('{autopf}\{#ApplicationName}') then
|
||||
WizardForm.DirEdit.Text := GetDefaultDirName('');
|
||||
end;
|
||||
end;
|
||||
|
||||
14
installer/sample_version.json
Normal file
14
installer/sample_version.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"stableVersion": "1.4.0",
|
||||
"betaVersion": "1.4.1-beta",
|
||||
"stableDownload": "EMLy_Installer_1.4.0.exe",
|
||||
"betaDownload": "EMLy_Installer_1.4.1-beta.exe",
|
||||
"sha256Checksums": {
|
||||
"EMLy_Installer_1.4.0.exe": "put_sha256_hash_here",
|
||||
"EMLy_Installer_1.4.1-beta.exe": "put_sha256_hash_here"
|
||||
},
|
||||
"releaseNotes": {
|
||||
"1.4.0": "Initial release with self-hosted update system",
|
||||
"1.4.1-beta": "Beta release with bug fixes"
|
||||
}
|
||||
}
|
||||
56
main.go
56
main.go
@@ -4,11 +4,14 @@ import (
|
||||
"embed"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/wailsapp/wails/v2"
|
||||
"github.com/wailsapp/wails/v2/pkg/options"
|
||||
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
|
||||
"github.com/wailsapp/wails/v2/pkg/options/windows"
|
||||
"github.com/wailsapp/wails/v2/pkg/runtime"
|
||||
)
|
||||
|
||||
@@ -33,6 +36,12 @@ func main() {
|
||||
}
|
||||
defer CloseLogger()
|
||||
|
||||
// Load config.ini to get WebView2 paths
|
||||
configPath := filepath.Join(filepath.Dir(os.Args[0]), "config.ini")
|
||||
if _, err := os.Stat(configPath); os.IsNotExist(err) {
|
||||
configPath = "config.ini" // fallback to current directory
|
||||
}
|
||||
|
||||
// Check for custom args
|
||||
args := os.Args
|
||||
uniqueId := "emly-app-lock"
|
||||
@@ -74,6 +83,49 @@ func main() {
|
||||
}
|
||||
|
||||
// Create application with options
|
||||
// Configure WebView2 DataPath (user data folder)
|
||||
userDataPath := filepath.Join(os.Getenv("APPDATA"), "EMLy") // default
|
||||
downloadPath := filepath.Join(os.Getenv("USERPROFILE"), "Downloads") // default
|
||||
|
||||
// Helper function to expand Windows-style environment variables
|
||||
expandEnvVars := func(path string) string {
|
||||
// Match %%VAR%% or %VAR% patterns and replace with actual values
|
||||
re := regexp.MustCompile(`%%([^%]+)%%|%([^%]+)%`)
|
||||
return re.ReplaceAllStringFunc(path, func(match string) string {
|
||||
varName := strings.Trim(match, "%")
|
||||
return os.Getenv(varName)
|
||||
})
|
||||
}
|
||||
|
||||
// Load paths from config.ini if available
|
||||
if cfg, err := os.ReadFile(configPath); err == nil {
|
||||
// Simple INI parsing for these specific values
|
||||
lines := strings.Split(string(cfg), "\n")
|
||||
for _, line := range lines {
|
||||
line = strings.TrimSpace(line)
|
||||
if strings.HasPrefix(line, "WEBVIEW2_USERDATA_PATH") {
|
||||
parts := strings.SplitN(line, "=", 2)
|
||||
if len(parts) == 2 {
|
||||
path := strings.TrimSpace(parts[1])
|
||||
if path != "" {
|
||||
userDataPath = expandEnvVars(path)
|
||||
}
|
||||
}
|
||||
} else if strings.HasPrefix(line, "WEBVIEW2_DOWNLOAD_PATH") {
|
||||
parts := strings.SplitN(line, "=", 2)
|
||||
if len(parts) == 2 {
|
||||
path := strings.TrimSpace(parts[1])
|
||||
if path != "" {
|
||||
downloadPath = expandEnvVars(path)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.Printf("WebView2 UserDataPath: %s", userDataPath)
|
||||
log.Printf("WebView2 DownloadPath: %s", downloadPath)
|
||||
|
||||
err := wails.Run(&options.App{
|
||||
Title: windowTitle,
|
||||
Width: windowWidth,
|
||||
@@ -94,6 +146,10 @@ func main() {
|
||||
MinWidth: 964,
|
||||
MinHeight: 690,
|
||||
Frameless: frameless,
|
||||
Windows: &windows.Options{
|
||||
WebviewUserDataPath: userDataPath,
|
||||
WebviewBrowserPath: "", // Empty = use system Edge WebView2
|
||||
},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user