功能: 添加服务器版本管理器(下载/更新/降级 Factorio 服务端)#443
Open
BAYUNZIYUE wants to merge 113 commits into
Open
Conversation
- mod_portal.go: 发布版兼容性从 Compatible(>=) 改为 GEC() 修复 2.1 服务器错误标为兼容的 portal 发布版 - mod_Mods.go: DepOp 从硬编码 >= 改为传递 modInfo.DepOp
- mod_portal_handler.go: Mod not found 时返回 404 + JSON - Mod.jsx: portal.info 失败时 try/catch 静默跳过更新检查
来源: joey00797-cell/factorio-server-manager develop (93a92ea) 合并内容: - mod_sync.go: 从存档自动同步模组 (level.dat0 解析 + 门户下载) - i18n: i18next 框架 (EN/RU) + 新增 zh-CN 翻译 - DLC 分组: ModList 中 elevated-rails/quality/space-age 聚合行 - DLC 模组显示: 从 mod-list.json 读取无 zip 的 DLC 模组 - LoadMods.jsx 重写: checkbox 选择同步 + WebSocket 进度 - ChangeLangDialog: 语言切换对话框 - 路由: GetModsFromSave / SyncModsFromSave 保留我们的: - save.go: readFromV2 完整 2.0 解析器 (跳过 Joey 的 +12 字节补丁) - Controls.jsx: 完整版本管理器 (跳过 Joey 的简易安装面板) - mod_sync.go DownloadMod 适配: nil progress callback
- common 命名空间: signIn/username/password 等登录页翻译 - i18n.js: ns 配置 + zh-CN 资源 - zh.json: 67 个顶层键 + 嵌套翻译 (完整镜像 en.json) - ChangeLangDialog: 添加简体中文按钮 - zh-common.json: 独立 common 命名空间翻译
合并后 Joey 的组件使用独立命名空间 (controls/console/logs/mods/saves/ serverSettings/serverVersion/userManagement/layout) 但 i18n.js 只注册了 translation/common 两个,导致页面显示原始键名。 - 创建 9 个 zh-*.json 命名空间翻译文件 - i18n.js 注册全部 ns + 加载对应资源 - 补全大小写键名 (STOPPED/RUNNING/serverStatus 等)
- Layout.jsx: 恢复 FSM 管理区的刷新模组按钮 (fsm_refresh_mods) - Mods.jsx: 移除 LoadMods 中未使用的共享 auth 属性 (Joey 版本自管 auth) - zh-layout.json / en.json: 添加 refresh 翻译键
- zh-layout.json: 12 keys (main_title, logout, refresh...) - zh-controls.json: 22 keys (RUNNING, STOPPED, saveStopServer...) - zh-console.json: 6 keys - zh-logs.json: 4 keys - zh-mods.json: 49 keys (confirmDeleteAllMods, loadingModList...) - zh-saves.json: 16 keys (createSave, uploadSave...) - zh-serverSettings.json: 32 keys (showTranslation, hideTranslation...) - zh-serverVersion.json: 24 keys (installSuccess, upToDate, fetchFailed...) - zh-userManagement.json: 24 keys (changePassword, passwordMismatch...) - zh.json: 新增 refresh 键 - en.json: 补全 Layout.jsx 引用的嵌套键
根因: Mod 组件 useEffect([mod]) 每次轮询都重新检查更新,导致 153 个 portal.info() 并发请求 + addUpdatableMod 连锁状态更新 → React 组件树崩溃 → 黑屏。 - Mod.jsx: portal.info 仅首次挂载检查一次 (checked flag) - Mods.jsx: addUpdatableMod 去重,避免重复添加触发多余渲染
根因: portal API 404 返回 {message:...} 对象,axios 拦截器将其传入
window.flash(),Flash 组件渲染 Object → React error OpenFactorioServerManager#31 → 全局黑屏。
- 404 响应静默跳过(portal 模组不存在是预期行为)
- 对象响应安全转为字符串(message 字段或 JSON.stringify)
- 仅非预期错误触发 flash 提示
- CHANGELOG: 新增 v0.12.0 条目,记录 50+ 项变更 (Added/Changed/Fixed/Removed) - ROADMAP: 标记已完成项 (版本管理器/2.1兼容/i18n中文/并发下载/存档解析...)
合并后 Joey 的 LoadMods 自管 isFactorioAuthenticated 状态, 每次切换标签都重查 API,导致加载存档标签重复要求登录。 改为接收父组件共享的认证状态,与 AddMod 标签保持一致。
合并 Joey develop 后 LoadMods 自管认证状态覆盖了我们的共享模式。 PR 提交时需向 Joey 说明此设计决策。
- ModList.jsx: 表头使用 t() 调用 + 新增文件大小列 - LoadMods.jsx: STATUS_TEXT/按钮/标签/错误信息全部 t() 调用 - zh-mods.json: +24 翻译键 (File Size/readModsFromSave/selectMissing...)
前因: 合并 Joey develop 时整文件覆盖导致大面积退化(丢失文件大小列、 表头翻译、共享认证、进度条等 10+ 功能)。 ModList.jsx — 我们基础 + 合并: ✅ 文件大小列 (我们的) ✅ t() 表头翻译 (我们的) ✅ DLC 分组行 (Joey) ✅ mod.name 作 key (修复索引 key 反模式) LoadMods.jsx — 我们基础 + 合并: ✅ 共享认证状态 (我们的,接收父组件 props) ✅ mod_sync.go 存档解析 + 选择性同步 (Joey) ✅ WebSocket 进度监听 (Joey) ✅ t() 全部翻译 (我们的) ✅ STATUS_ICON 图标映射 (Joey) ✅ checkbox + selectMissing/clearAll (Joey)
- Console.jsx: 固定高度日志区 (overflow-y:scroll) + 底部RCON输入 - 新增 auto-scroll 跟随最新日志 - 侧边栏移除单独日志链接(功能已在终端内) - zh: 控制台→终端,placeholder 提示输入指令 安全: 纯RCON通道,未引入任何shell/PTY,权限与之前完全一致
- handlers.go: 服务器停止时读 factorio-previous.log 替代 current - gamelog.go: 抽取 TailLogFile(path) 支持指定日志文件 - Console.jsx: 加载时先 GET /api/log/tail 获取历史日志 开服后 WebSocket 流实时追加,关服显示历史 + 禁用 RCON
- 字体: 小(12px)/中(14px)/大(16px) 三档切换 - 换行: 自动换行 / 横向滚动,长日志行不再截断 - 偏好保存到 localStorage,刷新不丢失
- Console.jsx: 宽度三档(窄/中/宽) + localStorage 记忆 - Console.jsx: 控制栏换行/宽度在小屏幕隐藏,移动端不挤压 - Console.jsx: 100dvh 适配移动浏览器地址栏收起 - Layout.jsx: container→w-full 全页面放宽,Panel 自身控宽
- max-w-4xl 等 Tailwind class 在生产构建中被 purged
- 改用 style={{maxWidth}} inline 确保生效
- mod_modInfo.go: dep_op 和 FactorioVersion 始终从 base 依赖提取 不再因 incompatible 而跳过(显示需求 ≠ 兼容性判断) - mod_Mods.go: 传递 Dependencies 到 API 响应 - Mod.jsx: 模组名旁显示依赖数量 [▶ 5],点击展开完整列表 跳过 optional/? 前缀依赖,最多显示前 10 条
兼容性 → 启用 → 名称 → 版本 → Factorio版本 → 文件大小 → 删除 先看状态再看名称,符合快速过滤场景
- 点击列头排序 (兼容性/启用/名称/版本/文件大小) - 升序↓降序↑图标指示 - 齿轮菜单切换列显示 - 列偏好保存到 localStorage - 排序用 useMemo 优化性能
- 每列右边缘 hover 蓝色触控区,拖拽调整宽度 - 宽度持久化 localStorage - 分割线: border-gray (列间竖线) + border-b-2 (表头底线)
- sort 相等时回退 name→version 二级排序,避免不稳定排序产生重复 - key 改为 file_name 避免同名 mod 键冲突
- isBusy 状态来自父组件,同步中/删除中/更新中任一为真 - isBusy 状态下禁用全部模组操作(安装/上传/同步/删除/切换) - 开服状态下仍独立阻止模组操作 - LoadMods 同步状态传递到父组件级联锁
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
为 FSM 添加完整的 Factorio 服务端版本管理功能,支持从官方 API 下载、安装、切换 Factorio 版本。
功能
技术实现
src/factorio/version_manager.gosrc/factorio/version_status.gosrc/api/version_handler.gosrc/api/routes.goui/App/views/ServerVersion.jsxui/api/resources/server.jsui/locales/