Files
Lu Fan(SonnyCalcr) 1b875267db refactor: 移除 WebView2,界面只保留 Direct2D (#1013)
* refactor(engine): 语音独立工具改用原生托盘菜单,移除 WebView2

托盘菜单改用 Win32 弹出菜单,设置项改为用关联编辑器打开 config.toml,关于页改为消息框。删除 window_webview2 与两份 HTML 资源,windows-app 特性不再依赖 webview2 端口。

* refactor(server): 移除 WebView2,候选窗、工具栏、托盘菜单与设置窗口只保留 Direct2D

删除 src/webview2 与 webview_utils,小窗口的置顶、皮肤重载和工具栏状态缓存移到 window/small_windows,presenter 成为唯一路径,D2D 下的置顶时序与 cloak 行为保持不变。设置进程去掉 WebView2 宿主、鼠标转发与启动图,只构建原生窗口;旧快捷方式传入的 --d2d / --webview2 被忽略。删除 appearance.ui_backend 与 appearance.settings_ui_backend(读取、写入、设置页下拉框与两份配置模板),升级时由模板合并丢弃旧值。设置窗口的图片资源移到 server/assets/settings,安装到数据目录的 assets\settings。不再链接 WebView2Loader,vcpkg 去掉 webview2 端口。

* build(installer): 打包与 CI 不再处理 WebView2 页面和运行时

Prepare-PackageFiles 去掉 -UiHtmlDirectory 与 html 暂存,改为暂存 server/assets/settings;安装器不再检查 WebView2 Runtime、不再创建 ProgramData 下的 WebView2 用户数据目录,升级和卸载时清理旧版留下的 webview2 / webview2-settings 与数据目录里的 html。CI 删除设置页构建、契约同步检查和候选窗 DOM 测试,release 的打包任务不再依赖网页产物;dependabot 去掉 npm。第三方声明去掉 WebView2Loader。

* refactor(ui-html): 删除 WebView2 页面与设置页前端工程

候选窗、工具栏、托盘菜单、设置页、主题和契约副本都已没有使用者;设置窗口用到的图片资源已移到 server/assets/settings。sync-contracts.py 与 pnpm/Vite/TypeScript 工程一并删除,契约仍以 engine/contracts/webview 为唯一来源。

* docs(server): 文档改为只描述 Direct2D 界面

仓库地图去掉 ui-html,组件边界、uiAccess 与置顶时序、设置窗口和配置读写的说明改写为 Direct2D 唯一界面;安装说明去掉 WebView2 Runtime 检查,打包命令去掉 -UiHtmlDirectory;engine/contracts/webview 的说明改为设置窗口是唯一使用者,名字是历史遗留。

* docs(skins): 皮肤说明不再区分 WebView2 与 D2D 渲染器

v2 字段去掉「仅 WebView2」,改为说明由 Direct2D 原生渲染、部分字段仍在补全;颜色必须带 # 改为清单格式约定。随包的 skins/niya-demo/skin.toml 不改,免得用户机器上的同名皮肤在升级时被当成已修改而改名备份。

* docs(ui): demo 说明文字不再提 WebView2
2026-10-17 02:48:02 +08:00

105 lines
4.0 KiB
Python

import json
import os
def normpath(path):
return path.replace("\\", "/")
local_app_data_dir = os.environ.get("LOCALAPPDATA")
home_dir = os.path.expanduser("~")
cur_file_path = os.path.dirname(os.path.abspath(__file__))
project_root_path = os.path.dirname(cur_file_path)
user_home = os.path.expanduser("~")
# vcpkg location. Prefer the VCPKG_ROOT environment variable so that installs
# outside Scoop work as well; fall back to the historical Scoop path.
vcpkg_root = normpath(
os.environ.get("VCPKG_ROOT") or os.path.join(user_home, "scoop", "apps", "vcpkg", "current")
).rstrip("/")
MetasequoiaImeTsf_root_path = normpath(project_root_path)
MetasequoiaImeTsf_src_path = normpath(os.path.join(MetasequoiaImeTsf_root_path, "src"))
vcpkg_include_path = normpath(
os.path.join(
MetasequoiaImeTsf_root_path,
"build",
"vcpkg_installed",
"x64-windows-static",
"include",
)
)
utfcpp_path = normpath(os.path.join(project_root_path, "..", "engine", "utfcpp", "source"))
wim_path = normpath(
os.path.join(
user_home,
".nuget",
"packages",
"microsoft.windows.implementationlibrary",
"1.0.240803.1",
"include",
)
)
#
# project_root/.clangd
#
dot_clangd_file = os.path.join(
MetasequoiaImeTsf_root_path, "scripts", "config_files", ".clangd"
)
dot_clangd_output_file = os.path.join(MetasequoiaImeTsf_root_path, ".clangd")
with open(dot_clangd_file, "r", encoding="utf-8") as f:
lines = f.readlines()
lines[8] = f' "-I{MetasequoiaImeTsf_root_path}/src",\n'
lines[9] = f' "-I{MetasequoiaImeTsf_root_path}/src/Candidate",\n'
lines[10] = f' "-I{MetasequoiaImeTsf_root_path}/src/Compartment",\n'
lines[11] = f' "-I{MetasequoiaImeTsf_root_path}/src/Composition",\n'
lines[12] = f' "-I{MetasequoiaImeTsf_root_path}/src/DictEngine",\n'
lines[13] = f' "-I{MetasequoiaImeTsf_root_path}/src/DisplayAttribute",\n'
lines[14] = f' "-I{MetasequoiaImeTsf_root_path}/src/Drawing",\n'
lines[15] = f' "-I{MetasequoiaImeTsf_root_path}/src/Edit",\n'
lines[16] = f' "-I{MetasequoiaImeTsf_root_path}/src/FanyLog",\n'
lines[17] = f' "-I{MetasequoiaImeTsf_root_path}/src/File",\n'
lines[18] = f' "-I{MetasequoiaImeTsf_root_path}/src/Global",\n'
lines[19] = f' "-I{MetasequoiaImeTsf_root_path}/src/Header",\n'
lines[20] = f' "-I{MetasequoiaImeTsf_root_path}/src/IME",\n'
lines[21] = f' "-I{MetasequoiaImeTsf_root_path}/src/IPC",\n'
lines[22] = f' "-I{MetasequoiaImeTsf_root_path}/src/Key",\n'
lines[23] = f' "-I{MetasequoiaImeTsf_root_path}/src/LanguageBar",\n'
lines[24] = f' "-I{MetasequoiaImeTsf_root_path}/src/Register",\n'
lines[25] = f' "-I{MetasequoiaImeTsf_root_path}/src/Tf",\n'
lines[26] = f' "-I{MetasequoiaImeTsf_root_path}/src/Thread",\n'
lines[27] = f' "-I{MetasequoiaImeTsf_root_path}/src/UI",\n'
lines[28] = f' "-I{MetasequoiaImeTsf_root_path}/src/Utils",\n'
lines[29] = f' "-I{MetasequoiaImeTsf_root_path}/src/Window",\n'
# utfcpp
lines[31] = f' "-I{utfcpp_path}",\n'
# vcpkg
lines[33] = (
f' "-I{MetasequoiaImeTsf_root_path}/build64/vcpkg_installed/x64-windows-static/include",\n'
)
lines[34] = (
f' "-I{MetasequoiaImeTsf_root_path}/build32/vcpkg_installed/x86-windows-static/include",\n'
)
with open(dot_clangd_output_file, "w", encoding="utf-8") as f:
f.writelines(lines)
#
# CMakePresets.json
#
# Preserve tracked presets and user-added fields; only resolve the local toolchain.
presets_path = os.path.join(project_root_path, "CMakePresets.json")
with open(presets_path, encoding="utf-8") as stream:
presets = json.load(stream)
for preset in presets.get("configurePresets", []):
if "VCPKG_ROOT" in preset.get("environment", {}):
preset["environment"]["VCPKG_ROOT"] = vcpkg_root + "/"
if "CMAKE_TOOLCHAIN_FILE" in preset.get("cacheVariables", {}):
preset["cacheVariables"]["CMAKE_TOOLCHAIN_FILE"] = vcpkg_root + "/scripts/buildsystems/vcpkg.cmake"
with open(presets_path, "w", encoding="utf-8") as stream:
json.dump(presets, stream, indent=2)
stream.write("\n")