mirror of
https://github.com/hicccc77/WeFlow.git
synced 2026-05-13 15:10:05 +00:00
This commit is contained in:
@@ -1,10 +1,23 @@
|
|||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { existsSync, readdirSync, statSync } from 'fs'
|
import { existsSync, readdirSync, statSync } from 'fs'
|
||||||
import { app, safeStorage } from 'electron'
|
|
||||||
import crypto from 'crypto'
|
import crypto from 'crypto'
|
||||||
import Store from 'electron-store'
|
import Store from 'electron-store'
|
||||||
import { expandHomePath } from '../utils/pathUtils'
|
import { expandHomePath } from '../utils/pathUtils'
|
||||||
|
|
||||||
|
// 条件导入 electron(Worker 环境中不可用)
|
||||||
|
let app: any = null
|
||||||
|
let safeStorage: any = null
|
||||||
|
const isWorkerThread = process.env.WEFLOW_WORKER === '1'
|
||||||
|
if (!isWorkerThread) {
|
||||||
|
try {
|
||||||
|
const electron = require('electron')
|
||||||
|
app = electron.app
|
||||||
|
safeStorage = electron.safeStorage
|
||||||
|
} catch {
|
||||||
|
// Worker 环境中 electron 不可用
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 加密前缀标记
|
// 加密前缀标记
|
||||||
const SAFE_PREFIX = 'safe:' // safeStorage 加密(普通模式)
|
const SAFE_PREFIX = 'safe:' // safeStorage 加密(普通模式)
|
||||||
const isSafeStorageAvailable = (): boolean => {
|
const isSafeStorageAvailable = (): boolean => {
|
||||||
|
|||||||
Reference in New Issue
Block a user