157af4399f
- 恢复 IPC 类型声明 (src/electron-api.d.ts),修复 31 个 TS2339 错误 - 修复构建断裂:vite.config.ts 改回 electron.vite.config.ts - 修复 2 个 verbatimModuleSyntax type-import 报错 - 修正 .gitignore 构建产物路径 (electron-dist/ -> dist-electron/ + release/) - 清理 55+ 处过时路径注释 - 更新 AGENTS.md 架构文档与 IPC 通道表 - 修正 docs/ROADMAP.md 过时引用
16 lines
479 B
TypeScript
16 lines
479 B
TypeScript
import { safeStorage } from 'electron'
|
|
|
|
export function encrypt(text: string): string {
|
|
if (!safeStorage.isEncryptionAvailable()) {
|
|
return Buffer.from(text).toString('base64')
|
|
}
|
|
return safeStorage.encryptString(text).toString('base64')
|
|
}
|
|
|
|
export function decrypt(encoded: string): string {
|
|
if (!safeStorage.isEncryptionAvailable()) {
|
|
return Buffer.from(encoded, 'base64').toString('utf-8')
|
|
}
|
|
return safeStorage.decryptString(Buffer.from(encoded, 'base64'))
|
|
}
|