Improve Linux compatibility (#6)

* Improve Linux compatibility

* Run CI on Linux builds

* Update release workflow for Linux builds
This commit is contained in:
Nexmoe
2025-10-30 21:36:00 +08:00
committed by GitHub
parent 10a97b1f4a
commit 37c1f22aee
4 changed files with 76 additions and 39 deletions

View File

@@ -6,7 +6,19 @@ on:
jobs:
test:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
build-script: pnpm run build:win
ytdlp-asset: yt-dlp.exe
ytdlp-output: yt-dlp.exe
- os: ubuntu-latest
build-script: pnpm run build:linux
ytdlp-asset: yt-dlp
ytdlp-output: yt-dlp_linux
runs-on: ${{ matrix.os }}
steps:
- name: Check out Git repository
@@ -25,13 +37,16 @@ jobs:
- name: Install Dependencies
run: pnpm install
- name: Download yt-dlp binaries
- name: Download yt-dlp binary
shell: bash
run: |
# Download yt-dlp.exe for Windows
curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp.exe -o resources/yt-dlp.exe
curl -L "https://github.com/yt-dlp/yt-dlp/releases/latest/download/${{ matrix.ytdlp-asset }}" -o "resources/${{ matrix.ytdlp-output }}"
if [[ "${{ runner.os }}" == "Linux" ]]; then
chmod +x "resources/${{ matrix.ytdlp-output }}"
fi
- name: Lint and format check
run: pnpm run check
- name: build-win
run: pnpm run build:win
- name: Build application
run: ${{ matrix.build-script }}

View File

@@ -11,7 +11,19 @@ jobs:
strategy:
matrix:
os: [windows-latest, macos-latest]
include:
- os: windows-latest
build_script: pnpm run build:win
ytdlp_asset: yt-dlp.exe
ytdlp_output: yt-dlp.exe
- os: macos-latest
build_script: pnpm run build:mac
ytdlp_asset: yt-dlp_macos
ytdlp_output: yt-dlp_macos
- os: ubuntu-latest
build_script: pnpm run build:linux
ytdlp_asset: yt-dlp
ytdlp_output: yt-dlp_linux
steps:
- name: Check out Git repository
@@ -30,33 +42,19 @@ jobs:
- name: Install Dependencies
run: pnpm install
- name: Download yt-dlp binaries
- name: Download yt-dlp binary
shell: bash
run: |
# Download yt-dlp.exe for Windows
curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp.exe -o resources/yt-dlp.exe
# Download yt-dlp for macOS (for cross-platform builds)
curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_macos -o resources/yt-dlp_macos
chmod +x resources/yt-dlp_macos
# Download yt-dlp for Linux (for cross-platform builds)
# curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o resources/yt-dlp_linux
# chmod +x resources/yt-dlp_linux
curl -L "https://github.com/yt-dlp/yt-dlp/releases/latest/download/${{ matrix.ytdlp_asset }}" -o "resources/${{ matrix.ytdlp_output }}"
if [[ "${{ runner.os }}" == "Linux" ]]; then
chmod +x "resources/${{ matrix.ytdlp_output }}"
fi
- name: Lint and format check
run: pnpm run check
# - name: build-linux
# if: matrix.os == 'ubuntu-latest'
# run: pnpm run build:linux
- name: build-mac
if: matrix.os == 'macos-latest'
run: pnpm run build:mac
- name: build-win
if: matrix.os == 'windows-latest'
run: pnpm run build:win
- name: Build application
run: ${{ matrix.build_script }}
- name: release
uses: softprops/action-gh-release@v1

View File

@@ -1,6 +1,6 @@
import { join } from 'node:path'
import { electronApp, optimizer } from '@electron-toolkit/utils'
import { app, BrowserWindow, shell } from 'electron'
import { app, BrowserWindow, type BrowserWindowConstructorOptions, shell } from 'electron'
import log from 'electron-log/main'
import { autoUpdater } from 'electron-updater'
import appIcon from '../../build/icon.png?asset'
@@ -22,18 +22,16 @@ let mainWindow: BrowserWindow | null = null
let isQuitting = false
export function createWindow(): void {
// Create the browser window
mainWindow = new BrowserWindow({
const isMac = process.platform === 'darwin'
const isWindows = process.platform === 'win32'
const windowOptions: BrowserWindowConstructorOptions = {
width: 1200,
height: 800,
show: false,
titleBarStyle: 'hidden', // Hide title bar on macOS
trafficLightPosition: { x: 12.5, y: 10 },
autoHideMenuBar: true,
icon: appIcon, // Set application icon
frame: false,
vibrancy: 'fullscreen-ui', // on MacOS
backgroundMaterial: 'acrylic', // on Windows 11
webPreferences: {
preload: join(__dirname, '../preload/index.js'),
sandbox: false,
@@ -41,7 +39,20 @@ export function createWindow(): void {
nodeIntegration: false,
webSecurity: false // Allow drag regions to work
}
})
}
if (isMac) {
windowOptions.titleBarStyle = 'hidden'
windowOptions.trafficLightPosition = { x: 12.5, y: 10 }
windowOptions.vibrancy = 'fullscreen-ui'
}
if (isWindows) {
windowOptions.backgroundMaterial = 'acrylic'
}
// Create the browser window
mainWindow = new BrowserWindow(windowOptions)
mainWindow.on('close', (event) => {
const closeToTray = settingsManager.get('closeToTray')

View File

@@ -1,4 +1,4 @@
import { execFile } from 'node:child_process'
import { execFile, execSync } from 'node:child_process'
import fs from 'node:fs/promises'
import os from 'node:os'
import path from 'node:path'
@@ -40,7 +40,20 @@ class FileSystemService extends IpcService {
@IpcMethod()
getDefaultDownloadPath(_context: IpcContext): string {
return `${os.homedir()}/Downloads`
const fallbackPath = path.join(os.homedir(), 'Downloads')
if (process.platform === 'linux' || process.platform === 'freebsd') {
try {
const xdgPath = execSync('xdg-user-dir DOWNLOAD', { encoding: 'utf8' }).trim()
if (xdgPath) {
return xdgPath
}
} catch (error) {
console.warn('Unable to resolve XDG download directory, falling back to default:', error)
}
}
return fallbackPath
}
@IpcMethod()