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 执行器上移。
118 lines
4.1 KiB
Plaintext
118 lines
4.1 KiB
Plaintext
// 设置页右栏的「schema 分组」渲染器:下载 / Java / 数据 / AI / MCP 五组。
|
||
//
|
||
// 行来自 Rust 侧的 `SettingGroupView`(core::setting schema 的键),这里只按控件类型画:
|
||
// 开关 → toggle;分段 → segmented;文本 → text;只读 → 纯文案;动作 → 按钮。
|
||
// 写回一律 `PageState.setting-changed(key, value)` / `setting-action(action)`,
|
||
// 由 host 走 `SettingStore::set`(同源 launcher.json)。
|
||
import { Theme } from "../theme/tokens.slint";
|
||
import { Metrics } from "../theme/metrics.slint";
|
||
import { UiSettingGroup, UiSettingRow, SettingControl } from "../models.slint";
|
||
import { PageState } from "../page_state.slint";
|
||
import { UiText, TextRole } from "../components/label.slint";
|
||
import { SettingItem, SettingGroup, ControlKind } from "../widgets/setting-item.slint";
|
||
|
||
component RowView inherits Rectangle {
|
||
in property <UiSettingRow> item;
|
||
/// 文本编辑的本地缓冲(编辑中不回写模型,失焦/回车才提交)
|
||
in-out property <string> draft;
|
||
|
||
height: root.item.control == SettingControl.readonly ? 48px
|
||
: root.item.description == "" ? 44px : 58px;
|
||
background: transparent;
|
||
|
||
init => { self.draft = root.item.value_text; }
|
||
changed item => { self.draft = root.item.value_text; }
|
||
|
||
if root.item.control == SettingControl.toggle : SettingItem {
|
||
label: root.item.label;
|
||
description: root.item.description;
|
||
kind: ControlKind.toggle;
|
||
checked: root.item.flag;
|
||
toggled(v) => { PageState.setting-changed(root.item.key, v ? "true" : "false"); }
|
||
}
|
||
|
||
if root.item.control == SettingControl.choice : SettingItem {
|
||
label: root.item.label;
|
||
description: root.item.description;
|
||
kind: ControlKind.segmented;
|
||
options: root.item.options;
|
||
selected: root.item.selected;
|
||
changed(i) => {
|
||
if (i >= 0 && i < root.item.options.length) {
|
||
PageState.setting-changed(root.item.key, root.item.options[i]);
|
||
}
|
||
}
|
||
}
|
||
|
||
if root.item.control == SettingControl.text : SettingItem {
|
||
label: root.item.label;
|
||
description: root.item.description;
|
||
kind: ControlKind.text;
|
||
value: root.draft;
|
||
edited(t) => {
|
||
root.draft = t;
|
||
PageState.setting-changed(root.item.key, t);
|
||
}
|
||
}
|
||
|
||
if root.item.control == SettingControl.action : SettingItem {
|
||
label: root.item.label;
|
||
description: root.item.description;
|
||
kind: ControlKind.button;
|
||
button-text: "执行";
|
||
clicked => { PageState.setting-action(root.item.action); }
|
||
}
|
||
|
||
if root.item.control == SettingControl.readonly : HorizontalLayout {
|
||
padding-left: Metrics.gap-4;
|
||
padding-right: Metrics.gap-4;
|
||
spacing: Metrics.gap-3;
|
||
|
||
UiText {
|
||
role: TextRole.body;
|
||
text: root.item.label;
|
||
width: 200px;
|
||
}
|
||
UiText {
|
||
role: TextRole.caption;
|
||
text: root.item.description;
|
||
horizontal-stretch: 1;
|
||
wrap: word-wrap;
|
||
}
|
||
}
|
||
}
|
||
|
||
export component SettingsGroups inherits Rectangle {
|
||
in property <string> tab: "";
|
||
|
||
background: transparent;
|
||
|
||
VerticalLayout {
|
||
padding-bottom: Metrics.gap-5;
|
||
|
||
if PageState.setting-groups.length == 0 : Rectangle {
|
||
height: 120px;
|
||
VerticalLayout {
|
||
alignment: center;
|
||
spacing: 2px;
|
||
UiText {
|
||
role: TextRole.caption;
|
||
text: "设置还没加载出来(host 未就绪或数据根不可写)";
|
||
horizontal-alignment: center;
|
||
}
|
||
}
|
||
}
|
||
|
||
for group in PageState.setting-groups : Rectangle {
|
||
visible: group.id == root.tab;
|
||
height: group.rows.length * 58px + 40px;
|
||
background: transparent;
|
||
|
||
VerticalLayout {
|
||
SettingGroup { title: group.title; }
|
||
for setting-row in group.rows : RowView { item: setting-row; }
|
||
}
|
||
}
|
||
}
|
||
}
|