feat(app): GUI 全量接线,五页改吃 core 真实数据(M43)
app 从「mock 骨架」切到「真实 core host」:新增 src/host 装配层(env/job/ game/launch/identity/versions/install/meter/java/accounts/logs/settings/engine/ dispatch),是 app 里除 settings_bridge 外唯一 use unlucky_core 的地方,出口只有 crate::dto 的 DTO/事件(三通道纪律,AGENTS §6)。 页面接线: - 实例页:profiles+版本 JSON 继承链+会话索引 → 磁贴(真实版本/加载器徽标/最后启动/ 隔离档位/载荷缺失);启动按钮走 LaunchRequest 装配 → Launcher::spawn → JSONL 尾随 → 运行/失败回写;M30 ModeChangeWarning 进横幅通知条。 - 新建实例向导:版本 → 加载器 → 名字 → 确认 → 真实安装进度;Fabric/Quilt 可装, Forge/NeoForge 因需要 installer processors(仅 CLI 有)显式拒装并给出 CLI 命令。 - 下载页:远端 manifest(12h 缓存)+ 内嵌 unlisted → 分类(正式/预览/远古四子类); 安装进度(文件数/字节/速度/ETA,速度由相邻采样差分)+ 阶段边界可取消; Java 分组:四家发行版 + 回退链可视化(计划链/真实 ChainLog)+ 本地运行时。 - 账户页:三轨账户列表(只读公开字段)+ 离线新增 + 删除/切换 + 微软设备码登录 (用户码/链接/轮询状态;取消后丢弃结果)。凭据只在 host/identity 与 host/accounts 出现,DTO 无 token 字段(单测钉住)。 - 设置页:新增 download/java/data/ai/mcp 五组,行由 core::setting schema 键生成, 写回走 SettingStore::set(与 ull config set / AI set_config 同源 launcher.json)。 - 日志页:会话索引 → 列表;事件 JSONL → 日志行(等级高亮)+ D8 规则引擎诊断卡片; 启动中实时尾随(600ms/拍,只读新增字节);崩溃日志导入分析(hs_err/crash/latest)。 架构与守线: - 新页面状态走 ui/page_state.slint 的 PageState global(main.slint 再导出), Rust 侧 page_sync.rs 灌入、callbacks_pages.rs 接线;避免属性逐层转发顶破 400 行。 - DTO 全部 Serialize+Deserialize(IPC 契约),新增 accounts/java/settings/install/ notices 五个子模块;事件扩展 LogAppended/LaunchFinished/AccountsChanged/ DeviceLoginChanged/JavaChanged/InstallProgress/SettingsChanged/NoticesChanged。 - 截图通道扩展:--data-dir(钉数据根且 settings 同源)/--mock/--screenshot-page/ --screenshot-wizard/--screenshot-session/--screenshot-install/--screenshot-launch (真实中间态,取图后自动 stop 防孤儿进程)。 已知边界:GUI 账户「当前启动账户」仅内存态(core schema 无 auth.* 键,app 不自建键); Forge/NeoForge GUI 安装待 processors 执行器上移。
This commit is contained in:
1 parent
bc41dfcf7d
commit
ddc0577f83
64 files changed
+8047
-408
No files matched your search
@@ -0,0 +1,256 @@
|
||||
//! `PageState` global 的回调接线:账户 / Java / 设置 / 通知 / 向导 / 崩溃导入 / 日志刷新。
|
||||
//!
|
||||
//! 与 `callbacks.rs` 同一纪律:每个回调 = 「改状态 + 发 AppCommand + 同步 UI」,一处看全。
|
||||
//! 用 global 而不是逐层转发属性(见 `ui/page_state.slint` 顶部的取舍说明)。
|
||||
|
||||
use std::rc::Weak;
|
||||
|
||||
use slint::ComponentHandle;
|
||||
|
||||
use crate::conv;
|
||||
use crate::dto::{AppCommand, CreateRequest, LoaderKind};
|
||||
use crate::ui_bind::Inner;
|
||||
|
||||
/// 接全部页面状态回调。
|
||||
pub(crate) fn wire_pages(weak: Weak<Inner>) {
|
||||
let Some(inner) = weak.upgrade() else { return };
|
||||
let page = inner.ui.global::<crate::PageState<'_>>();
|
||||
|
||||
// ── 账户 ──────────────────────────────────────────────────
|
||||
{
|
||||
let weak = weak.clone();
|
||||
page.on_account_add_offline(move |name| {
|
||||
let name = name.to_string();
|
||||
if name.trim().is_empty() {
|
||||
return;
|
||||
}
|
||||
let Some(this) = weak.upgrade() else { return };
|
||||
this.dispatch(AppCommand::AddOfflineAccount(name));
|
||||
this.ui
|
||||
.global::<crate::PageState<'_>>()
|
||||
.set_offline_name("".into());
|
||||
this.sync();
|
||||
});
|
||||
}
|
||||
{
|
||||
let weak = weak.clone();
|
||||
page.on_account_remove(move |id| {
|
||||
let Some(this) = weak.upgrade() else { return };
|
||||
this.dispatch(AppCommand::RemoveAccount(id.to_string()));
|
||||
this.sync();
|
||||
});
|
||||
}
|
||||
{
|
||||
let weak = weak.clone();
|
||||
page.on_account_switch(move |id| {
|
||||
let Some(this) = weak.upgrade() else { return };
|
||||
this.dispatch(AppCommand::SwitchAccount(id.to_string()));
|
||||
this.sync();
|
||||
});
|
||||
}
|
||||
{
|
||||
let weak = weak.clone();
|
||||
page.on_msa_begin(move || {
|
||||
let Some(this) = weak.upgrade() else { return };
|
||||
this.dispatch(AppCommand::StartDeviceLogin);
|
||||
this.sync();
|
||||
});
|
||||
}
|
||||
{
|
||||
let weak = weak.clone();
|
||||
page.on_msa_cancel(move || {
|
||||
let Some(this) = weak.upgrade() else { return };
|
||||
this.dispatch(AppCommand::CancelDeviceLogin);
|
||||
this.sync();
|
||||
});
|
||||
}
|
||||
|
||||
// ── Java ──────────────────────────────────────────────────
|
||||
{
|
||||
let weak = weak.clone();
|
||||
page.on_java_install(move |vendor| {
|
||||
let Some(this) = weak.upgrade() else { return };
|
||||
this.dispatch(AppCommand::InstallJava(vendor.to_string()));
|
||||
this.sync();
|
||||
});
|
||||
}
|
||||
|
||||
// ── 设置 ──────────────────────────────────────────────────
|
||||
{
|
||||
let weak = weak.clone();
|
||||
page.on_setting_changed(move |key, value| {
|
||||
let Some(this) = weak.upgrade() else { return };
|
||||
this.dispatch(AppCommand::SetSetting {
|
||||
key: key.to_string(),
|
||||
value: value.to_string(),
|
||||
});
|
||||
this.sync();
|
||||
});
|
||||
}
|
||||
{
|
||||
let weak = weak.clone();
|
||||
page.on_setting_action(move |action| {
|
||||
let Some(this) = weak.upgrade() else { return };
|
||||
let action = action.to_string();
|
||||
match action.as_str() {
|
||||
// 清 24h 地区缓存 → 下次下载重新判定
|
||||
"detect_region" => this.dispatch(AppCommand::SetSetting {
|
||||
key: "download.action.detect_region".to_string(),
|
||||
value: String::new(),
|
||||
}),
|
||||
// Java 分组的「安装/管理」→ 按回退链装一个托管 JDK
|
||||
"install_java" => this.dispatch(AppCommand::InstallJava(String::new())),
|
||||
_ => {}
|
||||
}
|
||||
this.sync();
|
||||
});
|
||||
}
|
||||
{
|
||||
let weak = weak.clone();
|
||||
page.on_settings_tab_changed(move |tab| {
|
||||
let Some(this) = weak.upgrade() else { return };
|
||||
this.state.borrow_mut().settings_tab = tab.to_string();
|
||||
this.sync();
|
||||
});
|
||||
}
|
||||
|
||||
// ── 通知 ──────────────────────────────────────────────────
|
||||
{
|
||||
let weak = weak.clone();
|
||||
page.on_notice_dismiss(move |id| {
|
||||
let Some(this) = weak.upgrade() else { return };
|
||||
this.dispatch(AppCommand::DismissNotice(id.to_string()));
|
||||
this.sync();
|
||||
});
|
||||
}
|
||||
|
||||
// ── 向导 ──────────────────────────────────────────────────
|
||||
{
|
||||
let weak = weak.clone();
|
||||
page.on_wizard_open(move || {
|
||||
let Some(this) = weak.upgrade() else { return };
|
||||
this.state.borrow_mut().wizard = crate::wizard::WizardState::open();
|
||||
this.sync();
|
||||
});
|
||||
}
|
||||
{
|
||||
let weak = weak.clone();
|
||||
page.on_wizard_close(move || {
|
||||
let Some(this) = weak.upgrade() else { return };
|
||||
this.state.borrow_mut().wizard.open = false;
|
||||
this.sync();
|
||||
});
|
||||
}
|
||||
{
|
||||
let weak = weak.clone();
|
||||
page.on_wizard_select_version(move |version| {
|
||||
let Some(this) = weak.upgrade() else { return };
|
||||
this.state
|
||||
.borrow_mut()
|
||||
.wizard
|
||||
.select_version(version.as_ref());
|
||||
this.sync();
|
||||
});
|
||||
}
|
||||
{
|
||||
let weak = weak.clone();
|
||||
page.on_wizard_select_loader(move |index| {
|
||||
let Some(this) = weak.upgrade() else { return };
|
||||
let loader = match index {
|
||||
1 => LoaderKind::Fabric,
|
||||
2 => LoaderKind::Quilt,
|
||||
3 => LoaderKind::Forge,
|
||||
4 => LoaderKind::NeoForge,
|
||||
_ => LoaderKind::Vanilla,
|
||||
};
|
||||
this.state.borrow_mut().wizard.select_loader(loader);
|
||||
this.sync();
|
||||
});
|
||||
}
|
||||
{
|
||||
let weak = weak.clone();
|
||||
page.on_wizard_name_changed(move |name| {
|
||||
let Some(this) = weak.upgrade() else { return };
|
||||
let mut state = this.state.borrow_mut();
|
||||
state.wizard.name = name.to_string();
|
||||
state.wizard.error.clear();
|
||||
drop(state);
|
||||
this.sync();
|
||||
});
|
||||
}
|
||||
{
|
||||
let weak = weak.clone();
|
||||
page.on_wizard_next(move || {
|
||||
let Some(this) = weak.upgrade() else { return };
|
||||
this.state.borrow_mut().wizard.advance();
|
||||
this.sync();
|
||||
});
|
||||
}
|
||||
{
|
||||
let weak = weak.clone();
|
||||
page.on_wizard_back(move || {
|
||||
let Some(this) = weak.upgrade() else { return };
|
||||
this.state.borrow_mut().wizard.step_back();
|
||||
this.sync();
|
||||
});
|
||||
}
|
||||
{
|
||||
let weak = weak.clone();
|
||||
page.on_wizard_confirm(move || {
|
||||
let Some(this) = weak.upgrade() else { return };
|
||||
let request = {
|
||||
let state = this.state.borrow();
|
||||
let wizard = &state.wizard;
|
||||
wizard.ready_to_submit().map(|()| CreateRequest {
|
||||
version: wizard.version.trim().to_string(),
|
||||
loader: wizard.loader,
|
||||
loader_version: wizard.loader_version.trim().to_string(),
|
||||
name: wizard.name.trim().to_string(),
|
||||
})
|
||||
};
|
||||
match request {
|
||||
Ok(request) => {
|
||||
this.dispatch(AppCommand::CreateInstance(request));
|
||||
this.state.borrow_mut().wizard.submitted();
|
||||
}
|
||||
Err(error) => {
|
||||
this.state.borrow_mut().wizard.error = error;
|
||||
}
|
||||
}
|
||||
this.sync();
|
||||
});
|
||||
}
|
||||
{
|
||||
let weak = weak.clone();
|
||||
page.on_install_cancel(move || {
|
||||
let Some(this) = weak.upgrade() else { return };
|
||||
this.dispatch(AppCommand::CancelInstall);
|
||||
this.sync();
|
||||
});
|
||||
}
|
||||
|
||||
// ── 日志页 ────────────────────────────────────────────────
|
||||
{
|
||||
let weak = weak.clone();
|
||||
page.on_crash_import(move |path| {
|
||||
let Some(this) = weak.upgrade() else { return };
|
||||
let path = path.to_string();
|
||||
if path.trim().is_empty() {
|
||||
return;
|
||||
}
|
||||
this.dispatch(AppCommand::ImportCrashLog(path));
|
||||
this.sync();
|
||||
});
|
||||
}
|
||||
{
|
||||
let weak = weak.clone();
|
||||
page.on_logs_refresh(move || {
|
||||
let Some(this) = weak.upgrade() else { return };
|
||||
this.dispatch(AppCommand::RefreshLogSessions);
|
||||
this.sync();
|
||||
});
|
||||
}
|
||||
|
||||
// 设置页分组切换同时刷新一遍分组快照(外部改配置后手点分组即最新)
|
||||
let _ = conv::setting_groups;
|
||||
}
|
||||
Reference in new issue
Block a user