feat: 一些适配

This commit is contained in:
Forrest
2026-01-29 21:25:36 +08:00
parent 26fbfd2c98
commit f3994a1a72
14 changed files with 1580 additions and 242 deletions

View File

@@ -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) }
}
}
}
}