Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: macOS状态栏增加歌词显示 #1940

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .ncurc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = {
'@types/ws',
'eslint',
'electron-debug',
'better-sqlite3',
// 'eslint-config-standard-with-typescript',
// 'typescript', // https://github.com/microsoft/TypeScript/pull/54567
],
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified build-config/lib/qrc_decode_electron-v110-win32-arm64.node
Binary file not shown.
Binary file modified build-config/lib/qrc_decode_electron-v110-win32-ia32.node
Binary file not shown.
Binary file modified build-config/lib/qrc_decode_electron-v110-win32-x64.node
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1,504 changes: 604 additions & 900 deletions package-lock.json

Large diffs are not rendered by default.

29 changes: 15 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lx-music-desktop",
"version": "2.8.0",
"version": "2.8.1-beta.3",
"description": "一个免费的音乐查找助手",
"main": "./dist/main.js",
"productName": "lx-music-desktop",
Expand Down Expand Up @@ -108,23 +108,23 @@
},
"homepage": "https://github.com/lyswhut/lx-music-desktop#readme",
"devDependencies": {
"@babel/core": "^7.24.6",
"@babel/eslint-parser": "^7.24.6",
"@babel/core": "^7.24.7",
"@babel/eslint-parser": "^7.24.7",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-transform-modules-umd": "^7.24.6",
"@babel/plugin-transform-runtime": "^7.24.6",
"@babel/preset-env": "^7.24.6",
"@babel/preset-typescript": "^7.24.6",
"@babel/plugin-transform-modules-umd": "^7.24.7",
"@babel/plugin-transform-runtime": "^7.24.7",
"@babel/preset-env": "^7.24.7",
"@babel/preset-typescript": "^7.24.7",
"@tsconfig/recommended": "^1.0.6",
"@types/better-sqlite3": "^7.6.10",
"@types/needle": "^3.3.0",
"@types/tunnel": "^0.0.7",
"@types/ws": "8.5.4",
"@volar/vue-language-plugin-pug": "^1.6.5",
"@vue/language-plugin-pug": "^2.0.19",
"@vue/language-plugin-pug": "^2.0.21",
"babel-loader": "^9.1.3",
"browserslist": "^4.23.0",
"browserslist": "^4.23.1",
"chalk": "^4.1.2",
"changelog-parser": "^3.0.1",
"copy-webpack-plugin": "^12.0.2",
Expand All @@ -133,12 +133,12 @@
"css-loader": "^7.1.2",
"css-minimizer-webpack-plugin": "^7.0.0",
"del": "^6.1.1",
"electron": "^28.3.3",
"electron": "^29.4.2",
"electron-builder": "^24.13.3",
"electron-debug": "^3.2.0",
"electron-devtools-installer": "^3.2.0",
"electron-to-chromium": "^1.4.787",
"electron-updater": "^6.1.8",
"electron-to-chromium": "^1.4.798",
"electron-updater": "^6.2.1",
"eslint": "^8.57.0",
"eslint-config-standard": "^17.1.0",
"eslint-config-standard-with-typescript": "^43.0.1",
Expand All @@ -162,7 +162,7 @@
"svg-sprite-loader": "^6.0.11",
"svg-transform-loader": "^2.0.13",
"svgo-loader": "^4.0.0",
"terser": "^5.31.0",
"terser": "^5.31.1",
"terser-webpack-plugin": "^5.3.10",
"tree-kill": "^1.2.2",
"ts-loader": "^9.5.1",
Expand Down Expand Up @@ -196,7 +196,7 @@
"tunnel": "^0.0.6",
"utf-8-validate": "^6.0.4",
"vue": "~3.3.13",
"vue-router": "^4.3.2",
"vue-router": "^4.3.3",
"ws": "^8.17.0"
},
"overrides": {
Expand All @@ -213,6 +213,7 @@
"svg-baker": {
"postcss": "latest"
},
"braces": "latest",
"node-gyp-build": "latest",
"http-cache-semantics": "latest"
}
Expand Down
40 changes: 6 additions & 34 deletions publish/changeLog.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,14 @@
我们发布了关于 LX Music 项目发展调整与新项目计划的说明,
详情看: https://github.com/lyswhut/lx-music-desktop/issues/1912

### 新增

