mirror of
https://github.com/hicccc77/WeFlow.git
synced 2026-03-24 23:06:51 +00:00
feat: 一些适配
This commit is contained in:
@@ -246,15 +246,37 @@ export class WcdbCore {
|
||||
|
||||
// InitProtection (Added for security)
|
||||
try {
|
||||
this.wcdbInitProtection = this.lib.func('int32 InitProtection(const char* resourcePath)')
|
||||
const protectionCode = this.wcdbInitProtection(dllDir)
|
||||
if (protectionCode !== 0) {
|
||||
console.error('Core security check failed:', protectionCode)
|
||||
lastDllInitError = `初始化失败,错误码: ${protectionCode}`
|
||||
return false
|
||||
this.wcdbInitProtection = this.lib.func('bool InitProtection(const char* resourcePath)')
|
||||
|
||||
// 尝试多个可能的资源路径
|
||||
const resourcePaths = [
|
||||
dllDir, // DLL 所在目录
|
||||
dirname(dllDir), // 上级目录
|
||||
this.resourcesPath, // 配置的资源路径
|
||||
join(process.cwd(), 'resources') // 开发环境
|
||||
].filter(Boolean)
|
||||
|
||||
let protectionOk = false
|
||||
for (const resPath of resourcePaths) {
|
||||
try {
|
||||
console.log(`[WCDB] 尝试 InitProtection: ${resPath}`)
|
||||
protectionOk = this.wcdbInitProtection(resPath)
|
||||
if (protectionOk) {
|
||||
console.log(`[WCDB] InitProtection 成功: ${resPath}`)
|
||||
break
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(`[WCDB] InitProtection 失败 (${resPath}):`, e)
|
||||
}
|
||||
}
|
||||
|
||||
if (!protectionOk) {
|
||||
console.warn('[WCDB] Core security check failed - 继续运行但可能不稳定')
|
||||
this.writeLog('InitProtection 失败,继续运行')
|
||||
// 不返回 false,允许继续运行
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('InitProtection symbol not found or failed:', e)
|
||||
console.warn('InitProtection symbol not found:', e)
|
||||
}
|
||||
|
||||
// 定义类型
|
||||
@@ -1439,4 +1461,4 @@ export class WcdbCore {
|
||||
return { success: false, error: String(e) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user