优化版本更新操作

pull/1168/head
lyswhut 2023-01-31 17:48:38 +08:00
parent c24b29a42c
commit 6b69cdf12f
22 changed files with 553 additions and 185 deletions

View File

@ -1,10 +1,13 @@
### 新增
- 新增桌面歌词设置字体加粗设置,可以到设置-桌面歌词设置-加粗字体修改
- 新增是否自动下载更新设置,默认开启,可以去设置-软件更新更改
- 新增当前版本更新日志显示弹窗(建议大家阅读更新日志以了解当前版本的变化),在更新版本后将自动弹出
### 优化
- 微调了桌面歌词逐行字体阴影,使其看起来更匀称
- 优化更新弹窗内容的显示,添加了自动更新失败时的更新指引
### 修复

File diff suppressed because one or more lines are too long

View File

@ -38,6 +38,8 @@ export const DATA_KEYS = {
leaderboardSetting: 'leaderboardSetting',
songListSetting: 'songListSetting',
searchSetting: 'searchSetting',
lastLastStartInfo: 'lastLastStartInfo',
} as const
export const DEFAULT_SETTING = {

View File

@ -16,6 +16,7 @@ const defaultSetting: LX.AppSetting = {
'common.isAgreePact': false,
'common.controlBtnPosition': process.platform === 'darwin' ? 'left' : 'right',
'common.playBarProgressStyle': 'mini',
'common.tryAutoUpdate': true,
'player.startupAutoPlay': false,
'player.togglePlayMethod': 'listLoop',

View File

@ -55,6 +55,7 @@ const modules = {
change_tray: 'change_tray',
quit_update: 'quit_update',
update_check: 'update_check',
update_download_update: 'update_download_update',
update_available: 'update_available',
update_error: 'update_error',
update_progress: 'update_progress',

View File

@ -68,6 +68,11 @@ declare global {
*/
'common.playBarProgressStyle': 'mini' | 'full' | 'middle'
/**
*
*/
'common.tryAutoUpdate': boolean
/**
*
*/

View File

@ -102,6 +102,7 @@ declare namespace LX {
prev: boolean
}
type UpdateStatus = 'downloaded' | 'downloading' | 'error' | 'checking' | 'idle'
interface VersionInfo {
version: string
desc: string

View File

@ -464,8 +464,10 @@
"setting__update_init": "Processing update...",
"setting__update_latest": "The software is up-to-date, enjoy yourself!🥂",
"setting__update_latest_label": "Latest version: ",
"setting__update_open_version_modal_btn": "Open the update window🚀",
"setting__update_progress": "Download progress: ",
"setting__update_new_version": "Found a new version, hurry up and update~🚀🚀",
"setting__update_open_version_modal_btn": "open update window",
"setting__update_progress": "state:",
"setting__update_try_auto_update": "Attempt to download updates automatically when a new version is found",
"setting__update_unknown": "Unknown",
"song_list": "Playlists",
"songlist__import_input_btn_confirm": "Open",
@ -569,6 +571,14 @@
"theme_selector_modal__title_tip": "Note: You can set a light theme and a dark theme in advance, and then it will automatically switch to the corresponding theme you set in advance according to the light and dark theme colors of the system.",
"toggle_source_failed": "Failed to change the source, please try to manually search for the song in other sources to play",
"toggle_source_try": "Try switching to another source...",
"update__downgrade_tip": "We found that you have downgraded the version ({ver}). If you encounter problems when using the new version, please try to read the FAQ first. If the problem you encounter is not recorded in the FAQ or cannot be solved, you can refer to \nGo to the feedback channel to give us feedback 😘!\nNote: When downgrading from the new version to the old version, it is recommended to back up the playlist first. If there is an exception, it can be solved by cleaning the data. The data directory path document has records.",
"update__error_top": "The automatic download of the new version failed, you can try to download the update again or manually download the update,\nThe address of the new version is written under the update pop-up window. Download the new version and overwrite the installation directly. If the installation fails, see FAQs.\nNote: Currently only the Windows installation version can be automatically updated (Linux AppImage, deb version seems to be also available, not tested), other versions please download and update manually!",
"update__ignore_cancel": "I don't want to update 🤨",
"update__ignore_confirm": "Ok, let's update it ❤️",
"update__ignore_confirm_tip": "At present, only the Windows installation version can be automatically updated (Linux AppImage, deb version seems to be also available, not tested), other versions please download and update manually,\nThe address of the new version is written under the update pop-up window. Download the new version and overwrite the installation directly. If the installation fails, see FAQ.",
"update__ignore_confirm_tip_confirm": "OK understood",
"update__ignore_tip": "The version you are using now is behind the latest version by {num} versions🤪, for a better user experience, it is recommended to update to the latest version~!\nNote: If you encounter problems when using the new version, please try to read the FAQ first. If the problem you encounter is not recorded in the FAQ or cannot be solved, you can give us feedback through the feedback channels mentioned in the document 😘!",
"update__timeout_top": "Download time is too long prompt\n\nYour current network access to GitHub is slow, and the new version has been downloaded for an hour and has not been completed yet😳, you can still choose to continue waiting, but the wall crack recommends manually updating the version!",
"user_api__allow_show_update_alert": "Allow update popup to show",
"user_api__btn_export": "Export",
"user_api__btn_import": "Import",

View File

@ -466,8 +466,10 @@
"setting__update_init": "处理更新中...",
"setting__update_latest": "软件已是最新,尽情地体验吧~🥂",
"setting__update_latest_label": "最新版本:",
"setting__update_open_version_modal_btn": "打开更新窗口 🚀",
"setting__update_progress": "下载进度:",
"setting__update_new_version": "发现新版本,赶快去更新吧~🚀🚀",
"setting__update_open_version_modal_btn": "打开更新窗口",
"setting__update_progress": "状态:",
"setting__update_try_auto_update": "发现新版本时尝试自动下载更新",
"setting__update_unknown": "未知",
"song_list": "歌单",
"songlist__import_input_btn_confirm": "打开",
@ -571,6 +573,14 @@
"theme_selector_modal__title_tip": "注:你可以预先设置一个亮色主题及暗色主题,此后将根据系统的亮、暗主题色自动切换为你预先设置的相应主题。",
"toggle_source_failed": "换源失败,请尝试手动在其他源搜索该歌曲播放",
"toggle_source_try": "尝试切换到其他源...",
"update__downgrade_tip": "我们发现你降级了版本({ver}),若使用新版本时遇到问题,请先尝试阅读常见问题解决,若你遇到的问题在常见问题中未记录或无法解决,可以通过文档中提到的反馈渠道给我们反馈😘!\n注意从新版本降级旧版时建议先备份歌单若出现异常则可通过清理数据解决数据目录路径文档有记录。",
"update__error_top": "自动下载新版本失败,你可以尝试重新下载更新或者手动去下载更新,\n新版地址在更新弹窗下面有写下载新版直接覆盖安装即可若安装失败则看常见问题解决\n注意目前只有Windows安装版可以自动更新Linux的AppImage、deb版似乎也可以未测试其他版本请手动下载更新",
"update__ignore_cancel": "我就不想更新🤨",
"update__ignore_confirm": "好 去更新看看❤️",
"update__ignore_confirm_tip": "目前只有Windows安装版可以自动更新Linux的AppImage、deb版似乎也可以未测试其他版本请手动下载更新\n新版地址在更新弹窗下面有写下载新版直接覆盖安装即可若安装失败看常见问题解决。",
"update__ignore_confirm_tip_confirm": "OK 已了解",
"update__ignore_tip": "你现在使用的版本距离最新版本已经落后了 {num} 个版本🤪,为了更好的使用体验,建议更新到最新版本哦~\n注若使用新版本时遇到问题请先尝试阅读常见问题解决若你遇到的问题在常见问题中未记录或无法解决可以通过文档中提到的反馈渠道给我们反馈😘",
"update__timeout_top": "下载时间过长提示\n\n你当前所在网络访问GitHub较慢新版本已经下了一个钟了还没完成😳你仍可选择继续等但墙裂建议手动更新版本",
"user_api__allow_show_update_alert": "允许显示更新弹窗",
"user_api__btn_export": "导出",
"user_api__btn_import": "导入",

View File

@ -465,8 +465,10 @@
"setting__update_init": "處理更新中...",
"setting__update_latest": "軟件已是最新,盡情地體驗吧~🥂",
"setting__update_latest_label": "最新版本:",
"setting__update_open_version_modal_btn": "打開更新窗口 🚀",
"setting__update_progress": "下載進度:",
"setting__update_new_version": "發現新版本,趕快去更新吧~🚀🚀",
"setting__update_open_version_modal_btn": "打開更新窗口",
"setting__update_progress": "狀態:",
"setting__update_try_auto_update": "發現新版本時嘗試自動下載更新",
"setting__update_unknown": "未知",
"song_list": "歌單",
"songlist__import_input_show_btn": "打開歌單",
@ -569,6 +571,14 @@
"theme_selector_modal__title_tip": "注:你可以預先設置一個亮色主題及暗色主題,此後將根據系統的亮、暗主題色自動切換為你預先設置的相應主題。",
"toggle_source_failed": "換源失敗,請嘗試手動在其他源搜索該歌曲播放",
"toggle_source_try": "嘗試切換到其他源...",
"update__downgrade_tip": "我們發現你降級了版本({ver}),若使用新版本時遇到問題,請先嘗試閱讀常見問題解決,若你遇到的問題在常見問題中未記錄或無法解決,可以通過文檔中提到的反饋渠道給我們反饋😘!\n注意從新版本降級舊版時建議先備份歌單若出現異常則可通過清理數據解決數據目錄路徑文檔有記錄。",
"update__error_top": "自動下載新版本失敗,你可以嘗試重新下載更新或者手動去下載更新,\n新版地址在更新彈窗下面有寫下載新版直接覆蓋安裝即可若安裝失敗則看常見問題解決\n注意目前只有Windows安裝版可以自動更新Linux的AppImage、deb版似乎也可以未測試其他版本請手動下載更新",
"update__ignore_cancel": "我就不想更新🤨",
"update__ignore_confirm": "好 去更新看看❤️",
"update__ignore_confirm_tip": "目前只有Windows安裝版可以自動更新Linux的AppImage、deb版似乎也可以未測試其他版本請手動下載更新\n新版地址在更新彈窗下面有寫下載新版直接覆蓋安裝即可若安裝失敗看常見問題解決。",
"update__ignore_confirm_tip_confirm": "OK 已了解",
"update__ignore_tip": "你現在使用的版本距離最新版本已經落後了 {num} 個版本🤪,為了更好的使用體驗,建議更新到最新版本哦~\n注若使用新版本時遇到問題請先嘗試閱讀常見問題解決若你遇到的問題在常見問題中未記錄或無法解決可以通過文檔中提到的反饋渠道給我們反饋😘",
"update__timeout_top": "下載時間過長提示\n\n你當前所在網絡訪問GitHub較慢新版本已經下了一個鐘了還沒完成😳你仍可選擇繼續等但牆裂建議手動更新版本",
"user_api__allow_show_update_alert": "允許顯示更新彈窗",
"user_api__btn_export": "導出",
"user_api__btn_import": "導入",

View File

@ -5,9 +5,11 @@ import { isExistWindow, sendEvent } from './index'
import { WIN_MAIN_RENDERER_EVENT_NAME } from '@common/ipcNames'
autoUpdater.logger = log
autoUpdater.autoDownload = false
// autoUpdater.forceDevUpdateConfig = true
// autoUpdater.autoDownload = false
let isFirstCheckedUpdate = true
// let isFirstCheckedUpdate = true
log.info('App starting...')
@ -65,14 +67,12 @@ interface WaitEvent {
info: any
}
let waitEvent: WaitEvent[] = []
// let waitEvent: WaitEvent[] = []
const handleSendEvent = (action: WaitEvent) => {
if (isExistWindow()) {
setTimeout(() => { // 延迟发送事件,过早发送可能渲染进程还没启动完成
sendEvent(action.type, action.info)
}, 2000)
} else {
waitEvent.push(action)
}, 1000)
}
}
@ -105,9 +105,15 @@ export default () => {
})
mainOn(WIN_MAIN_RENDERER_EVENT_NAME.update_check, () => {
console.log('check')
checkUpdate()
})
mainOn(WIN_MAIN_RENDERER_EVENT_NAME.update_download_update, () => {
if (!autoUpdater.isUpdaterActive()) return
void autoUpdater.downloadUpdate()
})
mainOn(WIN_MAIN_RENDERER_EVENT_NAME.quit_update, () => {
global.lx.isSkipTrayQuit = true
@ -117,24 +123,25 @@ export default () => {
})
}
export const checkUpdate = () => {
if (!isFirstCheckedUpdate) {
if (waitEvent.length) {
waitEvent.forEach((event, index) => {
setTimeout(() => { // 延迟发送事件,过早发送可能渲染进程还没启动完成
sendEvent(event.type, event.info)
}, 2000 * (index + 1))
})
waitEvent = []
}
return
}
isFirstCheckedUpdate = false
const checkUpdate = () => {
// if (!isFirstCheckedUpdate) {
// if (waitEvent.length) {
// waitEvent.forEach((event, index) => {
// setTimeout(() => { // 延迟发送事件,过早发送可能渲染进程还没启动完成
// sendEvent(event.type, event.info)
// }, 2000 * (index + 1))
// })
// waitEvent = []
// }
// return
// }
// isFirstCheckedUpdate = false
// 由于集合安装包中不包含win arm版这将会导致arm版更新失败
if (isWin && process.arch.includes('arm')) {
handleSendEvent({ type: WIN_MAIN_RENDERER_EVENT_NAME.update_error, info: 'failed' })
} else {
autoUpdater.autoDownload = global.lx.appSetting['common.tryAutoUpdate']
void autoUpdater.checkForUpdates()
}
}

View File

@ -7,7 +7,8 @@
<layout-play-bar id="player" />
</div>
<layout-icons />
<layout-version-modal />
<layout-change-log-modal />
<layout-update-modal />
<layout-pact-modal />
<layout-sync-mode-modal />
<layout-play-detail />

View File

@ -0,0 +1,200 @@
<template lang="pug">
material-modal(:show="isShowChangeLog" @close="isShowChangeLog = false" max-width="60%")
main(:class="$style.main")
h2 当前版本更新日志
div.scroll.select(:class="$style.info")
div(:class="$style.current")
h3 当前版本{{versionInfo.version}}
template(v-if="info.desc")
h3 版本变化
pre(:class="$style.desc" v-text="info.desc")
div(:class="[$style.history, $style.desc]" v-if="info.history.length")
h3 历史版本
div(:class="$style.item" v-for="ver in info.history")
h4 v{{ver.version}}
pre(v-text="ver.desc")
div(:class="$style.footer")
div(:class="$style.desc")
p 📢&nbsp;为了减少疑问我们墙裂建议阅读版本更新日志来了解当前所用版本的变化
p 📢&nbsp;若遇到问题可以去设置-关于查看常见问题
p(v-if="!info.isLatest") 🚀&nbsp;发现新版本v{{versionInfo.newVersion.version}}建议 去设置-软件更新 更新新版本
</template>
<script>
import { compareVer } from '@common/utils'
import { versionInfo, isShowChangeLog } from '@renderer/store'
import { getLastStartInfo } from '@renderer/utils/ipc'
import { computed, ref } from '@common/utils/vueTools'
export default {
setup() {
const lastStartVersion = ref(null)
getLastStartInfo().then(version => {
lastStartVersion.value = version
})
const info = computed(() => {
let currentVer = process.versions.app
let lastStartVer = lastStartVersion.value
let info = {
version: '',
desc: '',
history: [],
isLatest: true,
}
if (!versionInfo.newVersion || !versionInfo.newVersion?.history) return info
info.isLatest = compareVer(currentVer, versionInfo.newVersion.version) >= 0
for (const ver of versionInfo.newVersion.history) {
switch (compareVer(ver.version, currentVer)) {
case 0:
info.version = ver.version
info.desc = ver.desc
break
case -1:
if (lastStartVer && compareVer(lastStartVer, ver.version) < 0) info.history.push(ver)
}
}
if (!info.version) {
if (currentVer == versionInfo.newVersion.version) {
info.version = versionInfo.newVersion.version
info.desc = versionInfo.newVersion.desc
}
}
return info
})
return {
versionInfo,
info,
isShowChangeLog,
}
},
}
</script>
<style lang="less" module>
@import '@renderer/assets/styles/layout.less';
.main {
position: relative;
padding: 15px 0;
// max-width: 450px;
min-width: 300px;
display: flex;
flex-flow: column nowrap;
justify-content: center;
overflow: hidden;
// overflow-y: auto;
* {
box-sizing: border-box;
}
h2 {
flex: 0 0 none;
font-size: 16px;
color: var(--color-font);
line-height: 1.3;
text-align: center;
margin-bottom: 15px;
}
h3 {
font-size: 14px;
line-height: 1.3;
}
pre {
white-space: pre-wrap;
text-align: justify;
margin-top: 10px;
}
}
.info {
flex: 1 1 auto;
font-size: 14px;
line-height: 1.5;
overflow-y: auto;
height: 100%;
padding: 0 15px;
}
.current {
> p {
padding-left: 15px;
}
}
.desc {
h3, h4 {
font-weight: bold;
}
h3 {
padding: 5px 0 3px;
}
ul {
list-style: initial;
padding-inline-start: 30px;
}
p {
font-size: 14px;
line-height: 1.5;
}
}
.history {
h3 {
padding-top: 15px;
}
.item {
h3 {
padding: 5px 0 3px;
}
padding: 0 15px;
+ .item {
padding-top: 15px;
}
h4 {
font-weight: 700;
}
> p {
padding-left: 15px;
}
}
}
.footer {
flex: 0 0 none;
padding: 0 15px;
.desc {
padding-top: 20px;
font-size: 13px;
color: var(--color-primary-font);
line-height: 1.25;
p {
font-size: 13px;
color: var(--color-primary-font);
line-height: 1.25;
}
}
}
// .btns {
// display: flex;
// flex-flow: row nowrap;
// gap: 15px;
// }
// .btn {
// margin-top: 10px;
// display: block;
// width: 100%;
// }
// .btn2 {
// margin-top: 10px;
// display: block;
// width: 50%;
// }
</style>

View File

@ -1,6 +1,40 @@
<template lang="pug">
material-modal(:show="versionInfo.showModal" @close="handleClose")
main(:class="$style.main" v-if="versionInfo.isDownloaded")
material-modal(:show="versionInfo.showModal" @close="handleClose" max-width="60%")
main(:class="$style.main" v-if="versionInfo.isLatest")
h2 🎉 已是最新版本 🎉
div.scroll.select(:class="$style.info")
div(:class="$style.current")
h3 最新版本{{versionInfo.newVersion?.version}}
h3 当前版本{{versionInfo.version}}
h3 版本变化
pre(:class="$style.desc" v-text="versionInfo.newVersion?.desc")
div(:class="$style.footer")
div(:class="$style.btns")
base-btn(v-if="versionInfo.status == 'checking'" :class="$style.btn" disabled) 检查更新中...
base-btn(v-else :class="$style.btn" @click="handleCheckUpdate") 重新检查更新
main(:class="$style.main" v-else-if="versionInfo.isUnknown")
h2 获取最新版本信息失败
div.scroll.select(:class="$style.info")
div(:class="$style.current")
h3 当前版本{{versionInfo.version}}
div(:class="$style.desc")
p 更新信息获取失败可能是无法访问Github导致的请手动检查更新
p
| 检查方法打开
base-btn(min @click="handleOpenUrl('https://github.com/lyswhut/lx-music-desktop/releases')" aria-label="点击打开") 软件发布页
|
base-btn(min @click="handleOpenUrl('https://www.lanzoui.com/b0bf2cfa/')" aria-label="点击打开") 网盘
| (密码
strong.hover(@click="handleCopy('glqw')" aria-label="点击复制") glqw
| )查看它们的
strong 版本号
| 与当前版本({{versionInfo.version}})对比是否一样
p 若一样则不必理会该弹窗直接关闭即可否则请手动下载新版本更新
div(:class="$style.footer")
div(:class="$style.btns")
base-btn(v-if="versionInfo.status == 'error'" :class="$style.btn" @click="handleCheckUpdate") 重新检查更新
base-btn(v-else :class="$style.btn" disabled) 检查更新中...
main(:class="$style.main" v-else-if="versionInfo.status == 'downloaded'")
h2 🚀程序更新🚀
div.scroll.select(:class="$style.info")
@ -23,77 +57,10 @@ material-modal(:show="versionInfo.showModal" @close="handleClose")
| 或稍后
strong 关闭程序时
| 自动更新~
base-btn(:class="$style.btn" @click.onec="handleRestartClick") 立即重启更新
main(:class="$style.main" v-else-if="versionInfo.isError && !versionInfo.isUnknow && versionInfo.newVersion?.version != versionInfo.version")
h2 版本更新出错
div.scroll.select(:class="$style.info")
div(:class="$style.current")
h3 最新版本{{versionInfo.newVersion?.version}}
h3 当前版本{{versionInfo.version}}
h3 版本变化
pre(:class="$style.desc" v-text="versionInfo.newVersion?.desc")
div(:class="[$style.history, $style.desc]" v-if="history.length")
h3 历史版本
div(:class="$style.item" v-for="ver in history")
h4 v{{ver.version}}
pre(v-text="ver.desc")
div(:class="$style.footer")
div(:class="$style.desc")
p 发现有新版本啦但是自动更新功能出问题了
p
| 你可以去&nbsp;
strong.hover.underline(@click="handleOpenUrl('https://github.com/lyswhut/lx-music-desktop/releases')" aria-label="点击打开") 软件发布页
| &nbsp;&nbsp;
strong.hover.underline(@click="handleOpenUrl('https://www.lanzoui.com/b0bf2cfa/')" aria-label="点击打开") 网盘
| (密码
strong.hover(@click="handleCopy('glqw')" aria-label="点击复制") glqw
| )&nbsp;下载新版本
p
| 国内Windows/MAC用户推荐到
strong 网盘
| 下载
base-btn(:class="$style.btn" @click.onec="handleIgnoreClick") {{ isIgnored ? '恢复当前版本的更新失败提醒' : '忽略当前版本的更新失败提醒'}}
main(:class="$style.main" v-else-if="versionInfo.isDownloading && versionInfo.isTimeOut && !versionInfo.isUnknow")
h2 新版本下载超时
div(:class="$style.desc")
p 你当前所在网络访问GitHub较慢导致新版本下载超时已经下了半个钟了😳你仍可选择继续等但墙裂建议手动更新版本
p
| 你可以去
base-btn(min @click="handleOpenUrl('https://github.com/lyswhut/lx-music-desktop/releases')" aria-label="点击打开") 软件发布页
|
base-btn(min @click="handleOpenUrl('https://www.lanzoui.com/b0bf2cfa/')" aria-label="点击打开") 网盘
| (密码
strong.hover(@click="handleCopy('glqw')" aria-label="点击复制") glqw
| )下载新版本
p
| 国内Windows/MAC用户推荐到
strong 网盘
| 下载
p 当前下载进度{{progress}}
main(:class="$style.main" v-else-if="versionInfo.isUnknow")
h2 获取最新版本信息失败
div.scroll.select(:class="$style.info")
div(:class="$style.current")
h3 当前版本{{versionInfo.version}}
div(:class="$style.desc")
p 更新信息获取失败可能是无法访问Github导致的请手动检查更新
p
| 检查方法打开
base-btn(min @click="handleOpenUrl('https://github.com/lyswhut/lx-music-desktop/releases')" aria-label="点击打开") 软件发布页
|
base-btn(min @click="handleOpenUrl('https://www.lanzoui.com/b0bf2cfa/')" aria-label="点击打开") 网盘
| (密码
strong.hover(@click="handleCopy('glqw')" aria-label="点击复制") glqw
| )查看它们的
strong 版本号
| 与当前版本({{versionInfo.version}})对比是否一样
p 若一样则不必理会该弹窗直接关闭即可否则请手动下载新版本更新
div(:class="$style.btns")
base-btn(:class="$style.btn" @click.onec="handleRestartClick") 立即重启更新
main(:class="$style.main" v-else)
h2 🌟发现新版本🌟
div.scroll.select(:class="$style.info")
div(:class="$style.current")
h3 最新版本{{versionInfo.newVersion?.version}}
@ -108,28 +75,30 @@ material-modal(:show="versionInfo.showModal" @close="handleClose")
div(:class="$style.footer")
div(:class="$style.desc")
p 发现有新版本啦正在努力更新中若下载太慢可以手动更新哦~
p
| 你也可以关闭本弹窗继续使用软件还可在
strong 设置-软件更新
| 重新打开本弹窗
p
| 手动更新可以去&nbsp;
p 发现有新版本啦你可以尝试使用自动更新或手动更新
p 手动更新可以去&nbsp;
strong.hover.underline(@click="handleOpenUrl('https://github.com/lyswhut/lx-music-desktop/releases')" aria-label="点击打开") 软件发布页
| &nbsp;&nbsp;
strong.hover.underline(@click="handleOpenUrl('https://www.lanzoui.com/b0bf2cfa/')" aria-label="点击打开") 网盘
| (密码
strong.hover(@click="handleCopy('glqw')" aria-label="点击复制") glqw
| )&nbsp;下载
p 国内Windows/MAC用户推荐到网盘下载
p 当前下载进度{{progress}}
| )&nbsp;下载
p 国内Windows/MAC用户推荐到网盘下载若遇到问题可以看
strong.hover.underline(@click="handleOpenUrl('https://lyswhut.github.io/lx-music-doc/desktop/faq')" aria-label="点击打开") 常见问题
p(v-if="progress") 当前下载进度{{progress}}
p(v-else) &nbsp;
div(:class="$style.btns")
base-btn(:class="$style.btn2" @click="handleIgnoreClick") {{ isIgnored ? '取消忽略' : '忽略更新该版本'}}
base-btn(v-if="versionInfo.status == 'downloading'" :class="$style.btn2" disabled) 下载更新中...
base-btn(v-else :class="$style.btn2" @click="handleDonwloadClick") 下载更新
</template>
<script>
import { compareVer, sizeFormate } from '@common/utils'
import { openUrl, clipboardWriteText } from '@common/utils/electron'
import { dialog } from '@renderer/plugins/Dialog'
import { versionInfo } from '@renderer/store'
import { getIgnoreVersion, saveIgnoreVersion, quitUpdate } from '@renderer/utils/ipc'
import { getIgnoreVersion, saveIgnoreVersion, quitUpdate, downloadUpdate, checkUpdate } from '@renderer/utils/ipc'
export default {
setup() {
@ -154,16 +123,20 @@ export default {
return arr
},
progress() {
return this.versionInfo.downloadProgress
? `${this.versionInfo.downloadProgress.percent.toFixed(2)}% - ${sizeFormate(this.versionInfo.downloadProgress.transferred)}/${sizeFormate(this.versionInfo.downloadProgress.total)} - ${sizeFormate(this.versionInfo.downloadProgress.bytesPerSecond)}/s`
: '处理更新中...'
return this.versionInfo.status == 'downloading'
? this.versionInfo.downloadProgress
? `${this.versionInfo.downloadProgress.percent.toFixed(2)}% - ${sizeFormate(this.versionInfo.downloadProgress.transferred)}/${sizeFormate(this.versionInfo.downloadProgress.total)} - ${sizeFormate(this.versionInfo.downloadProgress.bytesPerSecond)}/s`
: '处理更新中...'
: ''
},
isIgnored() {
return this.ignoreVersion == this.versionInfo.newVersion?.version
},
},
created() {
this.ignoreVersion = getIgnoreVersion()
getIgnoreVersion().then(version => {
this.ignoreVersion = version
})
},
methods: {
handleClose() {
@ -180,9 +153,41 @@ export default {
handleCopy(text) {
clipboardWriteText(text)
},
handleIgnoreClick() {
saveIgnoreVersion(this.isIgnored ? null : this.versionInfo.newVersion?.version)
this.handleClose()
async handleIgnoreClick() {
if (this.isIgnored) {
saveIgnoreVersion(this.ignoreVersion = null)
return
}
if (this.history.length >= 2) {
if (await dialog.confirm({
message: window.i18n.t('update__ignore_tip', { num: this.history.length + 1 }),
cancelButtonText: window.i18n.t('update__ignore_cancel'),
confirmButtonText: window.i18n.t('update__ignore_confirm'),
})) {
setTimeout(() => {
dialog({
message: window.i18n.t('update__ignore_confirm_tip'),
confirmButtonText: window.i18n.t('update__ignore_confirm_tip_confirm'),
})
}, 500)
return
}
}
saveIgnoreVersion(this.ignoreVersion = this.versionInfo.newVersion?.version)
// saveIgnoreVersion(this.versionInfo.newVersion?.version)
// this.handleClose()
},
handleDonwloadClick() {
if (this.isIgnored) saveIgnoreVersion(this.ignoreVersion = null)
versionInfo.status = 'downloading'
downloadUpdate()
},
handleCheckUpdate() {
if (this.isIgnored) saveIgnoreVersion(this.ignoreVersion = null)
versionInfo.status = 'checking'
versionInfo.reCheck = true
checkUpdate()
},
},
}
@ -194,8 +199,8 @@ export default {
.main {
position: relative;
padding: 15px;
max-width: 450px;
padding: 15px 0;
// max-width: 450px;
min-width: 300px;
display: flex;
flex-flow: column nowrap;
@ -226,11 +231,11 @@ export default {
.info {
flex: 1 1 auto;
font-size: 13px;
font-size: 14px;
line-height: 1.5;
overflow-y: auto;
height: 100%;
padding-right: 5px;
padding: 0 15px;
}
.current {
> p {
@ -279,23 +284,36 @@ export default {
}
.footer {
flex: 0 0 none;
padding: 0 15px;
.desc {
padding-top: 10px;
font-size: 12px;
font-size: 13px;
color: var(--color-primary-font);
line-height: 1.25;
p {
font-size: 12px;
font-size: 13px;
color: var(--color-primary-font);
line-height: 1.25;
}
}
}
.btns {
display: flex;
flex-flow: row nowrap;
gap: 15px;
}
.btn {
margin-top: 10px;
display: block;
width: 100%;
}
.btn2 {
margin-top: 10px;
display: block;
width: 50%;
}
</style>

View File

@ -24,7 +24,7 @@ window.lx = {
},
restorePlayInfo: null,
worker: createWorkers(),
isDev: process.env.NODE_ENV == 'production',
isProd: process.env.NODE_ENV == 'production',
rootOffset: window.dt ? 0 : 8,
}

View File

@ -65,7 +65,7 @@ export default () => {
void initDeeplink(envParams)
void initSyncService()
handleListAutoUpdate()
if (window.lx.isDev) checkUpdate()
if (window.lx.isProd) checkUpdate()
sendInited()
})

View File

@ -1,4 +1,4 @@
import { nextTick, onBeforeUnmount } from '@common/utils/vueTools'
import { nextTick, onBeforeUnmount, watch } from '@common/utils/vueTools'
import {
onUpdateAvailable,
onUpdateDownloaded,
@ -6,20 +6,34 @@ import {
onUpdateNotAvailable,
onUpdateProgress,
getIgnoreVersion,
getLastStartInfo,
saveLastStartInfo,
} from '@renderer/utils/ipc'
import { compareVer } from '@common/utils'
import { versionInfo } from '@renderer/store'
import { compareVer, isWin } from '@common/utils'
import { isShowChangeLog, versionInfo } from '@renderer/store'
import { getVersionInfo } from '@renderer/utils/update'
import { dialog } from '@renderer/plugins/Dialog'
import { appSetting } from '@renderer/store/setting'
export default () => {
let isShowedChangeLog = false
// 更新超时定时器
let updateTimeout: number | null = window.setTimeout(() => {
updateTimeout = null
versionInfo.isTimeOut = true
void nextTick(() => {
showUpdateModal()
})
}, 60 * 30 * 1000)
let updateTimeout: number | null = null
if (window.lx.isProd && !(isWin && process.arch.includes('arm'))) {
updateTimeout = window.setTimeout(() => {
updateTimeout = null
void nextTick(() => {
showUpdateModal()
setTimeout(() => {
void dialog({
message: window.i18n.t('update__timeout_top'),
confirmButtonText: window.i18n.t('alert_button_text'),
})
}, 500)
})
}, 60 * 60 * 1000)
}
const clearUpdateTimeout = () => {
if (!updateTimeout) return
@ -27,8 +41,25 @@ export default () => {
updateTimeout = null
}
const showUpdateModal = () => {
void (versionInfo.newVersion?.history
const handleShowChangeLog = () => {
isShowedChangeLog = true
void getLastStartInfo().then((version) => {
if (version == process.versions.app) return
saveLastStartInfo(process.versions.app)
if (compareVer(process.versions.app, version) < 0) {
void dialog({
message: window.i18n.t('update__downgrade_tip', { ver: `${version}${process.versions.app}` }),
confirmButtonText: window.i18n.t('update__ignore_confirm_tip_confirm'),
})
return
}
if (compareVer(process.versions.app, versionInfo.newVersion!.version) > 0) return
isShowChangeLog.value = true
})
}
const handleGetVersionInfo = async(): Promise<NonNullable<typeof versionInfo['newVersion']>> => {
return (versionInfo.newVersion?.history && !versionInfo.reCheck
? Promise.resolve(versionInfo.newVersion)
: getVersionInfo().then(body => {
versionInfo.newVersion = body
@ -36,45 +67,77 @@ export default () => {
})
).catch(() => {
if (versionInfo.newVersion) return versionInfo.newVersion
versionInfo.isUnknow = true
let result = {
version: '0.0.0',
desc: '',
}
versionInfo.newVersion = result
return result
}).then((result: LX.VersionInfo) => {
})
}
let versionInfoPromise: null | ReturnType<typeof handleGetVersionInfo> = null
const showUpdateModal = (status?: LX.UpdateStatus) => {
if (versionInfoPromise) {
if (
// @ts-expect-error
versionInfoPromise.resolved &&
versionInfo.reCheck) {
versionInfoPromise = handleGetVersionInfo()
}
} else versionInfoPromise = handleGetVersionInfo()
void versionInfoPromise.then((result) => {
versionInfo.reCheck = false
if (result.version == '0.0.0') {
versionInfo.isUnknow = true
versionInfo.isUnknown = true
versionInfo.status = 'error'
versionInfo.showModal = true
return
}
versionInfo.isUnknown = false
if (compareVer(versionInfo.version, result.version) != -1) {
versionInfo.isLatestVer = true
versionInfo.status = 'idle'
versionInfo.isLatest = true
handleShowChangeLog()
return
}
return getIgnoreVersion().then((ignoreVersion) => {
versionInfo.isLatest = false
let preStatus = versionInfo.status
if (status) versionInfo.status = status
if (result.version === ignoreVersion) return
// console.log(this.version)
void nextTick(() => {
versionInfo.showModal = true
if (status == 'error' && preStatus == 'downloading') {
setTimeout(() => {
void dialog({
message: window.i18n.t('update__error_top'),
confirmButtonText: window.i18n.t('alert_button_text'),
})
}, 500)
}
})
})
}).finally(() => {
// @ts-expect-error
versionInfoPromise!.resolved = true
})
}
const rUpdateAvailable = onUpdateAvailable(({ params: info }) => {
versionInfo.isDownloading = true
void getVersionInfo().catch(() => ({
// versionInfo.isDownloading = true
console.log(info)
versionInfo.newVersion = {
version: info.version,
desc: info.releaseNotes,
})).then(body => {
// console.log(body)
versionInfo.newVersion = body
void nextTick(() => {
versionInfo.showModal = true
})
desc: info.releaseNotes as string,
}
versionInfo.isLatest = false
if (appSetting['common.tryAutoUpdate']) versionInfo.status = 'downloading'
void nextTick(() => {
showUpdateModal()
})
})
const rUpdateNotAvailable = onUpdateNotAvailable(({ params: info }) => {
@ -83,13 +146,15 @@ export default () => {
version: info.version,
desc: info.releaseNotes as string,
}
versionInfo.isLatestVer = true
versionInfo.isLatest = true
versionInfo.isUnknown = false
versionInfo.status = 'idle'
})
const rUpdateError = onUpdateError(() => {
const rUpdateError = onUpdateError((params) => {
clearUpdateTimeout()
versionInfo.isError = true
// versionInfo.status = 'error'
void nextTick(() => {
showUpdateModal()
showUpdateModal('error')
})
})
const rUpdateProgress = onUpdateProgress(({ params: progress }) => {
@ -97,12 +162,19 @@ export default () => {
})
const rUpdateDownloaded = onUpdateDownloaded(({ params: info }) => {
clearUpdateTimeout()
versionInfo.isDownloaded = true
// versionInfo.status = 'downloaded'
void nextTick(() => {
showUpdateModal()
showUpdateModal('downloaded')
})
})
watch(() => versionInfo.showModal, (visible) => {
if (visible || isShowedChangeLog || versionInfo.status == 'downloaded') return
setTimeout(() => {
handleShowChangeLog()
}, 1000)
})
onBeforeUnmount(() => {
clearUpdateTimeout()
rUpdateAvailable()

View File

@ -85,23 +85,19 @@ export const versionInfo = window.lxData.versionInfo = reactive<{
history?: LX.VersionInfo[]
} | null
showModal: boolean
isError: boolean
isTimeOut: boolean
isUnknow: boolean
isDownloaded: boolean
isDownloading: boolean
isLatestVer: boolean
isUnknown: boolean
isLatest: boolean
reCheck: boolean
status: LX.UpdateStatus
downloadProgress: ProgressInfo | null
}>({
version: pkg.version,
newVersion: null,
showModal: false,
isError: false,
isTimeOut: false,
isUnknow: false,
isDownloaded: false,
isDownloading: false,
isLatestVer: false,
reCheck: false,
isUnknown: false,
isLatest: false,
status: 'checking',
downloadProgress: null,
})
export const userApi = reactive<{
@ -116,6 +112,9 @@ export const userApi = reactive<{
apis: {},
})
export const isShowChangeLog = ref(false)
export const isFullscreen = ref(false)
watch(isFullscreen, isFullscreen => {
window.lx.rootOffset = window.dt || isFullscreen ? 0 : 8

View File

@ -202,7 +202,8 @@ export const setPlayMusicInfo = (listId: string | null, musicInfo: LX.Download.L
* @param playMusicInfo playMusicInfo
*/
export const addPlayedList = (playMusicInfo: LX.Player.PlayMusicInfo) => {
if (playedList.some(m => m.musicInfo === playMusicInfo.musicInfo)) return
const id = playMusicInfo.musicInfo.id
if (playedList.some(m => m.musicInfo.id === id)) return
playedList.push(playMusicInfo)
}
/**

View File

@ -18,7 +18,7 @@ interface Lx {
main: MainTypes
download: DownloadTypes
}
isDev: boolean
isProd: boolean
songListInfo: {
fromName: string
searchKey: string | null

View File

@ -68,6 +68,10 @@ export const checkUpdate = () => {
rendererSend(WIN_MAIN_RENDERER_EVENT_NAME.update_check)
}
export const downloadUpdate = () => {
rendererSend(WIN_MAIN_RENDERER_EVENT_NAME.update_download_update)
}
export const quitUpdate = () => {
rendererSend(WIN_MAIN_RENDERER_EVENT_NAME.quit_update)
}
@ -166,6 +170,17 @@ export const setTaskBarProgress = (progress: number, mode?: Electron.ProgressBar
})
}
export const saveLastStartInfo = (version: string) => {
rendererSend(WIN_MAIN_RENDERER_EVENT_NAME.save_data, {
path: DATA_KEYS.lastLastStartInfo,
data: version,
})
}
// 获取最后一次启动时的版本号
export const getLastStartInfo = async() => {
return rendererInvoke<string, string>(WIN_MAIN_RENDERER_EVENT_NAME.get_data, DATA_KEYS.lastLastStartInfo)
}
export const savePlayInfo = (playInfo: LX.Player.SavedPlayInfo) => {
rendererSend(WIN_MAIN_RENDERER_EVENT_NAME.save_data, {
path: DATA_KEYS.playInfo,

View File

@ -1,17 +1,24 @@
<template lang="pug">
dt#update {{$t('setting__update')}}
dd
p.small
| {{$t('setting__update_latest_label')}}{{versionInfo.newVersion ? versionInfo.newVersion.version : $t('setting__update_unknown')}}
p.small(@click="handleOPenDevTools") {{$t('setting__update_current_label')}}{{versionInfo.version}}
p.small(v-if="versionInfo.downloadProgress" style="line-height: 1.5;")
| {{$t('setting__update_downloading')}}
br
| {{$t('setting__update_progress')}}{{downloadProgress}}
p(v-if="versionInfo.newVersion")
span(v-if="versionInfo.isLatestVer") {{$t('setting__update_latest')}}
base-btn.btn.gap-left(v-else min @click="showUpdateModal") {{$t('setting__update_open_version_modal_btn')}}
p.small(v-else) {{$t('setting__update_checking')}}
.gap-top
base-checkbox(id="setting__update_tryAutoUpdate" :modelValue="appSetting['common.tryAutoUpdate']" @update:modelValue="updateSetting({'common.tryAutoUpdate': $event})" :label="$t('setting__update_try_auto_update')")
.gap-top
p.small
| {{$t('setting__update_latest_label')}}{{versionInfo.newVersion ? versionInfo.newVersion.version : $t('setting__update_unknown')}}
p.small(@click="handleOpenDevTools") {{$t('setting__update_current_label')}}{{versionInfo.version}}
p.small(v-if="downloadProgress" style="line-height: 1.5;")
| {{$t('setting__update_downloading')}}
br
| {{$t('setting__update_progress')}}{{downloadProgress}}
template(v-if="versionInfo.newVersion")
p(v-if="versionInfo.isLatest")
span {{$t('setting__update_latest')}}
p(v-else-if="versionInfo.status != 'downloading'")
span {{ $t('setting__update_new_version') }}
p
base-btn.btn.gap-left(min @click="showUpdateModal") {{$t('setting__update_open_version_modal_btn')}}
p.small(v-else-if="versionInfo.status =='checking'") {{$t('setting__update_checking')}}
</template>
<script>
@ -21,6 +28,7 @@ import { sizeFormate } from '@common/utils/common'
// import { openDirInExplorer, selectDir } from '@renderer/utils'
import { openDevTools } from '@renderer/utils/ipc'
import { useI18n } from '@renderer/plugins/i18n'
import { appSetting, updateSetting } from '@renderer/store/setting'
export default {
name: 'SettingUpdate',
@ -30,7 +38,7 @@ export default {
const t = useI18n()
const handleOPenDevTools = () => {
const handleOpenDevTools = () => {
if (window.performance.now() - lastClickTime > 1000) {
if (clickNum > 0) clickNum = 0
} else {
@ -45,9 +53,11 @@ export default {
}
const downloadProgress = computed(() => {
return versionInfo.downloadProgress
? `${versionInfo.downloadProgress.percent.toFixed(2)}% - ${sizeFormate(versionInfo.downloadProgress.transferred)}/${sizeFormate(versionInfo.downloadProgress.total)} - ${sizeFormate(versionInfo.downloadProgress.bytesPerSecond)}/s`
: t('setting__update_init')
return versionInfo.status == 'downloading'
? versionInfo.downloadProgress
? `${versionInfo.downloadProgress.percent.toFixed(2)}% - ${sizeFormate(versionInfo.downloadProgress.transferred)}/${sizeFormate(versionInfo.downloadProgress.total)} - ${sizeFormate(versionInfo.downloadProgress.bytesPerSecond)}/s`
: t('setting__update_init')
: ''
})
const showUpdateModal = () => {
@ -57,8 +67,10 @@ export default {
return {
versionInfo,
downloadProgress,
handleOPenDevTools,
handleOpenDevTools,
showUpdateModal,
appSetting,
updateSetting,
}
},
}