fix(windows): 全量代码审查修复——中文乱码风险/Inno 兼容/ffi 布局自检/部署说明
系统性把 mac 踩过的坑逐一在 Windows 对应路径排查后修复四处: 1. runner 加 /utf-8 编译选项(高危):MSVC 默认按系统代码页(中文 Windows=GBK) 解析 UTF-8 源码,main.cpp 的 L"资安信插件助手" 窗口标题会乱码 2. installer.iss 的 x64compatible → x64:前者需 Inno 6.3+,旧版 iscc 直接报错 3. PavoApi 构造加结构体布局 assert(80/32/16/48 字节,对齐 C# 实机验证值), Windows 首跑(debug)即暴露 ffi 对齐差异 4. README 补 Windows 部署注意:VC++ Redistributable(PavoApiW_x64.dll 可能 动态依赖 vcruntime140.dll)、SmartScreen 未签名提示、Inno 6.x 要求 其余复查项确认无问题:reg 命令引号(空格路径安全)、Dart/Inno 的 Run 键名 一致(ZaxDesktopPlugin)、vendor DLL 拷贝用生成器表达式(Debug/Release 通用)、 pavo 全部 ffi 调用在 Isolate.run、scheme 注册表路径拼接、关窗拦截走 window_manager 的 WM_CLOSE 主路径(无 mac 的 _close: 私有 selector 问题)。
This commit is contained in:
1 parent
78d6b82305
commit
fb399ae8f6
4 files changed
+20
-2
No files matched your search
@@ -100,3 +100,10 @@ flutter build macos --release
|
||||
3. `dart run bin/agent.dart`(或直接跑 App)→ status 返回真机型号/固件/色带余量
|
||||
4. 提交测试卡真实出卡(tool/make_test_card.dart 生成后走 print 接口)
|
||||
5. 顺带实测:不装 HiTi 官方驱动能否直打(PavoApiW_x64 疑似用户态直连 USB)
|
||||
|
||||
### Windows 部署注意事项(代码审查结论,待实机验证)
|
||||
- **中文乱码已防**:runner 已加 `/utf-8` 编译选项(MSVC 默认按系统代码页解析 UTF-8 源码,中文窗口标题/资源会乱码);Runner.rc 用 `#pragma code_page(65001)`
|
||||
- **VC++ 运行库**:PavoApiW_x64.dll 若动态链接 VC runtime,缺 vcruntime140.dll 会加载失败(表现为"打印机未连接"或 DLL 加载异常)——装 [VC++ Redistributable 2015-2022](https://aka.ms/vs/17/release/vc_redist.x64.exe) 即可
|
||||
- **SmartScreen**:安装包未签名,首次运行会弹"Windows 已保护你的电脑"→ 更多信息 → 仍要运行
|
||||
- **ffi 布局自检**:PavoApi 构造时 assert 四个结构体 sizeof(80/32/16/48),首跑即暴露对齐差异(debug 模式生效)
|
||||
- **Inno 打包**:`iscc windows\installer.iss` 需 Inno Setup 6.x(x64 架构标记用全系兼容的 `x64`)
|
||||
@@ -19,6 +19,12 @@ class PavoApi {
|
||||
_getDeviceInfo =
|
||||
_tryGetDeviceInfo('PAVO_GetDeviceInfoW') ?? _tryGetDeviceInfo('PAVO_GetDeviceInfo')!;
|
||||
_printOneCard = _tryPrintOneCard('PAVO_PrintOneCardW') ?? _tryPrintOneCard('PAVO_PrintOneCard')!;
|
||||
// 布局自检:Dart Struct 按 C ABI 自然对齐,与 C# 版(已实机验证)的
|
||||
// sizeof 逐一核对;首个 Windows 环境首跑即暴露对齐差异
|
||||
assert(sizeOf<HitiCardPrintParameter>() == 80, 'HitiCardPrintParameter 布局异常');
|
||||
assert(sizeOf<GdiBitmap>() == 32, 'GdiBitmap 布局异常');
|
||||
assert(sizeOf<HitiHeatingEnergy>() == 16, 'HitiHeatingEnergy 布局异常');
|
||||
assert(sizeOf<HitiSettings>() == 48, 'HitiSettings 布局异常');
|
||||
}
|
||||
|
||||
static const String _dllName = 'PavoApiW_x64.dll';
|
||||
|
||||
@@ -17,8 +17,9 @@ DefaultGroupName={#AppName}
|
||||
UninstallDisplayIcon={app}\{#AppExeName}
|
||||
OutputDir=..\dist
|
||||
OutputBaseFilename=资安信插件助手-windows-setup
|
||||
ArchitecturesInstallIn64BitMode=x64compatible
|
||||
ArchitecturesAllowed=x64compatible
|
||||
; x64compatible 需 Inno 6.3+;x64 全系 6.x 兼容
|
||||
ArchitecturesInstallIn64BitMode=x64
|
||||
ArchitecturesAllowed=x64
|
||||
Compression=lzma2/max
|
||||
SolidCompression=yes
|
||||
WizardStyle=modern
|
||||
|
||||
@@ -30,6 +30,10 @@ target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTT
|
||||
# Disable Windows macros that collide with C++ standard library functions.
|
||||
target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
|
||||
|
||||
# 源文件为 UTF-8:MSVC 默认按系统代码页(中文系统 GBK)解析源码,
|
||||
# main.cpp 的中文宽字符串(窗口标题"资安信插件助手")会乱码,必须显式声明
|
||||
target_compile_options(${BINARY_NAME} PRIVATE "/utf-8")
|
||||
|
||||
# Add dependency libraries and include directories. Add any application-specific
|
||||
# dependencies here.
|
||||
target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
|
||||
|
||||
Reference in new issue
Block a user