- 新增 设置-播放设置-使用设备能处理的最大声道数输出音频 设置(未启用时固定为2声道输出),由于这用到高级音频API,考虑到在某些设备上的兼容问题,默认禁用(#1873)
- 允许添加 `m4a`、`oga` 格式的本地歌曲到列表中(#1864)
- 开放API支持跨域请求(#1872 @Ceale)
- Scheme URL API新增 `music/searchPlay` 支持,用于搜索并播放指定的歌曲名字,详细入参请阅读 Scheme URL 支持文档(#1886)

### 优化

- 优化白色托盘图标显示,修复windows下托盘图标不清晰的问题(#1842)

### 修复

- 修复存在多级弹窗时的背景显示问题
- 增大在线导入自定义源文件的大小限制问题(#1857)
- 修复Mac下窗口出现残留阴影的问题,这解决了Mac下桌面歌词出现残留阴影的远古bug,感谢 @zclorne (#1869, Thanks @zclorne)
- 增大在线导入自定义源文件的大小限制,解决某些音源无法导入的问题(#1857)
- 修复Mac下即使开启了托盘, `cmd+w` 仍会中断播放的问题(#1844)
- 修复播放详情页的歌词无法使用触碰拖动的问题(#1865)
- 修复与优化繁体中文、英语翻译显示(#1845)
- 修复歌曲时文件名过长导致歌曲无法下载的问题(#1877)
- 修复文本提示气泡在内容过长时,文本未被换行而被截断的问题
- 修复翻页按钮栏切页按钮只显示前几页的问题
- 修复 MacOS 下点击 dock 右键菜单的退出按钮时,程序没有退出的问题(#1923)
- 修复 OpenAPI 的 `lyricLineAllText` 在切换到无歌词的音乐时内容没有更新的问题(#1925)
- 修复切换音源时可能出现切换死循环的问题

### 变更

- 设置-播放设置-优先播放320k音质选项改为“优先播放的音质”,允许选择更高优先播放的音质,如果歌曲及音源支持的话(#1839)

### 开放API变更

- `/status` 的入参现在与 `/subscribe-player-status` 保持一致
- `/status` 新增 `filter` 入参用于过滤返回的字段,并内置了默认值,与之前相比默认不再返回 `picUrl`
- `/status` 及 `/subscribe-player-status` 的可用字段名添加了 `lyricLineAllText`,它对应的值是当前句歌词及扩展歌词文本(扩展歌词包含翻译、罗马音等,按换行符分割)

详情看开放API接入文档
- 简化了应用退出行为,据测试,现在 linux 下,若启用了托盘,dock 右键菜单的 退出、关闭所有 之类的功能将不再退出程序,需改用托盘的退出按钮退出程序
- 现在如果在设置或者启动参数配置了代理服务,那么应用内的图片、音频加载,歌曲下载也将走代理

### 其他

- 更新 electron 到 v28.3.3
- 更新 electron 到 v29.4.2
1 change: 1 addition & 0 deletions src/common/defaultSetting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const defaultSetting: LX.AppSetting = {
'player.togglePlayMethod': 'listLoop',
'player.playQuality': '128k',
'player.isShowTaskProgess': true,
'player.isShowStatusBarLyric': false,
'player.volume': 1,
'player.powerSaveBlocker': true,
'player.isMute': false,
Expand Down
6 changes: 6 additions & 0 deletions src/common/types/app_setting.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ declare global {
*/
'player.isShowTaskProgess': boolean


/**
* 是否将将歌词显示在状态栏
*/
'player.isShowStatusBarLyric': boolean

/**
* 音量大小
*/
Expand Down
13 changes: 10 additions & 3 deletions src/common/utils/musicMeta/downloader.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
const http = require('http')
const https = require('https')
const fs = require('fs')
const { httpOverHttp, httpsOverHttp } = require('tunnel')

const sendRequest = (url) => {
const httpsRxp = /^https:/
const getRequestAgent = (url, proxy) => {
return proxy ? (httpsRxp.test(url) ? httpsOverHttp : httpOverHttp)({ proxy }) : undefined
}

const sendRequest = (url, proxy) => {
const urlParse = new URL(url)
const httpOptions = {
method: 'get',
host: urlParse.hostname,
port: urlParse.port,
path: urlParse.pathname + urlParse.search,
agent: getRequestAgent(url, proxy),
headers: {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36',
},
Expand All @@ -20,9 +27,9 @@ const sendRequest = (url) => {
: http.request(httpOptions)
}

module.exports = (url, filePath) => {
module.exports = (url, filePath, proxy) => {
return new Promise((resolve) => {
sendRequest(url)
sendRequest(url, proxy)
.on('response', response => {
// console.log(response.statusCode)
if (response.statusCode !== 200 && response.statusCode != 206) {
Expand Down
4 changes: 2 additions & 2 deletions src/common/utils/musicMeta/flacMeta.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const writeMeta = async(filePath, meta, picPath) => {
})
}

module.exports = (filePath, meta) => {
module.exports = (filePath, meta, proxy) => {
if (!meta.APIC) return writeMeta(filePath, meta)
let picUrl = meta.APIC
delete meta.APIC
Expand All @@ -68,7 +68,7 @@ module.exports = (filePath, meta) => {
let picPath = filePath.replace(/\.flac$/, '') + (ext ? ext.replace(extReg, '$1') : '.jpg')

if (picUrl.includes('music.126.net')) picUrl += `${picUrl.includes('?') ? '&' : '?'}param=500y500`
download(picUrl, picPath).then(success => {
download(picUrl, picPath, proxy).then(success => {
if (success) {
writeMeta(filePath, meta, picPath).finally(() => {
fs.unlink(picPath, err => {
Expand Down
2 changes: 1 addition & 1 deletion src/common/utils/musicMeta/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export interface MusicMeta {
APIC: string | null
lyrics: string | null
}
export function setMeta(filePath: string, meta: MusicMeta): void
export function setMeta(filePath: string, meta: MusicMeta, proxy?: { host: string, port: number }): void
6 changes: 3 additions & 3 deletions src/common/utils/musicMeta/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ const path = require('path')
const mp3Meta = require('./mp3Meta')
const flacMeta = require('./flacMeta')

exports.setMeta = (filePath, meta) => {
exports.setMeta = (filePath, meta, proxy) => {
switch (path.extname(filePath)) {
case '.mp3':
mp3Meta(filePath, meta)
mp3Meta(filePath, meta, proxy)
break
case '.flac':
flacMeta(filePath, meta)
flacMeta(filePath, meta, proxy)
break
}
}
4 changes: 2 additions & 2 deletions src/common/utils/musicMeta/mp3Meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const handleWriteMeta = (meta, filePath) => {
NodeID3.write(meta, filePath)
}

module.exports = (filePath, meta) => {
module.exports = (filePath, meta, proxy) => {
if (!meta.APIC) return handleWriteMeta(meta, filePath)
if (!/^http/.test(meta.APIC)) {
delete meta.APIC
Expand All @@ -26,7 +26,7 @@ module.exports = (filePath, meta) => {

let picUrl = meta.APIC
if (picUrl.includes('music.126.net')) picUrl += `${picUrl.includes('?') ? '&' : '?'}param=500y500`
download(picUrl, picPath).then(success => {
download(picUrl, picPath, proxy).then(success => {
if (success) {
meta.APIC = picPath
handleWriteMeta(meta, filePath)
Expand Down
6 changes: 4 additions & 2 deletions src/lang/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"audio_visualization": "Audio visualization (experimental)",
"back": "Back",
"btn_cancel": "Cancel",
"btn_close": "Closure",
"btn_close": "Close",
"btn_confirm": "Confirm",
"btn_save": "Save",
"cancel_button_text": "Cancel",
Expand Down Expand Up @@ -267,6 +267,7 @@
"player__sound_effect_convolution_file_tim_omni_35_10_magnetic": "Rock 2",
"player__sound_effect_convolution_main_gain": "Original Audio Gain",
"player__sound_effect_convolution_send_gain": "Ambient Sound Effect Gain",
"player__sound_effect_features_tip": "Tip: The sound effect settings conflicts with the the custom audio output device. After enabling the sound effect settings, the audio output device will be reset to the default output device. This problem cannot be solved at present.",
"player__sound_effect_panner": "3D stereo surround (need to use headphones)",
"player__sound_effect_panner_enabled": "enable",
"player__sound_effect_panner_sound_r": "Sound distance",
Expand Down Expand Up @@ -525,6 +526,7 @@
"setting__play_power_save_blocker": "Prevent computer from sleeping while playing songs",
"setting__play_save_play_time": "Remember playback progress",
"setting__play_startup_auto_play": "Play music automatically after launching the software",
"setting__play_statusbar_lyric": "Show lyrics in status bar (needs tray enabled)",
"setting__play_task_bar": "Show playing progress on the taskbar",
"setting__play_timeout": "Timed pause",
"setting__player_audio_visualization_tip": "The custom audio output device will conflict with the audio visualization function. After the audio visualization is enabled, the audio output device will be reset to the default output device. At present, this problem cannot be solved. Do you still want to enable it?",
Expand Down Expand Up @@ -650,7 +652,7 @@
"theme_edit_modal__bg_image_add": "Add background image",
"theme_edit_modal__bg_image_change": "Change background image",
"theme_edit_modal__bg_image_remove": "remove background image",
"theme_edit_modal__close_btn": "Closure",
"theme_edit_modal__close_btn": "Close",
"theme_edit_modal__control_btn": "Left control button color",
"theme_edit_modal__copy": "Copy theme",
"theme_edit_modal__dark": "Dark theme",
Expand Down
3 changes: 2 additions & 1 deletion src/lang/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@
"player__sound_effect_convolution_file_tim_omni_35_10_magnetic": "磁性立体声",
"player__sound_effect_convolution_main_gain": "原始音频增益",
"player__sound_effect_convolution_send_gain": "环境音效增益",
"player__sound_effect_features_tip": "提示:音效功能 与 自定义音频输出设备功能 冲突,启用音效功能后音频输出设备将会被重置为默认的输出设备,目前此问题暂无法解决。",
"player__sound_effect_features_tip": "提示:「音效设置」与「自定义音频输出设备」冲突,启用音效设置后音频输出设备将会被重置为默认的输出设备,目前此问题暂无法解决。",
"player__sound_effect_panner": "3D立体环绕(需使用耳机)",
"player__sound_effect_panner_enabled": "启用",
"player__sound_effect_panner_sound_r": "声音距离",
Expand Down Expand Up @@ -526,6 +526,7 @@
"setting__play_power_save_blocker": "播放歌曲时阻止电脑休眠",
"setting__play_save_play_time": "记住播放进度",
"setting__play_startup_auto_play": "启动软件后自动播放音乐",
"setting__play_statusbar_lyric": "在状态栏显示歌词(需要启用托盘)",
"setting__play_task_bar": "在任务栏上显示当前歌曲播放进度",
"setting__play_timeout": "定时暂停",
"setting__player_audio_visualization_tip": "自定义音频输出设备与音频可视化功能会冲突,启用了音频可视化后音频输出设备将会被重置为默认的输出设备,目前此问题暂无法解决,是否仍要开启?",
Expand Down
2 changes: 2 additions & 0 deletions src/lang/zh-tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@
"player__sound_effect_convolution_file_tim_omni_35_10_magnetic": "磁性立體聲",
"player__sound_effect_convolution_main_gain": "原始音訊增益",
"player__sound_effect_convolution_send_gain": "環境音效增益",
"player__sound_effect_features_tip": "提示:「音效設定」與「自訂音訊輸出設備」衝突,啟用音效設定後音訊輸出設備將會被重設為預設的輸出設備,目前此問題暫無法解決。",
"player__sound_effect_panner": "3D立體環繞(需使用耳機)",
"player__sound_effect_panner_enabled": "啟用",
"player__sound_effect_panner_sound_r": "聲音距離",
Expand Down Expand Up @@ -525,6 +526,7 @@
"setting__play_power_save_blocker": "播放歌曲時阻止電腦休眠",
"setting__play_save_play_time": "記住播放進度",
"setting__play_startup_auto_play": "啟動軟體後自動播放音樂",
"setting__play_statusbar_lyric": "在狀態列顯示歌詞(需要啟用托盤)",
"setting__play_task_bar": "在工作列上顯示目前歌曲播放進度",
"setting__play_timeout": "定時暫停",
"setting__player_audio_visualization_tip": "自訂音訊輸出設備與音訊視覺化功能會衝突,啟用了音訊視覺化後音訊輸出設備將會被重設為預設的輸出設備,目前此問題暫無法解決,是否仍要開啟?",
Expand Down
8 changes: 5 additions & 3 deletions src/main/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { URL_SCHEME_RXP } from '@common/constants'
import { getTheme, initHotKey, initSetting, parseEnvParams } from './utils'
import { navigationUrlWhiteList } from '@common/config'
import defaultSetting from '@common/defaultSetting'
import { closeWindow, isExistWindow as isExistMainWindow, showWindow as showMainWindow } from './modules/winMain'
import { isExistWindow as isExistMainWindow, showWindow as showMainWindow } from './modules/winMain'
import { createAppEvent, createDislikeEvent, createListEvent } from '@main/event'
import { isMac, log } from '@common/utils'
import createWorkers from './worker'
Expand Down Expand Up @@ -158,6 +158,9 @@ export const listenerAppEvent = (startApp: () => void) => {
}
})

app.on('before-quit', () => {
global.lx.isSkipTrayQuit = true
})
app.on('window-all-closed', () => {
if (isMac) return

Expand Down Expand Up @@ -209,7 +212,6 @@ export const initAppSetting = async() => {
if (!global.lx) {
const config = await initHotKey()
global.lx = {
isTrafficLightClose: false,
isSkipTrayQuit: false,
// mainWindowClosed: true,
event_app: createAppEvent(),
Expand Down Expand Up @@ -275,5 +277,5 @@ export const initAppSetting = async() => {

export const quitApp = () => {
global.lx.isSkipTrayQuit = true
closeWindow()
app.quit()
}
Loading