Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
guyutongxue committed Aug 16, 2022
1 parent 78a028c commit bca3378
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
- 修复了 MSVC 的错误的问题匹配设置(`vscext` 分支)
- CLI 增加了日志路径选项

## v4.0.0-beta.11
*2022.8.16*
- Windows 下检测 WebView 2 安装

## v4.0.0-beta.10
*2022.8.14*
- 修复了点击“新手模式”在非 Windows 系统上导致的错误
Expand Down
38 changes: 37 additions & 1 deletion src-tauri/src/gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// along with vscch4. If not, see <http://www.gnu.org/licenses/>.

use anyhow::{anyhow, Result};
use log::{debug, info, trace};
use log::{debug, info, trace, warn};
use serde::Serialize;

use crate::steps::{
Expand All @@ -25,7 +25,43 @@ use crate::steps::{
use crate::tasks;
use crate::tasks::TaskInitArgs;

#[cfg(windows)]
fn has_webview2_installed() -> bool {
use crate::utils::winreg;
if let Some(v) = winreg::get(
winreg::HKEY_LOCAL_MACHINE,
r#"SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}"#,
"pv",
) {
if v != "" && v != "0.0.0.0" { return true; }
}
if let Some(v) = winreg::get(
winreg::HKEY_CURRENT_USER,
r#"Software\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}"#,
"pv",
) {
if v != "" && v != "0.0.0.0" { return true; }
}
return false;
}

pub fn gui() -> Result<()> {
#[cfg(windows)]
{
if !has_webview2_installed() {
debug!("WebView 2 未安装");
let download = native_dialog::MessageDialog::new()
.set_title("WebView 2 未安装")
.set_type(native_dialog::MessageType::Warning)
.set_text("您的系统可能尚未安装 WebView 2。这表明您可能无法正常运行图形界面。\n 点击“确认”以前往 WebView 2 下载页面,并退出程序;\n 点击“取消”以继续尝试运行本程序。")
.show_confirm()?;
if download {
open::that("https://go.microsoft.com/fwlink/p/?LinkId=2124703")?;
std::process::exit(1);
}
warn!("用户执意执行 GUI。");
}
}
debug!("即将启动 tauri GUI。");
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![
Expand Down
2 changes: 2 additions & 0 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ fn handle_error(e: Error) -> ! {
native_dialog::MessageDialog::new()
.set_title("程序已报告错误")
.set_text(&format!("{}\n您可以将代码 “{}” 发送至 guyutongxue@163.com,开发者会尽快帮您解决问题。\n(使用 --no-stats 选项以关闭此弹窗。)", e.to_string(), &id[0..6]))
.set_type(native_dialog::MessageType::Error)
.show_alert()
.unwrap();
}
Expand All @@ -40,6 +41,7 @@ fn handle_error(e: Error) -> ! {
native_dialog::MessageDialog::new()
.set_title("日志未就绪前出现错误")
.set_text(&format!("{:?}", e))
.set_type(native_dialog::MessageType::Error)
.show_alert()
.unwrap();
} else {
Expand Down
4 changes: 2 additions & 2 deletions src-tauri/src/steps/compiler/msvc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fn scan() -> Vec<Compiler> {
return vec![];
}
let vswhere = vswhere.unwrap();
debug!("vswhere.exe is {:?}", vswhere);
debug!("vswhere.exe 路径:{:?}", vswhere);

#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
Expand All @@ -111,7 +111,7 @@ fn scan() -> Vec<Compiler> {
// 受 https://github.com/microsoft/vswhere/issues/262 影响,某些 vswhere 可能存在编码错误
let s = String::from_utf8_lossy(&o.stdout)
.into_owned();
debug!("vswhere.exe output: {}", s);
debug!("vswhere.exe 输出:{}", s);
serde_json::from_str(&s).ok()
});
if list.is_none() {
Expand Down

0 comments on commit bca3378

Please sign in to comment.