Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Artifacts

on:
push:
branches: [main, master]
# 任意分支推送都构建四平台产物(docs 等纯文档改动除外)
paths-ignore:
- '**/*.md'
- '**/*.mdx'
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,6 @@ docs-private/
# 内部审查/对齐文档只留本地,不入库
.report/
docs/

# Arch 打包工作目录(makepkg 产物与本地 PKGBUILD)
/build/
37 changes: 37 additions & 0 deletions scripts/run-tauri.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,48 @@
import { spawn } from 'node:child_process'
import { createRequire } from 'node:module'
import { existsSync, readFileSync, writeFileSync } from 'node:fs'

const require = createRequire(import.meta.url)
const tauriCli = require.resolve('@tauri-apps/cli/tauri.js')

// linuxdeploy bundles an old strip (no SHT_RELR support) that fails on
// distros whose system libs use RELR relocations (Arch/Fedora families):
// "unknown type [0x13] section `.relr.dyn'". NO_STRIP skips stripping
// entirely; only affects Linux AppImage bundling.
function isRelrDistro() {
try {
const release = readFileSync('/etc/os-release', 'utf8')
return /^ID(?:_LIKE)?=.*\b(?:arch|fedora)\b/m.test(release)
} catch {
return false
}
}

// linuxdeploy-plugin-gtk 的符号链接兜底(linuxdeploy/linuxdeploy-plugin-gtk#24
// 方案)不带 -f:linuxdeploy 已把 GTK 模块铺平到 $APPDIR/usr/lib 时,
// `ln: 文件已存在` 会让插件 set -e 直接失败(Arch 等发行版必现)。
// 幂等打补丁:ln -s -> ln -sf,符号链接目标不变,可安全覆盖平铺副本。
function patchGtkPluginSymlinks() {
try {
const cacheDir = process.env.XDG_CACHE_HOME
? `${process.env.XDG_CACHE_HOME}/tauri`
: `${process.env.HOME || ''}/.cache/tauri`
const pluginPath = `${cacheDir}/linuxdeploy-plugin-gtk.sh`
if (!existsSync(pluginPath)) return
const content = readFileSync(pluginPath, 'utf8')
const patched = content.replace('ln $verbose -s ', 'ln $verbose -sf ')
if (patched !== content) writeFileSync(pluginPath, patched)
} catch {
// 打补丁失败不阻塞构建(仅影响 AppImage 打包)
}
}

if (process.platform === 'linux') patchGtkPluginSymlinks()

const environment = {
...process.env,
NERI_BUILD_EPOCH: process.env.NERI_BUILD_EPOCH || Math.floor(Date.now() / 1000).toString(),
...(isRelrDistro() ? { NO_STRIP: '1' } : {}),
}

const child = spawn(process.execPath, [tauriCli, ...process.argv.slice(2)], {
Expand Down
1 change: 1 addition & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"
tauri-build = { version = "2", features = [] }

[dependencies]
tauri = { version = "2", features = ["protocol-asset"] }
tauri = { version = "2", features = ["protocol-asset", "tray-icon"] }
tauri-plugin-opener = "2.5.4"
tauri-plugin-store = "2"
tauri-plugin-dialog = "2"
Expand Down Expand Up @@ -77,3 +77,6 @@ opt-level = 2

[profile.dev.package.symphonia-format-ogg]
opt-level = 2

[target.'cfg(windows)'.dependencies]
winreg = "0.55"
1 change: 1 addition & 0 deletions src-tauri/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ pub mod settings_cmd;
pub mod stats_cmd;
pub mod storage_cmd;
pub mod sync_cmd;
pub mod tray_cmd;
29 changes: 29 additions & 0 deletions src-tauri/src/commands/settings_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,35 @@ pub async fn get_build_info() -> AppResult<BuildInfo> {
})
}

/// 读取系统强调色,供「自动跟随系统取色」使用,返回 "rgb(r, g, b)"。
/// Windows 从注册表 Explorer\Accent 读取 SystemAccentColor(ABGR,Win10 1903+),
/// 旧系统回退 AccentColorMenu;其余平台返回 None(由前端 CSS accent 关键字兜底)。
#[tauri::command]
pub fn get_system_accent_color() -> Option<String> {
#[cfg(target_os = "windows")]
{
use winreg::enums::HKEY_CURRENT_USER;
use winreg::RegKey;

let hkcu = RegKey::predef(HKEY_CURRENT_USER);
let accent = hkcu
.open_subkey(r"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Accent")
.ok()?;
let raw: u32 = accent
.get_value("SystemAccentColor")
.or_else(|_| accent.get_value("AccentColorMenu"))
.ok()?;
let r = raw & 0xFF;
let g = (raw >> 8) & 0xFF;
let b = (raw >> 16) & 0xFF;
return Some(format!("rgb({r}, {g}, {b})"));
}
#[cfg(not(target_os = "windows"))]
{
None
}
}

#[cfg(test)]
mod tests {
use super::{
Expand Down
Loading