mirror of
https://github.com/ILoveBingLu/CipherTalk.git
synced 2026-05-18 18:28:53 +08:00
85adc0aeb1
- 新增 WASM 视频解码模块(wasm_video_decode.js/wasm)支持视频流处理 - 新增 Isaac64 随机数生成器服务用于数据加密 - 新增 SNS 服务模块处理社交网络数据 - 新增 WASM 服务层封装 WebAssembly 功能调用 - 新增 Moments 窗口页面展示朋友圈内容 - 新增图片预览、JSON 查看器和日期跳转对话框组件 - 新增 LivePhoto 图标组件支持实况照片显示 - 更新视频服务集成 WASM 解码能力 - 更新图片解密服务支持新的解密方式 - 更新数据管理页面新增 Moments 数据查看功能 - 更新导出服务支持 HTML 格式导出 - 更新聊天页面布局和功能 - 更新 npm 配置使用环境变量标准化 Electron 镜像设置 - 更新版本号至 2.2.4 - 优化日期范围选择器样式和交互
80 lines
2.8 KiB
TypeScript
80 lines
2.8 KiB
TypeScript
import { app } from 'electron'
|
|
import { spawn } from 'child_process'
|
|
import { join } from 'path'
|
|
import { existsSync } from 'fs'
|
|
|
|
export class ShortcutService {
|
|
/**
|
|
* 更新桌面快捷方式的图标
|
|
* 注意:这需要调用 PowerShell,可能会短暂显示控制台窗口或被杀毒软件拦截
|
|
* @param iconPath ICO 图标文件的绝对路径
|
|
*/
|
|
async updateDesktopShortcutIcon(iconPath: string): Promise<{ success: boolean; error?: string }> {
|
|
return new Promise((resolve) => {
|
|
try {
|
|
if (!existsSync(iconPath)) {
|
|
resolve({ success: false, error: '图标文件不存在' })
|
|
return
|
|
}
|
|
|
|
const desktopPath = app.getPath('desktop')
|
|
const exePath = process.execPath
|
|
|
|
// PowerShell 脚本:遍历桌面所有 .lnk,如果目标指向当前 exe,则修改图标
|
|
// 使用 -WindowStyle Hidden 隐藏窗口
|
|
const psScript = `
|
|
$WshShell = New-Object -comObject WScript.Shell
|
|
$DesktopPath = "${desktopPath}"
|
|
$TargetExe = "${exePath}"
|
|
$IconPath = "${iconPath}"
|
|
|
|
Get-ChildItem -Path $DesktopPath -Filter *.lnk | ForEach-Object {
|
|
try {
|
|
$Shortcut = $WshShell.CreateShortcut($_.FullName)
|
|
if ($Shortcut.TargetPath -eq $TargetExe) {
|
|
$Shortcut.IconLocation = $IconPath
|
|
$Shortcut.Save()
|
|
Write-Host "Updated: $($_.Name)"
|
|
}
|
|
} catch {
|
|
Write-Error $_.Exception.Message
|
|
}
|
|
}
|
|
`
|
|
|
|
const ps = spawn('powershell.exe', [
|
|
'-NoProfile',
|
|
'-ExecutionPolicy', 'Bypass',
|
|
'-WindowStyle', 'Hidden',
|
|
'-Command', psScript
|
|
])
|
|
|
|
let output = ''
|
|
let errorOutput = ''
|
|
|
|
ps.stdout.on('data', (data) => {
|
|
output += data.toString()
|
|
})
|
|
|
|
ps.stderr.on('data', (data) => {
|
|
errorOutput += data.toString()
|
|
})
|
|
|
|
ps.on('close', (code) => {
|
|
if (code === 0) {
|
|
resolve({ success: true })
|
|
} else {
|
|
console.error('[ShortcutService] 更新快捷方式失败', errorOutput)
|
|
resolve({ success: false, error: errorOutput || 'Unknown PowerShell error' })
|
|
}
|
|
})
|
|
} catch (e) {
|
|
console.error('[ShortcutService] 执行出错', e)
|
|
resolve({ success: false, error: String(e) })
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
export const shortcutService = new ShortcutService()
|