feat(shortcut): ✨ increased mobile compatibility (60%) (#315)
* fix(view): 🐛 修复系统托盘在自动登录时不显示退出问题 优化在其他不需要显示window.$message提示的窗口可禁用 * perf(voice): ⚡ 优化录音组件的样式 * fix(store): 🐛 修复安卓无法获取安全区域问题 * fix(common): 🐛 token 更新bug修复 * feat(mobile): ✨ 新增和优化消息页面布局 * feat(common): ✨ 离线消息同步 * build(system): 📦 修改项目一些样式和图标 修复判断安卓的方法异步问题导致mac release版本页面不加载问题 * build(icon): 📦 更新除了mac系统的图标 * fix(common): 🐛 将数据库迁移 crate 集成到主进程中 * style(common): 💄 修改 tauri 日志配置,输出日志到 logs 目录下;并对日志级别添加颜色; * feat(mobile): ✨ 新增联系人页面 * feat(common): ✨ 引入 tauri-devtools * feat(mobile): ✨ 新增点击加号图标的小弹窗页面 * docs(common): 📝 env文件修改 * fix(router): 🐛 补充提交路由文件,前一次提交缺少更新的路由文件 * fix(common): 🐛 rust 依赖调整;配置调整; * build(config): 📦 修改配置 * fix(common): 🐛 rust .env 文件读取问题修复 * fix(layout): 🐛 修复主页布局漏洞 * build(system): 📦 拉取master的内容 * refactor(view): ♻️ 对接登录参数 * fix(common): 🐛 在线消息保存修复; * fix(common): 🐛 sqlite 保存消息 mark * fix(common): 🐛 消息标记同步问题 * feat(mobile): ✨ 新增通讯录页面内容 * fix(common): 🐛 项目启动之后,还在登录页面时,还会请求房间消息数据等 * fix(common): 🐛 windows启动造成 panic: 去掉 main 的运行时 * fix(common): 🐛 清除缓存,程序卡死 * fix(config): 🐛 更改sqlite configuration配置 修复windows启动控制台打印报错问题 * fix(common): 🐛 修复清除缓存,系统崩溃问题; * fix(common): 🐛 群成员角色判定 bug 修复 * fix(common): 🐛 修复群成员搜索 bug * fix(rust): 🐛 修复字段类型的字节数量 * feat(mobile): ✨ 联系人页面中移植客户端的好友组件 * fix(common): 🐛 修复动态窗口,邮件窗口,AI 插件窗口关闭 bug * fix(common): 🐛 修复会话列表最新消息显示问题 * fix(common): 🐛 左侧功能窗口打开之后,鼠标划上显示问题 * perf(system): ⚡ 适配cloud * perf(centext): ⚡ 优化切换会话时候卡顿问题 修复data.list[0]报错问题 * fix(common): 🐛 重构 Tauri事件的监听器释放逻辑; * refactor(common): ♻️ 重构 Tauri 的事件监听相关代码;增加日志记录; * feat(util): ✨ 新增DOM计算函数,完善社区页面和功能 * refactor(common): ♻️ 重构 useTauriListener * fix(common): 🐛 监听 home 窗口关闭的时候,把 home 窗口隐藏 * perf(ws): ⚡ 移除ws重连次数限制 * fix(common): 🐛 ios 窗口关闭弹窗 bug;修改群屏蔽状态导致消息错乱 bug; * feat(util): ✨ 新增小屏安全区域页面适配,优化多次监听resize导致的性能问题 * fix(common): 🐛 初始化消息发送时的消息状态为发送中 * fix(ios): 🐛 修复rust依赖问题导致ios启动失败 * chore(format): 🔨 使用biome替换eslint * perf(rust): ⚡ 添加超时机制和错误处理优化 优化数据库连接池配置,调整连接参数和日志级别 新增全局超时配置模块 改进 IM 客户端锁机制,避免跨 await 持有锁 增强命令函数错误处理,返回 Result 类型 优化托盘图标创建逻辑,添加默认图标检查 重构应用初始化流程,使用异步任务避免阻塞 * fix(scanner): 🐛 修复存储扫描导致程序崩溃(扫描中关闭未解决) * fix(configuration): 🐛 修复release打包后初始化应用数据失败问题 * perf(rust): ⚡ 优化未处理的unwrap() * fix(hide_notify): 🐛 修复hide_notify事件无限循环导致程序崩溃问题 * fix(voice): 🐛 修复输入框切换录音组件后选择表情包导致错位问题 * fix(view): 🐛 windwos notify和tray导致系统卡死 * fix(style): 🐛 修复样式错乱问题 * fix(common): 🐛 windows 接收消息 打开主窗口卡死 * fix(style): 🐛 修改图标样式 * fix(common): 🐛 windows接收群消息卡死 * build(sqlite): 📦 合并sqlite分支代码 * fix(common): 🐛 mac docker 计数 * fix(common): 🐛 添加macos编译;解决rust警告 * fix(common): 🐛 mac badge 计数 * fix(common): 🐛 修复自动登录问题;修复watch 的异步问题导致的数据竞态问题 * fix(common): 🐛 删除会话功能; * build(ios): 📦 增加移动端所需的配置 * fix(common): 🐛 ios 启动 tauri 插件和命令适配 * fix(common): 🐛 查询消息根据 id 排序时,将 id 转为数值进行排序 * refactor(common): ♻️ 使用 tracing 作为日志框架 * fix(unreadCount): 🐛 修复标记重复问题 * style(lint): 💄 优化了biome的配置 按照新的biome配置格式化代码 * style(biome): 💄 完善biome规则配置 * style(biome): 💄 增加自动移除未使用的导入 * feat(mobile): ✨ 新增“我的”页面内容及动画,修复安全边距问题 * fix(common): 🐛 修改AnnouncementBody类型 * fix(common): 🐛 修改 ApiResult 类型 * feat(mobile): ✨ 新增聊天室页面 * fix(ios): 🐛 添加log依赖 * fix(common): 🐛 去掉 home 窗口的重复监听 * fix(common): 🐛 发送消息接口,用channel 代替 event,解决系统卡死; * fix(common): 🐛 android启动问题 * fix(rust): 🐛 修复ios签名问题 修复ios底部栏不显示问题|移除冗余的权限配置 * refactor(common): ♻️ 将 db.sqlite 设置为resource,通过 tauri api 进行读取 * test(common): ✅ 新增视频通话局部代码 * fix(rust): 🐛 修复移动端无法启动并且无法创建对应文件的问题 * test(common): ✅ 优化通话逻辑 * feat(mobile): ✨ 新增客户端对象,修复加载页载入问题 * chore(common): 🔨 修改 tauri 配置文件 * ci(log): 🎡 修改日志打印的级别和语言都为英文 * feat(mobile): ✨ 新增聊天窗口页面内容 * fix(common): 🐛 notify_cotent事件修改 * feat(mobile): ✨ 新增hula插件 * perf(mobile): ⚡ 优化一些移动端逻辑的判断 * feat(mobile): ✨ 聊天页新增输入法高度适配功能,优化gradle的app构建性能 * feat(mobile): ✨ 新增聊天页面输入框的图标等内容 * feat(common): ✨ 初步实现 webrtc * fix(common): 🐛 发送视频通话请求 * fix(common): 🐛 webrtc实现-待测试 * fix(common): 🐛 webrtc-测试 * build(biome): 📦 升级biome版本 * style(common): 💄 webrtc 页面 ui调整 * build(package): 📦 增加package.json的$schema * build(lint-staged): 📦 更新lint-staged版本 * fix(common): 🐛 rtc 页面头像显示 * fix(common): 🐛 rtc 第一次切换摄像头未显示远程 * fix(common): 🐛 webrtc 挂断 * fix(common): 🐛 rtc 通话结束 * fix(common): 🐛 ws监听挂断消息 * fix(common): 🐛 rtc 设备检查 * fix(common): 🐛 检查audiooutput * fix(common): 🐛 检查音量来判断用户是否开启 audio * fix(common): 🐛 检查音量判断声音设备 * fix(agreement): 🐛 前端对接cloud的刷新token * feat(mobile): ✨ 新增postcss-px-to-viewport库用于转换px变量 * fix(common): 🐛 重构 webrtc * feat(build): ✨ 新增打包命令交互式终端 * fix(common): 🐛 webrtc 异常 * fix(common): 🐛 rtc 异常 * fix(common): 🐛 rtc candidate * fix(common): 🐛 通知窗口 * fix(common): 🐛 rtc 通话时间显示 * fix(common): 🐛 关闭扬声器功能 * fix(common): 🐛 关闭麦克风 * fix(common): 🐛 win 通知窗口显示问题 * fix(common): 🐛 rtc调整设置通知通知栏的高度 * feat(mobile): ✨ 新增AutoFixHeightPage页,用于适配移动端动态高度布局;新增聊天室页面内容 * feat(common): ✨ 新增处理进群审核接口、音视频处理约定逻辑 * fix(common): 🐛 前端刷新 token 之后调用 command 更新 rust 部分的 token * fix(common): 🐛 显示视频通话消息 * fix(common): 🐛 webrtc 语音通话调用 * feat(mobile): ✨ 初步实现聊天室页面列表 * fix(common): 🐛 查询所有会话 bug * build(build): 📦 升级一些依赖版本 * refactor(common): ♻️ rust 重构ws * style(avatar): 💄 优化头像加载失败时候展示的图片 * fix(common): 🐛 rust ws * fix(common): 🐛 修复群聊状态显示、同步后端打电话逻辑 * fix(common): 🐛 查询群成员报错 异步问题 * fix(common): 🐛 群成员 异步问题 * refactor(common): ♻️ rust 异常处理 * fix(common): 🐛 消息 骨架屏 异常 * fix(common): 🐛 删除无用代码 * fix(common): 🐛 win 图标闪烁问题 * fix(common): 🐛 ws 保活 * feat(mobile): ✨ 新增聊天室的聊天列表,修复websocket连接的移动端适配问题 * feat(ChatFooter): ✨ 增加输入框和ChatFooter组件的拖拽效果 优化私聊在线状态 * fix(common): 🐛 webrtc 切换视频关闭远程视频流 * fix(common): 🐛 message mark issue resolve * fix(common): 🐛 message mark issue resolve * refactor(common): ♻️ delete useless code * fix(common): 🐛 save_room_member_batch cause database lock * fix(common): 🐛 show the system messgage of join group * fix(common): 🐛 message sound * feat(mobile): ✨ add group settings page * build(img): 📦 压缩一些图片为webp 修改一下代码的逻辑 * perf(global): ⚡ 优化群成员排序、输入框发送事件为form表单的提交事件 优化chatfooter输入框高度拖拽和home窗口拖拽时性能问题 优化home窗口拖拽会持续触发当前会话选中后对应房间已读触发问题 * chore(lint): 🔨 优化lint的配置 * perf(rtcCall): ⚡ 优化通话窗口的样式和关闭窗口会挂断的功能 * chore(system): 🔨 合并cloud分支 * fix(common): 🐛 ws reconnect in backend reboot * fix(common): 🐛 webrtc relate message show * fix(common): 🐛 ws delete useless code * fix(common): 🐛 resolve ws multi connection * docs(config): 📝 更新群二维码和赞助榜 * fix(mobile): 🐛 fix loading page images and Android startup issue from init.rs builder * fix(common): 🐛 ws setAppBackGroundState * fix(common): 🐛 env config modify * fix(common): 🐛 webrtc on CANCEL * fix(common): 🐛 group announcement update * fix(common): 🐛 announcement issuce * fix(common): 🐛 webrtc windows dragable * feat(mobile): ✨ add notice page * fix(system): 🐛 fix location of call component and some page styles * fix(common): 🐛 webrtc issue * ci(common): 🎡 .env.dev modify * fix(common): 🐛 gET_ROOM_MEMBERS command issue * fix(common): 🐛 update my group info * feat(mobile): ✨ added page for editing group announcements * fix(common): 🐛 webrtc audio call issue * fix(common): 🐛 webrtc video or audio status switch issue * fix(group): 🐛 fixed some logic and restrictions on inviting members into groups Optimize Create Script * style(style): 💄 remove some styles and comments * fix(common): 🐛 fix WebRTC audio cannot be heard * fix(common): 🐛 info import error * fix(common): 🐛 fix #ICT1BO group info update * fix(common): 🐛 fix "不是好友关系" issue * feat(mobile): ✨ add 'Profile' related pages * fix(common): 🐛 add group apply list * feat(mobile): ✨ add page for creating new posts * fix(common): 🐛 webrtc if can't acquire device then hang up * fix(common): 🐛 mute local video ele * fix(common): 🐛 同步最新申请接口 * fix(common): 🐛 change isSpeakerOn and mute the bell * feat(mobile): ✨ add 'My Messages' page * fix(common): 🐛 group apply invite dom * style(style): 💄 change the style of language statistics and incoming call notifications * fix(rtc): 🐛 fix some problems when rtc dialed optimize some styles and icons of rtc window * perf(rtc): ⚡ optimize rtc window display on mac * feat(shortcut): ✨ add global shortcut management functionality Integrated global shortcut plugin to enable customizable keyboard shortcuts * build(biome): 📦 update biome * perf(shortcut): ⚡ optimize shortcut key functions * perf(screenshot): ⚡ optimize screenshot function * perf(style): ⚡ optimize.gitattributes configuration * fix(common): 🐛 handle friend and group invite * fix(screenshot): 🐛 fix drawing not cleared and option group logic issues * fix(common): 🐛 disconnect ws when logout * fix(common): 🐛 group invite api * fix(mac): 🐛 fix screenshot black screen issue on mac * fix(common): 🐛 connect to Qiniu Cloud, use the current room when requesting a session * fix(common): 🐛 src-tauri .env config * fix(mobile): 🐛 fix issue preventing Android from starting properly * fix(config): 🐛 fix some startup and styling issues caused by configuration --------- Co-authored-by: 卡仔 <1271013637@qq.com> Co-authored-by: wanwanruwoxin <254693270@qq.com> Co-authored-by: 乾乾 <1046762075@qq.com>
This commit is contained in:
411
scripts/interactive-build-inquirer.js
vendored
Normal file
411
scripts/interactive-build-inquirer.js
vendored
Normal file
@@ -0,0 +1,411 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { select } from '@inquirer/prompts'
|
||||
import { spawn } from 'child_process'
|
||||
import os from 'os'
|
||||
|
||||
// 检测当前平台
|
||||
function getCurrentPlatform() {
|
||||
const platform = os.platform()
|
||||
switch (platform) {
|
||||
case 'darwin':
|
||||
return { platform: 'macos', name: 'macOS' }
|
||||
case 'win32':
|
||||
return { platform: 'windows', name: 'Windows' }
|
||||
case 'linux':
|
||||
return { platform: 'linux', name: 'Linux' }
|
||||
default:
|
||||
return { platform: 'unknown', name: '未知平台' }
|
||||
}
|
||||
}
|
||||
|
||||
// 获取平台选择选项
|
||||
function getPlatformOptions() {
|
||||
const currentPlatform = getCurrentPlatform()
|
||||
|
||||
// 根据当前操作系统定义支持的平台
|
||||
const supportedPlatforms = {
|
||||
macos: ['macos', 'ios', 'android'], // macOS 可以打包 macOS、iOS、Android
|
||||
windows: ['windows', 'android'], // Windows 可以打包 Windows、Android
|
||||
linux: ['linux', 'android'] // Linux 可以打包 Linux、Android
|
||||
}
|
||||
|
||||
const allPlatforms = [
|
||||
{
|
||||
name: `MacOS${currentPlatform.platform === 'macos' ? ' (当前平台)' : ''}`,
|
||||
value: 'macos',
|
||||
description: '打包 macOS 应用',
|
||||
isCurrent: currentPlatform.platform === 'macos'
|
||||
},
|
||||
{
|
||||
name: `Windows${currentPlatform.platform === 'windows' ? ' (当前平台)' : ''}`,
|
||||
value: 'windows',
|
||||
description: '打包 Windows 应用',
|
||||
isCurrent: currentPlatform.platform === 'windows'
|
||||
},
|
||||
{
|
||||
name: `Linux${currentPlatform.platform === 'linux' ? ' (当前平台)' : ''}`,
|
||||
value: 'linux',
|
||||
description: '打包 Linux 应用',
|
||||
isCurrent: currentPlatform.platform === 'linux'
|
||||
},
|
||||
{
|
||||
name: 'Android',
|
||||
value: 'android',
|
||||
description: '打包 Android APK',
|
||||
isCurrent: false
|
||||
},
|
||||
{
|
||||
name: 'IOS',
|
||||
value: 'ios',
|
||||
description: '打包 IOS 应用',
|
||||
isCurrent: false
|
||||
},
|
||||
{
|
||||
name: '取消',
|
||||
value: 'cancel',
|
||||
description: '退出打包',
|
||||
isCurrent: false
|
||||
}
|
||||
]
|
||||
|
||||
// 获取当前系统支持的平台列表
|
||||
const supported = supportedPlatforms[currentPlatform.platform] || []
|
||||
|
||||
// 过滤出支持的平台,保留取消选项
|
||||
const platforms = allPlatforms.filter((platform) => supported.includes(platform.value) || platform.value === 'cancel')
|
||||
|
||||
// 将当前平台排在第一位
|
||||
return platforms.sort((a, b) => {
|
||||
if (a.isCurrent && !b.isCurrent) return -1
|
||||
if (!a.isCurrent && b.isCurrent) return 1
|
||||
return 0
|
||||
})
|
||||
}
|
||||
|
||||
// 获取包格式选项
|
||||
function getBundleOptions(platform) {
|
||||
switch (platform) {
|
||||
case 'macos':
|
||||
return [
|
||||
{
|
||||
name: '📦 dmg 磁盘映像',
|
||||
value: 'dmg',
|
||||
description: '生成 .dmg 安装包 (推荐)',
|
||||
command: 'tauri build --bundles dmg'
|
||||
},
|
||||
{
|
||||
name: '📁 app 应用包',
|
||||
value: 'app',
|
||||
description: '生成 .app 应用包',
|
||||
command: 'tauri build --bundles app'
|
||||
},
|
||||
{
|
||||
name: '📦 全部格式',
|
||||
value: 'all',
|
||||
description: '生成所有支持的格式 (.app, .dmg)',
|
||||
command: 'tauri build'
|
||||
},
|
||||
{
|
||||
name: '🔙 返回上一步',
|
||||
value: 'back',
|
||||
description: '返回平台选择',
|
||||
command: null
|
||||
}
|
||||
]
|
||||
|
||||
case 'windows':
|
||||
return [
|
||||
{
|
||||
name: '📦 msi 安装包',
|
||||
value: 'msi',
|
||||
description: '生成 .msi 安装包 (推荐)',
|
||||
command: 'tauri build --bundles msi'
|
||||
},
|
||||
{
|
||||
name: '📁 exe 可执行文件',
|
||||
value: 'exe',
|
||||
description: '生成 .exe 可执行文件',
|
||||
command: 'tauri build --bundles exe'
|
||||
},
|
||||
{
|
||||
name: '📦 nsis 安装程序',
|
||||
value: 'nsis',
|
||||
description: '生成 NSIS 安装程序',
|
||||
command: 'tauri build --bundles nsis'
|
||||
},
|
||||
{
|
||||
name: '📦 全部格式',
|
||||
value: 'all',
|
||||
description: '生成所有支持的格式',
|
||||
command: 'tauri build --target x86_64-pc-windows-msvc'
|
||||
},
|
||||
{
|
||||
name: '🔙 返回上一步',
|
||||
value: 'back',
|
||||
description: '返回平台选择',
|
||||
command: null
|
||||
}
|
||||
]
|
||||
|
||||
case 'linux':
|
||||
return [
|
||||
{
|
||||
name: '📦 deb 软件包',
|
||||
value: 'deb',
|
||||
description: '生成 .deb 软件包 (Ubuntu/Debian)',
|
||||
command: 'tauri build --bundles deb'
|
||||
},
|
||||
{
|
||||
name: '📁 AppImage',
|
||||
value: 'appimage',
|
||||
description: '生成 .AppImage 便携应用',
|
||||
command: 'tauri build --bundles appimage'
|
||||
},
|
||||
{
|
||||
name: '📦 rpm 软件包',
|
||||
value: 'rpm',
|
||||
description: '生成 .rpm 软件包 (RedHat/CentOS)',
|
||||
command: 'tauri build --bundles rpm'
|
||||
},
|
||||
{
|
||||
name: '📦 全部格式',
|
||||
value: 'all',
|
||||
description: '生成所有支持的格式',
|
||||
command: 'tauri build --target x86_64-unknown-linux-gnu'
|
||||
},
|
||||
{
|
||||
name: '🔙 返回上一步',
|
||||
value: 'back',
|
||||
description: '返回平台选择',
|
||||
command: null
|
||||
}
|
||||
]
|
||||
|
||||
case 'android':
|
||||
return [
|
||||
{
|
||||
name: '📱 apk 安装包',
|
||||
value: 'apk',
|
||||
description: '生成 Android APK 安装包',
|
||||
command: 'tauri android build'
|
||||
},
|
||||
{
|
||||
name: '📱 aab 应用包',
|
||||
value: 'aab',
|
||||
description: '生成 Android App Bundle (Google Play)',
|
||||
command: 'tauri android build --aab'
|
||||
},
|
||||
{
|
||||
name: '🔙 返回上一步',
|
||||
value: 'back',
|
||||
description: '返回平台选择',
|
||||
command: null
|
||||
}
|
||||
]
|
||||
|
||||
case 'ios':
|
||||
return [
|
||||
{
|
||||
name: '📱 IOS 应用',
|
||||
value: 'ios',
|
||||
description: '生成 IOS 应用包',
|
||||
command: 'tauri ios build'
|
||||
},
|
||||
{
|
||||
name: '🔙 返回上一步',
|
||||
value: 'back',
|
||||
description: '返回平台选择',
|
||||
command: null
|
||||
}
|
||||
]
|
||||
|
||||
default:
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
// 获取调试模式选项
|
||||
function getDebugOptions() {
|
||||
return [
|
||||
{
|
||||
name: '🚀 正式版本',
|
||||
value: 'release',
|
||||
description: '生成正式版本',
|
||||
isDebug: false
|
||||
},
|
||||
{
|
||||
name: '🔧 调试版本',
|
||||
value: 'debug',
|
||||
description: '生成调试版本 (可弹出控制台)',
|
||||
isDebug: true
|
||||
},
|
||||
{
|
||||
name: '🔙 返回上一步',
|
||||
value: 'back',
|
||||
description: '返回包格式选择',
|
||||
isDebug: null
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
// 执行打包命令
|
||||
async function executeBuild(command, description, isDebug = false) {
|
||||
// 如果是调试模式,添加 --debug 参数
|
||||
const finalCommand = isDebug ? `${command} --debug` : command
|
||||
const [cmd, ...args] = finalCommand.split(' ')
|
||||
const child = spawn(cmd, args, {
|
||||
stdio: 'inherit',
|
||||
shell: true
|
||||
})
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
child.on('close', (code) => {
|
||||
if (code === 0) {
|
||||
console.log('\n🎉 打包完成')
|
||||
resolve(code)
|
||||
} else {
|
||||
console.log(`\n❌ 打包失败,退出代码: ${code}`)
|
||||
resolve(code)
|
||||
}
|
||||
})
|
||||
|
||||
child.on('error', (error) => {
|
||||
console.error(`\n❌ 执行错误: ${error.message}`)
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// 选择平台的函数
|
||||
async function selectPlatform() {
|
||||
const platformOptions = getPlatformOptions()
|
||||
|
||||
const selectedPlatform = await select({
|
||||
message: '请选择要打包的平台:',
|
||||
choices: platformOptions.map((option) => ({
|
||||
name: option.name,
|
||||
value: option.value,
|
||||
description: `\x1b[90m${option.description}\x1b[0m`
|
||||
})),
|
||||
pageSize: 8,
|
||||
loop: false
|
||||
})
|
||||
|
||||
if (selectedPlatform === 'cancel') {
|
||||
console.log('\n👋 已取消打包')
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
return { selectedPlatform, platformOptions }
|
||||
}
|
||||
|
||||
// 选择调试模式的函数
|
||||
async function selectDebugMode() {
|
||||
const debugOptions = getDebugOptions()
|
||||
|
||||
const selectedDebug = await select({
|
||||
message: '第三步:请选择版本类型:',
|
||||
choices: debugOptions.map((option) => ({
|
||||
name: option.name,
|
||||
value: option.value,
|
||||
description: `\x1b[90m${option.description}\x1b[0m`
|
||||
})),
|
||||
pageSize: 4,
|
||||
loop: false
|
||||
})
|
||||
|
||||
if (selectedDebug === 'back') {
|
||||
return 'back'
|
||||
}
|
||||
|
||||
const selectedOption = debugOptions.find((option) => option.value === selectedDebug)
|
||||
return selectedOption.isDebug
|
||||
}
|
||||
|
||||
// 选择包格式的函数
|
||||
async function selectBundle(selectedPlatform, platformOptions) {
|
||||
const bundleOptions = getBundleOptions(selectedPlatform)
|
||||
|
||||
if (bundleOptions.length === 0) {
|
||||
console.log('\n❌ 该平台暂不支持')
|
||||
return 'back' // 返回平台选择
|
||||
}
|
||||
|
||||
const selectedBundle = await select({
|
||||
message: `请选择${selectedPlatform}的打包格式:`,
|
||||
choices: bundleOptions.map((option) => ({
|
||||
name: option.name,
|
||||
value: option.value,
|
||||
description: `\x1b[90m${option.description}\x1b[0m`
|
||||
})),
|
||||
pageSize: 6,
|
||||
loop: false
|
||||
})
|
||||
|
||||
if (selectedBundle === 'back') {
|
||||
return 'back' // 返回上一步
|
||||
}
|
||||
|
||||
// 找到选中的选项
|
||||
const selectedOption = bundleOptions.find((option) => option.value === selectedBundle)
|
||||
|
||||
if (!selectedOption || !selectedOption.command) {
|
||||
console.log('\n👋 已取消打包操作')
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
return selectedOption
|
||||
}
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
const currentPlatform = getCurrentPlatform()
|
||||
|
||||
// 主循环
|
||||
while (true) {
|
||||
// 第一步:选择平台
|
||||
const { selectedPlatform, platformOptions } = await selectPlatform()
|
||||
|
||||
// 第二步:选择包格式
|
||||
while (true) {
|
||||
const bundleResult = await selectBundle(selectedPlatform, platformOptions)
|
||||
|
||||
// 如果返回 'back',返回平台选择
|
||||
if (bundleResult === 'back') {
|
||||
break
|
||||
}
|
||||
|
||||
// 第三步:选择调试模式
|
||||
while (true) {
|
||||
const debugResult = await selectDebugMode()
|
||||
|
||||
// 如果返回 'back',返回包格式选择
|
||||
if (debugResult === 'back') {
|
||||
break
|
||||
}
|
||||
|
||||
// 执行打包命令
|
||||
try {
|
||||
const exitCode = await executeBuild(bundleResult.command, bundleResult.name, debugResult)
|
||||
process.exit(exitCode)
|
||||
} catch (error) {
|
||||
console.error(`\n❌ 执行错误: ${error.message}`)
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
if (error.name === 'ExitPromptError') {
|
||||
// 用户按了 Ctrl+C
|
||||
console.log('\n👋 已取消操作')
|
||||
process.exit(0)
|
||||
} else {
|
||||
console.error('发生错误:', error)
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
||||
Reference in New Issue
Block a user