Files
msime-windows/server/src/utils/common_utils.h
T
Lu Fan(SonnyCalcr) 5aed0fcbf0 fix: 修复部分用户打不开设置页,WebView2 缺失时仍可正常打字 (#801)
* fix(installer): VC++ 运行库要求提到 14.40 并给出直接下载链接

服务端程序用 MSVC 14.40+ 编译并导入 msvcp140.dll,配上更旧的运行库,
std::mutex 首次加锁即访问冲突、进程无声闪退,设置页因此打不开;原先
14.20 的门槛放过了装着 2019 / 早期 2022 运行库的机器。

- 缺失与「已装但过旧」分开提示,并显示当前版本
- 「是」直接下载 VC++ x64 运行库与 WebView2 Evergreen Bootstrapper
- 更正 WebView2 缺失的影响:只有设置页需要它,默认 D2D 候选窗照常打字

* fix(server): WebView2 不可用时设置页给出提示,候选窗退回 D2D

- 设置进程不再忽略 WebView2 environment / controller 创建失败(运行时缺失
  时同步失败、回调不来,界面会一直停在启动画面),改为弹框说明原因、错误码
  与下载直链后退出
- ui_backend = webview2 而检测不到运行时时,本次进程改用 D2D 渲染,保证能
  正常打字;不改配置,装好运行时后下次启动自动恢复
- WebView2 下载地址统一为 Evergreen Bootstrapper 直链
2026-10-11 02:21:40 +08:00

30 lines
1.2 KiB
C++

#pragma once
#include <string>
#include <windows.h>
#include <vector>
void ShowErrorMessage(HWND, const std::wstring &);
std::string wstring_to_string(const std::wstring &);
std::wstring string_to_wstring(const std::string &);
void SendImeInputs(std::wstring words);
namespace CommonUtils
{
// Evergreen Bootstrapper 的官方直链,点开即下载安装器,用户不用在文档页里自己找。
inline constexpr wchar_t kWebView2RuntimeDownloadUrl[] = L"https://go.microsoft.com/fwlink/p/?LinkId=2124703";
std::wstring get_local_appdata_path_w();
std::wstring get_ime_data_path_w();
// Directory holding config.toml. Same as the data directory unless METASEQUOIA_IME_CONFIG_DIR
// redirects it (tests only).
std::wstring get_ime_config_dir_w();
void ensure_ime_data_writable();
// WebView2 cache lives under ProgramData so Medium-IL Edge children can write
// it whether the host is a normal user or elevated. Falls back to LocalAppData.
std::wstring get_webview2_user_data_path(const std::wstring &folder_name);
std::string get_local_appdata_path();
std::string get_ime_data_path();
std::string get_username();
std::vector<std::wstring> cvt_str_to_vector(std::wstring text);
} // namespace CommonUtils