api修改和更新检查器修改
modrinth_api.dart:拦截器改为只替换 options.baseUrl,path 保持相对 /v2/search、query 留在 queryParameters,避免"整串写回 path"导致的 host 缺失 + query 重复拼接。mirror_service.dart:新增 apiBase getter,返回当前镜像的 API base(official→api.modrinth.com、mcim→modrinth-api.mcimirror.top、custom→自定义 base) Signed-off-by: driftinblock <3480428251@qq.com>
This commit is contained in:
35 files changed
+4171
-1325
No files matched your search
+188
-78
@@ -123,13 +123,14 @@ class S {
|
||||
// ---- 下载与镜像设置 ----
|
||||
'镜像线路': 'Mirror',
|
||||
'MCIM 国内镜像(推荐)': 'MCIM China mirror (recommended)',
|
||||
'modrinth.mcimirror.top,无需科学上网': 'modrinth.mcimirror.top, no VPN needed',
|
||||
'mod.mcimirror.top,无需科学上网': 'mod.mcimirror.top, no VPN needed',
|
||||
'Modrinth 官方': 'Modrinth official',
|
||||
'直连官方源,适合海外网络': 'Direct official source, best overseas',
|
||||
'自定义镜像': 'Custom mirror',
|
||||
'使用自建/第三方镜像地址': 'Use your own/third-party mirror URL',
|
||||
'一键测速并选择最快线路': 'Speed test & pick fastest',
|
||||
'自动在官方与镜像之间选择延迟最低的线路': 'Auto-pick lowest latency between official & mirrors',
|
||||
'自动在官方与镜像之间选择延迟最低的线路':
|
||||
'Auto-pick lowest latency between official & mirrors',
|
||||
'下载队列': 'Queue',
|
||||
'同时下载任务数': 'Concurrent downloads',
|
||||
'说明:下载完成的文件保存在应用目录 downloads/ 下;':
|
||||
@@ -152,7 +153,8 @@ class S {
|
||||
'下载与镜像设置': 'Download & mirror settings',
|
||||
'镜像线路、测速选线、同时下载任务数': 'Mirror, speed test, concurrent downloads',
|
||||
'使用教程': 'Tutorials',
|
||||
'如何开启 RCON / SSH、模组管理、下载与终端': 'How to enable RCON / SSH, mods, downloads & terminal',
|
||||
'如何开启 RCON / SSH、模组管理、下载与终端':
|
||||
'How to enable RCON / SSH, mods, downloads & terminal',
|
||||
'检查更新': 'Check updates',
|
||||
'关于': 'About',
|
||||
'开发者:Z有3笔,协作者:venti1112': 'Developer: Z有3笔, Collaborator: venti1112',
|
||||
@@ -190,7 +192,8 @@ class S {
|
||||
'该版本没有可用文件': 'No files for this version',
|
||||
'上次测速:{0}ms({1})': 'Last test: {0}ms ({1})',
|
||||
'已选择最快线路:{0}({1}ms)': 'Fastest route: {0} ({1}ms)',
|
||||
'当前:{0} 个(越大越占带宽,建议 1-3)': 'Now: {0} (more uses more bandwidth; 1-3 recommended)',
|
||||
'当前:{0} 个(越大越占带宽,建议 1-3)':
|
||||
'Now: {0} (more uses more bandwidth; 1-3 recommended)',
|
||||
'{0} 个版本共存': '{0} versions coexist',
|
||||
'同步失败:{0}': 'Sync failed: {0}',
|
||||
'当前版本: {0}': 'Current version: {0}',
|
||||
@@ -204,49 +207,85 @@ class S {
|
||||
'壁纸设置保存失败,请重试': 'Failed to save wallpaper settings, please retry',
|
||||
'背景已更新': 'Background updated',
|
||||
' rcon.password=你的RCON密码': ' rcon.password=your RCON password',
|
||||
'1. SSH 终端拥有服务器完全控制能力,您执行的任何命令(含删除文件、重启系统)后果由您自行承担。': '1. The SSH terminal grants full control of your server. You bear all consequences of any command you run (including deleting files or rebooting the system).',
|
||||
'1. 下载功能数据来自 Modrinth 公开接口及其镜像线路(如 MCIM)。镜像线路由第三方维护,其可用性与安全性不由开发者控制。': '1. Download data comes from the public Modrinth API and its mirrors (e.g. MCIM). Mirrors are maintained by third parties; the developer does not control their availability or safety.',
|
||||
'1. 仅管理您有权管理的服务器。严禁连接、探测、控制任何未获授权的第三方服务器——未经授权访问计算机系统属于违法行为。': '1. Only manage servers you are authorized to. Connecting to, probing or controlling any unauthorized third-party server is strictly prohibited — unauthorized access to computer systems is illegal.',
|
||||
'1. 本软件不收集、不上传您的任何个人数据,全部数据保存在设备本地,卸载即删除。': '1. This app does not collect or upload any personal data. All data is stored locally on your device and removed on uninstall.',
|
||||
'1. 本软件为免费开源软件,不提供商业担保。在法律允许的最大范围内,开发者不对因使用或无法使用本软件造成的任何直接或间接损失负责(包括数据丢失、服务器宕机、存档损坏、经济损失)。': '1. This software is free and open source, provided without commercial warranty. To the maximum extent permitted by law, the developer is not liable for any direct or indirect loss arising from use or inability to use (including data loss, server downtime, world corruption or financial loss).',
|
||||
'1. 本软件按开源协议发布,可依协议使用、修改和分发;"ZV Manager"名称与图标版权归作者所有。': '1. This software is released under an open source license and may be used, modified and distributed accordingly. The name and logo "ZV Manager" are copyrighted by the author.',
|
||||
'1. 连接凭据(RCON 密码、SSH 用户名/密码等)仅保存在您的设备本地(加密存储),本软件无云端账号系统,不会将凭据上传至开发者或任何第三方。': '1. Connection credentials (RCON password, SSH username/password, etc.) are stored only on your device (encrypted). This app has no cloud account system and never uploads credentials to the developer or any third party.',
|
||||
'2. Minecraft 是 Mojang Studios 的商标,本软件与 Mojang、微软无任何隶属关系。': '2. Minecraft is a trademark of Mojang Studios. This software is not affiliated with Mojang or Microsoft.',
|
||||
'2. 因第三方服务(Modrinth、镜像源、托管商、网络)变更或故障导致的异常,开发者不承担责任。': '2. The developer is not responsible for issues caused by changes or failures of third-party services (Modrinth, mirrors, hosting providers, networks).',
|
||||
'2. 应用仅联网检查更新(Gitee 发布页)及访问 Modrinth/镜像接口,无其他网络请求。': '2. The app only connects to the network to check updates (Gitee releases) and access the Modrinth/mirror APIs; there are no other network requests.',
|
||||
'2. 建议不要以 root 账户长期连接,执行不熟悉的命令前请先确认其作用。': '2. Avoid staying connected as root for long periods, and confirm what a command does before running unfamiliar ones.',
|
||||
'2. 第三方模组/插件可能影响服务器稳定性,安装前请备份重要数据;"依赖仓库"查询结果仅供参考。': '2. Third-party mods/plugins may affect server stability. Back up important data before installing; "Dependency Index" results are for reference only.',
|
||||
'2. 请妥善保管设备与凭据,因主动泄露、设备被他人使用、越狱/Root 等造成的损失由您自行承担。': '2. Keep your device and credentials safe. Losses caused by voluntary disclosure, unauthorized device use, jailbreak/Root, etc. are borne by you.',
|
||||
'2. 遵守《网络安全法》《计算机信息系统安全保护条例》等法律法规及 Minecraft EULA 与服务器规则。': '2. Comply with applicable laws and regulations (e.g. the Cybersecurity Law) as well as the Minecraft EULA and server rules.',
|
||||
'3. 不得利用本软件传播违法信息、破坏他人服务器、恶意攻击或盗取数据。': '3. Do not use this software to spread unlawful information, sabotage others\' servers, launch attacks or steal data.',
|
||||
'3. 仅连接您拥有管理权限的服务器,并使用强密码、定期更换。': '3. Only connect to servers you administer, using strong passwords changed regularly.',
|
||||
'3. 命令历史仅保存在设备本地,可在应用内清除,本软件不做任何云端记录。': '3. Command history is stored locally only, can be cleared in the app, and is never recorded in the cloud.',
|
||||
'4. 下载中心获取的模组/插件版权归原作者所有,请遵守对应开源协议,不得下载、分发盗版或破解内容。': '4. Mods/plugins obtained from the Download Center belong to their authors. Follow the corresponding licenses; pirated or cracked content must not be downloaded or distributed.',
|
||||
'Fabric 模组放 mods 目录;Paper/Spigot 插件放 plugins 目录': 'Fabric mods go in the mods directory; Paper/Spigot plugins go in the plugins directory',
|
||||
'Q:TPS 显示 —?→ 原版服务端不支持 tps 命令,Paper/Purpur 等服务端才支持': 'Q: TPS shows "—"? → Vanilla servers do not support the tps command; only Paper/Purpur and similar do',
|
||||
'Q:上传模组后不生效?→ 需要重启服务器': 'Q: Mod upload not taking effect? → Restart the server',
|
||||
'Q:控制台能连但模组页提示无 SSH?→ 编辑服务器开启 SSH 并填好账号密码': 'Q: Console connects but the mods page says no SSH? → Edit the server, enable SSH and fill in the credentials',
|
||||
'Q:连接失败?→ 检查防火墙是否放行端口、地址端口是否填对、服务器是否在线': 'Q: Connection failed? → Check firewall rules for the port, verify address/port, and confirm the server is online',
|
||||
'SSH 拥有服务器完全控制权,请勿随意执行不熟悉的命令': 'SSH grants full server control; do not run unfamiliar commands carelessly',
|
||||
'SSH 是服务器自带的远程管理服务,绝大多数独立服务器默认已开启(端口 22)': 'SSH is a built-in remote management service, enabled by default on most standalone servers (port 22)',
|
||||
'ZV Manager 是一款 Minecraft 服务器远程管理工具,通过 RCON、SSH/SFTP 等协议连接到您有权管理的服务器,提供服务器控制、玩家管理、模组插件管理、文件下载与远程终端等功能。本软件按"现状"提供。': 'ZV Manager is a remote management tool for Minecraft servers. It connects to servers you are authorized to manage via RCON, SSH/SFTP and other protocols, offering server control, player management, mod/plugin management, file downloads and a remote terminal. The software is provided "as is".',
|
||||
'ZV Manager:服务器页 → 编辑服务器 → 打开「SSH 连接」开关 → 填端口(默认 22)、用户名、密码 → 保存': 'ZV Manager: Servers → Edit server → enable "SSH Connection" → fill in port (default 22), username and password → Save',
|
||||
'screen -r 可以进入服务器控制台会话(开服时用了 screen 的话)': 'screen -r reattaches to the server console session (if you started the server inside screen)',
|
||||
'© 2026 ZV Team · 与 Mojang 无关': '© 2026 ZV Team · Not affiliated with Mojang',
|
||||
'一、如何开启 RCON(必配,控制台/玩家管理需要)': '1. How to enable RCON (required for console/player management)',
|
||||
'1. SSH 终端拥有服务器完全控制能力,您执行的任何命令(含删除文件、重启系统)后果由您自行承担。':
|
||||
'1. The SSH terminal grants full control of your server. You bear all consequences of any command you run (including deleting files or rebooting the system).',
|
||||
'1. 下载功能数据来自 Modrinth 公开接口及其镜像线路(如 MCIM)。镜像线路由第三方维护,其可用性与安全性不由开发者控制。':
|
||||
'1. Download data comes from the public Modrinth API and its mirrors (e.g. MCIM). Mirrors are maintained by third parties; the developer does not control their availability or safety.',
|
||||
'1. 仅管理您有权管理的服务器。严禁连接、探测、控制任何未获授权的第三方服务器——未经授权访问计算机系统属于违法行为。':
|
||||
'1. Only manage servers you are authorized to. Connecting to, probing or controlling any unauthorized third-party server is strictly prohibited — unauthorized access to computer systems is illegal.',
|
||||
'1. 本软件不收集、不上传您的任何个人数据,全部数据保存在设备本地,卸载即删除。':
|
||||
'1. This app does not collect or upload any personal data. All data is stored locally on your device and removed on uninstall.',
|
||||
'1. 本软件为免费开源软件,不提供商业担保。在法律允许的最大范围内,开发者不对因使用或无法使用本软件造成的任何直接或间接损失负责(包括数据丢失、服务器宕机、存档损坏、经济损失)。':
|
||||
'1. This software is free and open source, provided without commercial warranty. To the maximum extent permitted by law, the developer is not liable for any direct or indirect loss arising from use or inability to use (including data loss, server downtime, world corruption or financial loss).',
|
||||
'1. 本软件按开源协议发布,可依协议使用、修改和分发;"ZV Manager"名称与图标版权归作者所有。':
|
||||
'1. This software is released under an open source license and may be used, modified and distributed accordingly. The name and logo "ZV Manager" are copyrighted by the author.',
|
||||
'1. 连接凭据(RCON 密码、SSH 用户名/密码等)仅保存在您的设备本地(加密存储),本软件无云端账号系统,不会将凭据上传至开发者或任何第三方。':
|
||||
'1. Connection credentials (RCON password, SSH username/password, etc.) are stored only on your device (encrypted). This app has no cloud account system and never uploads credentials to the developer or any third party.',
|
||||
'2. Minecraft 是 Mojang Studios 的商标,本软件与 Mojang、微软无任何隶属关系。':
|
||||
'2. Minecraft is a trademark of Mojang Studios. This software is not affiliated with Mojang or Microsoft.',
|
||||
'2. 因第三方服务(Modrinth、镜像源、托管商、网络)变更或故障导致的异常,开发者不承担责任。':
|
||||
'2. The developer is not responsible for issues caused by changes or failures of third-party services (Modrinth, mirrors, hosting providers, networks).',
|
||||
'2. 应用仅联网检查更新(Gitee 发布页)及访问 Modrinth/镜像接口,无其他网络请求。':
|
||||
'2. The app only connects to the network to check updates (Gitee releases) and access the Modrinth/mirror APIs; there are no other network requests.',
|
||||
'2. 建议不要以 root 账户长期连接,执行不熟悉的命令前请先确认其作用。':
|
||||
'2. Avoid staying connected as root for long periods, and confirm what a command does before running unfamiliar ones.',
|
||||
'2. 第三方模组/插件可能影响服务器稳定性,安装前请备份重要数据;"依赖仓库"查询结果仅供参考。':
|
||||
'2. Third-party mods/plugins may affect server stability. Back up important data before installing; "Dependency Index" results are for reference only.',
|
||||
'2. 请妥善保管设备与凭据,因主动泄露、设备被他人使用、越狱/Root 等造成的损失由您自行承担。':
|
||||
'2. Keep your device and credentials safe. Losses caused by voluntary disclosure, unauthorized device use, jailbreak/Root, etc. are borne by you.',
|
||||
'2. 遵守《网络安全法》《计算机信息系统安全保护条例》等法律法规及 Minecraft EULA 与服务器规则。':
|
||||
'2. Comply with applicable laws and regulations (e.g. the Cybersecurity Law) as well as the Minecraft EULA and server rules.',
|
||||
'3. 不得利用本软件传播违法信息、破坏他人服务器、恶意攻击或盗取数据。':
|
||||
'3. Do not use this software to spread unlawful information, sabotage others\' servers, launch attacks or steal data.',
|
||||
'3. 仅连接您拥有管理权限的服务器,并使用强密码、定期更换。':
|
||||
'3. Only connect to servers you administer, using strong passwords changed regularly.',
|
||||
'3. 命令历史仅保存在设备本地,可在应用内清除,本软件不做任何云端记录。':
|
||||
'3. Command history is stored locally only, can be cleared in the app, and is never recorded in the cloud.',
|
||||
'4. 下载中心获取的模组/插件版权归原作者所有,请遵守对应开源协议,不得下载、分发盗版或破解内容。':
|
||||
'4. Mods/plugins obtained from the Download Center belong to their authors. Follow the corresponding licenses; pirated or cracked content must not be downloaded or distributed.',
|
||||
'Fabric 模组放 mods 目录;Paper/Spigot 插件放 plugins 目录':
|
||||
'Fabric mods go in the mods directory; Paper/Spigot plugins go in the plugins directory',
|
||||
'Q:TPS 显示 —?→ 原版服务端不支持 tps 命令,Paper/Purpur 等服务端才支持':
|
||||
'Q: TPS shows "—"? → Vanilla servers do not support the tps command; only Paper/Purpur and similar do',
|
||||
'Q:上传模组后不生效?→ 需要重启服务器':
|
||||
'Q: Mod upload not taking effect? → Restart the server',
|
||||
'Q:控制台能连但模组页提示无 SSH?→ 编辑服务器开启 SSH 并填好账号密码':
|
||||
'Q: Console connects but the mods page says no SSH? → Edit the server, enable SSH and fill in the credentials',
|
||||
'Q:连接失败?→ 检查防火墙是否放行端口、地址端口是否填对、服务器是否在线':
|
||||
'Q: Connection failed? → Check firewall rules for the port, verify address/port, and confirm the server is online',
|
||||
'SSH 拥有服务器完全控制权,请勿随意执行不熟悉的命令':
|
||||
'SSH grants full server control; do not run unfamiliar commands carelessly',
|
||||
'SSH 是服务器自带的远程管理服务,绝大多数独立服务器默认已开启(端口 22)':
|
||||
'SSH is a built-in remote management service, enabled by default on most standalone servers (port 22)',
|
||||
'ZV Manager 是一款 Minecraft 服务器远程管理工具,通过 RCON、SSH/SFTP 等协议连接到您有权管理的服务器,提供服务器控制、玩家管理、模组插件管理、文件下载与远程终端等功能。本软件按"现状"提供。':
|
||||
'ZV Manager is a remote management tool for Minecraft servers. It connects to servers you are authorized to manage via RCON, SSH/SFTP and other protocols, offering server control, player management, mod/plugin management, file downloads and a remote terminal. The software is provided "as is".',
|
||||
'ZV Manager:服务器页 → 编辑服务器 → 打开「SSH 连接」开关 → 填端口(默认 22)、用户名、密码 → 保存':
|
||||
'ZV Manager: Servers → Edit server → enable "SSH Connection" → fill in port (default 22), username and password → Save',
|
||||
'screen -r 可以进入服务器控制台会话(开服时用了 screen 的话)':
|
||||
'screen -r reattaches to the server console session (if you started the server inside screen)',
|
||||
'© 2026 ZV Team · 与 Mojang 无关':
|
||||
'© 2026 ZV Team · Not affiliated with Mojang',
|
||||
'一、如何开启 RCON(必配,控制台/玩家管理需要)':
|
||||
'1. How to enable RCON (required for console/player management)',
|
||||
'一、软件性质与用途': '1. Nature and Purpose of the Software',
|
||||
'七、常见问题': '7. FAQ',
|
||||
'七、数据与隐私': '7. Data and Privacy',
|
||||
'三、合法使用(重要)': '3. Lawful Use (Important)',
|
||||
'三、模组 / 插件管理怎么用': '3. Using Mod / Plugin Management',
|
||||
'上传后需重启服务器才会加载新模组(可在终端执行,或控制台发 stop 后重开)': 'The server must be restarted after uploading to load new mods (via terminal, or send stop in console and start again)',
|
||||
'下载完成且配置了 SSH 时,会自动上传到服务器的 mods/plugins 目录': 'When the download finishes and SSH is configured, files upload automatically to the server\'s mods/plugins directory',
|
||||
'不建议把 25575 端口直接暴露公网,强烈建议设置强密码': 'Do not expose port 25575 directly to the public internet; a strong password is strongly recommended',
|
||||
'不确定的话:用电脑终端执行 ssh 用户名@服务器IP 试试能否登录': 'If unsure: run ssh user@server-ip in a desktop terminal to test login',
|
||||
'上传后需重启服务器才会加载新模组(可在终端执行,或控制台发 stop 后重开)':
|
||||
'The server must be restarted after uploading to load new mods (via terminal, or send stop in console and start again)',
|
||||
'下载完成且配置了 SSH 时,会自动上传到服务器的 mods/plugins 目录':
|
||||
'When the download finishes and SSH is configured, files upload automatically to the server\'s mods/plugins directory',
|
||||
'不建议把 25575 端口直接暴露公网,强烈建议设置强密码':
|
||||
'Do not expose port 25575 directly to the public internet; a strong password is strongly recommended',
|
||||
'不确定的话:用电脑终端执行 ssh 用户名@服务器IP 试试能否登录':
|
||||
'If unsure: run ssh user@server-ip in a desktop terminal to test login',
|
||||
'九、守则变更': '9. Changes to This Agreement',
|
||||
'二、如何开启 SSH(模组管理 / 终端 / 下载自动上传需要)': '2. How to enable SSH (required for mod management / terminal / auto upload)',
|
||||
'二、如何开启 SSH(模组管理 / 终端 / 下载自动上传需要)':
|
||||
'2. How to enable SSH (required for mod management / terminal / auto upload)',
|
||||
'二、账号与凭据安全': '2. Account and Credential Security',
|
||||
'云服务器/虚拟主机需在防火墙或安全组放行 rcon.port 端口': 'For cloud servers/VPS, open rcon.port in the firewall or security group',
|
||||
'云服务器/虚拟主机需在防火墙或安全组放行 rcon.port 端口':
|
||||
'For cloud servers/VPS, open rcon.port in the firewall or security group',
|
||||
'五、模组管理与下载功能说明': '5. Mod Management and Downloads',
|
||||
'五、远程终端': '5. Remote Terminal',
|
||||
'保存后重启服务器生效': 'Restart the server after saving for changes to take effect',
|
||||
@@ -257,44 +296,82 @@ class S {
|
||||
'前提:该服务器已配置 SSH': 'Prerequisite: SSH is configured for this server',
|
||||
'十、其他': '10. Miscellaneous',
|
||||
'同意并进入': 'Agree and Continue',
|
||||
'命令历史只保存在手机本地,可放心使用': 'Command history is stored on your phone only; use it with confidence',
|
||||
'命令历史只保存在手机本地,可放心使用':
|
||||
'Command history is stored on your phone only; use it with confidence',
|
||||
'四、SSH / 终端功能风险提示': '4. SSH / Terminal Risk Notice',
|
||||
'四、下载中心与镜像加速': '4. Download Center and Mirror Acceleration',
|
||||
'回到 ZV Manager:服务器页 → 添加/编辑服务器,填入主机地址、端口(默认 25575)和 RCON 密码': 'Back in ZV Manager: Servers → Add/Edit server, fill in the host, port (default 25575) and RCON password',
|
||||
'国内网络慢时:点右上角测速图标 →「一键测速并选择最快线路」,或改用自定义镜像地址': 'If the network is slow in China: tap the speed-test icon in the top right → "Test and pick the fastest route", or use a custom mirror URL',
|
||||
'在服务器目录找到 server.properties 文件(与启动 jar 同目录)': 'Find server.properties in the server directory (same folder as the startup jar)',
|
||||
'底部快捷键栏:Tab 补全、Ctrl+C 中断、Ctrl+D 退出、↑↓ 调历史,以及 htop / df -h / screen -r 常用命令': 'Bottom shortcut bar: Tab completion, Ctrl+C interrupt, Ctrl+D exit, ↑↓ history, plus htop / df -h / screen -r quick commands',
|
||||
'开发者可能随版本更新修订本守则并在应用内展示;不同意修订内容请停止使用,继续使用即视为接受。': 'The developer may revise this agreement with version updates and display it in the app. If you disagree, stop using the app; continued use constitutes acceptance.',
|
||||
'回到 ZV Manager:服务器页 → 添加/编辑服务器,填入主机地址、端口(默认 25575)和 RCON 密码':
|
||||
'Back in ZV Manager: Servers → Add/Edit server, fill in the host, port (default 25575) and RCON password',
|
||||
'国内网络慢时:点右上角测速图标 →「一键测速并选择最快线路」,或改用自定义镜像地址':
|
||||
'If the network is slow in China: tap the speed-test icon in the top right → "Test and pick the fastest route", or use a custom mirror URL',
|
||||
'在服务器目录找到 server.properties 文件(与启动 jar 同目录)':
|
||||
'Find server.properties in the server directory (same folder as the startup jar)',
|
||||
'底部快捷键栏:Tab 补全、Ctrl+C 中断、Ctrl+D 退出、↑↓ 调历史,以及 htop / df -h / screen -r 常用命令':
|
||||
'Bottom shortcut bar: Tab completion, Ctrl+C interrupt, Ctrl+D exit, ↑↓ history, plus htop / df -h / screen -r quick commands',
|
||||
'开发者可能随版本更新修订本守则并在应用内展示;不同意修订内容请停止使用,继续使用即视为接受。':
|
||||
'The developer may revise this agreement with version updates and display it in the app. If you disagree, stop using the app; continued use constitutes acceptance.',
|
||||
'我已阅读并同意《用户守则》': 'I have read and agree to the User Agreement',
|
||||
'拿到 SSH 用户名(如 root)和密码': 'Obtain the SSH username (e.g. root) and password',
|
||||
'断网会自动重连(最多 3 次)': 'Reconnects automatically after network loss (up to 3 times)',
|
||||
'有的托管商需要先在控制台开启 SSH/SFTP 功能': 'Some hosting providers require enabling SSH/SFTP in their control panel first',
|
||||
'本守则最终解释权归 ZV Team 所有。如有疑问或发现漏洞,欢迎通过 Gitee 仓库(gitee.com/driftinblock/zvmanager)或官方 QQ 群反馈。': 'The final interpretation of this agreement belongs to ZV Team. For questions or vulnerability reports, reach us via the Gitee repo (gitee.com/driftinblock/zvmanager) or the official QQ group.',
|
||||
'本页教您一步步开启并使用 ZV Manager 的各项功能。': 'This guide walks you through enabling and using ZV Manager step by step.',
|
||||
'点「上传 jar」从手机选择文件上传;长按/点菜单可删除、重命名': 'Tap "Upload jar" to pick a file from your phone; long-press/menu to delete or rename',
|
||||
'点「同步」扫描服务器 mods/plugins,建立本地依赖索引': 'Tap "Sync" to scan the server\'s mods/plugins and build the local dependency index',
|
||||
'点击任意模组查看:它依赖什么、被谁依赖、缺失哪些依赖': 'Tap any mod to see what it depends on, what depends on it, and which dependencies are missing',
|
||||
'点击文件名可查看详情:模组名、版本、作者、依赖': 'Tap a file name for details: mod name, version, author, dependencies',
|
||||
'点右上角重复检测按钮重复安装 / 版本冲突的 jar': 'Tap the duplicate-check button in the top right to find duplicated or conflicting jars',
|
||||
'点结果选版本即可加入下载队列,支持暂停/继续/取消': 'Tap a result, pick a version and add it to the download queue; pause/resume/cancel supported',
|
||||
'版本 v2.0 · 下载、安装或使用本软件,即视为您已阅读并同意本守则全部条款。': 'Version v2.0 · By downloading, installing or using this software, you are deemed to have read and agreed to all terms of this agreement.',
|
||||
'版本要和 MC 版本、加载器匹配,否则服务器起不来': 'Versions must match the MC version and loader, or the server will fail to start',
|
||||
'断网会自动重连(最多 3 次)':
|
||||
'Reconnects automatically after network loss (up to 3 times)',
|
||||
'有的托管商需要先在控制台开启 SSH/SFTP 功能':
|
||||
'Some hosting providers require enabling SSH/SFTP in their control panel first',
|
||||
'本守则最终解释权归 ZV Team 所有。如有疑问或发现漏洞,欢迎通过 Gitee 仓库(gitee.com/driftinblock/zvmanager)或官方 QQ 群反馈。':
|
||||
'The final interpretation of this agreement belongs to ZV Team. For questions or vulnerability reports, reach us via the Gitee repo (gitee.com/driftinblock/zvmanager) or the official QQ group.',
|
||||
'本页教您一步步开启并使用 ZV Manager 的各项功能。':
|
||||
'This guide walks you through enabling and using ZV Manager step by step.',
|
||||
'点「上传 jar」从手机选择文件上传;长按/点菜单可删除、重命名':
|
||||
'Tap "Upload jar" to pick a file from your phone; long-press/menu to delete or rename',
|
||||
'点「同步」扫描服务器 mods/plugins,建立本地依赖索引':
|
||||
'Tap "Sync" to scan the server\'s mods/plugins and build the local dependency index',
|
||||
'点击任意模组查看:它依赖什么、被谁依赖、缺失哪些依赖':
|
||||
'Tap any mod to see what it depends on, what depends on it, and which dependencies are missing',
|
||||
'点击文件名可查看详情:模组名、版本、作者、依赖':
|
||||
'Tap a file name for details: mod name, version, author, dependencies',
|
||||
'点右上角重复检测按钮重复安装 / 版本冲突的 jar':
|
||||
'Tap the duplicate-check button in the top right to find duplicated or conflicting jars',
|
||||
'点结果选版本即可加入下载队列,支持暂停/继续/取消':
|
||||
'Tap a result, pick a version and add it to the download queue; pause/resume/cancel supported',
|
||||
'版本 v2.0 · 下载、安装或使用本软件,即视为您已阅读并同意本守则全部条款。':
|
||||
'Version v2.0 · By downloading, installing or using this software, you are deemed to have read and agreed to all terms of this agreement.',
|
||||
'版本要和 MC 版本、加载器匹配,否则服务器起不来':
|
||||
'Versions must match the MC version and loader, or the server will fail to start',
|
||||
'用户守则': 'User Agreement',
|
||||
'等同于电脑上的 SSH 终端,可以执行任意命令': 'Works like a desktop SSH terminal; you can run any command',
|
||||
'缺失依赖可一键从 Modrinth 下载补齐': 'Missing dependencies can be downloaded from Modrinth with one tap',
|
||||
'等同于电脑上的 SSH 终端,可以执行任意命令':
|
||||
'Works like a desktop SSH terminal; you can run any command',
|
||||
'缺失依赖可一键从 Modrinth 下载补齐':
|
||||
'Missing dependencies can be downloaded from Modrinth with one tap',
|
||||
'请仔细阅读守则({0}s)': 'Please read carefully ({0}s)',
|
||||
'请先滑动阅读至守则底部': 'Please scroll to the bottom of the agreement first',
|
||||
'请阅读至守则底部': 'Please read to the bottom of the agreement',
|
||||
'输入关键词搜索 Modrinth 上的模组/插件,可用 MC 版本、加载器筛选': 'Search Modrinth mods/plugins by keyword; filter by MC version and loader',
|
||||
'进入「服务器」页 → 下载中心(或首页快捷入口)': 'Go to the "Servers" page → Download Center (or the home shortcut)',
|
||||
'进入「模组」页签 → 右上角依赖仓库': 'Go to the "Mods" tab → Dependency Index in the top right',
|
||||
'进入「模组」页签,顶部切换 mods(模组)/ plugins(插件)目录': 'In the "Mods" tab, switch between mods and plugins directories at the top',
|
||||
'进入「终端」页签,点右上角 + 新建会话并选择服务器': 'In the "Terminal" tab, tap + in the top right to create a session and pick a server',
|
||||
'部分面板服 / 虚拟主机只提供网页面板,不提供 SSH,此时模组和终端功能不可用(入口会提示)': 'Some panel-hosted/virtual hosts offer only a web panel without SSH; mod management and terminal are unavailable then (the entry will tell you)',
|
||||
'输入关键词搜索 Modrinth 上的模组/插件,可用 MC 版本、加载器筛选':
|
||||
'Search Modrinth mods/plugins by keyword; filter by MC version and loader',
|
||||
'进入「服务器」页 → 下载中心(或首页快捷入口)':
|
||||
'Go to the "Servers" page → Download Center (or the home shortcut)',
|
||||
'进入「模组」页签 → 右上角依赖仓库':
|
||||
'Go to the "Mods" tab → Dependency Index in the top right',
|
||||
'进入「模组」页签,顶部切换 mods(模组)/ plugins(插件)目录':
|
||||
'In the "Mods" tab, switch between mods and plugins directories at the top',
|
||||
'进入「终端」页签,点右上角 + 新建会话并选择服务器':
|
||||
'In the "Terminal" tab, tap + in the top right to create a session and pick a server',
|
||||
'部分面板服 / 虚拟主机只提供网页面板,不提供 SSH,此时模组和终端功能不可用(入口会提示)':
|
||||
'Some panel-hosted/virtual hosts offer only a web panel without SSH; mod management and terminal are unavailable then (the entry will tell you)',
|
||||
'阅读倒计时 {0} 秒…': 'Reading countdown {0}s…',
|
||||
'默认使用 MCIM 国内镜像,无需科学上网': 'Uses the MCIM China mirror by default; no VPN needed',
|
||||
'首次使用建议按「一 → 二」顺序配置,其余功能即可解锁。': 'For first use, configure sections 1 → 2 in order to unlock the remaining features.',
|
||||
'和平难度': 'Peaceful',
|
||||
'默认使用 MCIM 国内镜像,无需科学上网':
|
||||
'Uses the MCIM China mirror by default; no VPN needed',
|
||||
'清空输出': 'Clear output',
|
||||
'输入命令后按回车执行': 'Type a command and press Enter',
|
||||
'当前': 'Active',
|
||||
'运行状态': 'Status',
|
||||
'搜索 Modrinth 模组,镜像加速下载': 'Search Modrinth mods with mirror acceleration',
|
||||
'通过 SSH 执行任意命令': 'Run any command over SSH',
|
||||
'上传、删除、查看依赖': 'Upload, delete, inspect dependencies',
|
||||
'{0} 个文件': '{0} files',
|
||||
'排序': 'Sort',
|
||||
// ---- ZL2 下载页 ----
|
||||
'共 {0} 个结果': '{0} results',
|
||||
'共 {0} 个任务': '{0} tasks',
|
||||
'在上方「搜索下载」页签中选择模组即可开始': 'Pick a mod in the Search tab above to get started',
|
||||
'在线公告': 'Online notice',
|
||||
'在线列表': 'Online list',
|
||||
'晴天': 'Clear weather',
|
||||
@@ -306,6 +383,19 @@ class S {
|
||||
'关闭': 'Close',
|
||||
'更新失败:{0}': 'Update failed: {0}',
|
||||
'未找到可下载的安装包': 'No downloadable package found',
|
||||
'版本号': 'Version',
|
||||
'更新时间': 'Release time',
|
||||
'当前版本': 'Current version',
|
||||
'更新发布页': 'Release page',
|
||||
'更新内容': 'Release notes',
|
||||
'更新': 'Updates',
|
||||
'修复': 'Fixes',
|
||||
'查看发布页': 'View release page',
|
||||
'忽略': 'Later',
|
||||
'本次更新暂无详细说明': 'No detailed release notes.',
|
||||
'完整的更新日志': 'Full changelog',
|
||||
'更新日志': 'Changelog',
|
||||
'相关链接': 'Related link',
|
||||
'正在下载更新': 'Downloading update',
|
||||
'正在下载,请稍候…': 'Downloading, please wait…',
|
||||
'立即更新': 'Update now',
|
||||
@@ -320,7 +410,8 @@ class S {
|
||||
'服务器控制台': 'Server Console',
|
||||
'标签': 'Label',
|
||||
'标签和命令都不能为空': 'Label and command cannot be empty',
|
||||
'点击标签一键发送,点击右侧按钮编辑': 'Tap a tag to send instantly; tap the button on the right to edit',
|
||||
'点击标签一键发送,点击右侧按钮编辑':
|
||||
'Tap a tag to send instantly; tap the button on the right to edit',
|
||||
'玩家管理': 'Players',
|
||||
'管理快速命令': 'Manage quick commands',
|
||||
'输入命令...': 'Enter command...',
|
||||
@@ -379,7 +470,8 @@ class S {
|
||||
'自定义 ({0})': 'Custom ({0})',
|
||||
'SFTP 未连接,请先调用 connect()': 'SFTP not connected; call connect() first',
|
||||
'RCON 未连接或未认证': 'RCON not connected or not authenticated',
|
||||
'新增 {0} · 更新 {1} · 未变化 {2} · 共 {3} 条': 'Added {0} · Updated {1} · Unchanged {2} · {3} total',
|
||||
'新增 {0} · 更新 {1} · 未变化 {2} · 共 {3} 条':
|
||||
'Added {0} · Updated {1} · Unchanged {2} · {3} total',
|
||||
'[警告] 连接断开,正在重连...': '[Warning] Connection lost, reconnecting...',
|
||||
'[信息] 重连成功': '[Info] Reconnected',
|
||||
'[错误] {0}': '[Error] {0}',
|
||||
@@ -391,13 +483,16 @@ class S {
|
||||
'端口不能为空': 'Port cannot be empty',
|
||||
'端口范围 1-65535': 'Port range 1-65535',
|
||||
'还没有添加服务器': 'No servers added yet',
|
||||
'填入主机地址与 RCON 密码,即可在手机上管理': 'Enter the host and RCON password to manage it from your phone',
|
||||
'填入主机地址与 RCON 密码,即可在手机上管理':
|
||||
'Enter the host and RCON password to manage it from your phone',
|
||||
'视频': 'Video',
|
||||
'图片': 'Image',
|
||||
'连接凭据已加密保存,仅存于本机': 'Credentials are encrypted and stored on this device only',
|
||||
'连接凭据已加密保存,仅存于本机':
|
||||
'Credentials are encrypted and stored on this device only',
|
||||
'服务器日志': 'Server Logs',
|
||||
'通过 SSH 查看服务器 logs 目录日志输出': 'View server logs directory output via SSH',
|
||||
'请先在「服务器」页配置 SSH 连接': 'Configure an SSH connection on the Servers page first',
|
||||
'请先在「服务器」页配置 SSH 连接':
|
||||
'Configure an SSH connection on the Servers page first',
|
||||
'选择服务器(需开启 SSH)': 'Select server (SSH required)',
|
||||
'日志目录路径': 'Logs directory path',
|
||||
'例如 /root/logs': 'e.g. /root/logs',
|
||||
@@ -413,9 +508,20 @@ class S {
|
||||
'版本、检查更新、创造者与开源许可': 'Version, updates, creators and licenses',
|
||||
'我知道了': 'Got it',
|
||||
'创造者': 'Creators',
|
||||
'ZV Manager 是一款 Minecraft 服务器远程管理工具,本软件与 Mojang、微软无任何隶属关系。': 'ZV Manager is a remote management tool for Minecraft servers. Not affiliated with Mojang or Microsoft.',
|
||||
'ZV Manager 是一款 Minecraft 服务器远程管理工具,本软件与 Mojang、微软无任何隶属关系。':
|
||||
'ZV Manager is a remote management tool for Minecraft servers. Not affiliated with Mojang or Microsoft.',
|
||||
'开发者 · Gitee: DriftinBlock': 'Developer · Gitee: DriftinBlock',
|
||||
'协作者 · Gitee: venti1112': 'Collaborator · Gitee: venti1112',
|
||||
// ---- ZL2 版式新增 ----
|
||||
'在线玩家 {0} 人': '{0} players online',
|
||||
'选择': 'Select',
|
||||
'底部': 'Bottom',
|
||||
'日志目录': 'Logs directory',
|
||||
'默认按 SSH 用户推导,可手动修改': 'Derived from the SSH user; edit if needed',
|
||||
'每 5 秒重新读取目录列表': 'Reload the file list every 5 seconds',
|
||||
'请选择一台已配置 SSH 的服务器': 'Select a server with SSH configured',
|
||||
'从 Gitee 获取最新版本': 'Fetch the latest version from Gitee',
|
||||
'查看本应用使用的第三方库许可': 'View third-party licenses used by this app',
|
||||
};
|
||||
|
||||
static String t(String zh) => en ? (_en[zh] ?? zh) : zh;
|
||||
@@ -438,9 +544,13 @@ class T extends StatelessWidget {
|
||||
final int? maxLines;
|
||||
final TextOverflow? overflow;
|
||||
|
||||
const T(this.zh, {super.key, this.style, this.textAlign, this.maxLines, this.overflow});
|
||||
const T(this.zh,
|
||||
{super.key, this.style, this.textAlign, this.maxLines, this.overflow});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) =>
|
||||
Text(S.t(zh), style: style, textAlign: textAlign, maxLines: maxLines, overflow: overflow);
|
||||
Widget build(BuildContext context) => Text(S.t(zh),
|
||||
style: style,
|
||||
textAlign: textAlign,
|
||||
maxLines: maxLines,
|
||||
overflow: overflow);
|
||||
}
|
||||
@@ -25,6 +25,28 @@ class MirrorService extends ChangeNotifier {
|
||||
return builtinMirrors[_current] ?? _current;
|
||||
}
|
||||
|
||||
/// 当前镜像的 API base(含 scheme、无尾斜杠),供请求 baseUrl 使用。
|
||||
///
|
||||
/// 仅替换 host,路径与查询串由调用方保持原样,避免与 queryParameters 二次拼接。
|
||||
/// MCIM 现行规则:Modrinth API 为 `mod.mcimirror.top/modrinth`(带 /modrinth 前缀),
|
||||
/// 请求路径 `/v2/search` 会拼成 `.../modrinth/v2/search`。
|
||||
String get apiBase {
|
||||
switch (_current) {
|
||||
case 'official':
|
||||
return 'https://api.modrinth.com';
|
||||
case 'mcim':
|
||||
return 'https://mod.mcimirror.top/modrinth';
|
||||
case 'custom':
|
||||
if (_customUrl.isEmpty) return 'https://api.modrinth.com';
|
||||
final trimmed = _customUrl.endsWith('/')
|
||||
? _customUrl.substring(0, _customUrl.length - 1)
|
||||
: _customUrl;
|
||||
return trimmed;
|
||||
default:
|
||||
return 'https://api.modrinth.com';
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> load() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
_current = prefs.getString(_prefKey) ?? 'mcim';
|
||||
@@ -43,9 +65,10 @@ class MirrorService extends ChangeNotifier {
|
||||
|
||||
/// 把 Modrinth 官方域名改写为镜像域名。
|
||||
///
|
||||
/// 镜像规则:
|
||||
/// - MCIM:api.modrinth.com → modrinth-api.mcimirror.top
|
||||
/// cdn.modrinth.com → modrinth-cdn.mcimirror.top
|
||||
/// 镜像规则(MCIM 官方 2026 现行规则,已核对 docs.mcimirror.top):
|
||||
/// - MCIM:api.modrinth.com/v2/... → mod.mcimirror.top/modrinth/v2/...(带前缀)
|
||||
/// cdn.modrinth.com/... → mod.mcimirror.top/...(仅换 host)
|
||||
/// 旧的 modrinth-api.mcimirror.top / modrinth-cdn.mcimirror.top 已废弃、DNS 无法解析
|
||||
/// - official:原样返回
|
||||
/// - custom:以自定义 base 替换 scheme/host,保留路径与查询串
|
||||
String rewrite(String url) {
|
||||
@@ -62,13 +85,16 @@ class MirrorService extends ChangeNotifier {
|
||||
}
|
||||
return url;
|
||||
}
|
||||
// MCIM
|
||||
final newHost = uri.host == 'api.modrinth.com'
|
||||
? 'modrinth-api.mcimirror.top'
|
||||
: uri.host == 'cdn.modrinth.com'
|
||||
? 'modrinth-cdn.mcimirror.top'
|
||||
: uri.host;
|
||||
return uri.replace(host: newHost).toString();
|
||||
// MCIM:API 需加 /modrinth 路径前缀,CDN 仅换 host
|
||||
if (uri.host == 'api.modrinth.com') {
|
||||
return uri
|
||||
.replace(host: 'mod.mcimirror.top', path: '/modrinth${uri.path}')
|
||||
.toString();
|
||||
}
|
||||
if (uri.host == 'cdn.modrinth.com') {
|
||||
return uri.replace(host: 'mod.mcimirror.top').toString();
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
/// 测速:对镜像的 api 域名发 HEAD 请求,返回毫秒数;失败返回 -1。
|
||||
@@ -78,7 +104,7 @@ class MirrorService extends ChangeNotifier {
|
||||
Future<int> speedTest(String mirrorId) async {
|
||||
final String probe = switch (mirrorId) {
|
||||
'official' => 'https://api.modrinth.com/v2/project/sodium/version?limit=1',
|
||||
'mcim' => 'https://modrinth-api.mcimirror.top/v2/project/sodium/version?limit=1',
|
||||
'mcim' => 'https://mod.mcimirror.top/modrinth/v2/project/sodium/version?limit=1',
|
||||
_ => _customUrl,
|
||||
};
|
||||
if (probe.isEmpty) return -1;
|
||||
|
||||
@@ -15,8 +15,10 @@ class ModrinthApi {
|
||||
));
|
||||
d.interceptors.add(InterceptorsWrapper(
|
||||
onRequest: (options, handler) {
|
||||
// 镜像改写:api.modrinth.com / cdn.modrinth.com → 镜像节点
|
||||
options.path = mirror.rewrite(options.uri.toString());
|
||||
// 镜像改写:仅替换 base(host + 可选路径前缀),路径与查询串保持原样。
|
||||
// 原实现把整串写回 options.path,因当时 baseUrl 为空、uri 无 host,
|
||||
// 最终拼成 ///v2/... 报 "No host specified";且整串回写会与 queryParameters 二次拼接。
|
||||
options.baseUrl = mirror.apiBase;
|
||||
// Modrinth 要求标明客户端身份,否则可能被限流
|
||||
options.headers['User-Agent'] = 'ZVManager/2.0 (gitee.com/driftinblock/zvmanager)';
|
||||
handler.next(options);
|
||||
@@ -25,6 +27,45 @@ class ModrinthApi {
|
||||
return d;
|
||||
}
|
||||
|
||||
/// 官方源 Dio(不经镜像拦截器),用于镜像连接失败时兜底重试。
|
||||
Dio get _officialDio => Dio(BaseOptions(
|
||||
baseUrl: 'https://api.modrinth.com',
|
||||
connectTimeout: const Duration(seconds: 15),
|
||||
receiveTimeout: const Duration(seconds: 30),
|
||||
headers: {'User-Agent': 'ZVManager/2.0 (gitee.com/driftinblock/zvmanager)'},
|
||||
));
|
||||
|
||||
/// 统一 GET:按当前镜像请求;若镜像出现连接层故障(DNS 失效/超时/拒连),
|
||||
/// 自动回退 Modrinth 官方源重试一次。MCIM 为第三方镜像,域名与可用性可能变化,
|
||||
/// 此兜底保证单点故障不会让搜索直接失败。
|
||||
Future<Response> _get(String path, {Map<String, dynamic>? queryParameters}) async {
|
||||
try {
|
||||
return await _dio.get(path, queryParameters: queryParameters);
|
||||
} on DioException catch (e) {
|
||||
if (mirror.currentId == 'official' || !_isConnectionFailure(e)) rethrow;
|
||||
return await _officialDio.get(path, queryParameters: queryParameters);
|
||||
}
|
||||
}
|
||||
|
||||
/// 判断是否为「连接层」故障(而非 4xx/5xx 业务响应),仅这类才值得回退。
|
||||
/// 不引入 dart:io,改用字符串匹配 SocketException 关键字,保证 Web 构建也可用。
|
||||
bool _isConnectionFailure(DioException e) {
|
||||
switch (e.type) {
|
||||
case DioExceptionType.connectionError:
|
||||
case DioExceptionType.connectionTimeout:
|
||||
case DioExceptionType.sendTimeout:
|
||||
case DioExceptionType.receiveTimeout:
|
||||
return true;
|
||||
case DioExceptionType.unknown:
|
||||
final s = '${e.error} ${e.message}';
|
||||
return s.contains('SocketException') ||
|
||||
s.contains('Failed host lookup') ||
|
||||
s.contains('No address associated');
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// 搜索项目。facets 例:[["versions:1.20.1"], ["categories:fabric"], ["project_type:mod"]]
|
||||
///
|
||||
/// Modrinth 的 facets 是「AND 组合、组内 OR」的结构,
|
||||
@@ -41,7 +82,7 @@ class ModrinthApi {
|
||||
];
|
||||
if (mcVersion != null && mcVersion.isNotEmpty) facets.add(['versions:$mcVersion']);
|
||||
if (loader != null && loader.isNotEmpty) facets.add(['categories:$loader']);
|
||||
final resp = await _dio.get('/v2/search', queryParameters: {
|
||||
final resp = await _get('/v2/search', queryParameters: {
|
||||
'query': query,
|
||||
'limit': limit,
|
||||
'facets': facets,
|
||||
@@ -52,7 +93,7 @@ class ModrinthApi {
|
||||
|
||||
/// 获取项目最新兼容版本列表(按日期倒序)。
|
||||
Future<List<ModrinthVersion>> versions(String projectId) async {
|
||||
final resp = await _dio.get('/v2/project/$projectId/version');
|
||||
final resp = await _get('/v2/project/$projectId/version');
|
||||
final list = (resp.data as List).map((e) => ModrinthVersion.fromJson(e)).toList();
|
||||
list.sort((a, b) => b.datePublished.compareTo(a.datePublished));
|
||||
return list;
|
||||
@@ -60,7 +101,7 @@ class ModrinthApi {
|
||||
|
||||
/// 项目详情(用于依赖信息)。
|
||||
Future<Map<String, dynamic>> project(String idOrSlug) async {
|
||||
final resp = await _dio.get('/v2/project/$idOrSlug');
|
||||
final resp = await _get('/v2/project/$idOrSlug');
|
||||
return Map<String, dynamic>.from(resp.data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ class AppTheme {
|
||||
centerTitle: false,
|
||||
elevation: 0,
|
||||
scrolledUnderElevation: 0,
|
||||
backgroundColor: scheme.surface,
|
||||
backgroundColor: Colors.transparent,
|
||||
surfaceTintColor: Colors.transparent,
|
||||
titleTextStyle: TextStyle(
|
||||
fontSize: 22,
|
||||
@@ -169,7 +169,8 @@ class AppTheme {
|
||||
elevation: 0,
|
||||
backgroundColor: isDark ? scheme.surfaceContainer : scheme.surfaceContainerLowest,
|
||||
surfaceTintColor: Colors.transparent,
|
||||
indicatorColor: scheme.secondaryContainer,
|
||||
// ZL2 风格:选中项用主色绿 + 浅绿圆角胶囊指示器
|
||||
indicatorColor: isDark ? scheme.primary.withOpacity(0.22) : scheme.primaryContainer,
|
||||
indicatorShape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(16)),
|
||||
),
|
||||
@@ -178,15 +179,15 @@ class AppTheme {
|
||||
final selected = states.contains(WidgetState.selected);
|
||||
return TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: selected ? FontWeight.w600 : FontWeight.w500,
|
||||
color: selected ? scheme.onSurface : scheme.onSurfaceVariant,
|
||||
fontWeight: selected ? FontWeight.w700 : FontWeight.w500,
|
||||
color: selected ? scheme.primary : scheme.onSurfaceVariant,
|
||||
);
|
||||
}),
|
||||
iconTheme: WidgetStateProperty.resolveWith((states) {
|
||||
final selected = states.contains(WidgetState.selected);
|
||||
return IconThemeData(
|
||||
size: 24,
|
||||
color: selected ? scheme.onSecondaryContainer : scheme.onSurfaceVariant,
|
||||
color: selected ? scheme.primary : scheme.onSurfaceVariant,
|
||||
);
|
||||
}),
|
||||
),
|
||||
|
||||
@@ -0,0 +1,210 @@
|
||||
/// 一条更新日志条目。
|
||||
class ReleaseNoteItem {
|
||||
final String text;
|
||||
|
||||
/// 是否为列表项(发布说明里以 `*`、`-` 或数字开头)。
|
||||
final bool bullet;
|
||||
|
||||
const ReleaseNoteItem({required this.text, required this.bullet});
|
||||
}
|
||||
|
||||
/// 一个更新日志分组,例如「更新」「修复」或发布者自定义的小标题。
|
||||
class ReleaseNoteSection {
|
||||
final String title;
|
||||
final List<ReleaseNoteItem> items;
|
||||
|
||||
const ReleaseNoteSection({required this.title, required this.items});
|
||||
}
|
||||
|
||||
/// 发布说明里提取出的链接。
|
||||
class ReleaseNoteLink {
|
||||
final String label;
|
||||
final String url;
|
||||
|
||||
const ReleaseNoteLink({required this.label, required this.url});
|
||||
}
|
||||
|
||||
/// Gitee 发布说明的轻量解析结果。
|
||||
///
|
||||
/// 不引入 Markdown 依赖,只处理发布说明里常见的标题、列表、粗体和链接。
|
||||
class ReleaseNotes {
|
||||
final List<ReleaseNoteSection> sections;
|
||||
final List<ReleaseNoteLink> links;
|
||||
|
||||
const ReleaseNotes({required this.sections, required this.links});
|
||||
|
||||
/// 没有任何可展示的正文条目。
|
||||
bool get isEmpty => sections.isEmpty;
|
||||
|
||||
factory ReleaseNotes.parse(String markdown) {
|
||||
final sections = <String, ReleaseNoteSection>{};
|
||||
final links = <ReleaseNoteLink>[];
|
||||
final seenUrls = <String>{};
|
||||
var activeTitle = '更新';
|
||||
|
||||
ReleaseNoteSection sectionFor(String title) {
|
||||
return sections.putIfAbsent(
|
||||
title,
|
||||
() => ReleaseNoteSection(title: title, items: <ReleaseNoteItem>[]),
|
||||
);
|
||||
}
|
||||
|
||||
void addLink(String label, String url) {
|
||||
final cleanedUrl =
|
||||
url.trim().replaceFirst(RegExp(r'[.,;:!?,。;:!?*_`]+$'), '');
|
||||
if (cleanedUrl.isEmpty || !seenUrls.add(cleanedUrl)) return;
|
||||
|
||||
final cleanedLabel =
|
||||
_cleanInline(label).replaceFirst(RegExp(r'[::\s]+$'), '').trim();
|
||||
links.add(
|
||||
ReleaseNoteLink(
|
||||
label: cleanedLabel.isEmpty ? '相关链接' : cleanedLabel,
|
||||
url: cleanedUrl,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
final normalized = markdown.replaceAll('\r\n', '\n').replaceAll('\r', '\n');
|
||||
for (var rawLine in normalized.split('\n')) {
|
||||
var line = rawLine.trim();
|
||||
if (line.isEmpty) continue;
|
||||
if (line.startsWith('```')) continue;
|
||||
if (RegExp(r'^[-*_]{3,}$').hasMatch(line)) continue;
|
||||
line = line.replaceFirst(RegExp(r'^>\s?'), '');
|
||||
|
||||
final heading = RegExp(r'^#{1,6}\s+(.*)$').firstMatch(line);
|
||||
if (heading != null) {
|
||||
final title = _cleanInline(heading.group(1) ?? '');
|
||||
if (title.isEmpty) continue;
|
||||
final lower = title.toLowerCase();
|
||||
if (title.contains('更新') ||
|
||||
title.contains('新增') ||
|
||||
lower.contains('feature') ||
|
||||
lower.contains('change')) {
|
||||
activeTitle = '更新';
|
||||
} else if (title.contains('修复') ||
|
||||
lower.contains('fix') ||
|
||||
lower.contains('bug')) {
|
||||
activeTitle = '修复';
|
||||
} else {
|
||||
activeTitle = title;
|
||||
sectionFor(title);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
final bulletMatch = RegExp(r'^[*+-]\s+(.*)$').firstMatch(line) ??
|
||||
RegExp(r'^\d+[.)]\s+(.*)$').firstMatch(line);
|
||||
final isBullet = bulletMatch != null;
|
||||
var content = bulletMatch?.group(1)?.trim() ?? line;
|
||||
|
||||
// 先提取 Markdown 链接,避免 URL 里的字符干扰后面的列表解析。
|
||||
content = content.replaceAllMapped(
|
||||
RegExp(r'\[([^\]]+)\]\((https?://[^)\s]+)\)'),
|
||||
(match) {
|
||||
addLink(match.group(1) ?? '', match.group(2) ?? '');
|
||||
return '';
|
||||
},
|
||||
);
|
||||
|
||||
// 提取裸链接,并从正文中移除,避免日志里出现很长的 URL。
|
||||
content = content.replaceAllMapped(
|
||||
RegExp(r'https?://[^\s)<>]+'),
|
||||
(match) {
|
||||
final rawUrl = match.group(0) ?? '';
|
||||
final rest = content.replaceRange(match.start, match.end, '');
|
||||
addLink(_linkLabel(rest), rawUrl);
|
||||
return '';
|
||||
},
|
||||
);
|
||||
|
||||
content = _cleanInline(content);
|
||||
content = content.replaceFirst(RegExp(r'[\s::]+$'), '').trim();
|
||||
if (content.isEmpty || _isChangelogLabel(content)) continue;
|
||||
|
||||
final prefixMatch = RegExp(
|
||||
r'^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\([^)]*\))?!?:\s*',
|
||||
caseSensitive: false,
|
||||
).firstMatch(content);
|
||||
String? prefix;
|
||||
if (prefixMatch != null) {
|
||||
prefix = (prefixMatch.group(1) ?? '').toLowerCase();
|
||||
content = content.substring(prefixMatch.end).trim();
|
||||
}
|
||||
if (content.isEmpty) continue;
|
||||
|
||||
final hasPrefix = prefix != null;
|
||||
final isFix = prefix == 'fix' ||
|
||||
prefix == 'revert' ||
|
||||
(!hasPrefix && content.startsWith('修复'));
|
||||
|
||||
final String title;
|
||||
if (hasPrefix) {
|
||||
title = isFix ? '修复' : '更新';
|
||||
} else if (activeTitle == '修复') {
|
||||
title = '修复';
|
||||
} else if (activeTitle == '更新') {
|
||||
title = isFix ? '修复' : '更新';
|
||||
} else {
|
||||
title = activeTitle;
|
||||
}
|
||||
|
||||
sectionFor(title).items.add(
|
||||
ReleaseNoteItem(text: content, bullet: isBullet),
|
||||
);
|
||||
}
|
||||
|
||||
// 固定先展示「更新」和「修复」,再展示发布者自定义的小标题。
|
||||
final ordered = <ReleaseNoteSection>[];
|
||||
for (final title in const ['更新', '修复']) {
|
||||
final section = sections[title];
|
||||
if (section != null && section.items.isNotEmpty) ordered.add(section);
|
||||
}
|
||||
for (final section in sections.values) {
|
||||
if (section.title != '更新' &&
|
||||
section.title != '修复' &&
|
||||
section.items.isNotEmpty) {
|
||||
ordered.add(section);
|
||||
}
|
||||
}
|
||||
|
||||
return ReleaseNotes(sections: ordered, links: links);
|
||||
}
|
||||
}
|
||||
|
||||
String _cleanInline(String text) {
|
||||
var value = text;
|
||||
value = value.replaceAllMapped(
|
||||
RegExp(r'!\[([^\]]*)\]\([^)]*\)'),
|
||||
(match) => match.group(1) ?? '',
|
||||
);
|
||||
value = value.replaceAllMapped(
|
||||
RegExp(r'\[([^\]]+)\]\([^)]*\)'),
|
||||
(match) => match.group(1) ?? '',
|
||||
);
|
||||
value = value.replaceAll(RegExp(r'<[^>]*>'), '');
|
||||
value = value.replaceAll('**', '').replaceAll('__', '').replaceAll('`', '');
|
||||
value = value.replaceFirst(RegExp(r'^\s*>\s?'), '');
|
||||
return value.trim();
|
||||
}
|
||||
|
||||
String _linkLabel(String text) {
|
||||
final label = _cleanInline(text).replaceFirst(RegExp(r'[::\s]+$'), '').trim();
|
||||
if (label.isEmpty) return '相关链接';
|
||||
if (label.contains('更新日志') ||
|
||||
label.contains('完整的更新') ||
|
||||
label.toLowerCase().contains('changelog')) {
|
||||
return '完整的更新日志';
|
||||
}
|
||||
return label.length > 32 ? '${label.substring(0, 32)}…' : label;
|
||||
}
|
||||
|
||||
bool _isChangelogLabel(String text) {
|
||||
final label = text.replaceAll(RegExp(r'[::\s]+'), '').toLowerCase();
|
||||
return label == '完整的更新日志' ||
|
||||
label == '完整更新日志' ||
|
||||
label == '更新日志' ||
|
||||
label == 'changelog' ||
|
||||
label == 'releasenotes' ||
|
||||
label == 'fullchangelog';
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/// 软件更新信息,由 Gitee 发布接口解析而来。
|
||||
class UpdateInfo {
|
||||
final String latestVersion;
|
||||
final String downloadUrl;
|
||||
final String apkName;
|
||||
|
||||
/// Gitee 发布说明(Markdown 原文)。
|
||||
final String releaseNotes;
|
||||
|
||||
/// Gitee 发布接口返回的发布时间。
|
||||
final DateTime? releasedAt;
|
||||
|
||||
/// Gitee 发布页地址。
|
||||
final String releasePageUrl;
|
||||
|
||||
const UpdateInfo({
|
||||
required this.latestVersion,
|
||||
required this.downloadUrl,
|
||||
required this.apkName,
|
||||
this.releaseNotes = '',
|
||||
this.releasedAt,
|
||||
this.releasePageUrl = '',
|
||||
});
|
||||
}
|
||||
@@ -1,26 +1,23 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import '../../core/l10n/strings.dart';
|
||||
|
||||
/// 软件更新信息,由 Gitee 发布接口的 tag_name 与 assets 解析而来
|
||||
class UpdateInfo {
|
||||
final String latestVersion;
|
||||
final String downloadUrl;
|
||||
final String apkName;
|
||||
const UpdateInfo({
|
||||
required this.latestVersion,
|
||||
required this.downloadUrl,
|
||||
required this.apkName,
|
||||
});
|
||||
}
|
||||
import '../l10n/strings.dart';
|
||||
import '../widgets/update_dialog.dart';
|
||||
import 'update_info.dart';
|
||||
|
||||
export 'update_info.dart';
|
||||
|
||||
/// 更新检查与安装服务:负责从 Gitee 拉取发布信息、下载并调起系统安装器。
|
||||
class UpdateService {
|
||||
const UpdateService._();
|
||||
|
||||
/// Gitee 仓库地址
|
||||
static const _repoUrl = 'https://gitee.com/driftinblock/zvmanager';
|
||||
|
||||
/// Gitee 仓库最新发布信息地址
|
||||
static const _updateInfoUrl =
|
||||
'https://gitee.com/api/v5/repos/driftinblock/zvmanager/releases/latest';
|
||||
@@ -59,33 +56,89 @@ class UpdateService {
|
||||
final json = jsonDecode(body) as Map<String, dynamic>;
|
||||
// Gitee 发布接口的 tag_name 形如 "v1.3.0",去掉开头的 "v" 用于版本号对比
|
||||
final tag = json['tag_name'] as String? ?? '';
|
||||
final latestVersion = tag.startsWith('v') ? tag.substring(1) : tag;
|
||||
final latestVersion =
|
||||
tag.startsWith('v') || tag.startsWith('V') ? tag.substring(1) : tag;
|
||||
if (latestVersion.isEmpty) return null;
|
||||
|
||||
// 从 assets 中筛选 APK 安装包,取其直链与文件名
|
||||
String downloadUrl = '';
|
||||
String apkName = '';
|
||||
final assets = json['assets'] as List<dynamic>? ?? [];
|
||||
for (final item in assets) {
|
||||
final name = (item as Map<String, dynamic>)['name'] as String? ?? '';
|
||||
final asset = item as Map<String, dynamic>;
|
||||
final name = asset['name'] as String? ?? '';
|
||||
if (name.endsWith('.apk')) {
|
||||
downloadUrl = (item['browser_download_url'] as String? ??
|
||||
item['download_url'] as String? ??
|
||||
downloadUrl = (asset['browser_download_url'] as String? ??
|
||||
asset['download_url'] as String? ??
|
||||
'');
|
||||
apkName = name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
final htmlUrl = json['html_url'] as String? ?? '';
|
||||
final releasePageUrl = htmlUrl.isNotEmpty
|
||||
? htmlUrl
|
||||
: (tag.isEmpty
|
||||
? '$_repoUrl/releases'
|
||||
: '$_repoUrl/releases/tag/${Uri.encodeComponent(tag)}');
|
||||
|
||||
return UpdateInfo(
|
||||
latestVersion: latestVersion,
|
||||
downloadUrl: downloadUrl,
|
||||
apkName: apkName,
|
||||
releaseNotes: json['body'] as String? ?? '',
|
||||
releasedAt: DateTime.tryParse(json['created_at'] as String? ?? ''),
|
||||
releasePageUrl: releasePageUrl,
|
||||
);
|
||||
} finally {
|
||||
client.close();
|
||||
}
|
||||
}
|
||||
|
||||
/// 判断 [latest] 是否比 [current] 新。只有新版本更高时才返回 true,
|
||||
/// 避免当前版本高于 Gitee 发布版本时误提示更新并引导降级。
|
||||
static bool isNewerVersion(String latest, String current) {
|
||||
if (latest.trim().isEmpty) return false;
|
||||
|
||||
final latestParts = _parseVersion(latest);
|
||||
final currentParts = _parseVersion(current);
|
||||
if (latestParts == null || currentParts == null) {
|
||||
return latest.trim() != current.trim();
|
||||
}
|
||||
|
||||
final length = latestParts.length > currentParts.length
|
||||
? latestParts.length
|
||||
: currentParts.length;
|
||||
for (var i = 0; i < length; i++) {
|
||||
final latestPart = i < latestParts.length ? latestParts[i] : 0;
|
||||
final currentPart = i < currentParts.length ? currentParts[i] : 0;
|
||||
if (latestPart != currentPart) return latestPart > currentPart;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// 把 "v2.0.3+16" 解析成 [2, 0, 3],忽略 v 前缀、后缀和构建号。
|
||||
static List<int>? _parseVersion(String version) {
|
||||
var value = version.trim();
|
||||
if (value.isEmpty) return null;
|
||||
if (value.startsWith('v') || value.startsWith('V')) {
|
||||
value = value.substring(1);
|
||||
}
|
||||
|
||||
final suffixIndex = value.indexOf(RegExp(r'[-+]'));
|
||||
if (suffixIndex >= 0) value = value.substring(0, suffixIndex);
|
||||
|
||||
final parts = value.split('.');
|
||||
final numbers = <int>[];
|
||||
for (final part in parts) {
|
||||
final match = RegExp(r'^\d+').firstMatch(part);
|
||||
if (match == null) return null;
|
||||
numbers.add(int.parse(match.group(0)!));
|
||||
}
|
||||
return numbers.isEmpty ? null : numbers;
|
||||
}
|
||||
|
||||
/// 展示版本对比结果弹窗;`hasUpdate` 为 false 时若无更新且 `silentOnNoUpdate` 为 true 则直接静默返回。
|
||||
static void showUpdateDialog(
|
||||
BuildContext context,
|
||||
@@ -93,28 +146,33 @@ class UpdateService {
|
||||
String currentVersion, {
|
||||
bool silentOnNoUpdate = false,
|
||||
}) {
|
||||
final hasUpdate = info.latestVersion != currentVersion;
|
||||
final hasUpdate = isNewerVersion(info.latestVersion, currentVersion);
|
||||
if (!hasUpdate && silentOnNoUpdate) return;
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) => AlertDialog(
|
||||
title: Text(hasUpdate ? S.t('发现新版本') : S.t('已是最新')),
|
||||
content: Text(hasUpdate
|
||||
? '最新版本: ${info.latestVersion}\n当前版本: $currentVersion'
|
||||
: S.f('当前版本 {0} 已是最新', [currentVersion])),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context), child: T('关闭')),
|
||||
if (hasUpdate)
|
||||
FilledButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
downloadAndInstall(context, info);
|
||||
},
|
||||
child: T('立即更新'),
|
||||
if (!hasUpdate) {
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
builder: (dialogContext) => AlertDialog(
|
||||
title: Text(S.t('已是最新')),
|
||||
content: Text(S.f('当前版本 {0} 已是最新', [currentVersion])),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(dialogContext).pop(),
|
||||
child: T('关闭'),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
builder: (_) => UpdateDialog(
|
||||
info: info,
|
||||
currentVersion: currentVersion,
|
||||
onUpdate: () => downloadAndInstall(context, info),
|
||||
onOpenUrl: openUrl,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -171,7 +229,9 @@ class UpdateService {
|
||||
CircularProgressIndicator(value: value),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
percent == null ? S.t('正在下载安装包…') : S.f('下载中:{0}%', [percent]),
|
||||
percent == null
|
||||
? S.t('正在下载安装包…')
|
||||
: S.f('下载中:{0}%', [percent]),
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
],
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../core/l10n/strings.dart';
|
||||
import '../widgets/z_widgets.dart';
|
||||
|
||||
/// 统一的「需要先选服务器 / 未配置」引导空状态页。
|
||||
/// 自带 AppBar 标题栏,避免页面看起来空白、引导文字无处安放。
|
||||
@@ -24,7 +25,7 @@ class EmptyStatePage extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: T(title)),
|
||||
appBar: ZAppBar(title: T(title)),
|
||||
body: Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(32),
|
||||
|
||||
@@ -0,0 +1,306 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../l10n/strings.dart';
|
||||
import '../utils/release_notes.dart';
|
||||
import '../utils/update_info.dart';
|
||||
|
||||
/// 检查更新详情弹窗:版本号、发布时间、发布页和解析后的更新日志。
|
||||
class UpdateDialog extends StatelessWidget {
|
||||
final UpdateInfo info;
|
||||
final String currentVersion;
|
||||
final VoidCallback onUpdate;
|
||||
final ValueChanged<String> onOpenUrl;
|
||||
|
||||
const UpdateDialog({
|
||||
super.key,
|
||||
required this.info,
|
||||
required this.currentVersion,
|
||||
required this.onUpdate,
|
||||
required this.onOpenUrl,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final scheme = theme.colorScheme;
|
||||
final notes = ReleaseNotes.parse(info.releaseNotes);
|
||||
final maxHeight = MediaQuery.sizeOf(context).height * 0.82;
|
||||
|
||||
return Dialog(
|
||||
insetPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 24),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(maxWidth: 560, maxHeight: maxHeight),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(24, 20, 24, 4),
|
||||
child: Text(
|
||||
S.t('发现新版本'),
|
||||
textAlign: TextAlign.center,
|
||||
style: theme.textTheme.titleLarge?.copyWith(
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.fromLTRB(24, 12, 24, 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_InfoRow(label: S.t('版本号'), value: info.latestVersion),
|
||||
const SizedBox(height: 7),
|
||||
if (info.releasedAt != null) ...[
|
||||
_InfoRow(
|
||||
label: S.t('更新时间'),
|
||||
value: _formatDateTime(info.releasedAt!),
|
||||
),
|
||||
const SizedBox(height: 7),
|
||||
],
|
||||
_InfoRow(
|
||||
label: S.t('当前版本'),
|
||||
value: currentVersion,
|
||||
),
|
||||
if (info.releasePageUrl.isNotEmpty) ...[
|
||||
const SizedBox(height: 10),
|
||||
_InfoRow(
|
||||
label: S.t('更新发布页'),
|
||||
value: 'Gitee',
|
||||
link: true,
|
||||
onTap: () => onOpenUrl(info.releasePageUrl),
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 16),
|
||||
Divider(height: 1, color: scheme.outlineVariant),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
S.t('更新内容'),
|
||||
style: theme.textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
if (notes.isEmpty)
|
||||
Text(
|
||||
S.t('本次更新暂无详细说明'),
|
||||
style: theme.textTheme.bodyMedium?.copyWith(
|
||||
color: scheme.onSurfaceVariant,
|
||||
),
|
||||
)
|
||||
else
|
||||
..._buildSections(context, notes.sections),
|
||||
if (notes.links.isNotEmpty) ...[
|
||||
const SizedBox(height: 12),
|
||||
...notes.links.map(
|
||||
(link) => _NoteLink(
|
||||
label: link.label,
|
||||
onTap: () => onOpenUrl(link.url),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Divider(height: 1, color: scheme.outlineVariant),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(12, 10, 12, 12),
|
||||
child: Row(
|
||||
children: [
|
||||
if (info.releasePageUrl.isNotEmpty)
|
||||
TextButton(
|
||||
onPressed: () => onOpenUrl(info.releasePageUrl),
|
||||
style: TextButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
),
|
||||
child: T('查看发布页'),
|
||||
),
|
||||
const Spacer(),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
style: TextButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
),
|
||||
child: T('忽略'),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
FilledButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
onUpdate();
|
||||
},
|
||||
child: T('立即更新'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> _buildSections(
|
||||
BuildContext context,
|
||||
List<ReleaseNoteSection> sections,
|
||||
) {
|
||||
final theme = Theme.of(context);
|
||||
final scheme = theme.colorScheme;
|
||||
final widgets = <Widget>[];
|
||||
|
||||
for (var i = 0; i < sections.length; i++) {
|
||||
final section = sections[i];
|
||||
if (i > 0) widgets.add(const SizedBox(height: 14));
|
||||
widgets.add(
|
||||
Text(
|
||||
S.t(section.title),
|
||||
style: theme.textTheme.titleSmall?.copyWith(
|
||||
fontWeight: FontWeight.w700,
|
||||
color: scheme.primary,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
for (final item in section.items) {
|
||||
widgets.add(const SizedBox(height: 6));
|
||||
if (item.bullet) {
|
||||
widgets.add(
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 1),
|
||||
child: Text(
|
||||
'•',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: scheme.primary,
|
||||
height: 1.55,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
item.text,
|
||||
style: theme.textTheme.bodyMedium?.copyWith(height: 1.55),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
widgets.add(
|
||||
Text(
|
||||
item.text,
|
||||
style: theme.textTheme.bodyMedium?.copyWith(height: 1.55),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return widgets;
|
||||
}
|
||||
}
|
||||
|
||||
/// 「版本号:xxx」形式的单行信息。
|
||||
class _InfoRow extends StatelessWidget {
|
||||
final String label;
|
||||
final String value;
|
||||
final bool link;
|
||||
final VoidCallback? onTap;
|
||||
|
||||
const _InfoRow({
|
||||
required this.label,
|
||||
required this.value,
|
||||
this.link = false,
|
||||
this.onTap,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
final separator = S.en ? ': ' : ':';
|
||||
final valueStyle = TextStyle(
|
||||
fontSize: 13.5,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: link ? scheme.primary : scheme.onSurface,
|
||||
);
|
||||
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'$label$separator',
|
||||
style: TextStyle(fontSize: 13.5, color: scheme.onSurfaceVariant),
|
||||
),
|
||||
Expanded(
|
||||
child: link
|
||||
? InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 1),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(value, style: valueStyle),
|
||||
const SizedBox(width: 2),
|
||||
Icon(
|
||||
Icons.open_in_new,
|
||||
size: 14,
|
||||
color: scheme.primary,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
: Text(value, style: valueStyle),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 发布说明底部提取出的可点击链接。
|
||||
class _NoteLink extends StatelessWidget {
|
||||
final String label;
|
||||
final VoidCallback onTap;
|
||||
|
||||
const _NoteLink({required this.label, required this.onTap});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
return Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: TextButton.icon(
|
||||
onPressed: onTap,
|
||||
icon: Icon(Icons.link, size: 17, color: scheme.primary),
|
||||
label: Text(S.t(label)),
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: scheme.primary,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 2),
|
||||
minimumSize: const Size(0, 36),
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String _formatDateTime(DateTime value) {
|
||||
final local = value.toLocal();
|
||||
String two(int number) => number.toString().padLeft(2, '0');
|
||||
|
||||
if (S.en) {
|
||||
return '${local.year}-${two(local.month)}-${two(local.day)} '
|
||||
'${two(local.hour)}:${two(local.minute)}:${two(local.second)}';
|
||||
}
|
||||
return '${local.year}年${two(local.month)}月${two(local.day)}日 '
|
||||
'${two(local.hour)}:${two(local.minute)}:${two(local.second)}';
|
||||
}
|
||||
@@ -0,0 +1,559 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../l10n/strings.dart';
|
||||
import '../../providers/wallpaper_provider.dart';
|
||||
|
||||
/// ZL2 风格的通用视觉组件集合。
|
||||
///
|
||||
/// 设计要点(与 ZalithLauncher 保持一致的观感):
|
||||
/// - **分组圆角面板**:一组相关设置包在 18px 圆角容器里,行与行之间用极细
|
||||
/// 分隔线,而不是每行一张 Card。这样竖屏下信息密度更高、层级更清晰。
|
||||
/// - **两行行样式**:左侧「粗标题 + 小字灰色说明」,右侧「当前值 / 控件 / 箭头」。
|
||||
/// 说明文字用较小字号 + 降低不透明度,形成明确的视觉主次。
|
||||
/// - **圆形勾选钮**:开关不用 Material Switch,而用 46px 圆形按钮,
|
||||
/// 选中时绿底白勾(ZL2 的标志性元素)。
|
||||
///
|
||||
/// 所有组件都接受 [hasWallpaper],在有自定义壁纸时自动切换为半透明深色
|
||||
/// 浮层 + 白色文字,保证文字在任意背景下都能读清。
|
||||
|
||||
/// ZL2 主色:勾选钮/选中态统一使用的绿色。
|
||||
const Color kZAccent = Color(0xFF4CAF50);
|
||||
|
||||
/// ZL2 圆角:分组面板与内部行的圆角。
|
||||
const double kZRadius = 18.0;
|
||||
|
||||
/// 分组面板的着色与文字色工具。
|
||||
///
|
||||
/// 把「有壁纸 / 无壁纸」两套配色集中在这里,避免每个页面各写一遍
|
||||
/// `Colors.black.withOpacity(0.45)` 之类的魔数。
|
||||
class ZStyle {
|
||||
final bool hasWallpaper;
|
||||
final ColorScheme scheme;
|
||||
|
||||
const ZStyle({required this.hasWallpaper, required this.scheme});
|
||||
|
||||
/// 从 BuildContext 推导(需要外部传入 hasWallpaper)。
|
||||
factory ZStyle.of(BuildContext context, {required bool hasWallpaper}) =>
|
||||
ZStyle(hasWallpaper: hasWallpaper, scheme: Theme.of(context).colorScheme);
|
||||
|
||||
/// 面板底色:有壁纸时半透明黑浮层,否则用主题的低层容器色。
|
||||
Color get panelColor =>
|
||||
hasWallpaper ? Colors.black.withOpacity(0.45) : scheme.surfaceContainerLow;
|
||||
|
||||
/// 主文字色。
|
||||
Color get titleColor => hasWallpaper ? Colors.white : scheme.onSurface;
|
||||
|
||||
/// 次要说明文字色。
|
||||
Color get subColor =>
|
||||
hasWallpaper ? Colors.white.withOpacity(0.62) : scheme.onSurfaceVariant;
|
||||
|
||||
/// 分隔线色。
|
||||
Color get dividerColor =>
|
||||
hasWallpaper ? Colors.white.withOpacity(0.10) : scheme.outlineVariant;
|
||||
|
||||
/// 面板描边色(浅色主题下几乎不可见,仅用于在深色壁纸上勾出边界)。
|
||||
Color get borderColor => Colors.white.withOpacity(0.08);
|
||||
}
|
||||
|
||||
/// 分组面板:圆角容器 + 子行纵向排列。
|
||||
///
|
||||
/// 用法:把若干 [ZRow] 之间用 [ZDivider] 隔开后放进 children。
|
||||
class ZPanel extends StatelessWidget {
|
||||
final List<Widget> children;
|
||||
final ZStyle style;
|
||||
|
||||
const ZPanel({super.key, required this.style, required this.children});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: style.panelColor,
|
||||
borderRadius: BorderRadius.circular(kZRadius),
|
||||
border: Border.all(color: style.borderColor, width: 1),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: children,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 面板内的行分隔线(左右各留 16 的缩进)。
|
||||
class ZDivider extends StatelessWidget {
|
||||
final ZStyle style;
|
||||
const ZDivider({super.key, required this.style});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Divider(height: 1, thickness: 1, color: style.dividerColor),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 两行式设置行:粗标题 + 灰色说明 + 右侧值/控件/箭头。
|
||||
///
|
||||
/// - [onTap] 为空时整行不可点击(纯展示行),也不显示右侧箭头;
|
||||
/// - [trailing] 与 [value] 可同时存在;都没有且 [onTap] 不为空时显示 chevron。
|
||||
/// - [leading] 可选,用于在标题左侧放一个小图标(如日志文件行)。
|
||||
class ZRow extends StatelessWidget {
|
||||
final String title;
|
||||
final String? subtitle;
|
||||
final ZStyle style;
|
||||
final Widget? leading;
|
||||
final Widget? trailing;
|
||||
final String? value;
|
||||
final VoidCallback? onTap;
|
||||
|
||||
/// 标题用主题色的强调样式(如危险操作变红)。
|
||||
final Color? titleOverride;
|
||||
|
||||
const ZRow({
|
||||
super.key,
|
||||
required this.title,
|
||||
required this.style,
|
||||
this.subtitle,
|
||||
this.leading,
|
||||
this.trailing,
|
||||
this.value,
|
||||
this.onTap,
|
||||
this.titleOverride,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final showChevron = trailing == null && onTap != null;
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: BorderRadius.circular(kZRadius),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 14, 12, 14),
|
||||
child: Row(
|
||||
children: [
|
||||
if (leading != null) ...[
|
||||
leading!,
|
||||
const SizedBox(width: 12),
|
||||
],
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
S.t(title),
|
||||
style: TextStyle(
|
||||
fontSize: 15.5,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: titleOverride ?? style.titleColor,
|
||||
),
|
||||
),
|
||||
if (subtitle != null && subtitle!.isNotEmpty) ...[
|
||||
const SizedBox(height: 3),
|
||||
Text(
|
||||
S.t(subtitle!),
|
||||
style: TextStyle(
|
||||
fontSize: 12.5,
|
||||
height: 1.35,
|
||||
color: style.subColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
if (value != null) ...[
|
||||
const SizedBox(width: 8),
|
||||
Flexible(
|
||||
child: Text(
|
||||
value!,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.right,
|
||||
style: TextStyle(fontSize: 13, color: style.subColor),
|
||||
),
|
||||
),
|
||||
],
|
||||
if (trailing != null) ...[
|
||||
const SizedBox(width: 10),
|
||||
trailing!,
|
||||
] else if (showChevron) ...[
|
||||
const SizedBox(width: 4),
|
||||
Icon(Icons.chevron_right, size: 20, color: style.subColor),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// ZL2 式圆形勾选开关:选中为绿底白勾,未选中为描边空心圆。
|
||||
class ZToggle extends StatelessWidget {
|
||||
final bool value;
|
||||
final ValueChanged<bool> onChanged;
|
||||
|
||||
/// 直径,设置页用 46,列表行内可用 40。
|
||||
final double size;
|
||||
|
||||
/// 未选中时描边颜色(有壁纸时传白色系)。
|
||||
final Color? borderColor;
|
||||
|
||||
const ZToggle({
|
||||
super.key,
|
||||
required this.value,
|
||||
required this.onChanged,
|
||||
this.size = 46,
|
||||
this.borderColor,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final dim = borderColor ?? Colors.white54;
|
||||
return GestureDetector(
|
||||
onTap: () => onChanged(!value),
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
width: size,
|
||||
height: size,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: value ? kZAccent : Colors.transparent,
|
||||
border: Border.all(color: value ? kZAccent : dim, width: 2),
|
||||
),
|
||||
child: value
|
||||
? Icon(Icons.check, size: size * 0.52, color: Colors.white)
|
||||
: const SizedBox.shrink(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 圆形选择钮组:一组互斥选项,选中项显示绿底白勾,未选中显示图标。
|
||||
///
|
||||
/// 用于「亮色 / 暗色 / 跟随系统」这类三选一,也可复用到镜像线路等单选场景。
|
||||
class ZSegmentedCircles<T> extends StatelessWidget {
|
||||
final List<ZCircleOption<T>> options;
|
||||
final T value;
|
||||
final ValueChanged<T> onChanged;
|
||||
final Color onSurface;
|
||||
final double size;
|
||||
|
||||
const ZSegmentedCircles({
|
||||
super.key,
|
||||
required this.options,
|
||||
required this.value,
|
||||
required this.onChanged,
|
||||
required this.onSurface,
|
||||
this.size = 38,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
for (final o in options)
|
||||
GestureDetector(
|
||||
onTap: () => onChanged(o.value),
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
width: size,
|
||||
height: size,
|
||||
margin: const EdgeInsets.only(left: 6),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: value == o.value ? kZAccent : Colors.transparent,
|
||||
border: Border.all(
|
||||
color: value == o.value
|
||||
? kZAccent
|
||||
: onSurface.withOpacity(0.35),
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
child: Icon(
|
||||
value == o.value ? Icons.check : o.icon,
|
||||
size: size * 0.53,
|
||||
color: value == o.value
|
||||
? Colors.white
|
||||
: onSurface.withOpacity(0.7),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// [ZSegmentedCircles] 的单个选项描述。
|
||||
class ZCircleOption<T> {
|
||||
final T value;
|
||||
final IconData icon;
|
||||
const ZCircleOption({required this.value, required this.icon});
|
||||
}
|
||||
|
||||
/// 小块状态胶囊(在线/离线、下载状态等),比 Chip 更紧凑。
|
||||
class ZBadge extends StatelessWidget {
|
||||
final String label;
|
||||
final Color color;
|
||||
final bool outlined;
|
||||
const ZBadge({
|
||||
super.key,
|
||||
required this.label,
|
||||
required this.color,
|
||||
this.outlined = true,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 9, vertical: 3),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withOpacity(0.13),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: outlined ? Border.all(color: color.withOpacity(0.28)) : null,
|
||||
),
|
||||
child: Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 11.5,
|
||||
height: 1.3,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// ZL2 风格的弹层/列表行:左侧彩色图标块 + 粗标题 + 可选说明 + 右侧控件/箭头。
|
||||
///
|
||||
/// 用于替换旧式 [ListTile](底部弹层、对话框、详情页头部、依赖列表等):
|
||||
/// - [icon] + [iconColor] 决定左侧圆角图标块(默认绿色,危险操作用红色);
|
||||
/// - [subtitleMono] 让说明文字用等宽字体(如命令、文件名);
|
||||
/// - 有 [onTap] 且无 [trailing] 时显示右侧 chevron;[danger] 让标题与图标变红。
|
||||
class ZSheetRow extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final Color? iconColor;
|
||||
final String title;
|
||||
final String? subtitle;
|
||||
final bool subtitleMono;
|
||||
final Widget? trailing;
|
||||
final VoidCallback? onTap;
|
||||
final bool danger;
|
||||
|
||||
const ZSheetRow({
|
||||
super.key,
|
||||
required this.icon,
|
||||
this.iconColor,
|
||||
required this.title,
|
||||
this.subtitle,
|
||||
this.subtitleMono = false,
|
||||
this.trailing,
|
||||
this.onTap,
|
||||
this.danger = false,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
final color = danger ? Colors.red : (iconColor ?? kZAccent);
|
||||
final showChevron = trailing == null && onTap != null;
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 11),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 38,
|
||||
height: 38,
|
||||
decoration: BoxDecoration(
|
||||
color: color.withOpacity(0.13),
|
||||
borderRadius: BorderRadius.circular(11),
|
||||
),
|
||||
child: Icon(icon, size: 20, color: color),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
S.t(title),
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: danger ? Colors.red : scheme.onSurface,
|
||||
),
|
||||
),
|
||||
if (subtitle != null && subtitle!.isNotEmpty) ...[
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
S.t(subtitle!),
|
||||
maxLines: 3,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 12.5,
|
||||
height: 1.35,
|
||||
fontFamily: subtitleMono ? 'monospace' : null,
|
||||
color: scheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
if (trailing != null) ...[
|
||||
const SizedBox(width: 8),
|
||||
trailing!,
|
||||
] else if (showChevron) ...[
|
||||
const SizedBox(width: 4),
|
||||
Icon(Icons.chevron_right, size: 20, color: scheme.onSurfaceVariant),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// ZL2 风格的顶部搜索框(圆角填充、无边框)。
|
||||
class ZSearchField extends StatelessWidget {
|
||||
final TextEditingController controller;
|
||||
final String hint;
|
||||
final ValueChanged<String>? onSubmitted;
|
||||
final ValueChanged<String>? onChanged;
|
||||
final Widget? trailing;
|
||||
|
||||
const ZSearchField({
|
||||
super.key,
|
||||
required this.controller,
|
||||
required this.hint,
|
||||
this.onSubmitted,
|
||||
this.onChanged,
|
||||
this.trailing,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: scheme.surfaceContainerHigh,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.search, size: 20, color: scheme.onSurfaceVariant),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: controller,
|
||||
onSubmitted: onSubmitted,
|
||||
onChanged: onChanged,
|
||||
decoration: InputDecoration(
|
||||
hintText: S.t(hint),
|
||||
border: InputBorder.none,
|
||||
isDense: true,
|
||||
contentPadding: const EdgeInsets.symmetric(vertical: 13),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (trailing != null) trailing!,
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// ZL2 风格的沉浸式 AppBar。
|
||||
///
|
||||
/// 全局 [appBarTheme] 已把底色设为透明,这里再统一处理「前景色」与「状态栏」,
|
||||
/// 避免两类问题:
|
||||
/// 1. 有壁纸时顶栏文字/图标仍是深色 → 看不清;
|
||||
/// 2. 切页时顶栏在「白不透明 ↔ 透明」之间跳变 → 视觉闪烁。
|
||||
///
|
||||
/// 有自定义壁纸时:标题/图标转白、状态栏图标转浅色;无壁纸时跟随主题。
|
||||
/// 接受与 [AppBar] 同名的常用参数,可直接替换页面里的 `AppBar(`,无需改动其余代码。
|
||||
class ZAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
final Widget? title;
|
||||
final String? subtitle;
|
||||
final List<Widget>? actions;
|
||||
final PreferredSizeWidget? bottom;
|
||||
final Widget? leading;
|
||||
final bool automaticallyImplyLeading;
|
||||
final Color? backgroundColor;
|
||||
final Color? foregroundColor;
|
||||
final SystemUiOverlayStyle? systemOverlayStyle;
|
||||
final double? elevation;
|
||||
final double? scrolledUnderElevation;
|
||||
|
||||
const ZAppBar({
|
||||
super.key,
|
||||
this.title,
|
||||
this.subtitle,
|
||||
this.actions,
|
||||
this.bottom,
|
||||
this.leading,
|
||||
this.automaticallyImplyLeading = true,
|
||||
this.backgroundColor,
|
||||
this.foregroundColor,
|
||||
this.systemOverlayStyle,
|
||||
this.elevation,
|
||||
this.scrolledUnderElevation,
|
||||
});
|
||||
|
||||
@override
|
||||
Size get preferredSize =>
|
||||
Size.fromHeight(kToolbarHeight + (bottom?.preferredSize.height ?? 0));
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final hasWallpaper = context.watch<WallpaperProvider>().hasWallpaper;
|
||||
final titleWidget = (subtitle == null || subtitle!.isEmpty)
|
||||
? title
|
||||
: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (title != null) title!,
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
subtitle!,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
height: 1.2,
|
||||
color: hasWallpaper
|
||||
? Colors.white.withOpacity(0.72)
|
||||
: Theme.of(context).hintColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
return AppBar(
|
||||
leading: leading,
|
||||
automaticallyImplyLeading: automaticallyImplyLeading,
|
||||
title: titleWidget,
|
||||
actions: actions,
|
||||
bottom: bottom,
|
||||
elevation: elevation ?? 0,
|
||||
scrolledUnderElevation: scrolledUnderElevation ?? 0,
|
||||
backgroundColor: backgroundColor ?? (hasWallpaper ? Colors.transparent : null),
|
||||
foregroundColor: foregroundColor ?? (hasWallpaper ? Colors.white : null),
|
||||
systemOverlayStyle: systemOverlayStyle ??
|
||||
(hasWallpaper
|
||||
? const SystemUiOverlayStyle(
|
||||
statusBarColor: Colors.transparent,
|
||||
statusBarIconBrightness: Brightness.light,
|
||||
statusBarBrightness: Brightness.dark,
|
||||
)
|
||||
: null),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user