新增avalonia-web前端子项目及WebView桥接支持
新增基于Vite+Vue3的avalonia-web前端子项目,包含完整工程结构、配置文件、静态资源和组件。完善.gitignore等忽略规则,并将前端项目集成进解决方案。增强MainWindow.axaml.cs中WebView脚本,支持自定义协议的XMLHttpRequest桥接,提升JS与C#通信能力。补充CHANGELOG及环境检测提示。
This commit is contained in:
@@ -32,10 +32,21 @@
|
||||
}
|
||||
};
|
||||
|
||||
const isWV2 = window.isWebView2 === true;
|
||||
setTimeout(() => {
|
||||
document.body.insertAdjacentHTML('beforeend', `<p>当前环境: ${isWV2 ? 'WebView2 (自定义协议)' : '普通浏览器 (HTTP API)'}</p>`);
|
||||
}, 100)
|
||||
const detectIsWebView2 = () => window.isWebView2 === true || typeof window.invokeCSharpAction === 'function';
|
||||
|
||||
const renderEnvironment = () => {
|
||||
const isWV2 = detectIsWebView2();
|
||||
const existing = document.getElementById('envTip');
|
||||
if (existing) {
|
||||
existing.textContent = `当前环境: ${isWV2 ? 'WebView2 (自定义协议)' : '普通浏览器 (HTTP API)'}`;
|
||||
return;
|
||||
}
|
||||
|
||||
document.body.insertAdjacentHTML('beforeend', `<p id="envTip">当前环境: ${isWV2 ? 'WebView2 (自定义协议)' : '普通浏览器 (HTTP API)'}</p>`);
|
||||
};
|
||||
|
||||
renderEnvironment();
|
||||
setTimeout(renderEnvironment, 300);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user