Compare commits
259 Commits
v3.0.0-alp
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf1490b923 | ||
|
|
70f342993c | ||
|
|
961f25d316 | ||
|
|
c6f0d0b75a | ||
|
|
92ede5739d | ||
|
|
880fc888e6 | ||
|
|
f4c8be7091 | ||
|
|
68f085c183 | ||
|
|
62722d7e2f | ||
|
|
ddd19397b5 | ||
|
|
33ab167e52 | ||
|
|
1b6ebd9c7c | ||
|
|
7721251a98 | ||
|
|
320047ca9c | ||
|
|
73be8d8657 | ||
|
|
d527b076dc | ||
|
|
7bf9c6d7bc | ||
|
|
4dfd897401 | ||
|
|
f0a6526fd1 | ||
|
|
6d4f78413b | ||
|
|
8866996e5b | ||
|
|
5d21709c58 | ||
|
|
54d77d08eb | ||
|
|
bd25a8fe2e | ||
|
|
f0270a2fb0 | ||
|
|
3ebfccdfcc | ||
|
|
c29f2ed0a0 | ||
|
|
6caf99da09 | ||
|
|
ad27d1eaea | ||
|
|
8846d7f669 | ||
|
|
807b72ed9e | ||
|
|
d89be488e2 | ||
|
|
4bf986b763 | ||
|
|
ffb1fcc1ea | ||
|
|
ea822f91e8 | ||
|
|
5e260ffc0d | ||
|
|
e3dcde71e8 | ||
|
|
39c35e8a31 | ||
|
|
772f6552e7 | ||
|
|
c9f3553806 | ||
|
|
7de1355f18 | ||
|
|
392c64f06b | ||
|
|
0d66ced637 | ||
|
|
ae1ee71e75 | ||
|
|
84d9c999eb | ||
|
|
1a36fbf1d5 | ||
|
|
e0e62cd906 | ||
|
|
6d367f1fd5 | ||
|
|
2ed6acf934 | ||
|
|
236ee0a345 | ||
|
|
fe0f7a0f25 | ||
|
|
8529663ea5 | ||
|
|
100bae7488 | ||
|
|
91927b8d76 | ||
|
|
8be209837d | ||
|
|
9ae09b5711 | ||
|
|
3509d73ecc | ||
|
|
0bdb9c07b7 | ||
|
|
3218ab05f1 | ||
|
|
e40343f91f | ||
|
|
fcf1c235c3 | ||
|
|
ef0433c645 | ||
|
|
207f84fcd7 | ||
|
|
2985aa5977 | ||
|
|
ffd7aeff49 | ||
|
|
7f4a88daa1 | ||
|
|
91171465b2 | ||
|
|
1744a5a678 | ||
|
|
ce3d469547 | ||
|
|
7cc5b85fc5 | ||
|
|
3b3f321a3d | ||
|
|
58e3c6e21c | ||
|
|
68756f2502 | ||
|
|
cea9f7b025 | ||
|
|
6b653bc5e8 | ||
|
|
1b2985892b | ||
|
|
eb0094c189 | ||
|
|
5edbd66398 | ||
|
|
4e731e976c | ||
|
|
bd6e23435e | ||
|
|
8ec91e1392 | ||
|
|
8f69b56378 | ||
|
|
ccd0c6bdeb | ||
|
|
1c9109af73 | ||
|
|
a556a2e102 | ||
|
|
9fcd5b0e98 | ||
|
|
a1be1e16b2 | ||
|
|
fc7fc08a6e | ||
|
|
d74515142d | ||
|
|
0aae10e8a0 | ||
|
|
242c6f2ca7 | ||
|
|
413b74bf9a | ||
|
|
aad5c9461f | ||
|
|
23cccbb660 | ||
|
|
ba7666526c | ||
|
|
82ea11b6fa | ||
|
|
9771cea25f | ||
|
|
6f4afd85d7 | ||
|
|
fe82fa623b | ||
|
|
28b521a192 | ||
|
|
bdfbb4d2b1 | ||
|
|
6937a93d17 | ||
|
|
2bc4fca4dd | ||
|
|
92428593e2 | ||
|
|
95e3f74301 | ||
|
|
9145eb034b | ||
|
|
829dc3b591 | ||
|
|
c4c6178b9e | ||
|
|
9967bcb102 | ||
|
|
feb186db65 | ||
|
|
84999338e6 | ||
|
|
7943b56dbb | ||
|
|
6a1657cf20 | ||
|
|
0eaf32b8a7 | ||
|
|
424c1e76f0 | ||
|
|
e854dbb816 | ||
|
|
5e37678348 | ||
|
|
9fcb5ca633 | ||
|
|
55aedc33c3 | ||
|
|
1d4aa43185 | ||
|
|
8014eedd72 | ||
|
|
4f018775ba | ||
|
|
4e7bd95366 | ||
|
|
3035056ded | ||
|
|
df42292f0a | ||
|
|
ca2ff2a890 | ||
|
|
bd06c3f8f4 | ||
|
|
a44cd904dc | ||
|
|
09838e632d | ||
|
|
7f77ccb18a | ||
|
|
f3f05aa72b | ||
|
|
6beb9c78e1 | ||
|
|
2efc0a5228 | ||
|
|
bb0cae2be1 | ||
|
|
22a6fdd0c4 | ||
|
|
d257a441c2 | ||
|
|
49c81b6afd | ||
|
|
045497a7c8 | ||
|
|
521970b8a1 | ||
|
|
a1e9dd7746 | ||
|
|
61d2467916 | ||
|
|
f3adf773a7 | ||
|
|
ad807cf478 | ||
|
|
a1194232af | ||
|
|
9fc1746495 | ||
|
|
103bf7948d | ||
|
|
12c2dea226 | ||
|
|
7fbe8ac6a5 | ||
|
|
ef6868fd40 | ||
|
|
f238845f9b | ||
|
|
d4d16b71ae | ||
|
|
9baf571478 | ||
|
|
6370ac77e6 | ||
|
|
2bf3f2a5c6 | ||
|
|
e8bf42891e | ||
|
|
c21f970b86 | ||
|
|
56045cd338 | ||
|
|
dbf6121098 | ||
|
|
103b2fe923 | ||
|
|
c70a266b22 | ||
|
|
a7b34ca4b0 | ||
|
|
caa6fa838f | ||
|
|
e98140d0ac | ||
|
|
ac47b38773 | ||
|
|
fef6e4f6fa | ||
|
|
0215e5944d | ||
|
|
1b6ad163e3 | ||
|
|
080de35545 | ||
|
|
163423222d | ||
|
|
fc49b7ad00 | ||
|
|
b83cd99d8c | ||
|
|
74a5de96c0 | ||
|
|
fcf78cdd08 | ||
|
|
98fbc81d2f | ||
|
|
5ad562ab1c | ||
|
|
10dc011f9a | ||
|
|
3df6e91f95 | ||
|
|
31ae15d242 | ||
|
|
a2cfbb5e52 | ||
|
|
c4bd94daae | ||
|
|
e18828cd08 | ||
|
|
82f6b4607b | ||
|
|
3874ab3483 | ||
|
|
fc297cb198 | ||
|
|
aec06c5a55 | ||
|
|
87ce076f26 | ||
|
|
45b1bf130d | ||
|
|
3966578015 | ||
|
|
fed7b3678b | ||
|
|
ac6ce257b8 | ||
|
|
b8b8f747d3 | ||
|
|
53468b2e3a | ||
|
|
ecadf6ade7 | ||
|
|
8187b09fcb | ||
|
|
89117d4198 | ||
|
|
6158dd2750 | ||
|
|
86f33d054a | ||
|
|
52e8458590 | ||
|
|
554cf45500 | ||
|
|
60f751713a | ||
|
|
edd9b38cfc | ||
|
|
9a87d73289 | ||
|
|
317763e2c3 | ||
|
|
aa3f9d2ca8 | ||
|
|
e64a5ba1bc | ||
|
|
00e6f7bb60 | ||
|
|
883ef05ab4 | ||
|
|
d0b5eb3371 | ||
|
|
590ef96aa7 | ||
|
|
172ca5a2f3 | ||
|
|
6e1e56c1bd | ||
|
|
105fed4bd0 | ||
|
|
8bd3dc56d8 | ||
|
|
8e88bf64b1 | ||
|
|
244a832c52 | ||
|
|
146af3aeba | ||
|
|
143e8e29d7 | ||
|
|
c702e6e01a | ||
|
|
b2ddb9f4e2 | ||
|
|
201186bab2 | ||
|
|
bfcd59daca | ||
|
|
d5c3843c3f | ||
|
|
d3f307eac5 | ||
|
|
675a52b8d1 | ||
|
|
aee90e9c4e | ||
|
|
eb39b81d8d | ||
|
|
436df47104 | ||
|
|
e04e5e34c6 | ||
|
|
b57d685c03 | ||
|
|
6684172592 | ||
|
|
0257e74ff0 | ||
|
|
16c8865651 | ||
|
|
1a61aa2458 | ||
|
|
e543f07d8e | ||
|
|
96a0495a88 | ||
|
|
02befcd8a4 | ||
|
|
15b500806a | ||
|
|
9accf5d27d | ||
|
|
191ab29a44 | ||
|
|
a4d4cd5f70 | ||
|
|
3b07f7346f | ||
|
|
1edceeebdd | ||
|
|
fbf261f80b | ||
|
|
432fa18299 | ||
|
|
b2dcec840b | ||
|
|
6f93d65f02 | ||
|
|
852b901353 | ||
|
|
71a282157d | ||
|
|
49f462cdf5 | ||
|
|
94c0ca70e1 | ||
|
|
813637762c | ||
|
|
eb39b85a8b | ||
|
|
201fd8d687 | ||
|
|
02116d8f0f | ||
|
|
551a190edf | ||
|
|
f5015a4028 | ||
|
|
ea55616bd6 | ||
|
|
2b8eb93404 | ||
|
|
18113d94e9 |
56
.github/ISSUE_TEMPLATE/bug.yml
vendored
@@ -1,35 +1,75 @@
|
|||||||
name: 遇到问题
|
name: 遇到问题
|
||||||
description: 关于使用过程中遇到的问题
|
description: 关于使用过程中遇到的问题
|
||||||
title: 请填写标题
|
|
||||||
labels: [bug]
|
labels: [bug]
|
||||||
body:
|
body:
|
||||||
- type: input
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
---
|
||||||
|
在此之前,我们默认你已经知道该如何提问。简而言之,**你要精确地描述问题并提供充足的信息**
|
||||||
|
|
||||||
|
此外,如果需要,你可以使用 <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>I</kbd> 打开开发者工具为我们提供信息
|
||||||
|
|
||||||
|
- type: checkboxes
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
attributes:
|
||||||
|
label: "检查清单"
|
||||||
|
description: |
|
||||||
|
我们需要了解一些信息,你需要检查下面的检查项 <br />
|
||||||
|
**这里并不是每一个检查项都必要,根据你的真实情况勾选即可**
|
||||||
|
options:
|
||||||
|
- label: "我已检索仓库中所有的 Issues,确保我**没有重复提交问题**;或有相似 Issue,但我觉得我的情况不包含在那个相似 Issue 之内"
|
||||||
|
- label: "我已经找到了可以复现这个问题的方法,并且写在了下面的「具体信息」中"
|
||||||
|
- label: "此问题可以在我的设备和当前环境中**稳定复现**"
|
||||||
|
- label: "此问题可以在最新版本 (Latest Release) 中复现"
|
||||||
|
- label: "此问题是在我更新到当前版本后**才**出现的"
|
||||||
|
|
||||||
|
- type: dropdown
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
attributes:
|
attributes:
|
||||||
label: "是网页端还是客户端"
|
label: "是网页端还是客户端"
|
||||||
placeholder: "客户端"
|
options:
|
||||||
|
- "客户端"
|
||||||
|
- "网页端"
|
||||||
|
default: 0
|
||||||
|
|
||||||
- type: input
|
- type: input
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
attributes:
|
attributes:
|
||||||
label: "当前系统环境"
|
label: "当前系统环境"
|
||||||
placeholder: "win11"
|
placeholder: "如:Windows 11"
|
||||||
|
|
||||||
- type: input
|
- type: input
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: false
|
||||||
attributes:
|
attributes:
|
||||||
label: "当前 Node.js 及 npm 版本"
|
label: "当前 Node.js 及 npm 版本"
|
||||||
placeholder: "v18.16.0 / v9.6.7"
|
placeholder: "如:v18.16.0 / v9.6.7 (选填)"
|
||||||
|
|
||||||
- type: input
|
- type: input
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
attributes:
|
attributes:
|
||||||
label: "当前版本"
|
label: "当前版本"
|
||||||
placeholder: "v1.0.0"
|
description: |
|
||||||
|
填写关于软件里的或 Releases 中版本号即可 <br />
|
||||||
|
如果是自行构建或从 GitHub Actions 下载的开发版,还需要提供 Commit ID
|
||||||
|
placeholder: "如:v1.0.0"
|
||||||
|
|
||||||
- type: textarea
|
- type: textarea
|
||||||
id: other
|
id: other
|
||||||
attributes:
|
attributes:
|
||||||
label: "具体信息"
|
label: "具体信息"
|
||||||
description: "请填写完整的复现步骤和遇到的问题,包括但不限于报错信息、控制台输出、网络请求等"
|
description: |
|
||||||
|
请填写完整的复现步骤和遇到的问题,还请尽量提供所有可能的信息,提供包括但不限于:
|
||||||
|
|
||||||
|
- 分步的复现步骤,可以使用 `1. xxx` (换行) `2. xxx` 的格式
|
||||||
|
- 截图(如果结合复现步骤还是无法详细表述,甚至可以录屏)
|
||||||
|
- 开发者工具中的:控制台输出报错、网络请求等
|
||||||
|
- 出现问题的在线歌曲链接、出现问题的文件(本地歌曲、歌词等)的下载链接
|
||||||
|
|
||||||
|
等信息,以更好地帮助我们解决你的问题
|
||||||
placeholder: "请填写具体的复现步骤和遇到的问题"
|
placeholder: "请填写具体的复现步骤和遇到的问题"
|
||||||
|
|||||||
61
.github/workflows/build.yml
vendored
@@ -1,61 +0,0 @@
|
|||||||
# Dev 分支推送部署预览
|
|
||||||
## 仅部署 Win 端
|
|
||||||
name: Build Dev
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- dev
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
release:
|
|
||||||
name: Build and electron app
|
|
||||||
runs-on: windows-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
# 检出 Git 仓库
|
|
||||||
- name: Check out git repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
# 安装 Node.js
|
|
||||||
- name: Install Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: "20.x"
|
|
||||||
# 复制环境变量文件
|
|
||||||
- name: Copy .env.example
|
|
||||||
run: |
|
|
||||||
if (-not (Test-Path .env)) {
|
|
||||||
Copy-Item .env.example .env
|
|
||||||
} else {
|
|
||||||
Write-Host ".env file already exists. Skipping the copy step."
|
|
||||||
}
|
|
||||||
# 安装项目依赖
|
|
||||||
- name: Install Dependencies
|
|
||||||
run: npm install
|
|
||||||
# 构建 Electron App
|
|
||||||
- name: Build Electron App
|
|
||||||
run: npm run build:win
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
|
||||||
# 清理不必要的构建产物
|
|
||||||
- name: Cleanup Artifacts
|
|
||||||
run: npx del-cli "dist/**/*" "!dist/*.exe"
|
|
||||||
# 上传构建产物
|
|
||||||
- name: Upload artifacts
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: SPlayer-dev
|
|
||||||
path: dist
|
|
||||||
# 创建 GitHub Release
|
|
||||||
- name: Release
|
|
||||||
uses: softprops/action-gh-release@v2
|
|
||||||
if: startsWith(github.ref, 'refs/tags/v')
|
|
||||||
with:
|
|
||||||
tag_name: ${{ github.ref }}
|
|
||||||
name: ${{ github.ref }}-rc
|
|
||||||
body: This version is still under development, currently only provides windows version, non-developers please do not use!
|
|
||||||
draft: false
|
|
||||||
prerelease: true
|
|
||||||
files: dist/*.exe
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
|
||||||
67
.github/workflows/dev.yml
vendored
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
# Dev 分支推送部署预览
|
||||||
|
## 部署 Windows x64 和 ARM64 版本
|
||||||
|
name: Build Dev
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- dev
|
||||||
|
|
||||||
|
env:
|
||||||
|
NODE_VERSION: 22.x
|
||||||
|
PNPM_VERSION: 8
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
# Windows x64 架构
|
||||||
|
build-win:
|
||||||
|
name: Build Electron App for Windows
|
||||||
|
runs-on: windows-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
# 检出 Git 仓库
|
||||||
|
- name: Check out git repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
# 设置 pnpm 版本
|
||||||
|
- name: Setup pnpm
|
||||||
|
uses: pnpm/action-setup@v3
|
||||||
|
with:
|
||||||
|
version: ${{ env.PNPM_VERSION }}
|
||||||
|
# 安装 Node.js
|
||||||
|
- name: Install Node.js
|
||||||
|
uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
|
cache: "pnpm"
|
||||||
|
# 复制环境变量文件
|
||||||
|
- name: Copy .env.example
|
||||||
|
run: |
|
||||||
|
if (-not (Test-Path .env)) {
|
||||||
|
Copy-Item .env.example .env
|
||||||
|
} else {
|
||||||
|
Write-Host ".env file already exists. Skipping the copy step."
|
||||||
|
}
|
||||||
|
# 安装项目依赖
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: pnpm install
|
||||||
|
# 清理旧的构建产物
|
||||||
|
- name: Clean dist folder
|
||||||
|
run: |
|
||||||
|
if (Test-Path dist) {
|
||||||
|
Remove-Item -Recurse -Force dist
|
||||||
|
}
|
||||||
|
# 构建 Electron App (x64)
|
||||||
|
- name: Build Electron App for Windows x64
|
||||||
|
# 仅 x64
|
||||||
|
run: pnpm run build:win -- --arch=x64
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
# 清理不必要的构建产物(保留 .exe 和 .blockmap 文件)
|
||||||
|
- name: Cleanup Artifacts
|
||||||
|
run: npx del-cli "dist/**/*.yaml" "dist/**/*.yml"
|
||||||
|
# 上传构建产物(仅上传 x64 架构的 .exe 文件)
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: SPlayer-dev
|
||||||
|
path: |
|
||||||
|
dist/**.exe
|
||||||
246
.github/workflows/release.yml
vendored
@@ -1,159 +1,169 @@
|
|||||||
# Release 发行版本部署
|
name: Build & Release
|
||||||
## 多端部署
|
|
||||||
name: Build Release
|
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- v*
|
- v* # 只在 tag v* 时触发
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
env:
|
||||||
|
NODE_VERSION: 22.x
|
||||||
|
PNPM_VERSION: 8
|
||||||
|
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# Windows
|
# ===================================================================
|
||||||
build-windows:
|
# 并行构建所有平台和架构
|
||||||
name: Build for Windows
|
# ===================================================================
|
||||||
runs-on: windows-latest
|
build:
|
||||||
timeout-minutes: 30
|
name: Build on ${{ matrix.os }}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
# 矩阵策略
|
||||||
|
# 即使一个矩阵任务失败,其他任务也会继续运行
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||||
|
# 开始步骤
|
||||||
steps:
|
steps:
|
||||||
# 检出 Git 仓库
|
# 检出 Git 仓库
|
||||||
- name: Check out git repository
|
- name: Check out git repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
# 安装 Node.js
|
# 设置 pnpm 版本
|
||||||
- name: Install Node.js
|
- name: Setup pnpm
|
||||||
uses: actions/setup-node@v4
|
uses: pnpm/action-setup@v3
|
||||||
with:
|
with:
|
||||||
node-version: "20.x"
|
version: ${{ env.PNPM_VERSION }}
|
||||||
|
# 安装 Node.js
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
|
cache: "pnpm"
|
||||||
|
# 清理旧的构建产物
|
||||||
|
- name: Clean workspace on Windows
|
||||||
|
if: runner.os == 'Windows'
|
||||||
|
run: |
|
||||||
|
Write-Host "🧹 Cleaning workspace, node_modules, and Electron caches..."
|
||||||
|
if (Test-Path dist) { Remove-Item -Recurse -Force dist }
|
||||||
|
if (Test-Path out) { Remove-Item -Recurse -Force out }
|
||||||
|
if (Test-Path node_modules) { Remove-Item -Recurse -Force node_modules }
|
||||||
|
|
||||||
|
if (Test-Path "$env:LOCALAPPDATA\electron-builder") {
|
||||||
|
Remove-Item "$env:LOCALAPPDATA\electron-builder" -Recurse -Force -ErrorAction SilentlyContinue
|
||||||
|
}
|
||||||
|
if (Test-Path "$env:LOCALAPPDATA\electron") {
|
||||||
|
Remove-Item "$env:LOCALAPPDATA\electron" -Recurse -Force -ErrorAction SilentlyContinue
|
||||||
|
}
|
||||||
|
- name: Clean workspace on macOS & Linux
|
||||||
|
if: runner.os == 'macOS' || runner.os == 'Linux'
|
||||||
|
run: |
|
||||||
|
echo "🧹 Cleaning workspace, node_modules, and Electron caches..."
|
||||||
|
rm -rf dist out node_modules ~/.cache/electron-builder ~/.cache/electron
|
||||||
|
# 安装项目依赖
|
||||||
|
- name: Install dependencies
|
||||||
|
run: pnpm install
|
||||||
# 复制环境变量文件
|
# 复制环境变量文件
|
||||||
- name: Copy .env.example
|
- name: Copy .env file on Windows
|
||||||
|
if: runner.os == 'Windows'
|
||||||
run: |
|
run: |
|
||||||
if (-not (Test-Path .env)) {
|
if (-not (Test-Path .env)) {
|
||||||
Copy-Item .env.example .env
|
Copy-Item .env.example .env
|
||||||
} else {
|
} else {
|
||||||
Write-Host ".env file already exists. Skipping the copy step."
|
Write-Host ".env file already exists. Skipping the copy step."
|
||||||
}
|
}
|
||||||
# 安装项目依赖
|
- name: Copy .env file on macOS & Linux
|
||||||
- name: Install Dependencies
|
if: runner.os == 'macOS' || runner.os == 'Linux'
|
||||||
run: npm install
|
|
||||||
# 构建 Electron App
|
|
||||||
- name: Build Electron App for Windows
|
|
||||||
run: npm run build:win || true
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
|
||||||
# 上传构建产物
|
|
||||||
- name: Upload Windows artifact
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: SPlarer-Win
|
|
||||||
if-no-files-found: ignore
|
|
||||||
path: dist/*.*
|
|
||||||
# 创建 GitHub Release
|
|
||||||
- name: Release
|
|
||||||
uses: softprops/action-gh-release@v2
|
|
||||||
if: startsWith(github.ref, 'refs/tags/v')
|
|
||||||
with:
|
|
||||||
draft: false
|
|
||||||
files: dist/*.*
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
|
||||||
# Mac
|
|
||||||
build-macos:
|
|
||||||
name: Build for macOS
|
|
||||||
runs-on: macos-latest
|
|
||||||
timeout-minutes: 30
|
|
||||||
steps:
|
|
||||||
# 检出 Git 仓库
|
|
||||||
- name: Check out git repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
# 安装 Node.js
|
|
||||||
- name: Install Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: "20.x"
|
|
||||||
# 复制环境变量文件
|
|
||||||
- name: Copy .env.example
|
|
||||||
run: |
|
run: |
|
||||||
if [ ! -f .env ]; then
|
if [ ! -f .env ]; then
|
||||||
cp .env.example .env
|
cp .env.example .env
|
||||||
else
|
else
|
||||||
echo ".env file already exists. Skipping the copy step."
|
echo ".env file already exists. Skipping the copy step."
|
||||||
fi
|
fi
|
||||||
# 安装项目依赖
|
|
||||||
- name: Install Dependencies
|
|
||||||
run: npm install
|
|
||||||
# 构建 Electron App
|
|
||||||
- name: Build Electron App for macOS
|
|
||||||
run: npm run build:mac || true
|
|
||||||
shell: bash
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
|
||||||
# 上传构建产物
|
|
||||||
- name: Upload macOS artifact
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: SPlarer-Macos
|
|
||||||
if-no-files-found: ignore
|
|
||||||
path: dist/*.*
|
|
||||||
# 创建 GitHub Release
|
|
||||||
- name: Release
|
|
||||||
uses: softprops/action-gh-release@v2
|
|
||||||
if: startsWith(github.ref, 'refs/tags/v')
|
|
||||||
with:
|
|
||||||
draft: false
|
|
||||||
files: dist/*.*
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
|
||||||
# Linux
|
|
||||||
build-linux:
|
|
||||||
name: Build for Linux
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
timeout-minutes: 30
|
|
||||||
steps:
|
|
||||||
# 检出 Git 仓库
|
|
||||||
- name: Check out git repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
# 安装 Node.js
|
|
||||||
- name: Install Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: "20.x"
|
|
||||||
# 更新 Ubuntu 软件源
|
# 更新 Ubuntu 软件源
|
||||||
- name: Ubuntu Update with sudo
|
- name: Ubuntu Update with sudo
|
||||||
|
if: runner.os == 'Linux'
|
||||||
run: sudo apt-get update
|
run: sudo apt-get update
|
||||||
# 安装依赖
|
# 安装依赖
|
||||||
- name: Install RPM & Pacman
|
- name: Install RPM & Pacman
|
||||||
|
if: runner.os == 'Linux'
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get install --no-install-recommends -y rpm &&
|
sudo apt-get install --no-install-recommends -y rpm &&
|
||||||
sudo apt-get install --no-install-recommends -y libarchive-tools &&
|
sudo apt-get install --no-install-recommends -y libarchive-tools &&
|
||||||
sudo apt-get install --no-install-recommends -y libopenjp2-tools
|
sudo apt-get install --no-install-recommends -y libopenjp2-tools
|
||||||
# 复制环境变量文件
|
# 安裝 Snapcraft
|
||||||
- name: Copy .env.example
|
- name: Install Snapcraft
|
||||||
run: |
|
if: runner.os == 'Linux'
|
||||||
if [ ! -f .env ]; then
|
uses: samuelmeuli/action-snapcraft@v2
|
||||||
cp .env.example .env
|
|
||||||
else
|
|
||||||
echo ".env file already exists. Skipping the copy step."
|
|
||||||
fi
|
|
||||||
# 安装项目依赖
|
|
||||||
- name: Install Dependencies
|
|
||||||
run: npm install
|
|
||||||
# 构建 Electron App
|
# 构建 Electron App
|
||||||
- name: Build Electron App for Linux
|
- name: Build Windows x64 & ARM64 App
|
||||||
run: npm run build:linux || true
|
if: runner.os == 'Windows'
|
||||||
|
run: pnpm build:win || true
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- name: Build macOS Universal App
|
||||||
|
if: runner.os == 'macOS'
|
||||||
|
run: pnpm build:mac || true
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
# 上传构建产物
|
- name: Build Linux x64 & ARM64 App
|
||||||
- name: Upload Linux artifact
|
if: runner.os == 'Linux'
|
||||||
|
run: pnpm build:linux || true
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
# 上传 Snap 包到 Snapcraft 商店
|
||||||
|
- name: Publish Snap to Snap Store
|
||||||
|
if: runner.os == 'Linux'
|
||||||
|
run: snapcraft upload dist/*.snap --release stable
|
||||||
|
continue-on-error: true
|
||||||
|
# 合并所有构建
|
||||||
|
- name: Upload Artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: SPlarer-Linux
|
name: SPlayer-${{ runner.os }}
|
||||||
if-no-files-found: ignore
|
|
||||||
path: dist/*.*
|
path: dist/*.*
|
||||||
# 创建 GitHub Release
|
|
||||||
- name: Release
|
# ===================================================================
|
||||||
uses: softprops/action-gh-release@v2
|
# 收集并发布 Release
|
||||||
if: startsWith(github.ref, 'refs/tags/v')
|
# ===================================================================
|
||||||
|
release:
|
||||||
|
name: Create GitHub Release
|
||||||
|
needs: build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
# 需要写入权限
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
steps:
|
||||||
|
# 将所有产物下载到 artifacts 文件夹
|
||||||
|
- name: Download all artifacts
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
|
path: artifacts
|
||||||
|
# 创建 GitHub Release 并上传所有产物
|
||||||
|
- name: Create GitHub Release and Upload Assets
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
continue-on-error: true
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
# 自动生成 Release 说明
|
||||||
|
generate_release_notes: true
|
||||||
|
# 发布为草稿
|
||||||
draft: false
|
draft: false
|
||||||
files: dist/*.*
|
# 发布为预发布
|
||||||
env:
|
prerelease: false
|
||||||
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
# 全部上传
|
||||||
|
files: |
|
||||||
|
!artifacts/**/*-unpacked/**
|
||||||
|
artifacts/**/*.exe
|
||||||
|
artifacts/**/*.dmg
|
||||||
|
artifacts/**/*.zip
|
||||||
|
artifacts/**/*.AppImage
|
||||||
|
artifacts/**/*.deb
|
||||||
|
artifacts/**/*.rpm
|
||||||
|
artifacts/**/*.pacman
|
||||||
|
artifacts/**/*.snap
|
||||||
|
artifacts/**/*.tar.gz
|
||||||
|
artifacts/**/*.yml
|
||||||
|
artifacts/**/*.blockmap
|
||||||
|
|||||||
2
.gitignore
vendored
@@ -28,3 +28,5 @@ components.d.ts
|
|||||||
*.njsproj
|
*.njsproj
|
||||||
*.sln
|
*.sln
|
||||||
*.sw?
|
*.sw?
|
||||||
|
.env.development
|
||||||
|
.env.production
|
||||||
|
|||||||
14
Dockerfile
@@ -23,8 +23,16 @@ COPY --from=builder /app/out/renderer /usr/share/nginx/html
|
|||||||
|
|
||||||
COPY --from=builder /app/nginx.conf /etc/nginx/conf.d/default.conf
|
COPY --from=builder /app/nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
RUN apk add --no-cache npm
|
COPY --from=builder /app/docker-entrypoint.sh /docker-entrypoint.sh
|
||||||
|
|
||||||
RUN npm install -g NeteaseCloudMusicApi
|
RUN apk add --no-cache npm python3 youtube-dl \
|
||||||
|
&& npm install -g @unblockneteasemusic/server NeteaseCloudMusicApi \
|
||||||
|
&& wget https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -O /usr/local/bin/yt-dlp \
|
||||||
|
&& chmod +x /usr/local/bin/yt-dlp \
|
||||||
|
&& chmod +x /docker-entrypoint.sh
|
||||||
|
|
||||||
CMD nginx && npx NeteaseCloudMusicApi
|
ENV NODE_TLS_REJECT_UNAUTHORIZED=0
|
||||||
|
|
||||||
|
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||||
|
|
||||||
|
CMD ["npx", "NeteaseCloudMusicApi"]
|
||||||
20
README.md
@@ -1,6 +1,12 @@
|
|||||||
# SPlayer
|
# SPlayer
|
||||||
|
|
||||||
> 一个简约的音乐播放器
|
> A simple music player
|
||||||
|
|
||||||
|

|
||||||
|

|
||||||
|
[](https://github.com/imsyy/SPlayer/actions/workflows/release.yml)
|
||||||
|

|
||||||
|

|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -24,6 +30,14 @@
|
|||||||
|
|
||||||
- 欢迎各位大佬 `Star` 😍
|
- 欢迎各位大佬 `Star` 😍
|
||||||
|
|
||||||
|
## 💬 交流群
|
||||||
|
|
||||||
|
<a href="https://qm.qq.com/cgi-bin/qm/qr?k=2-cVSf1bE0AvAehCib00qFEFdUvPaJ_k&jump_from=webapi&authKey=1NEhib9+GsmsXVo2rCc0IbRaVHeeRXJJ0gbsyKDcIwDdAzYySOubkFCvkV32+7Cw" target="_blank">
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
</a>
|
||||||
|
|
||||||
## 👀 Demo
|
## 👀 Demo
|
||||||
|
|
||||||
- [SPlayer](https://music.imsyy.top/)
|
- [SPlayer](https://music.imsyy.top/)
|
||||||
@@ -117,6 +131,10 @@
|
|||||||
|
|
||||||
[Dev Workflow](https://github.com/imsyy/SPlayer/actions/workflows/build.yml)
|
[Dev Workflow](https://github.com/imsyy/SPlayer/actions/workflows/build.yml)
|
||||||
|
|
||||||
|
## Snap Store
|
||||||
|
|
||||||
|
[](https://snapcraft.io/splayer)
|
||||||
|
|
||||||
## ⚙️ Docker 部署
|
## ⚙️ Docker 部署
|
||||||
|
|
||||||
> 安装及配置 `Docker` 将不在此处说明,请自行解决
|
> 安装及配置 `Docker` 将不在此处说明,请自行解决
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ export default {
|
|||||||
"MaybeRefOrGetter": true,
|
"MaybeRefOrGetter": true,
|
||||||
"PropType": true,
|
"PropType": true,
|
||||||
"Ref": true,
|
"Ref": true,
|
||||||
|
"ShallowRef": true,
|
||||||
|
"Slot": true,
|
||||||
|
"Slots": true,
|
||||||
"VNode": true,
|
"VNode": true,
|
||||||
"WritableComputedRef": true,
|
"WritableComputedRef": true,
|
||||||
"asyncComputed": true,
|
"asyncComputed": true,
|
||||||
@@ -29,6 +32,7 @@ export default {
|
|||||||
"createGlobalState": true,
|
"createGlobalState": true,
|
||||||
"createInjectionState": true,
|
"createInjectionState": true,
|
||||||
"createReactiveFn": true,
|
"createReactiveFn": true,
|
||||||
|
"createRef": true,
|
||||||
"createReusableTemplate": true,
|
"createReusableTemplate": true,
|
||||||
"createSharedComposable": true,
|
"createSharedComposable": true,
|
||||||
"createTemplatePromise": true,
|
"createTemplatePromise": true,
|
||||||
@@ -43,6 +47,7 @@ export default {
|
|||||||
"extendRef": true,
|
"extendRef": true,
|
||||||
"getCurrentInstance": true,
|
"getCurrentInstance": true,
|
||||||
"getCurrentScope": true,
|
"getCurrentScope": true,
|
||||||
|
"getCurrentWatcher": true,
|
||||||
"h": true,
|
"h": true,
|
||||||
"ignorableWatch": true,
|
"ignorableWatch": true,
|
||||||
"inject": true,
|
"inject": true,
|
||||||
@@ -52,6 +57,7 @@ export default {
|
|||||||
"isReactive": true,
|
"isReactive": true,
|
||||||
"isReadonly": true,
|
"isReadonly": true,
|
||||||
"isRef": true,
|
"isRef": true,
|
||||||
|
"isShallow": true,
|
||||||
"makeDestructurable": true,
|
"makeDestructurable": true,
|
||||||
"markRaw": true,
|
"markRaw": true,
|
||||||
"nextTick": true,
|
"nextTick": true,
|
||||||
@@ -63,6 +69,7 @@ export default {
|
|||||||
"onBeforeUpdate": true,
|
"onBeforeUpdate": true,
|
||||||
"onClickOutside": true,
|
"onClickOutside": true,
|
||||||
"onDeactivated": true,
|
"onDeactivated": true,
|
||||||
|
"onElementRemoval": true,
|
||||||
"onErrorCaptured": true,
|
"onErrorCaptured": true,
|
||||||
"onKeyStroke": true,
|
"onKeyStroke": true,
|
||||||
"onLongPress": true,
|
"onLongPress": true,
|
||||||
@@ -145,6 +152,7 @@ export default {
|
|||||||
"useCloned": true,
|
"useCloned": true,
|
||||||
"useColorMode": true,
|
"useColorMode": true,
|
||||||
"useConfirmDialog": true,
|
"useConfirmDialog": true,
|
||||||
|
"useCountdown": true,
|
||||||
"useCounter": true,
|
"useCounter": true,
|
||||||
"useCssModule": true,
|
"useCssModule": true,
|
||||||
"useCssVar": true,
|
"useCssVar": true,
|
||||||
@@ -229,12 +237,14 @@ export default {
|
|||||||
"usePreferredDark": true,
|
"usePreferredDark": true,
|
||||||
"usePreferredLanguages": true,
|
"usePreferredLanguages": true,
|
||||||
"usePreferredReducedMotion": true,
|
"usePreferredReducedMotion": true,
|
||||||
|
"usePreferredReducedTransparency": true,
|
||||||
"usePrevious": true,
|
"usePrevious": true,
|
||||||
"useRafFn": true,
|
"useRafFn": true,
|
||||||
"useRefHistory": true,
|
"useRefHistory": true,
|
||||||
"useResizeObserver": true,
|
"useResizeObserver": true,
|
||||||
"useRoute": true,
|
"useRoute": true,
|
||||||
"useRouter": true,
|
"useRouter": true,
|
||||||
|
"useSSRWidth": true,
|
||||||
"useScreenOrientation": true,
|
"useScreenOrientation": true,
|
||||||
"useScreenSafeArea": true,
|
"useScreenSafeArea": true,
|
||||||
"useScriptTag": true,
|
"useScriptTag": true,
|
||||||
@@ -261,6 +271,7 @@ export default {
|
|||||||
"useThrottleFn": true,
|
"useThrottleFn": true,
|
||||||
"useThrottledRefHistory": true,
|
"useThrottledRefHistory": true,
|
||||||
"useTimeAgo": true,
|
"useTimeAgo": true,
|
||||||
|
"useTimeAgoIntl": true,
|
||||||
"useTimeout": true,
|
"useTimeout": true,
|
||||||
"useTimeoutFn": true,
|
"useTimeoutFn": true,
|
||||||
"useTimeoutPoll": true,
|
"useTimeoutPoll": true,
|
||||||
|
|||||||
584
auto-imports.d.ts
vendored
@@ -6,296 +6,306 @@
|
|||||||
// biome-ignore lint: disable
|
// biome-ignore lint: disable
|
||||||
export {}
|
export {}
|
||||||
declare global {
|
declare global {
|
||||||
const EffectScope: typeof import('vue')['EffectScope']
|
const EffectScope: typeof import('vue').EffectScope
|
||||||
const asyncComputed: typeof import('@vueuse/core')['asyncComputed']
|
const asyncComputed: typeof import('@vueuse/core').asyncComputed
|
||||||
const autoResetRef: typeof import('@vueuse/core')['autoResetRef']
|
const autoResetRef: typeof import('@vueuse/core').autoResetRef
|
||||||
const computed: typeof import('vue')['computed']
|
const computed: typeof import('vue').computed
|
||||||
const computedAsync: typeof import('@vueuse/core')['computedAsync']
|
const computedAsync: typeof import('@vueuse/core').computedAsync
|
||||||
const computedEager: typeof import('@vueuse/core')['computedEager']
|
const computedEager: typeof import('@vueuse/core').computedEager
|
||||||
const computedInject: typeof import('@vueuse/core')['computedInject']
|
const computedInject: typeof import('@vueuse/core').computedInject
|
||||||
const computedWithControl: typeof import('@vueuse/core')['computedWithControl']
|
const computedWithControl: typeof import('@vueuse/core').computedWithControl
|
||||||
const controlledComputed: typeof import('@vueuse/core')['controlledComputed']
|
const controlledComputed: typeof import('@vueuse/core').controlledComputed
|
||||||
const controlledRef: typeof import('@vueuse/core')['controlledRef']
|
const controlledRef: typeof import('@vueuse/core').controlledRef
|
||||||
const createApp: typeof import('vue')['createApp']
|
const createApp: typeof import('vue').createApp
|
||||||
const createEventHook: typeof import('@vueuse/core')['createEventHook']
|
const createEventHook: typeof import('@vueuse/core').createEventHook
|
||||||
const createGlobalState: typeof import('@vueuse/core')['createGlobalState']
|
const createGlobalState: typeof import('@vueuse/core').createGlobalState
|
||||||
const createInjectionState: typeof import('@vueuse/core')['createInjectionState']
|
const createInjectionState: typeof import('@vueuse/core').createInjectionState
|
||||||
const createReactiveFn: typeof import('@vueuse/core')['createReactiveFn']
|
const createReactiveFn: typeof import('@vueuse/core').createReactiveFn
|
||||||
const createReusableTemplate: typeof import('@vueuse/core')['createReusableTemplate']
|
const createRef: typeof import('@vueuse/core').createRef
|
||||||
const createSharedComposable: typeof import('@vueuse/core')['createSharedComposable']
|
const createReusableTemplate: typeof import('@vueuse/core').createReusableTemplate
|
||||||
const createTemplatePromise: typeof import('@vueuse/core')['createTemplatePromise']
|
const createSharedComposable: typeof import('@vueuse/core').createSharedComposable
|
||||||
const createUnrefFn: typeof import('@vueuse/core')['createUnrefFn']
|
const createTemplatePromise: typeof import('@vueuse/core').createTemplatePromise
|
||||||
const customRef: typeof import('vue')['customRef']
|
const createUnrefFn: typeof import('@vueuse/core').createUnrefFn
|
||||||
const debouncedRef: typeof import('@vueuse/core')['debouncedRef']
|
const customRef: typeof import('vue').customRef
|
||||||
const debouncedWatch: typeof import('@vueuse/core')['debouncedWatch']
|
const debouncedRef: typeof import('@vueuse/core').debouncedRef
|
||||||
const defineAsyncComponent: typeof import('vue')['defineAsyncComponent']
|
const debouncedWatch: typeof import('@vueuse/core').debouncedWatch
|
||||||
const defineComponent: typeof import('vue')['defineComponent']
|
const defineAsyncComponent: typeof import('vue').defineAsyncComponent
|
||||||
const eagerComputed: typeof import('@vueuse/core')['eagerComputed']
|
const defineComponent: typeof import('vue').defineComponent
|
||||||
const effectScope: typeof import('vue')['effectScope']
|
const eagerComputed: typeof import('@vueuse/core').eagerComputed
|
||||||
const extendRef: typeof import('@vueuse/core')['extendRef']
|
const effectScope: typeof import('vue').effectScope
|
||||||
const getCurrentInstance: typeof import('vue')['getCurrentInstance']
|
const extendRef: typeof import('@vueuse/core').extendRef
|
||||||
const getCurrentScope: typeof import('vue')['getCurrentScope']
|
const getCurrentInstance: typeof import('vue').getCurrentInstance
|
||||||
const h: typeof import('vue')['h']
|
const getCurrentScope: typeof import('vue').getCurrentScope
|
||||||
const ignorableWatch: typeof import('@vueuse/core')['ignorableWatch']
|
const getCurrentWatcher: typeof import('vue').getCurrentWatcher
|
||||||
const inject: typeof import('vue')['inject']
|
const h: typeof import('vue').h
|
||||||
const injectLocal: typeof import('@vueuse/core')['injectLocal']
|
const ignorableWatch: typeof import('@vueuse/core').ignorableWatch
|
||||||
const isDefined: typeof import('@vueuse/core')['isDefined']
|
const inject: typeof import('vue').inject
|
||||||
const isProxy: typeof import('vue')['isProxy']
|
const injectLocal: typeof import('@vueuse/core').injectLocal
|
||||||
const isReactive: typeof import('vue')['isReactive']
|
const isDefined: typeof import('@vueuse/core').isDefined
|
||||||
const isReadonly: typeof import('vue')['isReadonly']
|
const isProxy: typeof import('vue').isProxy
|
||||||
const isRef: typeof import('vue')['isRef']
|
const isReactive: typeof import('vue').isReactive
|
||||||
const makeDestructurable: typeof import('@vueuse/core')['makeDestructurable']
|
const isReadonly: typeof import('vue').isReadonly
|
||||||
const markRaw: typeof import('vue')['markRaw']
|
const isRef: typeof import('vue').isRef
|
||||||
const nextTick: typeof import('vue')['nextTick']
|
const isShallow: typeof import('vue').isShallow
|
||||||
const onActivated: typeof import('vue')['onActivated']
|
const makeDestructurable: typeof import('@vueuse/core').makeDestructurable
|
||||||
const onBeforeMount: typeof import('vue')['onBeforeMount']
|
const manualResetRef: typeof import('@vueuse/core').manualResetRef
|
||||||
const onBeforeRouteLeave: typeof import('vue-router')['onBeforeRouteLeave']
|
const markRaw: typeof import('vue').markRaw
|
||||||
const onBeforeRouteUpdate: typeof import('vue-router')['onBeforeRouteUpdate']
|
const nextTick: typeof import('vue').nextTick
|
||||||
const onBeforeUnmount: typeof import('vue')['onBeforeUnmount']
|
const onActivated: typeof import('vue').onActivated
|
||||||
const onBeforeUpdate: typeof import('vue')['onBeforeUpdate']
|
const onBeforeMount: typeof import('vue').onBeforeMount
|
||||||
const onClickOutside: typeof import('@vueuse/core')['onClickOutside']
|
const onBeforeRouteLeave: typeof import('vue-router').onBeforeRouteLeave
|
||||||
const onDeactivated: typeof import('vue')['onDeactivated']
|
const onBeforeRouteUpdate: typeof import('vue-router').onBeforeRouteUpdate
|
||||||
const onErrorCaptured: typeof import('vue')['onErrorCaptured']
|
const onBeforeUnmount: typeof import('vue').onBeforeUnmount
|
||||||
const onKeyStroke: typeof import('@vueuse/core')['onKeyStroke']
|
const onBeforeUpdate: typeof import('vue').onBeforeUpdate
|
||||||
const onLongPress: typeof import('@vueuse/core')['onLongPress']
|
const onClickOutside: typeof import('@vueuse/core').onClickOutside
|
||||||
const onMounted: typeof import('vue')['onMounted']
|
const onDeactivated: typeof import('vue').onDeactivated
|
||||||
const onRenderTracked: typeof import('vue')['onRenderTracked']
|
const onElementRemoval: typeof import('@vueuse/core').onElementRemoval
|
||||||
const onRenderTriggered: typeof import('vue')['onRenderTriggered']
|
const onErrorCaptured: typeof import('vue').onErrorCaptured
|
||||||
const onScopeDispose: typeof import('vue')['onScopeDispose']
|
const onKeyStroke: typeof import('@vueuse/core').onKeyStroke
|
||||||
const onServerPrefetch: typeof import('vue')['onServerPrefetch']
|
const onLongPress: typeof import('@vueuse/core').onLongPress
|
||||||
const onStartTyping: typeof import('@vueuse/core')['onStartTyping']
|
const onMounted: typeof import('vue').onMounted
|
||||||
const onUnmounted: typeof import('vue')['onUnmounted']
|
const onRenderTracked: typeof import('vue').onRenderTracked
|
||||||
const onUpdated: typeof import('vue')['onUpdated']
|
const onRenderTriggered: typeof import('vue').onRenderTriggered
|
||||||
const onWatcherCleanup: typeof import('vue')['onWatcherCleanup']
|
const onScopeDispose: typeof import('vue').onScopeDispose
|
||||||
const pausableWatch: typeof import('@vueuse/core')['pausableWatch']
|
const onServerPrefetch: typeof import('vue').onServerPrefetch
|
||||||
const provide: typeof import('vue')['provide']
|
const onStartTyping: typeof import('@vueuse/core').onStartTyping
|
||||||
const provideLocal: typeof import('@vueuse/core')['provideLocal']
|
const onUnmounted: typeof import('vue').onUnmounted
|
||||||
const reactify: typeof import('@vueuse/core')['reactify']
|
const onUpdated: typeof import('vue').onUpdated
|
||||||
const reactifyObject: typeof import('@vueuse/core')['reactifyObject']
|
const onWatcherCleanup: typeof import('vue').onWatcherCleanup
|
||||||
const reactive: typeof import('vue')['reactive']
|
const pausableWatch: typeof import('@vueuse/core').pausableWatch
|
||||||
const reactiveComputed: typeof import('@vueuse/core')['reactiveComputed']
|
const provide: typeof import('vue').provide
|
||||||
const reactiveOmit: typeof import('@vueuse/core')['reactiveOmit']
|
const provideLocal: typeof import('@vueuse/core').provideLocal
|
||||||
const reactivePick: typeof import('@vueuse/core')['reactivePick']
|
const reactify: typeof import('@vueuse/core').reactify
|
||||||
const readonly: typeof import('vue')['readonly']
|
const reactifyObject: typeof import('@vueuse/core').reactifyObject
|
||||||
const ref: typeof import('vue')['ref']
|
const reactive: typeof import('vue').reactive
|
||||||
const refAutoReset: typeof import('@vueuse/core')['refAutoReset']
|
const reactiveComputed: typeof import('@vueuse/core').reactiveComputed
|
||||||
const refDebounced: typeof import('@vueuse/core')['refDebounced']
|
const reactiveOmit: typeof import('@vueuse/core').reactiveOmit
|
||||||
const refDefault: typeof import('@vueuse/core')['refDefault']
|
const reactivePick: typeof import('@vueuse/core').reactivePick
|
||||||
const refThrottled: typeof import('@vueuse/core')['refThrottled']
|
const readonly: typeof import('vue').readonly
|
||||||
const refWithControl: typeof import('@vueuse/core')['refWithControl']
|
const ref: typeof import('vue').ref
|
||||||
const resolveComponent: typeof import('vue')['resolveComponent']
|
const refAutoReset: typeof import('@vueuse/core').refAutoReset
|
||||||
const resolveRef: typeof import('@vueuse/core')['resolveRef']
|
const refDebounced: typeof import('@vueuse/core').refDebounced
|
||||||
const resolveUnref: typeof import('@vueuse/core')['resolveUnref']
|
const refDefault: typeof import('@vueuse/core').refDefault
|
||||||
const shallowReactive: typeof import('vue')['shallowReactive']
|
const refManualReset: typeof import('@vueuse/core').refManualReset
|
||||||
const shallowReadonly: typeof import('vue')['shallowReadonly']
|
const refThrottled: typeof import('@vueuse/core').refThrottled
|
||||||
const shallowRef: typeof import('vue')['shallowRef']
|
const refWithControl: typeof import('@vueuse/core').refWithControl
|
||||||
const syncRef: typeof import('@vueuse/core')['syncRef']
|
const resolveComponent: typeof import('vue').resolveComponent
|
||||||
const syncRefs: typeof import('@vueuse/core')['syncRefs']
|
const resolveRef: typeof import('@vueuse/core').resolveRef
|
||||||
const templateRef: typeof import('@vueuse/core')['templateRef']
|
const resolveUnref: typeof import('@vueuse/core').resolveUnref
|
||||||
const throttledRef: typeof import('@vueuse/core')['throttledRef']
|
const shallowReactive: typeof import('vue').shallowReactive
|
||||||
const throttledWatch: typeof import('@vueuse/core')['throttledWatch']
|
const shallowReadonly: typeof import('vue').shallowReadonly
|
||||||
const toRaw: typeof import('vue')['toRaw']
|
const shallowRef: typeof import('vue').shallowRef
|
||||||
const toReactive: typeof import('@vueuse/core')['toReactive']
|
const syncRef: typeof import('@vueuse/core').syncRef
|
||||||
const toRef: typeof import('vue')['toRef']
|
const syncRefs: typeof import('@vueuse/core').syncRefs
|
||||||
const toRefs: typeof import('vue')['toRefs']
|
const templateRef: typeof import('@vueuse/core').templateRef
|
||||||
const toValue: typeof import('vue')['toValue']
|
const throttledRef: typeof import('@vueuse/core').throttledRef
|
||||||
const triggerRef: typeof import('vue')['triggerRef']
|
const throttledWatch: typeof import('@vueuse/core').throttledWatch
|
||||||
const tryOnBeforeMount: typeof import('@vueuse/core')['tryOnBeforeMount']
|
const toRaw: typeof import('vue').toRaw
|
||||||
const tryOnBeforeUnmount: typeof import('@vueuse/core')['tryOnBeforeUnmount']
|
const toReactive: typeof import('@vueuse/core').toReactive
|
||||||
const tryOnMounted: typeof import('@vueuse/core')['tryOnMounted']
|
const toRef: typeof import('vue').toRef
|
||||||
const tryOnScopeDispose: typeof import('@vueuse/core')['tryOnScopeDispose']
|
const toRefs: typeof import('vue').toRefs
|
||||||
const tryOnUnmounted: typeof import('@vueuse/core')['tryOnUnmounted']
|
const toValue: typeof import('vue').toValue
|
||||||
const unref: typeof import('vue')['unref']
|
const triggerRef: typeof import('vue').triggerRef
|
||||||
const unrefElement: typeof import('@vueuse/core')['unrefElement']
|
const tryOnBeforeMount: typeof import('@vueuse/core').tryOnBeforeMount
|
||||||
const until: typeof import('@vueuse/core')['until']
|
const tryOnBeforeUnmount: typeof import('@vueuse/core').tryOnBeforeUnmount
|
||||||
const useActiveElement: typeof import('@vueuse/core')['useActiveElement']
|
const tryOnMounted: typeof import('@vueuse/core').tryOnMounted
|
||||||
const useAnimate: typeof import('@vueuse/core')['useAnimate']
|
const tryOnScopeDispose: typeof import('@vueuse/core').tryOnScopeDispose
|
||||||
const useArrayDifference: typeof import('@vueuse/core')['useArrayDifference']
|
const tryOnUnmounted: typeof import('@vueuse/core').tryOnUnmounted
|
||||||
const useArrayEvery: typeof import('@vueuse/core')['useArrayEvery']
|
const unref: typeof import('vue').unref
|
||||||
const useArrayFilter: typeof import('@vueuse/core')['useArrayFilter']
|
const unrefElement: typeof import('@vueuse/core').unrefElement
|
||||||
const useArrayFind: typeof import('@vueuse/core')['useArrayFind']
|
const until: typeof import('@vueuse/core').until
|
||||||
const useArrayFindIndex: typeof import('@vueuse/core')['useArrayFindIndex']
|
const useActiveElement: typeof import('@vueuse/core').useActiveElement
|
||||||
const useArrayFindLast: typeof import('@vueuse/core')['useArrayFindLast']
|
const useAnimate: typeof import('@vueuse/core').useAnimate
|
||||||
const useArrayIncludes: typeof import('@vueuse/core')['useArrayIncludes']
|
const useArrayDifference: typeof import('@vueuse/core').useArrayDifference
|
||||||
const useArrayJoin: typeof import('@vueuse/core')['useArrayJoin']
|
const useArrayEvery: typeof import('@vueuse/core').useArrayEvery
|
||||||
const useArrayMap: typeof import('@vueuse/core')['useArrayMap']
|
const useArrayFilter: typeof import('@vueuse/core').useArrayFilter
|
||||||
const useArrayReduce: typeof import('@vueuse/core')['useArrayReduce']
|
const useArrayFind: typeof import('@vueuse/core').useArrayFind
|
||||||
const useArraySome: typeof import('@vueuse/core')['useArraySome']
|
const useArrayFindIndex: typeof import('@vueuse/core').useArrayFindIndex
|
||||||
const useArrayUnique: typeof import('@vueuse/core')['useArrayUnique']
|
const useArrayFindLast: typeof import('@vueuse/core').useArrayFindLast
|
||||||
const useAsyncQueue: typeof import('@vueuse/core')['useAsyncQueue']
|
const useArrayIncludes: typeof import('@vueuse/core').useArrayIncludes
|
||||||
const useAsyncState: typeof import('@vueuse/core')['useAsyncState']
|
const useArrayJoin: typeof import('@vueuse/core').useArrayJoin
|
||||||
const useAttrs: typeof import('vue')['useAttrs']
|
const useArrayMap: typeof import('@vueuse/core').useArrayMap
|
||||||
const useBase64: typeof import('@vueuse/core')['useBase64']
|
const useArrayReduce: typeof import('@vueuse/core').useArrayReduce
|
||||||
const useBattery: typeof import('@vueuse/core')['useBattery']
|
const useArraySome: typeof import('@vueuse/core').useArraySome
|
||||||
const useBluetooth: typeof import('@vueuse/core')['useBluetooth']
|
const useArrayUnique: typeof import('@vueuse/core').useArrayUnique
|
||||||
const useBreakpoints: typeof import('@vueuse/core')['useBreakpoints']
|
const useAsyncQueue: typeof import('@vueuse/core').useAsyncQueue
|
||||||
const useBroadcastChannel: typeof import('@vueuse/core')['useBroadcastChannel']
|
const useAsyncState: typeof import('@vueuse/core').useAsyncState
|
||||||
const useBrowserLocation: typeof import('@vueuse/core')['useBrowserLocation']
|
const useAttrs: typeof import('vue').useAttrs
|
||||||
const useCached: typeof import('@vueuse/core')['useCached']
|
const useBase64: typeof import('@vueuse/core').useBase64
|
||||||
const useClipboard: typeof import('@vueuse/core')['useClipboard']
|
const useBattery: typeof import('@vueuse/core').useBattery
|
||||||
const useClipboardItems: typeof import('@vueuse/core')['useClipboardItems']
|
const useBluetooth: typeof import('@vueuse/core').useBluetooth
|
||||||
const useCloned: typeof import('@vueuse/core')['useCloned']
|
const useBreakpoints: typeof import('@vueuse/core').useBreakpoints
|
||||||
const useColorMode: typeof import('@vueuse/core')['useColorMode']
|
const useBroadcastChannel: typeof import('@vueuse/core').useBroadcastChannel
|
||||||
const useConfirmDialog: typeof import('@vueuse/core')['useConfirmDialog']
|
const useBrowserLocation: typeof import('@vueuse/core').useBrowserLocation
|
||||||
const useCounter: typeof import('@vueuse/core')['useCounter']
|
const useCached: typeof import('@vueuse/core').useCached
|
||||||
const useCssModule: typeof import('vue')['useCssModule']
|
const useClipboard: typeof import('@vueuse/core').useClipboard
|
||||||
const useCssVar: typeof import('@vueuse/core')['useCssVar']
|
const useClipboardItems: typeof import('@vueuse/core').useClipboardItems
|
||||||
const useCssVars: typeof import('vue')['useCssVars']
|
const useCloned: typeof import('@vueuse/core').useCloned
|
||||||
const useCurrentElement: typeof import('@vueuse/core')['useCurrentElement']
|
const useColorMode: typeof import('@vueuse/core').useColorMode
|
||||||
const useCycleList: typeof import('@vueuse/core')['useCycleList']
|
const useConfirmDialog: typeof import('@vueuse/core').useConfirmDialog
|
||||||
const useDark: typeof import('@vueuse/core')['useDark']
|
const useCountdown: typeof import('@vueuse/core').useCountdown
|
||||||
const useDateFormat: typeof import('@vueuse/core')['useDateFormat']
|
const useCounter: typeof import('@vueuse/core').useCounter
|
||||||
const useDebounce: typeof import('@vueuse/core')['useDebounce']
|
const useCssModule: typeof import('vue').useCssModule
|
||||||
const useDebounceFn: typeof import('@vueuse/core')['useDebounceFn']
|
const useCssVar: typeof import('@vueuse/core').useCssVar
|
||||||
const useDebouncedRefHistory: typeof import('@vueuse/core')['useDebouncedRefHistory']
|
const useCssVars: typeof import('vue').useCssVars
|
||||||
const useDeviceMotion: typeof import('@vueuse/core')['useDeviceMotion']
|
const useCurrentElement: typeof import('@vueuse/core').useCurrentElement
|
||||||
const useDeviceOrientation: typeof import('@vueuse/core')['useDeviceOrientation']
|
const useCycleList: typeof import('@vueuse/core').useCycleList
|
||||||
const useDevicePixelRatio: typeof import('@vueuse/core')['useDevicePixelRatio']
|
const useDark: typeof import('@vueuse/core').useDark
|
||||||
const useDevicesList: typeof import('@vueuse/core')['useDevicesList']
|
const useDateFormat: typeof import('@vueuse/core').useDateFormat
|
||||||
const useDialog: typeof import('naive-ui')['useDialog']
|
const useDebounce: typeof import('@vueuse/core').useDebounce
|
||||||
const useDisplayMedia: typeof import('@vueuse/core')['useDisplayMedia']
|
const useDebounceFn: typeof import('@vueuse/core').useDebounceFn
|
||||||
const useDocumentVisibility: typeof import('@vueuse/core')['useDocumentVisibility']
|
const useDebouncedRefHistory: typeof import('@vueuse/core').useDebouncedRefHistory
|
||||||
const useDraggable: typeof import('@vueuse/core')['useDraggable']
|
const useDeviceMotion: typeof import('@vueuse/core').useDeviceMotion
|
||||||
const useDropZone: typeof import('@vueuse/core')['useDropZone']
|
const useDeviceOrientation: typeof import('@vueuse/core').useDeviceOrientation
|
||||||
const useElementBounding: typeof import('@vueuse/core')['useElementBounding']
|
const useDevicePixelRatio: typeof import('@vueuse/core').useDevicePixelRatio
|
||||||
const useElementByPoint: typeof import('@vueuse/core')['useElementByPoint']
|
const useDevicesList: typeof import('@vueuse/core').useDevicesList
|
||||||
const useElementHover: typeof import('@vueuse/core')['useElementHover']
|
const useDialog: typeof import('naive-ui').useDialog
|
||||||
const useElementSize: typeof import('@vueuse/core')['useElementSize']
|
const useDisplayMedia: typeof import('@vueuse/core').useDisplayMedia
|
||||||
const useElementVisibility: typeof import('@vueuse/core')['useElementVisibility']
|
const useDocumentVisibility: typeof import('@vueuse/core').useDocumentVisibility
|
||||||
const useEventBus: typeof import('@vueuse/core')['useEventBus']
|
const useDraggable: typeof import('@vueuse/core').useDraggable
|
||||||
const useEventListener: typeof import('@vueuse/core')['useEventListener']
|
const useDropZone: typeof import('@vueuse/core').useDropZone
|
||||||
const useEventSource: typeof import('@vueuse/core')['useEventSource']
|
const useElementBounding: typeof import('@vueuse/core').useElementBounding
|
||||||
const useEyeDropper: typeof import('@vueuse/core')['useEyeDropper']
|
const useElementByPoint: typeof import('@vueuse/core').useElementByPoint
|
||||||
const useFavicon: typeof import('@vueuse/core')['useFavicon']
|
const useElementHover: typeof import('@vueuse/core').useElementHover
|
||||||
const useFetch: typeof import('@vueuse/core')['useFetch']
|
const useElementSize: typeof import('@vueuse/core').useElementSize
|
||||||
const useFileDialog: typeof import('@vueuse/core')['useFileDialog']
|
const useElementVisibility: typeof import('@vueuse/core').useElementVisibility
|
||||||
const useFileSystemAccess: typeof import('@vueuse/core')['useFileSystemAccess']
|
const useEventBus: typeof import('@vueuse/core').useEventBus
|
||||||
const useFocus: typeof import('@vueuse/core')['useFocus']
|
const useEventListener: typeof import('@vueuse/core').useEventListener
|
||||||
const useFocusWithin: typeof import('@vueuse/core')['useFocusWithin']
|
const useEventSource: typeof import('@vueuse/core').useEventSource
|
||||||
const useFps: typeof import('@vueuse/core')['useFps']
|
const useEyeDropper: typeof import('@vueuse/core').useEyeDropper
|
||||||
const useFullscreen: typeof import('@vueuse/core')['useFullscreen']
|
const useFavicon: typeof import('@vueuse/core').useFavicon
|
||||||
const useGamepad: typeof import('@vueuse/core')['useGamepad']
|
const useFetch: typeof import('@vueuse/core').useFetch
|
||||||
const useGeolocation: typeof import('@vueuse/core')['useGeolocation']
|
const useFileDialog: typeof import('@vueuse/core').useFileDialog
|
||||||
const useId: typeof import('vue')['useId']
|
const useFileSystemAccess: typeof import('@vueuse/core').useFileSystemAccess
|
||||||
const useIdle: typeof import('@vueuse/core')['useIdle']
|
const useFocus: typeof import('@vueuse/core').useFocus
|
||||||
const useImage: typeof import('@vueuse/core')['useImage']
|
const useFocusWithin: typeof import('@vueuse/core').useFocusWithin
|
||||||
const useInfiniteScroll: typeof import('@vueuse/core')['useInfiniteScroll']
|
const useFps: typeof import('@vueuse/core').useFps
|
||||||
const useIntersectionObserver: typeof import('@vueuse/core')['useIntersectionObserver']
|
const useFullscreen: typeof import('@vueuse/core').useFullscreen
|
||||||
const useInterval: typeof import('@vueuse/core')['useInterval']
|
const useGamepad: typeof import('@vueuse/core').useGamepad
|
||||||
const useIntervalFn: typeof import('@vueuse/core')['useIntervalFn']
|
const useGeolocation: typeof import('@vueuse/core').useGeolocation
|
||||||
const useKeyModifier: typeof import('@vueuse/core')['useKeyModifier']
|
const useId: typeof import('vue').useId
|
||||||
const useLastChanged: typeof import('@vueuse/core')['useLastChanged']
|
const useIdle: typeof import('@vueuse/core').useIdle
|
||||||
const useLink: typeof import('vue-router')['useLink']
|
const useImage: typeof import('@vueuse/core').useImage
|
||||||
const useLoadingBar: typeof import('naive-ui')['useLoadingBar']
|
const useInfiniteScroll: typeof import('@vueuse/core').useInfiniteScroll
|
||||||
const useLocalStorage: typeof import('@vueuse/core')['useLocalStorage']
|
const useIntersectionObserver: typeof import('@vueuse/core').useIntersectionObserver
|
||||||
const useMagicKeys: typeof import('@vueuse/core')['useMagicKeys']
|
const useInterval: typeof import('@vueuse/core').useInterval
|
||||||
const useManualRefHistory: typeof import('@vueuse/core')['useManualRefHistory']
|
const useIntervalFn: typeof import('@vueuse/core').useIntervalFn
|
||||||
const useMediaControls: typeof import('@vueuse/core')['useMediaControls']
|
const useKeyModifier: typeof import('@vueuse/core').useKeyModifier
|
||||||
const useMediaQuery: typeof import('@vueuse/core')['useMediaQuery']
|
const useLastChanged: typeof import('@vueuse/core').useLastChanged
|
||||||
const useMemoize: typeof import('@vueuse/core')['useMemoize']
|
const useLink: typeof import('vue-router').useLink
|
||||||
const useMemory: typeof import('@vueuse/core')['useMemory']
|
const useLoadingBar: typeof import('naive-ui').useLoadingBar
|
||||||
const useMessage: typeof import('naive-ui')['useMessage']
|
const useLocalStorage: typeof import('@vueuse/core').useLocalStorage
|
||||||
const useModel: typeof import('vue')['useModel']
|
const useMagicKeys: typeof import('@vueuse/core').useMagicKeys
|
||||||
const useMounted: typeof import('@vueuse/core')['useMounted']
|
const useManualRefHistory: typeof import('@vueuse/core').useManualRefHistory
|
||||||
const useMouse: typeof import('@vueuse/core')['useMouse']
|
const useMediaControls: typeof import('@vueuse/core').useMediaControls
|
||||||
const useMouseInElement: typeof import('@vueuse/core')['useMouseInElement']
|
const useMediaQuery: typeof import('@vueuse/core').useMediaQuery
|
||||||
const useMousePressed: typeof import('@vueuse/core')['useMousePressed']
|
const useMemoize: typeof import('@vueuse/core').useMemoize
|
||||||
const useMutationObserver: typeof import('@vueuse/core')['useMutationObserver']
|
const useMemory: typeof import('@vueuse/core').useMemory
|
||||||
const useNavigatorLanguage: typeof import('@vueuse/core')['useNavigatorLanguage']
|
const useMessage: typeof import('naive-ui').useMessage
|
||||||
const useNetwork: typeof import('@vueuse/core')['useNetwork']
|
const useModel: typeof import('vue').useModel
|
||||||
const useNotification: typeof import('naive-ui')['useNotification']
|
const useMounted: typeof import('@vueuse/core').useMounted
|
||||||
const useNow: typeof import('@vueuse/core')['useNow']
|
const useMouse: typeof import('@vueuse/core').useMouse
|
||||||
const useObjectUrl: typeof import('@vueuse/core')['useObjectUrl']
|
const useMouseInElement: typeof import('@vueuse/core').useMouseInElement
|
||||||
const useOffsetPagination: typeof import('@vueuse/core')['useOffsetPagination']
|
const useMousePressed: typeof import('@vueuse/core').useMousePressed
|
||||||
const useOnline: typeof import('@vueuse/core')['useOnline']
|
const useMutationObserver: typeof import('@vueuse/core').useMutationObserver
|
||||||
const usePageLeave: typeof import('@vueuse/core')['usePageLeave']
|
const useNavigatorLanguage: typeof import('@vueuse/core').useNavigatorLanguage
|
||||||
const useParallax: typeof import('@vueuse/core')['useParallax']
|
const useNetwork: typeof import('@vueuse/core').useNetwork
|
||||||
const useParentElement: typeof import('@vueuse/core')['useParentElement']
|
const useNotification: typeof import('naive-ui').useNotification
|
||||||
const usePerformanceObserver: typeof import('@vueuse/core')['usePerformanceObserver']
|
const useNow: typeof import('@vueuse/core').useNow
|
||||||
const usePermission: typeof import('@vueuse/core')['usePermission']
|
const useObjectUrl: typeof import('@vueuse/core').useObjectUrl
|
||||||
const usePointer: typeof import('@vueuse/core')['usePointer']
|
const useOffsetPagination: typeof import('@vueuse/core').useOffsetPagination
|
||||||
const usePointerLock: typeof import('@vueuse/core')['usePointerLock']
|
const useOnline: typeof import('@vueuse/core').useOnline
|
||||||
const usePointerSwipe: typeof import('@vueuse/core')['usePointerSwipe']
|
const usePageLeave: typeof import('@vueuse/core').usePageLeave
|
||||||
const usePreferredColorScheme: typeof import('@vueuse/core')['usePreferredColorScheme']
|
const useParallax: typeof import('@vueuse/core').useParallax
|
||||||
const usePreferredContrast: typeof import('@vueuse/core')['usePreferredContrast']
|
const useParentElement: typeof import('@vueuse/core').useParentElement
|
||||||
const usePreferredDark: typeof import('@vueuse/core')['usePreferredDark']
|
const usePerformanceObserver: typeof import('@vueuse/core').usePerformanceObserver
|
||||||
const usePreferredLanguages: typeof import('@vueuse/core')['usePreferredLanguages']
|
const usePermission: typeof import('@vueuse/core').usePermission
|
||||||
const usePreferredReducedMotion: typeof import('@vueuse/core')['usePreferredReducedMotion']
|
const usePointer: typeof import('@vueuse/core').usePointer
|
||||||
const usePrevious: typeof import('@vueuse/core')['usePrevious']
|
const usePointerLock: typeof import('@vueuse/core').usePointerLock
|
||||||
const useRafFn: typeof import('@vueuse/core')['useRafFn']
|
const usePointerSwipe: typeof import('@vueuse/core').usePointerSwipe
|
||||||
const useRefHistory: typeof import('@vueuse/core')['useRefHistory']
|
const usePreferredColorScheme: typeof import('@vueuse/core').usePreferredColorScheme
|
||||||
const useResizeObserver: typeof import('@vueuse/core')['useResizeObserver']
|
const usePreferredContrast: typeof import('@vueuse/core').usePreferredContrast
|
||||||
const useRoute: typeof import('vue-router')['useRoute']
|
const usePreferredDark: typeof import('@vueuse/core').usePreferredDark
|
||||||
const useRouter: typeof import('vue-router')['useRouter']
|
const usePreferredLanguages: typeof import('@vueuse/core').usePreferredLanguages
|
||||||
const useScreenOrientation: typeof import('@vueuse/core')['useScreenOrientation']
|
const usePreferredReducedMotion: typeof import('@vueuse/core').usePreferredReducedMotion
|
||||||
const useScreenSafeArea: typeof import('@vueuse/core')['useScreenSafeArea']
|
const usePreferredReducedTransparency: typeof import('@vueuse/core').usePreferredReducedTransparency
|
||||||
const useScriptTag: typeof import('@vueuse/core')['useScriptTag']
|
const usePrevious: typeof import('@vueuse/core').usePrevious
|
||||||
const useScroll: typeof import('@vueuse/core')['useScroll']
|
const useRafFn: typeof import('@vueuse/core').useRafFn
|
||||||
const useScrollLock: typeof import('@vueuse/core')['useScrollLock']
|
const useRefHistory: typeof import('@vueuse/core').useRefHistory
|
||||||
const useSessionStorage: typeof import('@vueuse/core')['useSessionStorage']
|
const useResizeObserver: typeof import('@vueuse/core').useResizeObserver
|
||||||
const useShare: typeof import('@vueuse/core')['useShare']
|
const useRoute: typeof import('vue-router').useRoute
|
||||||
const useSlots: typeof import('vue')['useSlots']
|
const useRouter: typeof import('vue-router').useRouter
|
||||||
const useSorted: typeof import('@vueuse/core')['useSorted']
|
const useSSRWidth: typeof import('@vueuse/core').useSSRWidth
|
||||||
const useSpeechRecognition: typeof import('@vueuse/core')['useSpeechRecognition']
|
const useScreenOrientation: typeof import('@vueuse/core').useScreenOrientation
|
||||||
const useSpeechSynthesis: typeof import('@vueuse/core')['useSpeechSynthesis']
|
const useScreenSafeArea: typeof import('@vueuse/core').useScreenSafeArea
|
||||||
const useStepper: typeof import('@vueuse/core')['useStepper']
|
const useScriptTag: typeof import('@vueuse/core').useScriptTag
|
||||||
const useStorage: typeof import('@vueuse/core')['useStorage']
|
const useScroll: typeof import('@vueuse/core').useScroll
|
||||||
const useStorageAsync: typeof import('@vueuse/core')['useStorageAsync']
|
const useScrollLock: typeof import('@vueuse/core').useScrollLock
|
||||||
const useStyleTag: typeof import('@vueuse/core')['useStyleTag']
|
const useSessionStorage: typeof import('@vueuse/core').useSessionStorage
|
||||||
const useSupported: typeof import('@vueuse/core')['useSupported']
|
const useShare: typeof import('@vueuse/core').useShare
|
||||||
const useSwipe: typeof import('@vueuse/core')['useSwipe']
|
const useSlots: typeof import('vue').useSlots
|
||||||
const useTemplateRef: typeof import('vue')['useTemplateRef']
|
const useSorted: typeof import('@vueuse/core').useSorted
|
||||||
const useTemplateRefsList: typeof import('@vueuse/core')['useTemplateRefsList']
|
const useSpeechRecognition: typeof import('@vueuse/core').useSpeechRecognition
|
||||||
const useTextDirection: typeof import('@vueuse/core')['useTextDirection']
|
const useSpeechSynthesis: typeof import('@vueuse/core').useSpeechSynthesis
|
||||||
const useTextSelection: typeof import('@vueuse/core')['useTextSelection']
|
const useStepper: typeof import('@vueuse/core').useStepper
|
||||||
const useTextareaAutosize: typeof import('@vueuse/core')['useTextareaAutosize']
|
const useStorage: typeof import('@vueuse/core').useStorage
|
||||||
const useThrottle: typeof import('@vueuse/core')['useThrottle']
|
const useStorageAsync: typeof import('@vueuse/core').useStorageAsync
|
||||||
const useThrottleFn: typeof import('@vueuse/core')['useThrottleFn']
|
const useStyleTag: typeof import('@vueuse/core').useStyleTag
|
||||||
const useThrottledRefHistory: typeof import('@vueuse/core')['useThrottledRefHistory']
|
const useSupported: typeof import('@vueuse/core').useSupported
|
||||||
const useTimeAgo: typeof import('@vueuse/core')['useTimeAgo']
|
const useSwipe: typeof import('@vueuse/core').useSwipe
|
||||||
const useTimeout: typeof import('@vueuse/core')['useTimeout']
|
const useTemplateRef: typeof import('vue').useTemplateRef
|
||||||
const useTimeoutFn: typeof import('@vueuse/core')['useTimeoutFn']
|
const useTemplateRefsList: typeof import('@vueuse/core').useTemplateRefsList
|
||||||
const useTimeoutPoll: typeof import('@vueuse/core')['useTimeoutPoll']
|
const useTextDirection: typeof import('@vueuse/core').useTextDirection
|
||||||
const useTimestamp: typeof import('@vueuse/core')['useTimestamp']
|
const useTextSelection: typeof import('@vueuse/core').useTextSelection
|
||||||
const useTitle: typeof import('@vueuse/core')['useTitle']
|
const useTextareaAutosize: typeof import('@vueuse/core').useTextareaAutosize
|
||||||
const useToNumber: typeof import('@vueuse/core')['useToNumber']
|
const useThrottle: typeof import('@vueuse/core').useThrottle
|
||||||
const useToString: typeof import('@vueuse/core')['useToString']
|
const useThrottleFn: typeof import('@vueuse/core').useThrottleFn
|
||||||
const useToggle: typeof import('@vueuse/core')['useToggle']
|
const useThrottledRefHistory: typeof import('@vueuse/core').useThrottledRefHistory
|
||||||
const useTransition: typeof import('@vueuse/core')['useTransition']
|
const useTimeAgo: typeof import('@vueuse/core').useTimeAgo
|
||||||
const useUrlSearchParams: typeof import('@vueuse/core')['useUrlSearchParams']
|
const useTimeAgoIntl: typeof import('@vueuse/core').useTimeAgoIntl
|
||||||
const useUserMedia: typeof import('@vueuse/core')['useUserMedia']
|
const useTimeout: typeof import('@vueuse/core').useTimeout
|
||||||
const useVModel: typeof import('@vueuse/core')['useVModel']
|
const useTimeoutFn: typeof import('@vueuse/core').useTimeoutFn
|
||||||
const useVModels: typeof import('@vueuse/core')['useVModels']
|
const useTimeoutPoll: typeof import('@vueuse/core').useTimeoutPoll
|
||||||
const useVibrate: typeof import('@vueuse/core')['useVibrate']
|
const useTimestamp: typeof import('@vueuse/core').useTimestamp
|
||||||
const useVirtualList: typeof import('@vueuse/core')['useVirtualList']
|
const useTitle: typeof import('@vueuse/core').useTitle
|
||||||
const useWakeLock: typeof import('@vueuse/core')['useWakeLock']
|
const useToNumber: typeof import('@vueuse/core').useToNumber
|
||||||
const useWebNotification: typeof import('@vueuse/core')['useWebNotification']
|
const useToString: typeof import('@vueuse/core').useToString
|
||||||
const useWebSocket: typeof import('@vueuse/core')['useWebSocket']
|
const useToggle: typeof import('@vueuse/core').useToggle
|
||||||
const useWebWorker: typeof import('@vueuse/core')['useWebWorker']
|
const useTransition: typeof import('@vueuse/core').useTransition
|
||||||
const useWebWorkerFn: typeof import('@vueuse/core')['useWebWorkerFn']
|
const useUrlSearchParams: typeof import('@vueuse/core').useUrlSearchParams
|
||||||
const useWindowFocus: typeof import('@vueuse/core')['useWindowFocus']
|
const useUserMedia: typeof import('@vueuse/core').useUserMedia
|
||||||
const useWindowScroll: typeof import('@vueuse/core')['useWindowScroll']
|
const useVModel: typeof import('@vueuse/core').useVModel
|
||||||
const useWindowSize: typeof import('@vueuse/core')['useWindowSize']
|
const useVModels: typeof import('@vueuse/core').useVModels
|
||||||
const watch: typeof import('vue')['watch']
|
const useVibrate: typeof import('@vueuse/core').useVibrate
|
||||||
const watchArray: typeof import('@vueuse/core')['watchArray']
|
const useVirtualList: typeof import('@vueuse/core').useVirtualList
|
||||||
const watchAtMost: typeof import('@vueuse/core')['watchAtMost']
|
const useWakeLock: typeof import('@vueuse/core').useWakeLock
|
||||||
const watchDebounced: typeof import('@vueuse/core')['watchDebounced']
|
const useWebNotification: typeof import('@vueuse/core').useWebNotification
|
||||||
const watchDeep: typeof import('@vueuse/core')['watchDeep']
|
const useWebSocket: typeof import('@vueuse/core').useWebSocket
|
||||||
const watchEffect: typeof import('vue')['watchEffect']
|
const useWebWorker: typeof import('@vueuse/core').useWebWorker
|
||||||
const watchIgnorable: typeof import('@vueuse/core')['watchIgnorable']
|
const useWebWorkerFn: typeof import('@vueuse/core').useWebWorkerFn
|
||||||
const watchImmediate: typeof import('@vueuse/core')['watchImmediate']
|
const useWindowFocus: typeof import('@vueuse/core').useWindowFocus
|
||||||
const watchOnce: typeof import('@vueuse/core')['watchOnce']
|
const useWindowScroll: typeof import('@vueuse/core').useWindowScroll
|
||||||
const watchPausable: typeof import('@vueuse/core')['watchPausable']
|
const useWindowSize: typeof import('@vueuse/core').useWindowSize
|
||||||
const watchPostEffect: typeof import('vue')['watchPostEffect']
|
const watch: typeof import('vue').watch
|
||||||
const watchSyncEffect: typeof import('vue')['watchSyncEffect']
|
const watchArray: typeof import('@vueuse/core').watchArray
|
||||||
const watchThrottled: typeof import('@vueuse/core')['watchThrottled']
|
const watchAtMost: typeof import('@vueuse/core').watchAtMost
|
||||||
const watchTriggerable: typeof import('@vueuse/core')['watchTriggerable']
|
const watchDebounced: typeof import('@vueuse/core').watchDebounced
|
||||||
const watchWithFilter: typeof import('@vueuse/core')['watchWithFilter']
|
const watchDeep: typeof import('@vueuse/core').watchDeep
|
||||||
const whenever: typeof import('@vueuse/core')['whenever']
|
const watchEffect: typeof import('vue').watchEffect
|
||||||
|
const watchIgnorable: typeof import('@vueuse/core').watchIgnorable
|
||||||
|
const watchImmediate: typeof import('@vueuse/core').watchImmediate
|
||||||
|
const watchOnce: typeof import('@vueuse/core').watchOnce
|
||||||
|
const watchPausable: typeof import('@vueuse/core').watchPausable
|
||||||
|
const watchPostEffect: typeof import('vue').watchPostEffect
|
||||||
|
const watchSyncEffect: typeof import('vue').watchSyncEffect
|
||||||
|
const watchThrottled: typeof import('@vueuse/core').watchThrottled
|
||||||
|
const watchTriggerable: typeof import('@vueuse/core').watchTriggerable
|
||||||
|
const watchWithFilter: typeof import('@vueuse/core').watchWithFilter
|
||||||
|
const whenever: typeof import('@vueuse/core').whenever
|
||||||
}
|
}
|
||||||
// for type re-export
|
// for type re-export
|
||||||
declare global {
|
declare global {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
export type { Component, ComponentPublicInstance, ComputedRef, DirectiveBinding, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, MaybeRef, MaybeRefOrGetter, VNode, WritableComputedRef } from 'vue'
|
export type { Component, Slot, Slots, ComponentPublicInstance, ComputedRef, DirectiveBinding, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, ShallowRef, MaybeRef, MaybeRefOrGetter, VNode, WritableComputedRef } from 'vue'
|
||||||
import('vue')
|
import('vue')
|
||||||
}
|
}
|
||||||
|
|||||||
16
components.d.ts
vendored
@@ -1,7 +1,11 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
|
// biome-ignore lint: disable
|
||||||
|
// oxlint-disable
|
||||||
|
// ------
|
||||||
// Generated by unplugin-vue-components
|
// Generated by unplugin-vue-components
|
||||||
// Read more: https://github.com/vuejs/core/pull/3399
|
// Read more: https://github.com/vuejs/core/pull/3399
|
||||||
|
|
||||||
export {}
|
export {}
|
||||||
|
|
||||||
/* prettier-ignore */
|
/* prettier-ignore */
|
||||||
@@ -9,7 +13,9 @@ declare module 'vue' {
|
|||||||
export interface GlobalComponents {
|
export interface GlobalComponents {
|
||||||
AboutSetting: typeof import('./src/components/Setting/AboutSetting.vue')['default']
|
AboutSetting: typeof import('./src/components/Setting/AboutSetting.vue')['default']
|
||||||
ArtistList: typeof import('./src/components/List/ArtistList.vue')['default']
|
ArtistList: typeof import('./src/components/List/ArtistList.vue')['default']
|
||||||
BatchList: typeof import('./src/components/Modal/batchList.vue')['default']
|
AutoClose: typeof import('./src/components/Modal/AutoClose.vue')['default']
|
||||||
|
BatchList: typeof import('./src/components/Modal/BatchList.vue')['default']
|
||||||
|
ChangeRate: typeof import('./src/components/Modal/ChangeRate.vue')['default']
|
||||||
CloudMatch: typeof import('./src/components/Modal/CloudMatch.vue')['default']
|
CloudMatch: typeof import('./src/components/Modal/CloudMatch.vue')['default']
|
||||||
CommentList: typeof import('./src/components/List/CommentList.vue')['default']
|
CommentList: typeof import('./src/components/List/CommentList.vue')['default']
|
||||||
CountDown: typeof import('./src/components/Player/CountDown.vue')['default']
|
CountDown: typeof import('./src/components/Player/CountDown.vue')['default']
|
||||||
@@ -17,6 +23,8 @@ declare module 'vue' {
|
|||||||
CoverMenu: typeof import('./src/components/Menu/CoverMenu.vue')['default']
|
CoverMenu: typeof import('./src/components/Menu/CoverMenu.vue')['default']
|
||||||
CreatePlaylist: typeof import('./src/components/Modal/CreatePlaylist.vue')['default']
|
CreatePlaylist: typeof import('./src/components/Modal/CreatePlaylist.vue')['default']
|
||||||
DownloadSong: typeof import('./src/components/Modal/DownloadSong.vue')['default']
|
DownloadSong: typeof import('./src/components/Modal/DownloadSong.vue')['default']
|
||||||
|
Equalizer: typeof import('./src/components/Modal/Equalizer.vue')['default']
|
||||||
|
ExcludeLyrics: typeof import('./src/components/Modal/ExcludeLyrics.vue')['default']
|
||||||
FullPlayer: typeof import('./src/components/Player/FullPlayer.vue')['default']
|
FullPlayer: typeof import('./src/components/Player/FullPlayer.vue')['default']
|
||||||
GeneralSetting: typeof import('./src/components/Setting/GeneralSetting.vue')['default']
|
GeneralSetting: typeof import('./src/components/Setting/GeneralSetting.vue')['default']
|
||||||
JumpArtist: typeof import('./src/components/Modal/JumpArtist.vue')['default']
|
JumpArtist: typeof import('./src/components/Modal/JumpArtist.vue')['default']
|
||||||
@@ -27,6 +35,7 @@ declare module 'vue' {
|
|||||||
LoginPhone: typeof import('./src/components/Modal/Login/LoginPhone.vue')['default']
|
LoginPhone: typeof import('./src/components/Modal/Login/LoginPhone.vue')['default']
|
||||||
LoginQRCode: typeof import('./src/components/Modal/Login/LoginQRCode.vue')['default']
|
LoginQRCode: typeof import('./src/components/Modal/Login/LoginQRCode.vue')['default']
|
||||||
LoginUID: typeof import('./src/components/Modal/Login/LoginUID.vue')['default']
|
LoginUID: typeof import('./src/components/Modal/Login/LoginUID.vue')['default']
|
||||||
|
LyricMenu: typeof import('./src/components/Player/LyricMenu.vue')['default']
|
||||||
LyricsSetting: typeof import('./src/components/Setting/LyricsSetting.vue')['default']
|
LyricsSetting: typeof import('./src/components/Setting/LyricsSetting.vue')['default']
|
||||||
MainAMLyric: typeof import('./src/components/Player/MainAMLyric.vue')['default']
|
MainAMLyric: typeof import('./src/components/Player/MainAMLyric.vue')['default']
|
||||||
MainLyric: typeof import('./src/components/Player/MainLyric.vue')['default']
|
MainLyric: typeof import('./src/components/Player/MainLyric.vue')['default']
|
||||||
@@ -54,6 +63,7 @@ declare module 'vue' {
|
|||||||
NDrawer: typeof import('naive-ui')['NDrawer']
|
NDrawer: typeof import('naive-ui')['NDrawer']
|
||||||
NDrawerContent: typeof import('naive-ui')['NDrawerContent']
|
NDrawerContent: typeof import('naive-ui')['NDrawerContent']
|
||||||
NDropdown: typeof import('naive-ui')['NDropdown']
|
NDropdown: typeof import('naive-ui')['NDropdown']
|
||||||
|
NDynamicTags: typeof import('naive-ui')['NDynamicTags']
|
||||||
NEllipsis: typeof import('naive-ui')['NEllipsis']
|
NEllipsis: typeof import('naive-ui')['NEllipsis']
|
||||||
NEmpty: typeof import('naive-ui')['NEmpty']
|
NEmpty: typeof import('naive-ui')['NEmpty']
|
||||||
NFlex: typeof import('naive-ui')['NFlex']
|
NFlex: typeof import('naive-ui')['NFlex']
|
||||||
@@ -88,6 +98,7 @@ declare module 'vue' {
|
|||||||
NNumberAnimation: typeof import('naive-ui')['NNumberAnimation']
|
NNumberAnimation: typeof import('naive-ui')['NNumberAnimation']
|
||||||
NOl: typeof import('naive-ui')['NOl']
|
NOl: typeof import('naive-ui')['NOl']
|
||||||
NP: typeof import('naive-ui')['NP']
|
NP: typeof import('naive-ui')['NP']
|
||||||
|
NPopconfirm: typeof import('naive-ui')['NPopconfirm']
|
||||||
NPopover: typeof import('naive-ui')['NPopover']
|
NPopover: typeof import('naive-ui')['NPopover']
|
||||||
NProgress: typeof import('naive-ui')['NProgress']
|
NProgress: typeof import('naive-ui')['NProgress']
|
||||||
NQrCode: typeof import('naive-ui')['NQrCode']
|
NQrCode: typeof import('naive-ui')['NQrCode']
|
||||||
@@ -115,6 +126,8 @@ declare module 'vue' {
|
|||||||
PlayerCover: typeof import('./src/components/Player/PlayerCover.vue')['default']
|
PlayerCover: typeof import('./src/components/Player/PlayerCover.vue')['default']
|
||||||
PlayerData: typeof import('./src/components/Player/PlayerData.vue')['default']
|
PlayerData: typeof import('./src/components/Player/PlayerData.vue')['default']
|
||||||
PlayerMenu: typeof import('./src/components/Player/PlayerMenu.vue')['default']
|
PlayerMenu: typeof import('./src/components/Player/PlayerMenu.vue')['default']
|
||||||
|
PlayerRightMenu: typeof import('./src/components/Player/PlayerRightMenu.vue')['default']
|
||||||
|
PlayerSlider: typeof import('./src/components/Player/PlayerSlider.vue')['default']
|
||||||
PlayerSpectrum: typeof import('./src/components/Player/PlayerSpectrum.vue')['default']
|
PlayerSpectrum: typeof import('./src/components/Player/PlayerSpectrum.vue')['default']
|
||||||
PlaylistAdd: typeof import('./src/components/Modal/PlaylistAdd.vue')['default']
|
PlaylistAdd: typeof import('./src/components/Modal/PlaylistAdd.vue')['default']
|
||||||
PlaySetting: typeof import('./src/components/Setting/PlaySetting.vue')['default']
|
PlaySetting: typeof import('./src/components/Setting/PlaySetting.vue')['default']
|
||||||
@@ -133,6 +146,7 @@ declare module 'vue' {
|
|||||||
SongList: typeof import('./src/components/List/SongList.vue')['default']
|
SongList: typeof import('./src/components/List/SongList.vue')['default']
|
||||||
SongListCard: typeof import('./src/components/Card/SongListCard.vue')['default']
|
SongListCard: typeof import('./src/components/Card/SongListCard.vue')['default']
|
||||||
SongListMenu: typeof import('./src/components/Menu/SongListMenu.vue')['default']
|
SongListMenu: typeof import('./src/components/Menu/SongListMenu.vue')['default']
|
||||||
|
SongUnlockManager: typeof import('./src/components/Modal/SongUnlockManager.vue')['default']
|
||||||
SvgIcon: typeof import('./src/components/Global/SvgIcon.vue')['default']
|
SvgIcon: typeof import('./src/components/Global/SvgIcon.vue')['default']
|
||||||
TextContainer: typeof import('./src/components/Global/TextContainer.vue')['default']
|
TextContainer: typeof import('./src/components/Global/TextContainer.vue')['default']
|
||||||
UpdateApp: typeof import('./src/components/Modal/UpdateApp.vue')['default']
|
UpdateApp: typeof import('./src/components/Modal/UpdateApp.vue')['default']
|
||||||
|
|||||||
@@ -10,3 +10,21 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- 25884:25884
|
- 25884:25884
|
||||||
restart: always
|
restart: always
|
||||||
|
environment:
|
||||||
|
# 所有变量都不是必填项
|
||||||
|
# 网易云服务端 IP, 可在宿主机通过 ping music.163.com 获得
|
||||||
|
- NETEASE_SERVER_IP=220.197.30.65
|
||||||
|
# UnblockNeteaseMusic 使用的音源, 支持列表见 https://github.com/UnblockNeteaseMusic/server?tab=readme-ov-file#%E9%9F%B3%E6%BA%90%E6%B8%85%E5%8D%95
|
||||||
|
- UNBLOCK_SOURCES=kugou kuwo bilibili
|
||||||
|
# 可添加 UnblockNeteaseMusic 支持的任何环境变量, 支持列表见 https://github.com/UnblockNeteaseMusic/server?tab=readme-ov-file#%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F
|
||||||
|
- ENABLE_FLAC=false
|
||||||
|
- ENABLE_HTTPDNS=false
|
||||||
|
- BLOCK_ADS=true
|
||||||
|
- DISABLE_UPGRADE_CHECK=false
|
||||||
|
- DEVELOPMENT=false
|
||||||
|
- FOLLOW_SOURCE_ORDER=true
|
||||||
|
- JSON_LOG=false
|
||||||
|
- NO_CACHE=false
|
||||||
|
- SELECT_MAX_BR=true
|
||||||
|
- LOG_LEVEL=info
|
||||||
|
- SEARCH_ALBUM=true
|
||||||
|
|||||||
29
docker-entrypoint.sh
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# start unblock service in the background
|
||||||
|
npx unblockneteasemusic -p 80:443 -s -f ${NETEASE_SERVER_IP:-220.197.30.65} -o ${UNBLOCK_SOURCES:-kugou bodian pyncmd} 2>&1 &
|
||||||
|
|
||||||
|
# point the neteasemusic address to the unblock service
|
||||||
|
if ! grep -q "music.163.com" /etc/hosts; then
|
||||||
|
echo "127.0.0.1 music.163.com" >> /etc/hosts
|
||||||
|
fi
|
||||||
|
if ! grep -q "interface.music.163.com" /etc/hosts; then
|
||||||
|
echo "127.0.0.1 interface.music.163.com" >> /etc/hosts
|
||||||
|
fi
|
||||||
|
if ! grep -q "interface3.music.163.com" /etc/hosts; then
|
||||||
|
echo "127.0.0.1 interface3.music.163.com" >> /etc/hosts
|
||||||
|
fi
|
||||||
|
if ! grep -q "interface.music.163.com.163jiasu.com" /etc/hosts; then
|
||||||
|
echo "127.0.0.1 interface.music.163.com.163jiasu.com" >> /etc/hosts
|
||||||
|
fi
|
||||||
|
if ! grep -q "interface3.music.163.com.163jiasu.com" /etc/hosts; then
|
||||||
|
echo "127.0.0.1 interface3.music.163.com.163jiasu.com" >> /etc/hosts
|
||||||
|
fi
|
||||||
|
|
||||||
|
# start the nginx daemon
|
||||||
|
nginx
|
||||||
|
|
||||||
|
# start the main process
|
||||||
|
exec "$@"
|
||||||
173
electron-builder.config.ts
Normal file
@@ -0,0 +1,173 @@
|
|||||||
|
import type { Configuration } from "electron-builder";
|
||||||
|
|
||||||
|
const config: Configuration = {
|
||||||
|
// 应用程序的唯一标识符
|
||||||
|
appId: "com.imsyy.splayer",
|
||||||
|
// 应用程序的产品名称
|
||||||
|
productName: "SPlayer",
|
||||||
|
copyright: "Copyright © imsyy 2023",
|
||||||
|
// 构建资源所在的目录
|
||||||
|
directories: {
|
||||||
|
buildResources: "build",
|
||||||
|
},
|
||||||
|
// 包含在最终应用程序构建中的文件列表
|
||||||
|
// 使用通配符 ! 表示排除不需要的文件
|
||||||
|
files: [
|
||||||
|
"public/**",
|
||||||
|
"out/**",
|
||||||
|
"!**/.vscode/*",
|
||||||
|
"!src/*",
|
||||||
|
"!electron.vite.config.{js,ts,mjs,cjs}",
|
||||||
|
"!{.eslintignore,.eslintrc.cjs,.prettierignore,.prettierrc.yaml,dev-app-update.yml,CHANGELOG.md,README.md}",
|
||||||
|
"!{.env,.env.*,.npmrc,pnpm-lock.yaml}",
|
||||||
|
],
|
||||||
|
// 哪些文件将不会被压缩,而是解压到构建目录
|
||||||
|
asarUnpack: ["public/**"],
|
||||||
|
win: {
|
||||||
|
// 可执行文件名
|
||||||
|
executableName: "SPlayer",
|
||||||
|
// 应用程序的图标文件路径
|
||||||
|
icon: "public/icons/logo.ico",
|
||||||
|
// Windows 平台全局文件名模板
|
||||||
|
artifactName: "${productName}-${version}-${arch}.${ext}",
|
||||||
|
// 是否对可执行文件进行签名和编辑
|
||||||
|
// signAndEditExecutable: false,
|
||||||
|
// 构建类型(架构由命令行参数 --x64 或 --arm64 指定)
|
||||||
|
target: [
|
||||||
|
// 安装版
|
||||||
|
{
|
||||||
|
target: "nsis",
|
||||||
|
arch: ["x64", "arm64"],
|
||||||
|
},
|
||||||
|
// 打包版
|
||||||
|
{
|
||||||
|
target: "portable",
|
||||||
|
arch: ["x64", "arm64"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
// NSIS 安装器配置
|
||||||
|
nsis: {
|
||||||
|
// 是否一键式安装
|
||||||
|
oneClick: false,
|
||||||
|
// 安装程序的生成名称
|
||||||
|
artifactName: "${productName}-${version}-${arch}-setup.${ext}",
|
||||||
|
// 创建的桌面快捷方式名称
|
||||||
|
shortcutName: "${productName}",
|
||||||
|
// 卸载时显示的名称
|
||||||
|
uninstallDisplayName: "${productName}",
|
||||||
|
// 创建桌面图标
|
||||||
|
createDesktopShortcut: "always",
|
||||||
|
// 是否允许 UAC 提升权限
|
||||||
|
allowElevation: true,
|
||||||
|
// 是否允许用户更改安装目录
|
||||||
|
allowToChangeInstallationDirectory: true,
|
||||||
|
// 安装包图标
|
||||||
|
installerIcon: "public/icons/favicon.ico",
|
||||||
|
// 卸载命令图标
|
||||||
|
uninstallerIcon: "public/icons/favicon.ico",
|
||||||
|
},
|
||||||
|
// Portable 便携版配置
|
||||||
|
portable: {
|
||||||
|
// 便携版文件名
|
||||||
|
artifactName: "${productName}-${version}-${arch}-portable.${ext}",
|
||||||
|
},
|
||||||
|
// macOS 平台配置
|
||||||
|
mac: {
|
||||||
|
// 可执行文件名
|
||||||
|
executableName: "SPlayer",
|
||||||
|
// 应用程序的图标文件路径
|
||||||
|
icon: "public/icons/favicon-512x512.png",
|
||||||
|
// 权限继承的文件路径
|
||||||
|
entitlementsInherit: "build/entitlements.mac.plist",
|
||||||
|
// macOS 平台全局文件名模板
|
||||||
|
artifactName: "${productName}-${version}-${arch}.${ext}",
|
||||||
|
// 扩展信息,如权限描述
|
||||||
|
extendInfo: {
|
||||||
|
NSCameraUsageDescription: "Application requests access to the device's camera.",
|
||||||
|
NSMicrophoneUsageDescription: "Application requests access to the device's microphone.",
|
||||||
|
NSDocumentsFolderUsageDescription:
|
||||||
|
"Application requests access to the user's Documents folder.",
|
||||||
|
NSDownloadsFolderUsageDescription:
|
||||||
|
"Application requests access to the user's Downloads folder.",
|
||||||
|
},
|
||||||
|
// 是否启用应用程序的 Notarization(苹果的安全审核)
|
||||||
|
notarize: false,
|
||||||
|
darkModeSupport: true,
|
||||||
|
category: "public.app-category.music",
|
||||||
|
target: [
|
||||||
|
// DMG 安装版
|
||||||
|
{
|
||||||
|
target: "dmg",
|
||||||
|
arch: ["x64", "arm64"],
|
||||||
|
},
|
||||||
|
// 压缩包安装版
|
||||||
|
{
|
||||||
|
target: "zip",
|
||||||
|
arch: ["x64", "arm64"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
// Linux 平台配置
|
||||||
|
linux: {
|
||||||
|
// 可执行文件名
|
||||||
|
executableName: "SPlayer",
|
||||||
|
// 应用程序的图标文件路径
|
||||||
|
icon: "public/icons/favicon-512x512.png",
|
||||||
|
// Linux 所有格式的统一文件名模板
|
||||||
|
artifactName: "${name}-${version}-${arch}.${ext}",
|
||||||
|
// 构建类型 - 支持 x64 和 ARM64 架构
|
||||||
|
target: [
|
||||||
|
// Pacman 包管理器
|
||||||
|
{
|
||||||
|
target: "pacman",
|
||||||
|
arch: ["x64", "arm64"],
|
||||||
|
},
|
||||||
|
// AppImage 格式
|
||||||
|
{
|
||||||
|
target: "AppImage",
|
||||||
|
arch: ["x64", "arm64"],
|
||||||
|
},
|
||||||
|
// Debian 包管理器
|
||||||
|
{
|
||||||
|
target: "deb",
|
||||||
|
arch: ["x64", "arm64"],
|
||||||
|
},
|
||||||
|
// RPM 包管理器
|
||||||
|
{
|
||||||
|
target: "rpm",
|
||||||
|
arch: ["x64", "arm64"],
|
||||||
|
},
|
||||||
|
// Snap 包管理器(仅支持 x64 架构)
|
||||||
|
{
|
||||||
|
target: "snap",
|
||||||
|
arch: ["x64"],
|
||||||
|
},
|
||||||
|
// 压缩包格式
|
||||||
|
{
|
||||||
|
target: "tar.gz",
|
||||||
|
arch: ["x64", "arm64"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
// 维护者信息
|
||||||
|
maintainer: "imsyy.top",
|
||||||
|
// 应用程序类别
|
||||||
|
category: "Audio;Music;AudioVideo;",
|
||||||
|
},
|
||||||
|
// AppImage 特定配置
|
||||||
|
appImage: {
|
||||||
|
// AppImage 文件的生成名称
|
||||||
|
artifactName: "${name}-${version}-${arch}.${ext}",
|
||||||
|
},
|
||||||
|
// 是否在构建之前重新编译原生模块
|
||||||
|
npmRebuild: false,
|
||||||
|
// Electron 下载镜像配置
|
||||||
|
electronDownload: {
|
||||||
|
mirror: "https://npmmirror.com/mirrors/electron/",
|
||||||
|
},
|
||||||
|
// 发布配置
|
||||||
|
// 先留空,不自动上传
|
||||||
|
publish: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
export default config;
|
||||||
@@ -1,114 +0,0 @@
|
|||||||
# 应用程序的唯一标识符
|
|
||||||
appId: com.imsyy.splayer
|
|
||||||
# 应用程序的产品名称
|
|
||||||
productName: SPlayer
|
|
||||||
copyright: Copyright © imsyy 2023
|
|
||||||
# 构建资源所在的目录
|
|
||||||
directories:
|
|
||||||
buildResources: public
|
|
||||||
# 包含在最终应用程序构建中的文件列表
|
|
||||||
# 使用通配符 ! 表示排除不需要的文件
|
|
||||||
files:
|
|
||||||
- "public/**"
|
|
||||||
- "out/**"
|
|
||||||
- "!**/.vscode/*"
|
|
||||||
- "!src/*"
|
|
||||||
- "!electron.vite.config.{js,ts,mjs,cjs}"
|
|
||||||
- "!{.eslintignore,.eslintrc.cjs,.prettierignore,.prettierrc.yaml,dev-app-update.yml,CHANGELOG.md,README.md}"
|
|
||||||
- "!{.env,.env.*,.npmrc,pnpm-lock.yaml}"
|
|
||||||
# 哪些文件将不会被压缩,而是解压到构建目录
|
|
||||||
asarUnpack:
|
|
||||||
- public/**
|
|
||||||
win:
|
|
||||||
# 可执行文件名
|
|
||||||
executableName: SPlayer
|
|
||||||
# 应用程序的图标文件路径
|
|
||||||
icon: public/icons/favicon-512x512.png
|
|
||||||
# 构建类型
|
|
||||||
target:
|
|
||||||
# 安装版
|
|
||||||
- nsis
|
|
||||||
# 打包版
|
|
||||||
- portable
|
|
||||||
# NSIS 安装器配置
|
|
||||||
nsis:
|
|
||||||
# 是否一键式安装
|
|
||||||
oneClick: false
|
|
||||||
# 安装程序的生成名称
|
|
||||||
artifactName: ${productName}-${version}-setup.${ext}
|
|
||||||
# 创建的桌面快捷方式名称
|
|
||||||
shortcutName: ${productName}
|
|
||||||
# 卸载时显示的名称
|
|
||||||
uninstallDisplayName: ${productName}
|
|
||||||
# 创建桌面图标
|
|
||||||
createDesktopShortcut: always
|
|
||||||
# 是否允许 UAC 提升权限
|
|
||||||
allowElevation: true
|
|
||||||
# 是否允许用户更改安装目录
|
|
||||||
allowToChangeInstallationDirectory: true
|
|
||||||
# 安装包图标
|
|
||||||
installerIcon: public/icons/favicon.ico
|
|
||||||
# 卸载命令图标
|
|
||||||
uninstallerIcon: public/icons/favicon.ico
|
|
||||||
# macOS 平台配置
|
|
||||||
mac:
|
|
||||||
# 可执行文件名
|
|
||||||
executableName: SPlayer
|
|
||||||
# 应用程序的图标文件路径
|
|
||||||
icon: public/icons/favicon-512x512.png
|
|
||||||
# 权限继承的文件路径
|
|
||||||
entitlementsInherit: build/entitlements.mac.plist
|
|
||||||
# 扩展信息,如权限描述
|
|
||||||
extendInfo:
|
|
||||||
- NSCameraUsageDescription: Application requests access to the device's camera.
|
|
||||||
- NSMicrophoneUsageDescription: Application requests access to the device's microphone.
|
|
||||||
- NSDocumentsFolderUsageDescription: Application requests access to the user's Documents folder.
|
|
||||||
- NSDownloadsFolderUsageDescription: Application requests access to the user's Downloads folder.
|
|
||||||
# 是否启用应用程序的 Notarization(苹果的安全审核)
|
|
||||||
notarize: false
|
|
||||||
darkModeSupport: true
|
|
||||||
category: public.app-category.music
|
|
||||||
target:
|
|
||||||
- target: dmg
|
|
||||||
arch:
|
|
||||||
- x64
|
|
||||||
- arm64
|
|
||||||
- target: zip
|
|
||||||
arch:
|
|
||||||
- x64
|
|
||||||
- arm64
|
|
||||||
# macOS 平台的 DMG 配置
|
|
||||||
dmg:
|
|
||||||
# DMG 文件的生成名称
|
|
||||||
artifactName: ${name}-${version}.${ext}
|
|
||||||
# Linux 平台配置
|
|
||||||
linux:
|
|
||||||
# 可执行文件名
|
|
||||||
executableName: SPlayer
|
|
||||||
# 应用程序的图标文件路径
|
|
||||||
icon: public/icons/favicon-512x512.png
|
|
||||||
# 构建类型
|
|
||||||
target:
|
|
||||||
- pacman
|
|
||||||
- AppImage
|
|
||||||
- deb
|
|
||||||
- rpm
|
|
||||||
- tar.gz
|
|
||||||
# 维护者信息
|
|
||||||
maintainer: imsyy.top
|
|
||||||
# 应用程序类别
|
|
||||||
category: Audio;Music
|
|
||||||
# AppImage 配置
|
|
||||||
appImage:
|
|
||||||
# AppImage 文件的生成名称
|
|
||||||
artifactName: ${name}-${version}.${ext}
|
|
||||||
# 是否在构建之前重新编译原生模块
|
|
||||||
npmRebuild: false
|
|
||||||
# 自动更新的配置
|
|
||||||
publish:
|
|
||||||
# 更新提供商
|
|
||||||
provider: github
|
|
||||||
# 自动更新检查的 URL
|
|
||||||
# url: https://example.com/auto-updates
|
|
||||||
owner: "imsyy"
|
|
||||||
repo: "SPlayer"
|
|
||||||
@@ -6,6 +6,7 @@ import vue from "@vitejs/plugin-vue";
|
|||||||
import AutoImport from "unplugin-auto-import/vite";
|
import AutoImport from "unplugin-auto-import/vite";
|
||||||
import Components from "unplugin-vue-components/vite";
|
import Components from "unplugin-vue-components/vite";
|
||||||
import viteCompression from "vite-plugin-compression";
|
import viteCompression from "vite-plugin-compression";
|
||||||
|
// import VueDevTools from "vite-plugin-vue-devtools";
|
||||||
import wasm from "vite-plugin-wasm";
|
import wasm from "vite-plugin-wasm";
|
||||||
|
|
||||||
export default defineConfig(({ command, mode }) => {
|
export default defineConfig(({ command, mode }) => {
|
||||||
@@ -28,7 +29,6 @@ export default defineConfig(({ command, mode }) => {
|
|||||||
input: {
|
input: {
|
||||||
index: resolve(__dirname, "electron/main/index.ts"),
|
index: resolve(__dirname, "electron/main/index.ts"),
|
||||||
lyric: resolve(__dirname, "web/lyric.html"),
|
lyric: resolve(__dirname, "web/lyric.html"),
|
||||||
loading: resolve(__dirname, "web/loading.html"),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -49,6 +49,7 @@ export default defineConfig(({ command, mode }) => {
|
|||||||
root: ".",
|
root: ".",
|
||||||
plugins: [
|
plugins: [
|
||||||
vue(),
|
vue(),
|
||||||
|
// mode === "development" && VueDevTools(),
|
||||||
AutoImport({
|
AutoImport({
|
||||||
imports: [
|
imports: [
|
||||||
"vue",
|
"vue",
|
||||||
@@ -88,7 +89,7 @@ export default defineConfig(({ command, mode }) => {
|
|||||||
"/api": {
|
"/api": {
|
||||||
target: `http://127.0.0.1:${servePort}`,
|
target: `http://127.0.0.1:${servePort}`,
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
rewrite: (path) => path.replace(/^\/api/, "/api/"),
|
rewrite: (path) => path.replace(/^\/api/, "/api"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -101,6 +102,7 @@ export default defineConfig(({ command, mode }) => {
|
|||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
input: {
|
input: {
|
||||||
index: resolve(__dirname, "index.html"),
|
index: resolve(__dirname, "index.html"),
|
||||||
|
loading: resolve(__dirname, "web/loading/index.html"),
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
manualChunks: {
|
manualChunks: {
|
||||||
|
|||||||
@@ -1,201 +1,73 @@
|
|||||||
import { app, shell, BrowserWindow, BrowserWindowConstructorOptions } from "electron";
|
import { app, BrowserWindow } from "electron";
|
||||||
import { electronApp, optimizer } from "@electron-toolkit/utils";
|
import { electronApp } from "@electron-toolkit/utils";
|
||||||
import { join } from "path";
|
|
||||||
import { release, type } from "os";
|
import { release, type } from "os";
|
||||||
import { isDev, isMac, appName } from "./utils";
|
import { isMac } from "./utils/config";
|
||||||
import { registerAllShortcuts, unregisterShortcuts } from "./shortcut";
|
import { initSingleLock } from "./utils/single-lock";
|
||||||
|
import { unregisterShortcuts } from "./shortcut";
|
||||||
import { initTray, MainTray } from "./tray";
|
import { initTray, MainTray } from "./tray";
|
||||||
import { initThumbar, Thumbar } from "./thumbar";
|
import { processLog } from "./logger";
|
||||||
|
import { existsSync, mkdirSync } from "fs";
|
||||||
|
import { join } from "path";
|
||||||
import initAppServer from "../server";
|
import initAppServer from "../server";
|
||||||
import initIpcMain from "./ipcMain";
|
import loadWindow from "./windows/load-window";
|
||||||
import log from "./logger";
|
import mainWindow from "./windows/main-window";
|
||||||
import store from "./store";
|
import initIpc from "./ipc";
|
||||||
// icon
|
|
||||||
import icon from "../../public/icons/favicon.png?asset";
|
|
||||||
|
|
||||||
// 屏蔽报错
|
// 屏蔽报错
|
||||||
process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = "true";
|
process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = "true";
|
||||||
|
|
||||||
// 模拟打包
|
// 便携模式下设置用户数据路径
|
||||||
Object.defineProperty(app, "isPackaged", {
|
if (process.env.PORTABLE_EXECUTABLE_DIR) {
|
||||||
get() {
|
processLog.info(
|
||||||
return true;
|
"🔍 Portable mode detected, setting userData path to:",
|
||||||
},
|
join(process.env.PORTABLE_EXECUTABLE_DIR, "UserData"),
|
||||||
});
|
);
|
||||||
|
const userDataPath = join(process.env.PORTABLE_EXECUTABLE_DIR, "UserData");
|
||||||
|
if (!existsSync(userDataPath)) mkdirSync(userDataPath, { recursive: true });
|
||||||
|
app.setPath("userData", userDataPath);
|
||||||
|
}
|
||||||
|
|
||||||
// 主进程
|
// 主进程
|
||||||
class MainProcess {
|
class MainProcess {
|
||||||
// 窗口
|
// 窗口
|
||||||
mainWindow: BrowserWindow | null = null;
|
mainWindow: BrowserWindow | null = null;
|
||||||
lyricWindow: BrowserWindow | null = null;
|
loadWindow: BrowserWindow | null = null;
|
||||||
loadingWindow: BrowserWindow | null = null;
|
|
||||||
// 托盘
|
// 托盘
|
||||||
mainTray: MainTray | null = null;
|
mainTray: MainTray | null = null;
|
||||||
// 工具栏
|
|
||||||
thumbar: Thumbar | null = null;
|
|
||||||
// 是否退出
|
// 是否退出
|
||||||
isQuit: boolean = false;
|
isQuit: boolean = false;
|
||||||
constructor() {
|
constructor() {
|
||||||
log.info("🚀 Main process startup");
|
processLog.info("🚀 Main process startup");
|
||||||
|
// 程序单例锁
|
||||||
|
initSingleLock();
|
||||||
// 禁用 Windows 7 的 GPU 加速功能
|
// 禁用 Windows 7 的 GPU 加速功能
|
||||||
if (release().startsWith("6.1") && type() == 'Windows_NT') app.disableHardwareAcceleration();
|
if (release().startsWith("6.1") && type() == "Windows_NT") app.disableHardwareAcceleration();
|
||||||
// 单例锁
|
// 监听应用事件
|
||||||
if (!app.requestSingleInstanceLock()) {
|
this.handleAppEvents();
|
||||||
log.error("❌ There is already a program running and this process is terminated");
|
// Electron 初始化完成后
|
||||||
app.quit();
|
// 某些API只有在此事件发生后才能使用
|
||||||
process.exit(0);
|
|
||||||
} else this.showWindow();
|
|
||||||
// 准备就绪
|
|
||||||
app.whenReady().then(async () => {
|
app.whenReady().then(async () => {
|
||||||
log.info("🚀 Application Process Startup");
|
processLog.info("🚀 Application Process Startup");
|
||||||
// 设置应用程序名称
|
// 设置应用程序名称
|
||||||
electronApp.setAppUserModelId(app.getName());
|
electronApp.setAppUserModelId("com.imsyy.splayer");
|
||||||
// 启动主服务进程
|
// 启动主服务进程
|
||||||
await initAppServer();
|
await initAppServer();
|
||||||
// 启动进程
|
// 启动窗口
|
||||||
this.createLoadingWindow();
|
this.loadWindow = loadWindow.create();
|
||||||
this.createMainWindow();
|
this.mainWindow = mainWindow.create();
|
||||||
this.createLyricsWindow();
|
|
||||||
this.handleAppEvents();
|
|
||||||
this.handleWindowEvents();
|
|
||||||
// 注册其他服务
|
// 注册其他服务
|
||||||
this.mainTray = initTray(this.mainWindow!, this.lyricWindow!);
|
this.mainTray = initTray(this.mainWindow!);
|
||||||
this.thumbar = initThumbar(this.mainWindow!);
|
// 注册 IPC 通信
|
||||||
// 注册主进程事件
|
initIpc();
|
||||||
initIpcMain(
|
|
||||||
this.mainWindow,
|
|
||||||
this.lyricWindow,
|
|
||||||
this.loadingWindow,
|
|
||||||
this.mainTray,
|
|
||||||
this.thumbar,
|
|
||||||
store,
|
|
||||||
);
|
|
||||||
// 注册快捷键
|
|
||||||
registerAllShortcuts(this.mainWindow!);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// 创建窗口
|
|
||||||
createWindow(options: BrowserWindowConstructorOptions = {}): BrowserWindow {
|
|
||||||
const defaultOptions: BrowserWindowConstructorOptions = {
|
|
||||||
title: appName,
|
|
||||||
width: 1280,
|
|
||||||
height: 720,
|
|
||||||
frame: false,
|
|
||||||
center: true,
|
|
||||||
// 图标
|
|
||||||
icon,
|
|
||||||
webPreferences: {
|
|
||||||
preload: join(__dirname, "../preload/index.mjs"),
|
|
||||||
// 禁用渲染器沙盒
|
|
||||||
sandbox: false,
|
|
||||||
// 禁用同源策略
|
|
||||||
webSecurity: false,
|
|
||||||
// 允许 HTTP
|
|
||||||
allowRunningInsecureContent: true,
|
|
||||||
// 禁用拼写检查
|
|
||||||
spellcheck: false,
|
|
||||||
// 启用 Node.js
|
|
||||||
nodeIntegration: true,
|
|
||||||
nodeIntegrationInWorker: true,
|
|
||||||
// 启用上下文隔离
|
|
||||||
contextIsolation: false,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
// 合并参数
|
|
||||||
options = Object.assign(defaultOptions, options);
|
|
||||||
// 创建窗口
|
|
||||||
const win = new BrowserWindow(options);
|
|
||||||
return win;
|
|
||||||
}
|
|
||||||
// 创建主窗口
|
|
||||||
createMainWindow() {
|
|
||||||
// 窗口配置项
|
|
||||||
const options: BrowserWindowConstructorOptions = {
|
|
||||||
width: store.get("window").width,
|
|
||||||
height: store.get("window").height,
|
|
||||||
minHeight: 800,
|
|
||||||
minWidth: 1280,
|
|
||||||
// 菜单栏
|
|
||||||
titleBarStyle: "customButtonsOnHover",
|
|
||||||
// 立即显示窗口
|
|
||||||
show: false,
|
|
||||||
};
|
|
||||||
// 初始化窗口
|
|
||||||
this.mainWindow = this.createWindow(options);
|
|
||||||
|
|
||||||
// 渲染路径
|
|
||||||
if (isDev && process.env["ELECTRON_RENDERER_URL"]) {
|
|
||||||
this.mainWindow.loadURL(process.env["ELECTRON_RENDERER_URL"]);
|
|
||||||
} else {
|
|
||||||
const port = Number(import.meta.env["VITE_SERVER_PORT"] || 25884);
|
|
||||||
this.mainWindow.loadURL(`http://127.0.0.1:${port}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 配置网络代理
|
|
||||||
if (store.get("proxy")) {
|
|
||||||
this.mainWindow.webContents.session.setProxy({ proxyRules: store.get("proxy") });
|
|
||||||
}
|
|
||||||
|
|
||||||
// 窗口打开处理程序
|
|
||||||
this.mainWindow.webContents.setWindowOpenHandler((details) => {
|
|
||||||
const { url } = details;
|
|
||||||
if (url.startsWith("https://") || url.startsWith("http://")) {
|
|
||||||
shell.openExternal(url);
|
|
||||||
}
|
|
||||||
return { action: "deny" };
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// 创建加载窗口
|
|
||||||
createLoadingWindow() {
|
|
||||||
// 初始化窗口
|
|
||||||
this.loadingWindow = this.createWindow({
|
|
||||||
width: 800,
|
|
||||||
height: 560,
|
|
||||||
maxWidth: 800,
|
|
||||||
maxHeight: 560,
|
|
||||||
resizable: false,
|
|
||||||
});
|
|
||||||
// 渲染路径
|
|
||||||
this.loadingWindow.loadFile(join(__dirname, "../main/web/loading.html"));
|
|
||||||
}
|
|
||||||
// 创建桌面歌词窗口
|
|
||||||
createLyricsWindow() {
|
|
||||||
// 初始化窗口
|
|
||||||
this.lyricWindow = this.createWindow({
|
|
||||||
width: store.get("lyric").width || 800,
|
|
||||||
height: store.get("lyric").height || 180,
|
|
||||||
minWidth: 440,
|
|
||||||
minHeight: 120,
|
|
||||||
maxWidth: 1600,
|
|
||||||
maxHeight: 300,
|
|
||||||
// 窗口位置
|
|
||||||
x: store.get("lyric").x,
|
|
||||||
y: store.get("lyric").y,
|
|
||||||
transparent: true,
|
|
||||||
backgroundColor: "rgba(0, 0, 0, 0)",
|
|
||||||
alwaysOnTop: true,
|
|
||||||
resizable: true,
|
|
||||||
movable: true,
|
|
||||||
// 不在任务栏显示
|
|
||||||
skipTaskbar: true,
|
|
||||||
// 窗口不能最小化
|
|
||||||
minimizable: false,
|
|
||||||
// 窗口不能最大化
|
|
||||||
maximizable: false,
|
|
||||||
// 窗口不能进入全屏状态
|
|
||||||
fullscreenable: false,
|
|
||||||
show: false,
|
|
||||||
});
|
|
||||||
// 渲染路径
|
|
||||||
this.lyricWindow.loadFile(join(__dirname, "../main/web/lyric.html"));
|
|
||||||
}
|
|
||||||
// 应用程序事件
|
// 应用程序事件
|
||||||
handleAppEvents() {
|
handleAppEvents() {
|
||||||
// 窗口被关闭时
|
// 窗口被关闭时
|
||||||
app.on("window-all-closed", () => {
|
app.on("window-all-closed", () => {
|
||||||
if (!isMac) app.quit();
|
if (!isMac) app.quit();
|
||||||
this.mainWindow = null;
|
this.mainWindow = null;
|
||||||
this.loadingWindow = null;
|
this.loadWindow = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
// 应用被激活
|
// 应用被激活
|
||||||
@@ -203,24 +75,12 @@ class MainProcess {
|
|||||||
const allWindows = BrowserWindow.getAllWindows();
|
const allWindows = BrowserWindow.getAllWindows();
|
||||||
if (allWindows.length) {
|
if (allWindows.length) {
|
||||||
allWindows[0].focus();
|
allWindows[0].focus();
|
||||||
} else {
|
|
||||||
this.createMainWindow();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 新增 session
|
|
||||||
app.on("second-instance", () => {
|
|
||||||
this.showWindow();
|
|
||||||
});
|
|
||||||
|
|
||||||
// 开发环境控制台
|
|
||||||
app.on("browser-window-created", (_, window) => {
|
|
||||||
optimizer.watchWindowShortcuts(window);
|
|
||||||
});
|
|
||||||
|
|
||||||
// 自定义协议
|
// 自定义协议
|
||||||
app.on("open-url", (_, url) => {
|
app.on("open-url", (_, url) => {
|
||||||
console.log("Received custom protocol URL:", url);
|
processLog.log("Received custom protocol URL:", url);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 将要退出
|
// 将要退出
|
||||||
@@ -234,57 +94,6 @@ class MainProcess {
|
|||||||
this.isQuit = true;
|
this.isQuit = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// 窗口事件
|
|
||||||
handleWindowEvents() {
|
|
||||||
this.mainWindow?.on("show", () => {
|
|
||||||
// this.mainWindow?.webContents.send("lyricsScroll");
|
|
||||||
});
|
|
||||||
this.mainWindow?.on("focus", () => {
|
|
||||||
this.saveBounds();
|
|
||||||
});
|
|
||||||
// 移动或缩放
|
|
||||||
this.mainWindow?.on("resized", () => {
|
|
||||||
// 若处于全屏则不保存
|
|
||||||
if (this.mainWindow?.isFullScreen()) return;
|
|
||||||
this.saveBounds();
|
|
||||||
});
|
|
||||||
this.mainWindow?.on("moved", () => {
|
|
||||||
this.saveBounds();
|
|
||||||
});
|
|
||||||
|
|
||||||
// 歌词窗口缩放
|
|
||||||
this.lyricWindow?.on("resized", () => {
|
|
||||||
const bounds = this.lyricWindow?.getBounds();
|
|
||||||
if (bounds) {
|
|
||||||
const { width, height } = bounds;
|
|
||||||
store.set("lyric", { ...store.get("lyric"), width, height });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// 窗口关闭
|
|
||||||
this.mainWindow?.on("close", (event) => {
|
|
||||||
event.preventDefault();
|
|
||||||
if (this.isQuit) {
|
|
||||||
app.exit();
|
|
||||||
} else {
|
|
||||||
this.mainWindow?.hide();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// 更新窗口大小
|
|
||||||
saveBounds() {
|
|
||||||
if (this.mainWindow?.isFullScreen()) return;
|
|
||||||
const bounds = this.mainWindow?.getBounds();
|
|
||||||
if (bounds) store.set("window", bounds);
|
|
||||||
}
|
|
||||||
// 显示窗口
|
|
||||||
showWindow() {
|
|
||||||
if (this.mainWindow) {
|
|
||||||
this.mainWindow.show();
|
|
||||||
if (this.mainWindow.isMinimized()) this.mainWindow.restore();
|
|
||||||
this.mainWindow.focus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new MainProcess();
|
export default new MainProcess();
|
||||||
|
|||||||
27
electron/main/ipc/index.ts
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import initFileIpc from "./ipc-file";
|
||||||
|
import initLyricIpc from "./ipc-lyric";
|
||||||
|
import initShortcutIpc from "./ipc-shortcut";
|
||||||
|
import initStoreIpc from "./ipc-store";
|
||||||
|
import initSystemIpc from "./ipc-system";
|
||||||
|
import initThumbarIpc from "./ipc-thumbar";
|
||||||
|
import initTrayIpc from "./ipc-tray";
|
||||||
|
import initUpdateIpc from "./ipc-update";
|
||||||
|
import initWindowsIpc from "./ipc-window";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化全部 IPC 通信
|
||||||
|
* @returns void
|
||||||
|
*/
|
||||||
|
const initIpc = (): void => {
|
||||||
|
initSystemIpc();
|
||||||
|
initWindowsIpc();
|
||||||
|
initUpdateIpc();
|
||||||
|
initFileIpc();
|
||||||
|
initTrayIpc();
|
||||||
|
initLyricIpc();
|
||||||
|
initStoreIpc();
|
||||||
|
initThumbarIpc();
|
||||||
|
initShortcutIpc();
|
||||||
|
};
|
||||||
|
|
||||||
|
export default initIpc;
|
||||||
425
electron/main/ipc/ipc-file.ts
Normal file
@@ -0,0 +1,425 @@
|
|||||||
|
import { app, BrowserWindow, dialog, ipcMain, shell } from "electron";
|
||||||
|
import { basename, isAbsolute, join, relative, resolve } from "path";
|
||||||
|
import { access, readFile, stat, unlink, writeFile } from "fs/promises";
|
||||||
|
import { parseFile } from "music-metadata";
|
||||||
|
import { getFileID, getFileMD5, metaDataLyricsArrayToLrc } from "../utils/helper";
|
||||||
|
import { File, Picture, Id3v2Settings } from "node-taglib-sharp";
|
||||||
|
import { ipcLog } from "../logger";
|
||||||
|
import { download } from "electron-dl";
|
||||||
|
import { Options as GlobOptions } from "fast-glob/out/settings";
|
||||||
|
import FastGlob from "fast-glob";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件相关 IPC
|
||||||
|
*/
|
||||||
|
const initFileIpc = (): void => {
|
||||||
|
/**
|
||||||
|
* 获取全局搜索配置
|
||||||
|
* @param cwd 当前工作目录
|
||||||
|
*/
|
||||||
|
const globOpt = (cwd?: string): GlobOptions => ({
|
||||||
|
cwd,
|
||||||
|
caseSensitiveMatch: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
// 默认文件夹
|
||||||
|
ipcMain.handle(
|
||||||
|
"get-default-dir",
|
||||||
|
(_event, type: "documents" | "downloads" | "pictures" | "music" | "videos"): string => {
|
||||||
|
return app.getPath(type);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
// 遍历音乐文件
|
||||||
|
ipcMain.handle("get-music-files", async (_, dirPath: string) => {
|
||||||
|
try {
|
||||||
|
// 规范化路径
|
||||||
|
const filePath = resolve(dirPath).replace(/\\/g, "/");
|
||||||
|
console.info(`📂 Fetching music files from: ${filePath}`);
|
||||||
|
// 查找指定目录下的所有音乐文件
|
||||||
|
const musicFiles = await FastGlob("**/*.{mp3,wav,flac,aac,webm}", globOpt(filePath));
|
||||||
|
// 解析元信息
|
||||||
|
const metadataPromises = musicFiles.map(async (file) => {
|
||||||
|
const filePath = join(dirPath, file);
|
||||||
|
// 处理元信息
|
||||||
|
const { common, format } = await parseFile(filePath);
|
||||||
|
// 获取文件大小
|
||||||
|
const { size } = await stat(filePath);
|
||||||
|
return {
|
||||||
|
id: getFileID(filePath),
|
||||||
|
name: common.title || basename(filePath),
|
||||||
|
artists: common.artists?.[0] || common.artist,
|
||||||
|
album: common.album || "",
|
||||||
|
alia: common.comment?.[0]?.text || "",
|
||||||
|
duration: (format?.duration ?? 0) * 1000,
|
||||||
|
size: (size / (1024 * 1024)).toFixed(2),
|
||||||
|
path: filePath,
|
||||||
|
quality: format.bitrate ?? 0,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
const metadataArray = await Promise.all(metadataPromises);
|
||||||
|
return metadataArray;
|
||||||
|
} catch (error) {
|
||||||
|
ipcLog.error("❌ Error fetching music metadata:", error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 获取音乐元信息
|
||||||
|
ipcMain.handle("get-music-metadata", async (_, path: string) => {
|
||||||
|
try {
|
||||||
|
const filePath = resolve(path).replace(/\\/g, "/");
|
||||||
|
const { common, format } = await parseFile(filePath);
|
||||||
|
return {
|
||||||
|
// 文件名称
|
||||||
|
fileName: basename(filePath),
|
||||||
|
// 文件大小
|
||||||
|
fileSize: (await stat(filePath)).size / (1024 * 1024),
|
||||||
|
// 元信息
|
||||||
|
common,
|
||||||
|
// 歌词
|
||||||
|
lyric:
|
||||||
|
metaDataLyricsArrayToLrc(common?.lyrics?.[0]?.syncText || []) ||
|
||||||
|
common?.lyrics?.[0]?.text ||
|
||||||
|
"",
|
||||||
|
// 音质信息
|
||||||
|
format,
|
||||||
|
// md5
|
||||||
|
md5: await getFileMD5(filePath),
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
ipcLog.error("❌ Error fetching music metadata:", error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 修改音乐元信息
|
||||||
|
ipcMain.handle("set-music-metadata", async (_, path: string, metadata: any) => {
|
||||||
|
try {
|
||||||
|
const { name, artist, album, alia, lyric, cover } = metadata;
|
||||||
|
// 规范化路径
|
||||||
|
const songPath = resolve(path);
|
||||||
|
const coverPath = cover ? resolve(cover) : null;
|
||||||
|
// 读取歌曲文件
|
||||||
|
const songFile = File.createFromPath(songPath);
|
||||||
|
// 读取封面文件
|
||||||
|
const songCover = coverPath ? Picture.fromPath(coverPath) : null;
|
||||||
|
// 保存元数据
|
||||||
|
Id3v2Settings.forceDefaultVersion = true;
|
||||||
|
Id3v2Settings.defaultVersion = 3;
|
||||||
|
songFile.tag.title = name || "未知曲目";
|
||||||
|
songFile.tag.performers = [artist || "未知艺术家"];
|
||||||
|
songFile.tag.album = album || "未知专辑";
|
||||||
|
songFile.tag.albumArtists = [artist || "未知艺术家"];
|
||||||
|
songFile.tag.lyrics = lyric || "";
|
||||||
|
songFile.tag.description = alia || "";
|
||||||
|
songFile.tag.comment = alia || "";
|
||||||
|
if (songCover) songFile.tag.pictures = [songCover];
|
||||||
|
// 保存元信息
|
||||||
|
songFile.save();
|
||||||
|
songFile.dispose();
|
||||||
|
return true;
|
||||||
|
} catch (error) {
|
||||||
|
ipcLog.error("❌ Error setting music metadata:", error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 获取音乐歌词
|
||||||
|
ipcMain.handle(
|
||||||
|
"get-music-lyric",
|
||||||
|
async (
|
||||||
|
_,
|
||||||
|
path: string,
|
||||||
|
): Promise<{
|
||||||
|
lyric: string;
|
||||||
|
format: "lrc" | "ttml";
|
||||||
|
}> => {
|
||||||
|
try {
|
||||||
|
const filePath = resolve(path).replace(/\\/g, "/");
|
||||||
|
|
||||||
|
// 尝试获取同名的歌词文件
|
||||||
|
const filePathWithoutExt = filePath.replace(/\.[^.]+$/, "");
|
||||||
|
for (const ext of ["ttml", "lrc"] as const) {
|
||||||
|
const lyricPath = `${filePathWithoutExt}.${ext}`;
|
||||||
|
const matches = await FastGlob(lyricPath, globOpt());
|
||||||
|
ipcLog.info("lyric matches", matches);
|
||||||
|
if (matches.length > 0) {
|
||||||
|
try {
|
||||||
|
const lyric = await readFile(matches[0], "utf-8");
|
||||||
|
if (lyric && lyric !== "") return { lyric, format: ext };
|
||||||
|
} catch {
|
||||||
|
/* empty */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 尝试获取元数据
|
||||||
|
const { common } = await parseFile(filePath);
|
||||||
|
const lyric = common?.lyrics?.[0]?.syncText;
|
||||||
|
if (lyric && lyric.length > 0) {
|
||||||
|
return { lyric: metaDataLyricsArrayToLrc(lyric), format: "lrc" };
|
||||||
|
} else if (common?.lyrics?.[0]?.text) {
|
||||||
|
return { lyric: common?.lyrics?.[0]?.text, format: "lrc" };
|
||||||
|
}
|
||||||
|
|
||||||
|
// 没有歌词
|
||||||
|
return { lyric: "", format: "lrc" };
|
||||||
|
} catch (error) {
|
||||||
|
ipcLog.error("❌ Error fetching music lyric:", error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
// 获取音乐封面
|
||||||
|
ipcMain.handle(
|
||||||
|
"get-music-cover",
|
||||||
|
async (_, path: string): Promise<{ data: Buffer; format: string } | null> => {
|
||||||
|
try {
|
||||||
|
const { common } = await parseFile(path);
|
||||||
|
// 获取封面数据
|
||||||
|
const picture = common.picture?.[0];
|
||||||
|
if (picture) {
|
||||||
|
return { data: Buffer.from(picture.data), format: picture.format };
|
||||||
|
} else {
|
||||||
|
const coverFilePath = path.replace(/\.[^.]+$/, ".jpg");
|
||||||
|
try {
|
||||||
|
await access(coverFilePath);
|
||||||
|
const coverData = await readFile(coverFilePath);
|
||||||
|
return { data: coverData, format: "image/jpeg" };
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("❌ Error fetching music cover:", error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
// 读取本地歌词
|
||||||
|
ipcMain.handle(
|
||||||
|
"read-local-lyric",
|
||||||
|
async (_, lyricDirs: string[], id: number): Promise<{ lrc: string; ttml: string }> => {
|
||||||
|
const result = { lrc: "", ttml: "" };
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 定义需要查找的模式
|
||||||
|
// 此处的 `{,*.}` 表示这里可以取 `` (empty) 也可以取 `*.`
|
||||||
|
// 将歌词文件命名为 `歌曲ID.后缀名` 或者 `任意前缀.歌曲ID.后缀名` 均可
|
||||||
|
const patterns = {
|
||||||
|
ttml: `**/{,*.}${id}.ttml`,
|
||||||
|
lrc: `**/{,*.}${id}.lrc`,
|
||||||
|
};
|
||||||
|
|
||||||
|
// 遍历每一个目录
|
||||||
|
for (const dir of lyricDirs) {
|
||||||
|
try {
|
||||||
|
// 查找 ttml
|
||||||
|
if (!result.ttml) {
|
||||||
|
const ttmlFiles = await FastGlob(patterns.ttml, globOpt(dir));
|
||||||
|
if (ttmlFiles.length > 0) {
|
||||||
|
const filePath = join(dir, ttmlFiles[0]);
|
||||||
|
await access(filePath);
|
||||||
|
result.ttml = await readFile(filePath, "utf-8");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查找 lrc
|
||||||
|
if (!result.lrc) {
|
||||||
|
const lrcFiles = await FastGlob(patterns.lrc, globOpt(dir));
|
||||||
|
if (lrcFiles.length > 0) {
|
||||||
|
const filePath = join(dir, lrcFiles[0]);
|
||||||
|
await access(filePath);
|
||||||
|
result.lrc = await readFile(filePath, "utf-8");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果两种文件都找到了就提前结束搜索
|
||||||
|
if (result.ttml && result.lrc) break;
|
||||||
|
} catch {
|
||||||
|
// 某个路径异常,跳过
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
/* 忽略错误 */
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
// 删除文件
|
||||||
|
ipcMain.handle("delete-file", async (_, path: string) => {
|
||||||
|
try {
|
||||||
|
// 规范化路径
|
||||||
|
const resolvedPath = resolve(path);
|
||||||
|
// 检查文件是否存在
|
||||||
|
try {
|
||||||
|
await access(resolvedPath);
|
||||||
|
} catch {
|
||||||
|
throw new Error("❌ File not found");
|
||||||
|
}
|
||||||
|
// 删除文件
|
||||||
|
await unlink(resolvedPath);
|
||||||
|
return true;
|
||||||
|
} catch (error) {
|
||||||
|
ipcLog.error("❌ File delete error", error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 打开文件夹
|
||||||
|
ipcMain.on("open-folder", async (_, path: string) => {
|
||||||
|
try {
|
||||||
|
// 规范化路径
|
||||||
|
const resolvedPath = resolve(path);
|
||||||
|
// 检查文件夹是否存在
|
||||||
|
try {
|
||||||
|
await access(resolvedPath);
|
||||||
|
} catch {
|
||||||
|
throw new Error("❌ Folder not found");
|
||||||
|
}
|
||||||
|
// 打开文件夹
|
||||||
|
shell.showItemInFolder(resolvedPath);
|
||||||
|
} catch (error) {
|
||||||
|
ipcLog.error("❌ Folder open error", error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 图片选择窗口
|
||||||
|
ipcMain.handle("choose-image", async () => {
|
||||||
|
try {
|
||||||
|
const { filePaths } = await dialog.showOpenDialog({
|
||||||
|
properties: ["openFile"],
|
||||||
|
filters: [{ name: "Images", extensions: ["jpg", "jpeg", "png"] }],
|
||||||
|
});
|
||||||
|
if (!filePaths || filePaths.length === 0) return null;
|
||||||
|
return filePaths[0];
|
||||||
|
} catch (error) {
|
||||||
|
ipcLog.error("❌ Image choose error", error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 路径选择窗口
|
||||||
|
ipcMain.handle("choose-path", async () => {
|
||||||
|
try {
|
||||||
|
const { filePaths } = await dialog.showOpenDialog({
|
||||||
|
title: "选择文件夹",
|
||||||
|
defaultPath: app.getPath("downloads"),
|
||||||
|
properties: ["openDirectory", "createDirectory"],
|
||||||
|
buttonLabel: "选择文件夹",
|
||||||
|
});
|
||||||
|
if (!filePaths || filePaths.length === 0) return null;
|
||||||
|
return filePaths[0];
|
||||||
|
} catch (error) {
|
||||||
|
ipcLog.error("❌ Path choose error", error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 下载文件
|
||||||
|
ipcMain.handle(
|
||||||
|
"download-file",
|
||||||
|
async (
|
||||||
|
event,
|
||||||
|
url: string,
|
||||||
|
options: {
|
||||||
|
fileName: string;
|
||||||
|
fileType: string;
|
||||||
|
path: string;
|
||||||
|
downloadMeta?: boolean;
|
||||||
|
downloadCover?: boolean;
|
||||||
|
downloadLyric?: boolean;
|
||||||
|
saveMetaFile?: boolean;
|
||||||
|
lyric?: string;
|
||||||
|
songData?: any;
|
||||||
|
} = {
|
||||||
|
fileName: "未知文件名",
|
||||||
|
fileType: "mp3",
|
||||||
|
path: app.getPath("downloads"),
|
||||||
|
},
|
||||||
|
): Promise<boolean> => {
|
||||||
|
try {
|
||||||
|
// 获取窗口
|
||||||
|
const win = BrowserWindow.fromWebContents(event.sender);
|
||||||
|
if (!win) return false;
|
||||||
|
// 获取配置
|
||||||
|
const {
|
||||||
|
fileName,
|
||||||
|
fileType,
|
||||||
|
path,
|
||||||
|
lyric,
|
||||||
|
downloadMeta,
|
||||||
|
downloadCover,
|
||||||
|
downloadLyric,
|
||||||
|
saveMetaFile,
|
||||||
|
songData,
|
||||||
|
} = options;
|
||||||
|
// 规范化路径
|
||||||
|
const downloadPath = resolve(path);
|
||||||
|
// 检查文件夹是否存在
|
||||||
|
try {
|
||||||
|
await access(downloadPath);
|
||||||
|
} catch {
|
||||||
|
throw new Error("❌ Folder not found");
|
||||||
|
}
|
||||||
|
// 下载文件
|
||||||
|
const songDownload = await download(win, url, {
|
||||||
|
directory: downloadPath,
|
||||||
|
filename: `${fileName}.${fileType}`,
|
||||||
|
});
|
||||||
|
if (!downloadMeta || !songData?.cover) return true;
|
||||||
|
// 下载封面
|
||||||
|
const coverUrl = songData?.coverSize?.l || songData.cover;
|
||||||
|
const coverDownload = await download(win, coverUrl, {
|
||||||
|
directory: downloadPath,
|
||||||
|
filename: `${fileName}.jpg`,
|
||||||
|
});
|
||||||
|
// 读取歌曲文件
|
||||||
|
const songFile = File.createFromPath(songDownload.getSavePath());
|
||||||
|
// 生成图片信息
|
||||||
|
const songCover = Picture.fromPath(coverDownload.getSavePath());
|
||||||
|
// 保存修改后的元数据
|
||||||
|
Id3v2Settings.forceDefaultVersion = true;
|
||||||
|
Id3v2Settings.defaultVersion = 3;
|
||||||
|
songFile.tag.title = songData?.name || "未知曲目";
|
||||||
|
songFile.tag.album = songData?.album?.name || "未知专辑";
|
||||||
|
songFile.tag.performers = songData?.artists?.map((ar: any) => ar.name) || ["未知艺术家"];
|
||||||
|
songFile.tag.albumArtists = songData?.artists?.map((ar: any) => ar.name) || ["未知艺术家"];
|
||||||
|
if (lyric && downloadLyric) songFile.tag.lyrics = lyric;
|
||||||
|
if (songCover && downloadCover) songFile.tag.pictures = [songCover];
|
||||||
|
// 保存元信息
|
||||||
|
songFile.save();
|
||||||
|
songFile.dispose();
|
||||||
|
// 创建同名歌词文件
|
||||||
|
if (lyric && saveMetaFile && downloadLyric) {
|
||||||
|
const lrcPath = join(downloadPath, `${fileName}.lrc`);
|
||||||
|
await writeFile(lrcPath, lyric, "utf-8");
|
||||||
|
}
|
||||||
|
// 是否删除封面
|
||||||
|
if (!saveMetaFile || !downloadCover) await unlink(coverDownload.getSavePath());
|
||||||
|
return true;
|
||||||
|
} catch (error) {
|
||||||
|
ipcLog.error("❌ Error downloading file:", error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
// 检查是否是子文件夹
|
||||||
|
ipcMain.handle("check-if-subfolder", (_, localFilesPath: string[], selectedDir: string) => {
|
||||||
|
const resolvedSelectedDir = resolve(selectedDir);
|
||||||
|
const allPaths = localFilesPath.map((p) => resolve(p));
|
||||||
|
return allPaths.some((existingPath) => {
|
||||||
|
const relativePath = relative(existingPath, resolvedSelectedDir);
|
||||||
|
return relativePath && !relativePath.startsWith("..") && !isAbsolute(relativePath);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export default initFileIpc;
|
||||||
201
electron/main/ipc/ipc-lyric.ts
Normal file
@@ -0,0 +1,201 @@
|
|||||||
|
import { BrowserWindow, ipcMain, screen } from "electron";
|
||||||
|
import { useStore } from "../store";
|
||||||
|
import lyricWindow from "../windows/lyric-window";
|
||||||
|
import mainWindow from "../windows/main-window";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 歌词相关 IPC
|
||||||
|
*/
|
||||||
|
const initLyricIpc = (): void => {
|
||||||
|
const store = useStore();
|
||||||
|
|
||||||
|
// 歌词窗口
|
||||||
|
let lyricWin: BrowserWindow | null = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 窗口是否存活
|
||||||
|
* @param win 窗口实例
|
||||||
|
* @returns 是否存活
|
||||||
|
*/
|
||||||
|
const isWinAlive = (win: BrowserWindow | null): win is BrowserWindow =>
|
||||||
|
!!win && !win.isDestroyed();
|
||||||
|
|
||||||
|
// 切换桌面歌词
|
||||||
|
ipcMain.on("toggle-desktop-lyric", (_event, val: boolean) => {
|
||||||
|
if (val) {
|
||||||
|
if (!isWinAlive(lyricWin)) {
|
||||||
|
lyricWin = lyricWindow.create();
|
||||||
|
// 监听关闭,置空引用,防止后续调用报错
|
||||||
|
lyricWin?.on("closed", () => {
|
||||||
|
lyricWin = null;
|
||||||
|
});
|
||||||
|
// 设置位置
|
||||||
|
const { x, y } = store.get("lyric");
|
||||||
|
const xPos = Number(x);
|
||||||
|
const yPos = Number(y);
|
||||||
|
if (Number.isFinite(xPos) && Number.isFinite(yPos)) {
|
||||||
|
lyricWin?.setPosition(Math.round(xPos), Math.round(yPos));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
lyricWin.show();
|
||||||
|
}
|
||||||
|
if (isWinAlive(lyricWin)) {
|
||||||
|
lyricWin.setAlwaysOnTop(true, "screen-saver");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 关闭:不销毁窗口,直接隐藏,保留位置与状态
|
||||||
|
if (!isWinAlive(lyricWin)) return;
|
||||||
|
lyricWin.hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 更新歌词窗口数据
|
||||||
|
ipcMain.on("update-desktop-lyric-data", (_, lyricData) => {
|
||||||
|
if (!lyricData || !isWinAlive(lyricWin)) return;
|
||||||
|
lyricWin.webContents.send("update-desktop-lyric-data", lyricData);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 更新歌词窗口配置
|
||||||
|
ipcMain.on("update-desktop-lyric-option", (_, option, callback: boolean = false) => {
|
||||||
|
const mainWin = mainWindow.getWin();
|
||||||
|
if (!option || !isWinAlive(lyricWin)) return;
|
||||||
|
// 增量更新
|
||||||
|
const prevOption = store.get("lyric.config");
|
||||||
|
if (prevOption) {
|
||||||
|
option = { ...prevOption, ...option };
|
||||||
|
}
|
||||||
|
store.set("lyric.config", option);
|
||||||
|
// 触发窗口更新
|
||||||
|
if (callback && isWinAlive(lyricWin)) {
|
||||||
|
lyricWin.webContents.send("update-desktop-lyric-option", option);
|
||||||
|
}
|
||||||
|
if (isWinAlive(mainWin)) {
|
||||||
|
mainWin?.webContents.send("update-desktop-lyric-option", option);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 播放状态更改
|
||||||
|
ipcMain.on("play-status-change", (_, status) => {
|
||||||
|
if (!isWinAlive(lyricWin)) return;
|
||||||
|
lyricWin.webContents.send("update-desktop-lyric-data", { playStatus: status });
|
||||||
|
});
|
||||||
|
|
||||||
|
// 音乐名称更改
|
||||||
|
ipcMain.on("play-song-change", (_, title) => {
|
||||||
|
if (!isWinAlive(lyricWin)) return;
|
||||||
|
lyricWin.webContents.send("update-desktop-lyric-data", { playName: title });
|
||||||
|
});
|
||||||
|
|
||||||
|
// 音乐歌词更改
|
||||||
|
ipcMain.on("play-lyric-change", (_, lyricData) => {
|
||||||
|
if (!lyricData || !isWinAlive(lyricWin)) return;
|
||||||
|
lyricWin.webContents.send("update-desktop-lyric-data", lyricData);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 获取窗口位置
|
||||||
|
ipcMain.handle("get-window-bounds", () => {
|
||||||
|
if (!isWinAlive(lyricWin)) return {};
|
||||||
|
return lyricWin.getBounds();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 获取屏幕尺寸
|
||||||
|
ipcMain.handle("get-screen-size", () => {
|
||||||
|
const { width, height } = screen.getPrimaryDisplay().workAreaSize;
|
||||||
|
return { width, height };
|
||||||
|
});
|
||||||
|
|
||||||
|
// 获取多屏虚拟边界(支持负坐标)
|
||||||
|
ipcMain.handle("get-virtual-screen-bounds", () => {
|
||||||
|
const displays = screen.getAllDisplays();
|
||||||
|
const bounds = displays.map((d) => d.workArea);
|
||||||
|
const minX = Math.min(...bounds.map((b) => b.x));
|
||||||
|
const minY = Math.min(...bounds.map((b) => b.y));
|
||||||
|
const maxX = Math.max(...bounds.map((b) => b.x + b.width));
|
||||||
|
const maxY = Math.max(...bounds.map((b) => b.y + b.height));
|
||||||
|
return { minX, minY, maxX, maxY };
|
||||||
|
});
|
||||||
|
|
||||||
|
// 移动窗口
|
||||||
|
ipcMain.on("move-window", (_, x, y, width, height) => {
|
||||||
|
if (!isWinAlive(lyricWin)) return;
|
||||||
|
lyricWin.setBounds({ x, y, width, height });
|
||||||
|
// 保存配置
|
||||||
|
store.set("lyric", { ...store.get("lyric"), x, y, width, height });
|
||||||
|
});
|
||||||
|
|
||||||
|
// 更新歌词窗口宽高
|
||||||
|
ipcMain.on("update-lyric-size", (_, width, height) => {
|
||||||
|
if (!isWinAlive(lyricWin)) return;
|
||||||
|
// 更新窗口宽度
|
||||||
|
lyricWin.setBounds({ width, height });
|
||||||
|
store.set("lyric", { ...store.get("lyric"), width, height });
|
||||||
|
});
|
||||||
|
|
||||||
|
// 更新高度
|
||||||
|
ipcMain.on("update-window-height", (_, height) => {
|
||||||
|
if (!isWinAlive(lyricWin)) return;
|
||||||
|
const store = useStore();
|
||||||
|
const { width } = lyricWin.getBounds();
|
||||||
|
// 更新窗口高度
|
||||||
|
lyricWin.setBounds({ width, height });
|
||||||
|
store.set("lyric", { ...store.get("lyric"), height });
|
||||||
|
});
|
||||||
|
|
||||||
|
// 是否固定当前最大宽高
|
||||||
|
ipcMain.on(
|
||||||
|
"toggle-fixed-max-size",
|
||||||
|
(_, options: { width: number; height: number; fixed: boolean }) => {
|
||||||
|
if (!isWinAlive(lyricWin)) return;
|
||||||
|
const { width, height, fixed } = options;
|
||||||
|
if (fixed) {
|
||||||
|
lyricWin.setMaximumSize(width, height);
|
||||||
|
} else {
|
||||||
|
lyricWin.setMaximumSize(1400, 360);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
// 请求歌词数据
|
||||||
|
ipcMain.on("request-desktop-lyric-data", () => {
|
||||||
|
const mainWin = mainWindow.getWin();
|
||||||
|
if (!isWinAlive(lyricWin) || !isWinAlive(mainWin)) return;
|
||||||
|
// 触发窗口更新
|
||||||
|
mainWin?.webContents.send("request-desktop-lyric-data");
|
||||||
|
});
|
||||||
|
|
||||||
|
// 请求歌词配置
|
||||||
|
ipcMain.handle("request-desktop-lyric-option", () => {
|
||||||
|
const config = store.get("lyric.config");
|
||||||
|
if (isWinAlive(lyricWin)) {
|
||||||
|
lyricWin.webContents.send("update-desktop-lyric-option", config);
|
||||||
|
}
|
||||||
|
return config;
|
||||||
|
});
|
||||||
|
|
||||||
|
// 关闭桌面歌词
|
||||||
|
ipcMain.on("closeDesktopLyric", () => {
|
||||||
|
const mainWin = mainWindow.getWin();
|
||||||
|
if (!isWinAlive(lyricWin) || !isWinAlive(mainWin)) return;
|
||||||
|
lyricWin.hide();
|
||||||
|
mainWin?.webContents.send("closeDesktopLyric");
|
||||||
|
});
|
||||||
|
|
||||||
|
// 锁定/解锁桌面歌词
|
||||||
|
ipcMain.on("toogleDesktopLyricLock", (_, isLock: boolean, isTemp: boolean = false) => {
|
||||||
|
const mainWin = mainWindow.getWin();
|
||||||
|
if (!isWinAlive(lyricWin) || !isWinAlive(mainWin)) return;
|
||||||
|
// 是否穿透
|
||||||
|
if (isLock) {
|
||||||
|
lyricWin.setIgnoreMouseEvents(true, { forward: true });
|
||||||
|
} else {
|
||||||
|
lyricWin.setIgnoreMouseEvents(false);
|
||||||
|
}
|
||||||
|
if (isTemp) return;
|
||||||
|
store.set("lyric.config", { ...store.get("lyric.config"), isLock });
|
||||||
|
// 触发窗口更新
|
||||||
|
const config = store.get("lyric.config");
|
||||||
|
mainWin?.webContents.send("update-desktop-lyric-option", config);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export default initLyricIpc;
|
||||||
36
electron/main/ipc/ipc-shortcut.ts
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import { ipcMain } from "electron";
|
||||||
|
import { isShortcutRegistered, registerShortcut, unregisterShortcuts } from "../shortcut";
|
||||||
|
import mainWindow from "../windows/main-window";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化快捷键 IPC 主进程
|
||||||
|
* @returns void
|
||||||
|
*/
|
||||||
|
const initShortcutIpc = (): void => {
|
||||||
|
// 快捷键是否被注册
|
||||||
|
ipcMain.handle("is-shortcut-registered", (_, shortcut: string) => isShortcutRegistered(shortcut));
|
||||||
|
|
||||||
|
// 注册快捷键
|
||||||
|
ipcMain.handle("register-all-shortcut", (_, allShortcuts: any): string[] | false => {
|
||||||
|
const mainWin = mainWindow.getWin();
|
||||||
|
if (!mainWin || !allShortcuts) return false;
|
||||||
|
// 卸载所有快捷键
|
||||||
|
unregisterShortcuts();
|
||||||
|
// 注册快捷键
|
||||||
|
const failedShortcuts: string[] = [];
|
||||||
|
for (const key in allShortcuts) {
|
||||||
|
const shortcut = allShortcuts[key].globalShortcut;
|
||||||
|
if (!shortcut) continue;
|
||||||
|
// 快捷键回调
|
||||||
|
const callback = () => mainWin.webContents.send(key);
|
||||||
|
const isSuccess = registerShortcut(shortcut, callback);
|
||||||
|
if (!isSuccess) failedShortcuts.push(shortcut);
|
||||||
|
}
|
||||||
|
return failedShortcuts;
|
||||||
|
});
|
||||||
|
|
||||||
|
// 卸载所有快捷键
|
||||||
|
ipcMain.on("unregister-all-shortcut", () => unregisterShortcuts());
|
||||||
|
};
|
||||||
|
|
||||||
|
export default initShortcutIpc;
|
||||||
45
electron/main/ipc/ipc-store.ts
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
import { ipcMain } from "electron";
|
||||||
|
import { useStore } from "../store";
|
||||||
|
import type { StoreType } from "../store";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化 store IPC 主进程
|
||||||
|
*/
|
||||||
|
const initStoreIpc = (): void => {
|
||||||
|
const store = useStore();
|
||||||
|
if (!store) return;
|
||||||
|
|
||||||
|
// 获取配置项
|
||||||
|
ipcMain.handle("store-get", (_event, key: keyof StoreType) => {
|
||||||
|
return store.get(key as any);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 设置配置项
|
||||||
|
ipcMain.handle("store-set", (_event, key: keyof StoreType, value: unknown) => {
|
||||||
|
store.set(key as any, value as any);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
// 判断配置项是否存在
|
||||||
|
ipcMain.handle("store-has", (_event, key: keyof StoreType) => {
|
||||||
|
return store.has(key as any);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 删除配置项
|
||||||
|
ipcMain.handle("store-delete", (_event, key: keyof StoreType) => {
|
||||||
|
store.delete(key as any);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
// 重置配置(支持指定 keys 或全部重置)
|
||||||
|
ipcMain.handle("store-reset", (_event, keys?: (keyof StoreType)[]) => {
|
||||||
|
if (keys && keys.length > 0) {
|
||||||
|
store.reset(...(keys as any));
|
||||||
|
} else {
|
||||||
|
store.reset();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export default initStoreIpc;
|
||||||
105
electron/main/ipc/ipc-system.ts
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
import { app, ipcMain, net, powerSaveBlocker, session } from "electron";
|
||||||
|
import { ipcLog } from "../logger";
|
||||||
|
import { getFonts } from "font-list";
|
||||||
|
import { useStore } from "../store";
|
||||||
|
import mainWindow from "../windows/main-window";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化系统 IPC 通信
|
||||||
|
* @returns void
|
||||||
|
*/
|
||||||
|
const initSystemIpc = (): void => {
|
||||||
|
const store = useStore();
|
||||||
|
|
||||||
|
/** 阻止系统息屏 ID */
|
||||||
|
let preventId: number | null = null;
|
||||||
|
|
||||||
|
// 是否阻止系统息屏
|
||||||
|
ipcMain.on("prevent-sleep", (_event, val: boolean) => {
|
||||||
|
if (val) {
|
||||||
|
preventId = powerSaveBlocker.start("prevent-display-sleep");
|
||||||
|
ipcLog.info("⏾ System sleep prevention started");
|
||||||
|
} else {
|
||||||
|
if (preventId !== null) {
|
||||||
|
powerSaveBlocker.stop(preventId);
|
||||||
|
ipcLog.info("✅ System sleep prevention stopped");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 退出应用
|
||||||
|
ipcMain.on("quit-app", () => {
|
||||||
|
app.exit(0);
|
||||||
|
app.quit();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 获取系统全部字体
|
||||||
|
ipcMain.handle("get-all-fonts", async () => {
|
||||||
|
try {
|
||||||
|
const fonts = await getFonts();
|
||||||
|
return fonts;
|
||||||
|
} catch (error) {
|
||||||
|
ipcLog.error(`❌ Failed to get all system fonts: ${error}`);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 取消代理
|
||||||
|
ipcMain.on("remove-proxy", () => {
|
||||||
|
const mainWin = mainWindow.getWin();
|
||||||
|
store.set("proxy", "");
|
||||||
|
if (mainWin) {
|
||||||
|
mainWin?.webContents.session.setProxy({ proxyRules: "" });
|
||||||
|
}
|
||||||
|
ipcLog.info("✅ Remove proxy successfully");
|
||||||
|
});
|
||||||
|
|
||||||
|
// 配置网络代理
|
||||||
|
ipcMain.on("set-proxy", (_, config) => {
|
||||||
|
const mainWin = mainWindow.getWin();
|
||||||
|
if (!mainWin) return;
|
||||||
|
const proxyRules = `${config.protocol}://${config.server}:${config.port}`;
|
||||||
|
store.set("proxy", proxyRules);
|
||||||
|
mainWin?.webContents.session.setProxy({ proxyRules });
|
||||||
|
ipcLog.info("✅ Set proxy successfully:", proxyRules);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 代理测试
|
||||||
|
ipcMain.handle("test-proxy", async (_, config) => {
|
||||||
|
const proxyRules = `${config.protocol}://${config.server}:${config.port}`;
|
||||||
|
try {
|
||||||
|
// 设置代理
|
||||||
|
const ses = session.defaultSession;
|
||||||
|
await ses.setProxy({ proxyRules });
|
||||||
|
// 测试请求
|
||||||
|
const request = net.request({ url: "https://www.baidu.com" });
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
request.on("response", (response) => {
|
||||||
|
if (response.statusCode === 200) {
|
||||||
|
ipcLog.info("✅ Proxy test successful");
|
||||||
|
resolve(true);
|
||||||
|
} else {
|
||||||
|
ipcLog.error(`❌ Proxy test failed with status code: ${response.statusCode}`);
|
||||||
|
resolve(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
request.on("error", (error) => {
|
||||||
|
ipcLog.error("❌ Error testing proxy:", error);
|
||||||
|
resolve(false);
|
||||||
|
});
|
||||||
|
request.end();
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
ipcLog.error("❌ Error testing proxy:", error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 重置全部设置
|
||||||
|
ipcMain.on("reset-setting", () => {
|
||||||
|
store.reset();
|
||||||
|
ipcLog.info("✅ Reset setting successfully");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export default initSystemIpc;
|
||||||
15
electron/main/ipc/ipc-thumbar.ts
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import { ipcMain } from "electron";
|
||||||
|
import { getThumbar } from "../thumbar";
|
||||||
|
|
||||||
|
const initThumbarIpc = (): void => {
|
||||||
|
// 更新工具栏
|
||||||
|
ipcMain.on("play-status-change", (_, playStatus: boolean) => {
|
||||||
|
const thumbar = getThumbar();
|
||||||
|
if (!thumbar) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
thumbar.updateThumbar(playStatus);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export default initThumbarIpc;
|
||||||
49
electron/main/ipc/ipc-tray.ts
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
import { ipcMain } from "electron";
|
||||||
|
import { getMainTray } from "../tray";
|
||||||
|
import lyricWindow from "../windows/lyric-window";
|
||||||
|
import { appName } from "../utils/config";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 托盘 IPC
|
||||||
|
*/
|
||||||
|
const initTrayIpc = (): void => {
|
||||||
|
const tray = getMainTray();
|
||||||
|
|
||||||
|
// 音乐播放状态更改
|
||||||
|
ipcMain.on("play-status-change", (_, playStatus: boolean) => {
|
||||||
|
const lyricWin = lyricWindow.getWin();
|
||||||
|
tray?.setPlayState(playStatus ? "play" : "pause");
|
||||||
|
if (!lyricWin) return;
|
||||||
|
lyricWin.webContents.send("play-status-change", playStatus);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 音乐名称更改
|
||||||
|
ipcMain.on("play-song-change", (_, title) => {
|
||||||
|
if (!title) title = appName;
|
||||||
|
// 更改标题
|
||||||
|
tray?.setTitle(title);
|
||||||
|
tray?.setPlayName(title);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 播放模式切换
|
||||||
|
ipcMain.on("play-mode-change", (_, mode) => {
|
||||||
|
tray?.setPlayMode(mode);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 喜欢状态切换
|
||||||
|
ipcMain.on("like-status-change", (_, likeStatus: boolean) => {
|
||||||
|
tray?.setLikeState(likeStatus);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 桌面歌词开关
|
||||||
|
ipcMain.on("toggle-desktop-lyric", (_, val: boolean) => {
|
||||||
|
tray?.setDesktopLyricShow(val);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 锁定/解锁桌面歌词
|
||||||
|
ipcMain.on("toogleDesktopLyricLock", (_, isLock: boolean) => {
|
||||||
|
tray?.setDesktopLyricLock(isLock);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export default initTrayIpc;
|
||||||
17
electron/main/ipc/ipc-update.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import { ipcMain } from "electron";
|
||||||
|
import { checkUpdate, startDownloadUpdate } from "../update";
|
||||||
|
import mainWindow from "../windows/main-window";
|
||||||
|
|
||||||
|
const initUpdateIpc = () => {
|
||||||
|
// 检查更新
|
||||||
|
ipcMain.on("check-update", (_event, showTip) => {
|
||||||
|
const mainWin = mainWindow.getWin();
|
||||||
|
if (!mainWin) return;
|
||||||
|
checkUpdate(mainWin, showTip);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 开始下载更新
|
||||||
|
ipcMain.on("start-download-update", () => startDownloadUpdate());
|
||||||
|
};
|
||||||
|
|
||||||
|
export default initUpdateIpc;
|
||||||
152
electron/main/ipc/ipc-window.ts
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
import { app, ipcMain } from "electron";
|
||||||
|
import { useStore } from "../store";
|
||||||
|
import { isDev } from "../utils/config";
|
||||||
|
import { initThumbar } from "../thumbar";
|
||||||
|
import mainWindow from "../windows/main-window";
|
||||||
|
import loadWindow from "../windows/load-window";
|
||||||
|
import loginWindow from "../windows/login-window";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 窗口 IPC 通信
|
||||||
|
* @returns void
|
||||||
|
*/
|
||||||
|
const initWindowsIpc = (): void => {
|
||||||
|
// store
|
||||||
|
const store = useStore();
|
||||||
|
|
||||||
|
// 当前窗口状态
|
||||||
|
ipcMain.on("win-state", (event) => {
|
||||||
|
const mainWin = mainWindow.getWin();
|
||||||
|
if (!mainWin) return;
|
||||||
|
event.returnValue = mainWin?.isMaximized();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 加载完成
|
||||||
|
ipcMain.on("win-loaded", () => {
|
||||||
|
const loadWin = loadWindow.getWin();
|
||||||
|
const mainWin = mainWindow.getWin();
|
||||||
|
if (loadWin && !loadWin.isDestroyed()) loadWin.destroy();
|
||||||
|
const isMaximized = store.get("window")?.maximized;
|
||||||
|
if (isMaximized) mainWin?.maximize();
|
||||||
|
if (!mainWin) return;
|
||||||
|
mainWin?.show();
|
||||||
|
mainWin?.focus();
|
||||||
|
// 解决窗口不立即显示
|
||||||
|
mainWin?.setAlwaysOnTop(true);
|
||||||
|
// 100ms 后取消置顶
|
||||||
|
const timer = setTimeout(() => {
|
||||||
|
if (mainWin && !mainWin.isDestroyed()) {
|
||||||
|
mainWin.setAlwaysOnTop(false);
|
||||||
|
mainWin.focus();
|
||||||
|
clearTimeout(timer);
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
// 初始化缩略图工具栏
|
||||||
|
if (mainWin) initThumbar(mainWin);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 最小化
|
||||||
|
ipcMain.on("win-min", (event) => {
|
||||||
|
const mainWin = mainWindow.getWin();
|
||||||
|
if (!mainWin) return;
|
||||||
|
event.preventDefault();
|
||||||
|
mainWin?.minimize();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 最大化
|
||||||
|
ipcMain.on("win-max", () => {
|
||||||
|
const mainWin = mainWindow.getWin();
|
||||||
|
if (!mainWin) return;
|
||||||
|
mainWin?.maximize();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 还原
|
||||||
|
ipcMain.on("win-restore", () => {
|
||||||
|
const mainWin = mainWindow.getWin();
|
||||||
|
if (!mainWin) return;
|
||||||
|
mainWin?.restore();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 隐藏
|
||||||
|
ipcMain.on("win-hide", () => {
|
||||||
|
const mainWin = mainWindow.getWin();
|
||||||
|
if (!mainWin) return;
|
||||||
|
mainWin?.hide();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 显示
|
||||||
|
ipcMain.on("win-show", () => {
|
||||||
|
const mainWin = mainWindow.getWin();
|
||||||
|
if (!mainWin) return;
|
||||||
|
mainWin?.show();
|
||||||
|
mainWin?.focus();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 重启
|
||||||
|
ipcMain.on("win-reload", () => {
|
||||||
|
app.quit();
|
||||||
|
app.relaunch();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 向主窗口发送事件
|
||||||
|
ipcMain.on("send-to-mainWin", (_, eventName, ...args) => {
|
||||||
|
const mainWin = mainWindow.getWin();
|
||||||
|
if (!mainWin || mainWin.isDestroyed() || mainWin.webContents.isDestroyed()) return;
|
||||||
|
mainWin.webContents.send(eventName, ...args);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 显示进度
|
||||||
|
ipcMain.on("set-bar", (_event, val: number | "none" | "indeterminate" | "error" | "paused") => {
|
||||||
|
const mainWin = mainWindow.getWin();
|
||||||
|
if (!mainWin) return;
|
||||||
|
switch (val) {
|
||||||
|
case "none":
|
||||||
|
mainWin?.setProgressBar(-1);
|
||||||
|
break;
|
||||||
|
case "indeterminate":
|
||||||
|
mainWin?.setProgressBar(2, { mode: "indeterminate" });
|
||||||
|
break;
|
||||||
|
case "error":
|
||||||
|
mainWin?.setProgressBar(1, { mode: "error" });
|
||||||
|
break;
|
||||||
|
case "paused":
|
||||||
|
mainWin?.setProgressBar(1, { mode: "paused" });
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (typeof val === "number") {
|
||||||
|
mainWin?.setProgressBar(val / 100);
|
||||||
|
} else {
|
||||||
|
mainWin?.setProgressBar(-1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 开启控制台
|
||||||
|
ipcMain.on("open-dev-tools", () => {
|
||||||
|
const mainWin = mainWindow.getWin();
|
||||||
|
if (!mainWin) return;
|
||||||
|
mainWin?.webContents.openDevTools({
|
||||||
|
title: "SPlayer DevTools",
|
||||||
|
mode: isDev ? "right" : "detach",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// 开启登录窗口
|
||||||
|
ipcMain.on("open-login-web", () => {
|
||||||
|
const mainWin = mainWindow.getWin();
|
||||||
|
if (!mainWin) return;
|
||||||
|
loginWindow.create(mainWin);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 开启设置
|
||||||
|
ipcMain.on("open-setting", (_, type) => {
|
||||||
|
const mainWin = mainWindow.getWin();
|
||||||
|
if (!mainWin) return;
|
||||||
|
mainWin?.show();
|
||||||
|
mainWin?.focus();
|
||||||
|
mainWin?.webContents.send("openSetting", type);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export default initWindowsIpc;
|
||||||
@@ -1,703 +0,0 @@
|
|||||||
import {
|
|
||||||
app,
|
|
||||||
ipcMain,
|
|
||||||
BrowserWindow,
|
|
||||||
powerSaveBlocker,
|
|
||||||
screen,
|
|
||||||
shell,
|
|
||||||
dialog,
|
|
||||||
net,
|
|
||||||
session,
|
|
||||||
} from "electron";
|
|
||||||
import { File, Picture, Id3v2Settings } from "node-taglib-sharp";
|
|
||||||
import { parseFile } from "music-metadata";
|
|
||||||
import { getFonts } from "font-list";
|
|
||||||
import { MainTray } from "./tray";
|
|
||||||
import { Thumbar } from "./thumbar";
|
|
||||||
import { StoreType } from "./store";
|
|
||||||
import { isDev, getFileID, getFileMD5 } from "./utils";
|
|
||||||
import { isShortcutRegistered, registerShortcut, unregisterShortcuts } from "./shortcut";
|
|
||||||
import { join, basename, resolve } from "path";
|
|
||||||
import { download } from "electron-dl";
|
|
||||||
import { checkUpdate, startDownloadUpdate } from "./update";
|
|
||||||
import fs from "fs/promises";
|
|
||||||
import log from "../main/logger";
|
|
||||||
import Store from "electron-store";
|
|
||||||
import fg from "fast-glob";
|
|
||||||
|
|
||||||
// 注册 ipcMain
|
|
||||||
const initIpcMain = (
|
|
||||||
win: BrowserWindow | null,
|
|
||||||
lyricWin: BrowserWindow | null,
|
|
||||||
loadingWin: BrowserWindow | null,
|
|
||||||
tray: MainTray | null,
|
|
||||||
thumbar: Thumbar | null,
|
|
||||||
store: Store<StoreType>,
|
|
||||||
) => {
|
|
||||||
initWinIpcMain(win, loadingWin, lyricWin, store);
|
|
||||||
initLyricIpcMain(lyricWin, win, store);
|
|
||||||
initTrayIpcMain(tray, win, lyricWin);
|
|
||||||
initThumbarIpcMain(thumbar);
|
|
||||||
initStoreIpcMain(store);
|
|
||||||
initOtherIpcMain(win);
|
|
||||||
};
|
|
||||||
|
|
||||||
// win
|
|
||||||
const initWinIpcMain = (
|
|
||||||
win: BrowserWindow | null,
|
|
||||||
loadingWin: BrowserWindow | null,
|
|
||||||
lyricWin: BrowserWindow | null,
|
|
||||||
store: Store<StoreType>,
|
|
||||||
) => {
|
|
||||||
let preventId: number | null = null;
|
|
||||||
|
|
||||||
// 当前窗口状态
|
|
||||||
ipcMain.on("win-state", (ev) => {
|
|
||||||
ev.returnValue = win?.isMaximized();
|
|
||||||
});
|
|
||||||
|
|
||||||
// 加载完成
|
|
||||||
ipcMain.on("win-loaded", () => {
|
|
||||||
if (loadingWin && !loadingWin.isDestroyed()) loadingWin.close();
|
|
||||||
win?.show();
|
|
||||||
win?.focus();
|
|
||||||
});
|
|
||||||
|
|
||||||
// 最小化
|
|
||||||
ipcMain.on("win-min", (ev) => {
|
|
||||||
ev.preventDefault();
|
|
||||||
win?.minimize();
|
|
||||||
});
|
|
||||||
// 最大化
|
|
||||||
ipcMain.on("win-max", () => {
|
|
||||||
win?.maximize();
|
|
||||||
});
|
|
||||||
// 还原
|
|
||||||
ipcMain.on("win-restore", () => {
|
|
||||||
win?.restore();
|
|
||||||
});
|
|
||||||
// 关闭
|
|
||||||
ipcMain.on("win-close", (ev) => {
|
|
||||||
ev.preventDefault();
|
|
||||||
win?.close();
|
|
||||||
app.quit();
|
|
||||||
});
|
|
||||||
// 隐藏
|
|
||||||
ipcMain.on("win-hide", () => {
|
|
||||||
win?.hide();
|
|
||||||
});
|
|
||||||
// 显示
|
|
||||||
ipcMain.on("win-show", () => {
|
|
||||||
win?.show();
|
|
||||||
});
|
|
||||||
// 重启
|
|
||||||
ipcMain.on("win-reload", () => {
|
|
||||||
app.quit();
|
|
||||||
app.relaunch();
|
|
||||||
});
|
|
||||||
|
|
||||||
// 显示进度
|
|
||||||
ipcMain.on("set-bar", (_, val: number | "none" | "indeterminate" | "error" | "paused") => {
|
|
||||||
switch (val) {
|
|
||||||
case "none":
|
|
||||||
win?.setProgressBar(-1);
|
|
||||||
break;
|
|
||||||
case "indeterminate":
|
|
||||||
win?.setProgressBar(2, { mode: "indeterminate" });
|
|
||||||
break;
|
|
||||||
case "error":
|
|
||||||
win?.setProgressBar(1, { mode: "error" });
|
|
||||||
break;
|
|
||||||
case "paused":
|
|
||||||
win?.setProgressBar(1, { mode: "paused" });
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (typeof val === "number") {
|
|
||||||
win?.setProgressBar(val / 100);
|
|
||||||
} else {
|
|
||||||
win?.setProgressBar(-1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// 开启控制台
|
|
||||||
ipcMain.on("open-dev-tools", () => {
|
|
||||||
win?.webContents.openDevTools({
|
|
||||||
title: "SPlayer DevTools",
|
|
||||||
mode: isDev ? "right" : "detach",
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// 获取系统全部字体
|
|
||||||
ipcMain.handle("get-all-fonts", async () => {
|
|
||||||
try {
|
|
||||||
const fonts = await getFonts();
|
|
||||||
return fonts;
|
|
||||||
} catch (error) {
|
|
||||||
log.error(`❌ Failed to get all system fonts: ${error}`);
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// 切换桌面歌词
|
|
||||||
ipcMain.on("change-desktop-lyric", (_, val: boolean) => {
|
|
||||||
if (val) {
|
|
||||||
lyricWin?.show();
|
|
||||||
lyricWin?.setAlwaysOnTop(true, "screen-saver");
|
|
||||||
} else lyricWin?.hide();
|
|
||||||
});
|
|
||||||
|
|
||||||
// 是否阻止系统息屏
|
|
||||||
ipcMain.on("prevent-sleep", (_, val: boolean) => {
|
|
||||||
if (val) {
|
|
||||||
preventId = powerSaveBlocker.start("prevent-display-sleep");
|
|
||||||
log.info("⏾ System sleep prevention started");
|
|
||||||
} else {
|
|
||||||
if (preventId !== null) {
|
|
||||||
powerSaveBlocker.stop(preventId);
|
|
||||||
log.info("✅ System sleep prevention stopped");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// 默认文件夹
|
|
||||||
ipcMain.handle(
|
|
||||||
"get-default-dir",
|
|
||||||
(_, type: "documents" | "downloads" | "pictures" | "music" | "videos"): string => {
|
|
||||||
return app.getPath(type);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
// 遍历音乐文件
|
|
||||||
ipcMain.handle("get-music-files", async (_, dirPath: string) => {
|
|
||||||
try {
|
|
||||||
// 查找指定目录下的所有音乐文件
|
|
||||||
const musicFiles = await fg("**/*.{mp3,wav,flac}", { cwd: dirPath });
|
|
||||||
// 解析元信息
|
|
||||||
const metadataPromises = musicFiles.map(async (file) => {
|
|
||||||
const filePath = join(dirPath, file);
|
|
||||||
// 处理元信息
|
|
||||||
const { common, format } = await parseFile(filePath);
|
|
||||||
// 获取文件大小
|
|
||||||
const { size } = await fs.stat(filePath);
|
|
||||||
// 判断音质等级
|
|
||||||
let quality: string;
|
|
||||||
if ((format.sampleRate || 0) >= 96000 || (format.bitsPerSample || 0) > 16) {
|
|
||||||
quality = "Hi-Res";
|
|
||||||
} else if ((format.sampleRate || 0) >= 44100) {
|
|
||||||
quality = "HQ";
|
|
||||||
} else {
|
|
||||||
quality = "SQ";
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
id: getFileID(filePath),
|
|
||||||
name: common.title || basename(filePath),
|
|
||||||
artists: common.artists?.[0] || common.artist,
|
|
||||||
album: common.album || "",
|
|
||||||
alia: common.comment?.[0],
|
|
||||||
duration: (format?.duration ?? 0) * 1000,
|
|
||||||
size: (size / (1024 * 1024)).toFixed(2),
|
|
||||||
path: filePath,
|
|
||||||
quality,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
const metadataArray = await Promise.all(metadataPromises);
|
|
||||||
return metadataArray;
|
|
||||||
} catch (error) {
|
|
||||||
log.error("❌ Error fetching music metadata:", error);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// 获取音乐元信息
|
|
||||||
ipcMain.handle("get-music-metadata", async (_, path: string) => {
|
|
||||||
try {
|
|
||||||
const { common, format } = await parseFile(path);
|
|
||||||
return {
|
|
||||||
// 文件名称
|
|
||||||
fileName: basename(path),
|
|
||||||
// 文件大小
|
|
||||||
fileSize: (await fs.stat(path)).size / (1024 * 1024),
|
|
||||||
// 元信息
|
|
||||||
common,
|
|
||||||
// 音质信息
|
|
||||||
format,
|
|
||||||
// md5
|
|
||||||
md5: await getFileMD5(path),
|
|
||||||
};
|
|
||||||
} catch (error) {
|
|
||||||
log.error("❌ Error fetching music metadata:", error);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// 获取音乐歌词
|
|
||||||
ipcMain.handle("get-music-lyric", async (_, path: string): Promise<string> => {
|
|
||||||
try {
|
|
||||||
const { common, native } = await parseFile(path);
|
|
||||||
const lyric = common?.lyrics;
|
|
||||||
if (lyric && lyric.length > 0) return String(lyric[0]);
|
|
||||||
else {
|
|
||||||
// 尝试读取 UNSYNCEDLYRICS
|
|
||||||
const nativeTags = native["ID3v2.3"] || native["ID3v2.4"];
|
|
||||||
const usltTag = nativeTags?.find((tag) => tag.id === "USLT");
|
|
||||||
if (usltTag) return String(usltTag.value.text);
|
|
||||||
// 如果歌词数据不存在,尝试读取同名的 lrc 文件
|
|
||||||
else {
|
|
||||||
const lrcFilePath = path.replace(/\.[^.]+$/, ".lrc");
|
|
||||||
try {
|
|
||||||
await fs.access(lrcFilePath);
|
|
||||||
const lrcData = await fs.readFile(lrcFilePath, "utf-8");
|
|
||||||
return lrcData || "";
|
|
||||||
} catch {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
log.error("❌ Error fetching music lyric:", error);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// 获取音乐封面
|
|
||||||
ipcMain.handle(
|
|
||||||
"get-music-cover",
|
|
||||||
async (_, path: string): Promise<{ data: Buffer; format: string } | null> => {
|
|
||||||
try {
|
|
||||||
const { common } = await parseFile(path);
|
|
||||||
// 获取封面数据
|
|
||||||
const picture = common.picture?.[0];
|
|
||||||
if (picture) {
|
|
||||||
return { data: Buffer.from(picture.data), format: picture.format };
|
|
||||||
} else {
|
|
||||||
const coverFilePath = path.replace(/\.[^.]+$/, ".jpg");
|
|
||||||
try {
|
|
||||||
await fs.access(coverFilePath);
|
|
||||||
const coverData = await fs.readFile(coverFilePath);
|
|
||||||
return { data: coverData, format: "image/jpeg" };
|
|
||||||
} catch {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error("❌ Error fetching music cover:", error);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
// 删除文件
|
|
||||||
ipcMain.handle("delete-file", async (_, path: string) => {
|
|
||||||
try {
|
|
||||||
// 规范化路径
|
|
||||||
const resolvedPath = resolve(path);
|
|
||||||
// 检查文件是否存在
|
|
||||||
try {
|
|
||||||
await fs.access(resolvedPath);
|
|
||||||
} catch {
|
|
||||||
throw new Error("❌ File not found");
|
|
||||||
}
|
|
||||||
// 删除文件
|
|
||||||
await fs.unlink(resolvedPath);
|
|
||||||
return true;
|
|
||||||
} catch (error) {
|
|
||||||
log.error("❌ File delete error", error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// 打开文件夹
|
|
||||||
ipcMain.on("open-folder", async (_, path: string) => {
|
|
||||||
try {
|
|
||||||
// 规范化路径
|
|
||||||
const resolvedPath = resolve(path);
|
|
||||||
// 检查文件夹是否存在
|
|
||||||
try {
|
|
||||||
await fs.access(resolvedPath);
|
|
||||||
} catch {
|
|
||||||
throw new Error("❌ Folder not found");
|
|
||||||
}
|
|
||||||
// 打开文件夹
|
|
||||||
shell.showItemInFolder(resolvedPath);
|
|
||||||
} catch (error) {
|
|
||||||
log.error("❌ Folder open error", error);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// 图片选择窗口
|
|
||||||
ipcMain.handle("choose-image", async () => {
|
|
||||||
try {
|
|
||||||
const { filePaths } = await dialog.showOpenDialog({
|
|
||||||
properties: ["openFile"],
|
|
||||||
filters: [{ name: "Images", extensions: ["jpg", "jpeg", "png"] }],
|
|
||||||
});
|
|
||||||
if (!filePaths || filePaths.length === 0) return null;
|
|
||||||
return filePaths[0];
|
|
||||||
} catch (error) {
|
|
||||||
log.error("❌ Image choose error", error);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// 路径选择窗口
|
|
||||||
ipcMain.handle("choose-path", async () => {
|
|
||||||
try {
|
|
||||||
const { filePaths } = await dialog.showOpenDialog({
|
|
||||||
title: "选择文件夹",
|
|
||||||
defaultPath: app.getPath("downloads"),
|
|
||||||
properties: ["openDirectory", "createDirectory"],
|
|
||||||
buttonLabel: "选择文件夹",
|
|
||||||
});
|
|
||||||
if (!filePaths || filePaths.length === 0) return null;
|
|
||||||
return filePaths[0];
|
|
||||||
} catch (error) {
|
|
||||||
log.error("❌ Path choose error", error);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// 修改音乐元信息
|
|
||||||
ipcMain.handle("set-music-metadata", async (_, path: string, metadata: any) => {
|
|
||||||
try {
|
|
||||||
const { name, artist, album, alia, lyric, cover } = metadata;
|
|
||||||
// 规范化路径
|
|
||||||
const songPath = resolve(path);
|
|
||||||
const coverPath = cover ? resolve(cover) : null;
|
|
||||||
// 读取歌曲文件
|
|
||||||
const songFile = File.createFromPath(songPath);
|
|
||||||
// 读取封面文件
|
|
||||||
const songCover = coverPath ? Picture.fromPath(coverPath) : null;
|
|
||||||
// 保存元数据
|
|
||||||
Id3v2Settings.forceDefaultVersion = true;
|
|
||||||
Id3v2Settings.defaultVersion = 3;
|
|
||||||
songFile.tag.title = name || "未知曲目";
|
|
||||||
songFile.tag.performers = [artist || "未知艺术家"];
|
|
||||||
songFile.tag.album = album || "未知专辑";
|
|
||||||
songFile.tag.albumArtists = [artist || "未知艺术家"];
|
|
||||||
songFile.tag.lyrics = lyric || "";
|
|
||||||
songFile.tag.description = alia || "";
|
|
||||||
songFile.tag.comment = alia || "";
|
|
||||||
if (songCover) songFile.tag.pictures = [songCover];
|
|
||||||
// 保存元信息
|
|
||||||
songFile.save();
|
|
||||||
songFile.dispose();
|
|
||||||
return true;
|
|
||||||
} catch (error) {
|
|
||||||
log.error("❌ Error setting music metadata:", error);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// 下载文件
|
|
||||||
ipcMain.handle(
|
|
||||||
"download-file",
|
|
||||||
async (
|
|
||||||
_,
|
|
||||||
url: string,
|
|
||||||
options: {
|
|
||||||
fileName: string;
|
|
||||||
fileType: string;
|
|
||||||
path: string;
|
|
||||||
downloadMeta?: boolean;
|
|
||||||
downloadCover?: boolean;
|
|
||||||
downloadLyric?: boolean;
|
|
||||||
saveMetaFile?: boolean;
|
|
||||||
lyric?: string;
|
|
||||||
songData?: any;
|
|
||||||
} = {
|
|
||||||
fileName: "未知文件名",
|
|
||||||
fileType: "mp3",
|
|
||||||
path: app.getPath("downloads"),
|
|
||||||
},
|
|
||||||
): Promise<boolean> => {
|
|
||||||
try {
|
|
||||||
if (!win) return false;
|
|
||||||
// 获取配置
|
|
||||||
const {
|
|
||||||
fileName,
|
|
||||||
fileType,
|
|
||||||
path,
|
|
||||||
lyric,
|
|
||||||
downloadMeta,
|
|
||||||
downloadCover,
|
|
||||||
downloadLyric,
|
|
||||||
saveMetaFile,
|
|
||||||
songData,
|
|
||||||
} = options;
|
|
||||||
// 规范化路径
|
|
||||||
const downloadPath = resolve(path);
|
|
||||||
// 检查文件夹是否存在
|
|
||||||
try {
|
|
||||||
await fs.access(downloadPath);
|
|
||||||
} catch {
|
|
||||||
throw new Error("❌ Folder not found");
|
|
||||||
}
|
|
||||||
// 下载文件
|
|
||||||
const songDownload = await download(win, url, {
|
|
||||||
directory: downloadPath,
|
|
||||||
filename: `${fileName}.${fileType}`,
|
|
||||||
});
|
|
||||||
if (!downloadMeta || !songData?.cover) return true;
|
|
||||||
// 下载封面
|
|
||||||
const coverUrl = songData?.coverSize?.l || songData.cover;
|
|
||||||
const coverDownload = await download(win, coverUrl, {
|
|
||||||
directory: downloadPath,
|
|
||||||
filename: `${fileName}.jpg`,
|
|
||||||
});
|
|
||||||
// 读取歌曲文件
|
|
||||||
const songFile = File.createFromPath(songDownload.getSavePath());
|
|
||||||
// 生成图片信息
|
|
||||||
const songCover = Picture.fromPath(coverDownload.getSavePath());
|
|
||||||
// 保存修改后的元数据
|
|
||||||
Id3v2Settings.forceDefaultVersion = true;
|
|
||||||
Id3v2Settings.defaultVersion = 3;
|
|
||||||
songFile.tag.title = songData?.name || "未知曲目";
|
|
||||||
songFile.tag.album = songData?.album?.name || "未知专辑";
|
|
||||||
songFile.tag.performers = songData?.artists?.map((ar: any) => ar.name) || ["未知艺术家"];
|
|
||||||
songFile.tag.albumArtists = songData?.artists?.map((ar: any) => ar.name) || ["未知艺术家"];
|
|
||||||
if (lyric && downloadLyric) songFile.tag.lyrics = lyric;
|
|
||||||
if (songCover && downloadCover) songFile.tag.pictures = [songCover];
|
|
||||||
// 保存元信息
|
|
||||||
songFile.save();
|
|
||||||
songFile.dispose();
|
|
||||||
// 创建同名歌词文件
|
|
||||||
if (lyric && saveMetaFile && downloadLyric) {
|
|
||||||
const lrcPath = join(downloadPath, `${fileName}.lrc`);
|
|
||||||
await fs.writeFile(lrcPath, lyric, "utf-8");
|
|
||||||
}
|
|
||||||
// 是否删除封面
|
|
||||||
if (!saveMetaFile || !downloadCover) await fs.unlink(coverDownload.getSavePath());
|
|
||||||
return true;
|
|
||||||
} catch (error) {
|
|
||||||
log.error("❌ Error downloading file:", error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
// 取消代理
|
|
||||||
ipcMain.on("remove-proxy", () => {
|
|
||||||
store.set("proxy", "");
|
|
||||||
win?.webContents.session.setProxy({ proxyRules: "" });
|
|
||||||
log.info("✅ Remove proxy successfully");
|
|
||||||
});
|
|
||||||
|
|
||||||
// 配置网络代理
|
|
||||||
ipcMain.on("set-proxy", (_, config) => {
|
|
||||||
const proxyRules = `${config.protocol}://${config.server}:${config.port}`;
|
|
||||||
store.set("proxy", proxyRules);
|
|
||||||
win?.webContents.session.setProxy({ proxyRules });
|
|
||||||
log.info("✅ Set proxy successfully:", proxyRules);
|
|
||||||
});
|
|
||||||
|
|
||||||
// 代理测试
|
|
||||||
ipcMain.handle("test-proxy", async (_, config) => {
|
|
||||||
const proxyRules = `${config.protocol}://${config.server}:${config.port}`;
|
|
||||||
try {
|
|
||||||
// 设置代理
|
|
||||||
const ses = session.defaultSession;
|
|
||||||
await ses.setProxy({ proxyRules });
|
|
||||||
// 测试请求
|
|
||||||
const request = net.request({ url: "https://www.baidu.com" });
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
request.on("response", (response) => {
|
|
||||||
if (response.statusCode === 200) {
|
|
||||||
log.info("✅ Proxy test successful");
|
|
||||||
resolve(true);
|
|
||||||
} else {
|
|
||||||
log.error(`❌ Proxy test failed with status code: ${response.statusCode}`);
|
|
||||||
resolve(false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
request.on("error", (error) => {
|
|
||||||
log.error("❌ Error testing proxy:", error);
|
|
||||||
resolve(false);
|
|
||||||
});
|
|
||||||
request.end();
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
log.error("❌ Error testing proxy:", error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// 重置全部设置
|
|
||||||
ipcMain.on("reset-setting", () => {
|
|
||||||
store.reset();
|
|
||||||
log.info("✅ Reset setting successfully");
|
|
||||||
});
|
|
||||||
|
|
||||||
// 检查更新
|
|
||||||
ipcMain.on("check-update", (_, showTip) => checkUpdate(win!, showTip));
|
|
||||||
|
|
||||||
// 开始下载更新
|
|
||||||
ipcMain.on("start-download-update", () => startDownloadUpdate());
|
|
||||||
};
|
|
||||||
|
|
||||||
// lyric
|
|
||||||
const initLyricIpcMain = (
|
|
||||||
lyricWin: BrowserWindow | null,
|
|
||||||
mainWin: BrowserWindow | null,
|
|
||||||
store: Store<StoreType>,
|
|
||||||
): void => {
|
|
||||||
// 音乐名称更改
|
|
||||||
ipcMain.on("play-song-change", (_, title) => {
|
|
||||||
if (!title) return;
|
|
||||||
lyricWin?.webContents.send("play-song-change", title);
|
|
||||||
});
|
|
||||||
|
|
||||||
// 音乐歌词更改
|
|
||||||
ipcMain.on("play-lyric-change", (_, lyricData) => {
|
|
||||||
if (!lyricData) return;
|
|
||||||
lyricWin?.webContents.send("play-lyric-change", lyricData);
|
|
||||||
});
|
|
||||||
|
|
||||||
// 获取窗口位置
|
|
||||||
ipcMain.handle("get-window-bounds", () => {
|
|
||||||
return lyricWin?.getBounds();
|
|
||||||
});
|
|
||||||
|
|
||||||
// 获取屏幕尺寸
|
|
||||||
ipcMain.handle("get-screen-size", () => {
|
|
||||||
const { width, height } = screen.getPrimaryDisplay().workAreaSize;
|
|
||||||
return { width, height };
|
|
||||||
});
|
|
||||||
|
|
||||||
// 移动窗口
|
|
||||||
ipcMain.on("move-window", (_, x, y, width, height) => {
|
|
||||||
lyricWin?.setBounds({ x, y, width, height });
|
|
||||||
// 保存配置
|
|
||||||
store.set("lyric", { ...store.get("lyric"), x, y, width, height });
|
|
||||||
// 保持置顶
|
|
||||||
lyricWin?.setAlwaysOnTop(true, "screen-saver");
|
|
||||||
});
|
|
||||||
|
|
||||||
// 更新高度
|
|
||||||
ipcMain.on("update-window-height", (_, height) => {
|
|
||||||
if (!lyricWin) return;
|
|
||||||
const { width } = lyricWin.getBounds();
|
|
||||||
// 更新窗口高度
|
|
||||||
lyricWin.setBounds({ width, height });
|
|
||||||
});
|
|
||||||
|
|
||||||
// 获取配置
|
|
||||||
ipcMain.handle("get-desktop-lyric-option", () => {
|
|
||||||
return store.get("lyric");
|
|
||||||
});
|
|
||||||
|
|
||||||
// 保存配置
|
|
||||||
ipcMain.on("set-desktop-lyric-option", (_, option, callback: boolean = false) => {
|
|
||||||
store.set("lyric", option);
|
|
||||||
// 触发窗口更新
|
|
||||||
if (callback && lyricWin) {
|
|
||||||
lyricWin.webContents.send("desktop-lyric-option-change", option);
|
|
||||||
}
|
|
||||||
mainWin?.webContents.send("desktop-lyric-option-change", option);
|
|
||||||
});
|
|
||||||
|
|
||||||
// 发送主程序事件
|
|
||||||
ipcMain.on("send-main-event", (_, name, val) => {
|
|
||||||
mainWin?.webContents.send(name, val);
|
|
||||||
});
|
|
||||||
|
|
||||||
// 关闭桌面歌词
|
|
||||||
ipcMain.on("closeDesktopLyric", () => {
|
|
||||||
lyricWin?.hide();
|
|
||||||
mainWin?.webContents.send("closeDesktopLyric");
|
|
||||||
});
|
|
||||||
|
|
||||||
// 锁定/解锁桌面歌词
|
|
||||||
ipcMain.on("toogleDesktopLyricLock", (_, isLock: boolean) => {
|
|
||||||
if (!lyricWin) return;
|
|
||||||
// 是否穿透
|
|
||||||
if (isLock) {
|
|
||||||
lyricWin.setIgnoreMouseEvents(true, { forward: true });
|
|
||||||
} else {
|
|
||||||
lyricWin.setIgnoreMouseEvents(false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// tray
|
|
||||||
const initTrayIpcMain = (
|
|
||||||
tray: MainTray | null,
|
|
||||||
win: BrowserWindow | null,
|
|
||||||
lyricWin: BrowserWindow | null,
|
|
||||||
): void => {
|
|
||||||
// 音乐播放状态更改
|
|
||||||
ipcMain.on("play-status-change", (_, playStatus: boolean) => {
|
|
||||||
tray?.setPlayState(playStatus ? "play" : "pause");
|
|
||||||
lyricWin?.webContents.send("play-status-change", playStatus);
|
|
||||||
});
|
|
||||||
|
|
||||||
// 音乐名称更改
|
|
||||||
ipcMain.on("play-song-change", (_, title) => {
|
|
||||||
if (!title) return;
|
|
||||||
// 更改标题
|
|
||||||
win?.setTitle(title);
|
|
||||||
tray?.setTitle(title);
|
|
||||||
tray?.setPlayName(title);
|
|
||||||
});
|
|
||||||
|
|
||||||
// 播放模式切换
|
|
||||||
ipcMain.on("play-mode-change", (_, mode) => {
|
|
||||||
tray?.setPlayMode(mode);
|
|
||||||
});
|
|
||||||
|
|
||||||
// 喜欢状态切换
|
|
||||||
ipcMain.on("like-status-change", (_, likeStatus: boolean) => {
|
|
||||||
tray?.setLikeState(likeStatus);
|
|
||||||
});
|
|
||||||
|
|
||||||
// 桌面歌词开关
|
|
||||||
ipcMain.on("change-desktop-lyric", (_, val: boolean) => {
|
|
||||||
tray?.setDesktopLyricShow(val);
|
|
||||||
});
|
|
||||||
|
|
||||||
// 锁定/解锁桌面歌词
|
|
||||||
ipcMain.on("toogleDesktopLyricLock", (_, isLock: boolean) => {
|
|
||||||
tray?.setDesktopLyricLock(isLock);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// thumbar
|
|
||||||
const initThumbarIpcMain = (thumbar: Thumbar | null): void => {
|
|
||||||
if (!thumbar) return;
|
|
||||||
};
|
|
||||||
|
|
||||||
// store
|
|
||||||
const initStoreIpcMain = (store: Store<StoreType>): void => {
|
|
||||||
if (!store) return;
|
|
||||||
};
|
|
||||||
|
|
||||||
// other
|
|
||||||
const initOtherIpcMain = (mainWin: BrowserWindow | null): void => {
|
|
||||||
// 快捷键是否被注册
|
|
||||||
ipcMain.handle("is-shortcut-registered", (_, shortcut: string) => isShortcutRegistered(shortcut));
|
|
||||||
|
|
||||||
// 注册快捷键
|
|
||||||
ipcMain.handle("register-all-shortcut", (_, allShortcuts: any): string[] | false => {
|
|
||||||
if (!mainWin || !allShortcuts) return false;
|
|
||||||
// 卸载所有快捷键
|
|
||||||
unregisterShortcuts();
|
|
||||||
// 注册快捷键
|
|
||||||
const failedShortcuts: string[] = [];
|
|
||||||
for (const key in allShortcuts) {
|
|
||||||
const shortcut = allShortcuts[key].globalShortcut;
|
|
||||||
if (!shortcut) continue;
|
|
||||||
// 快捷键回调
|
|
||||||
const callback = () => mainWin.webContents.send(key);
|
|
||||||
const isSuccess = registerShortcut(shortcut, callback);
|
|
||||||
if (!isSuccess) failedShortcuts.push(shortcut);
|
|
||||||
}
|
|
||||||
return failedShortcuts;
|
|
||||||
});
|
|
||||||
|
|
||||||
// 卸载所有快捷键
|
|
||||||
ipcMain.on("unregister-all-shortcut", () => unregisterShortcuts());
|
|
||||||
};
|
|
||||||
|
|
||||||
export default initIpcMain;
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
// 日志输出
|
|
||||||
import { join } from "path";
|
|
||||||
import { app } from "electron";
|
|
||||||
import { isDev } from "./utils";
|
|
||||||
import log from "electron-log";
|
|
||||||
|
|
||||||
// 绑定事件
|
|
||||||
Object.assign(console, log.functions);
|
|
||||||
|
|
||||||
// 日志配置
|
|
||||||
log.transports.file.level = "info";
|
|
||||||
log.transports.file.maxSize = 2 * 1024 * 1024; // 2M
|
|
||||||
if (log.transports.ipc) log.transports.ipc.level = false;
|
|
||||||
|
|
||||||
// 控制台输出
|
|
||||||
log.transports.console.useStyles = true;
|
|
||||||
|
|
||||||
// 文件输出
|
|
||||||
log.transports.file.format = "{y}-{m}-{d} {h}:{i}:{s}:{ms} {text}";
|
|
||||||
|
|
||||||
// 本地输出
|
|
||||||
if (!isDev) {
|
|
||||||
log.transports.file.resolvePathFn = () =>
|
|
||||||
join(app.getPath("documents"), "/SPlayer/SPlayer-log.txt");
|
|
||||||
} else {
|
|
||||||
log.transports.file.level = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
log.info("📃 logger initialized");
|
|
||||||
|
|
||||||
export default log;
|
|
||||||
47
electron/main/logger/index.ts
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
// 日志输出
|
||||||
|
import { existsSync, mkdirSync } from "fs";
|
||||||
|
import { join } from "path";
|
||||||
|
import { app } from "electron";
|
||||||
|
import log from "electron-log";
|
||||||
|
|
||||||
|
// 日志文件路径
|
||||||
|
const logDir = join(app.getPath("logs"));
|
||||||
|
|
||||||
|
// 是否存在日志目录
|
||||||
|
if (!existsSync(logDir)) mkdirSync(logDir);
|
||||||
|
|
||||||
|
// 获取日期 - YYYY-MM-DD
|
||||||
|
const dateString = new Date().toISOString().slice(0, 10);
|
||||||
|
const logFilePath = join(logDir, `${dateString}.log`);
|
||||||
|
|
||||||
|
// 配置日志系统
|
||||||
|
log.transports.console.useStyles = true; // 颜色输出
|
||||||
|
log.transports.file.level = "info"; // 仅记录 info 及以上级别
|
||||||
|
log.transports.file.resolvePathFn = (): string => logFilePath; // 日志文件路径
|
||||||
|
log.transports.file.maxSize = 2 * 1024 * 1024; // 文件最大 2MB
|
||||||
|
|
||||||
|
// 日志格式化
|
||||||
|
// log.transports.file.format = "[{y}-{m}-{d} {h}:{i}:{s}] [{level}] [{scope}] {text}";
|
||||||
|
|
||||||
|
// 绑定默认事件
|
||||||
|
const defaultLog = log.scope("default");
|
||||||
|
console.log = defaultLog.log;
|
||||||
|
console.info = defaultLog.info;
|
||||||
|
console.warn = defaultLog.warn;
|
||||||
|
console.error = defaultLog.error;
|
||||||
|
|
||||||
|
// 分作用域导出
|
||||||
|
export { defaultLog };
|
||||||
|
export const ipcLog = log.scope("ipc");
|
||||||
|
export const trayLog = log.scope("tray");
|
||||||
|
export const thumbarLog = log.scope("thumbar");
|
||||||
|
export const storeLog = log.scope("store");
|
||||||
|
export const updateLog = log.scope("update");
|
||||||
|
export const systemLog = log.scope("system");
|
||||||
|
export const configLog = log.scope("config");
|
||||||
|
export const windowsLog = log.scope("windows");
|
||||||
|
export const processLog = log.scope("process");
|
||||||
|
export const preloadLog = log.scope("preload");
|
||||||
|
export const rendererLog = log.scope("renderer");
|
||||||
|
export const shortcutLog = log.scope("shortcut");
|
||||||
|
export const serverLog = log.scope("server");
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
import { BrowserWindow, globalShortcut } from "electron";
|
|
||||||
import { isDev } from "./utils";
|
|
||||||
import log from "../main/logger";
|
|
||||||
|
|
||||||
// 注册快捷键并检查
|
|
||||||
export const registerShortcut = (shortcut: string, callback: () => void): boolean => {
|
|
||||||
try {
|
|
||||||
const success = globalShortcut.register(shortcut, callback);
|
|
||||||
if (!success) {
|
|
||||||
log.error(`❌ Failed to register shortcut: ${shortcut}`);
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
log.info(`✅ Shortcut registered: ${shortcut}`);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
log.error(`ℹ️ Error registering shortcut ${shortcut}:`, error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// 检查快捷键是否被注册
|
|
||||||
export const isShortcutRegistered = (shortcut: string): boolean => {
|
|
||||||
return globalShortcut.isRegistered(shortcut);
|
|
||||||
};
|
|
||||||
|
|
||||||
// 卸载所有快捷键
|
|
||||||
export const unregisterShortcuts = () => {
|
|
||||||
globalShortcut.unregisterAll();
|
|
||||||
log.info("🚫 All shortcuts unregistered.");
|
|
||||||
};
|
|
||||||
|
|
||||||
// 注册所有快捷键
|
|
||||||
export const registerAllShortcuts = (win: BrowserWindow) => {
|
|
||||||
// 开启控制台
|
|
||||||
registerShortcut("CmdOrCtrl+Shift+I", () => {
|
|
||||||
win.webContents.openDevTools({
|
|
||||||
title: "SPlayer DevTools",
|
|
||||||
// 客户端分离
|
|
||||||
mode: isDev ? "right" : "detach",
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
30
electron/main/shortcut/index.ts
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import { globalShortcut } from "electron";
|
||||||
|
import { shortcutLog } from "../logger";
|
||||||
|
|
||||||
|
// 注册快捷键并检查
|
||||||
|
export const registerShortcut = (shortcut: string, callback: () => void): boolean => {
|
||||||
|
try {
|
||||||
|
const success = globalShortcut.register(shortcut, callback);
|
||||||
|
if (!success) {
|
||||||
|
shortcutLog.error(`❌ Failed to register shortcut: ${shortcut}`);
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
shortcutLog.info(`✅ Shortcut registered: ${shortcut}`);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
shortcutLog.error(`ℹ️ Error registering shortcut ${shortcut}:`, error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 检查快捷键是否被注册
|
||||||
|
export const isShortcutRegistered = (shortcut: string): boolean => {
|
||||||
|
return globalShortcut.isRegistered(shortcut);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 卸载所有快捷键
|
||||||
|
export const unregisterShortcuts = () => {
|
||||||
|
globalShortcut.unregisterAll();
|
||||||
|
shortcutLog.info("🚫 All shortcuts unregistered.");
|
||||||
|
};
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
import Store from "electron-store";
|
|
||||||
import log from "./logger";
|
|
||||||
|
|
||||||
log.info("🌱 Store init");
|
|
||||||
|
|
||||||
export interface StoreType {
|
|
||||||
window: {
|
|
||||||
width: number;
|
|
||||||
height: number;
|
|
||||||
x?: number;
|
|
||||||
y?: number;
|
|
||||||
};
|
|
||||||
lyric: {
|
|
||||||
fontSize: number;
|
|
||||||
mainColor: string;
|
|
||||||
shadowColor: string;
|
|
||||||
// 窗口位置
|
|
||||||
x?: number;
|
|
||||||
y?: number;
|
|
||||||
width?: number;
|
|
||||||
height?: number;
|
|
||||||
};
|
|
||||||
proxy: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 初始化仓库
|
|
||||||
const store = new Store<StoreType>({
|
|
||||||
defaults: {
|
|
||||||
window: {
|
|
||||||
width: 1280,
|
|
||||||
height: 800,
|
|
||||||
},
|
|
||||||
lyric: {
|
|
||||||
fontSize: 30,
|
|
||||||
mainColor: "#fff",
|
|
||||||
shadowColor: "rgba(0, 0, 0, 0.5)",
|
|
||||||
x: 0,
|
|
||||||
y: 0,
|
|
||||||
width: 800,
|
|
||||||
height: 180,
|
|
||||||
},
|
|
||||||
proxy: "",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
export default store;
|
|
||||||
52
electron/main/store/index.ts
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
import { screen } from "electron";
|
||||||
|
import { storeLog } from "../logger";
|
||||||
|
import type { LyricConfig } from "../../../src/types/desktop-lyric";
|
||||||
|
import defaultLyricConfig from "../../../src/assets/data/lyricConfig";
|
||||||
|
import Store from "electron-store";
|
||||||
|
|
||||||
|
storeLog.info("🌱 Store init");
|
||||||
|
|
||||||
|
export interface StoreType {
|
||||||
|
window: {
|
||||||
|
width: number;
|
||||||
|
height: number;
|
||||||
|
x?: number;
|
||||||
|
y?: number;
|
||||||
|
maximized?: boolean;
|
||||||
|
};
|
||||||
|
lyric: {
|
||||||
|
// 窗口位置
|
||||||
|
x?: number;
|
||||||
|
y?: number;
|
||||||
|
width?: number;
|
||||||
|
height?: number;
|
||||||
|
// 配置
|
||||||
|
config?: LyricConfig;
|
||||||
|
};
|
||||||
|
proxy: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用 Store
|
||||||
|
* @returns Store<StoreType>
|
||||||
|
*/
|
||||||
|
export const useStore = () => {
|
||||||
|
// 获取主屏幕
|
||||||
|
const screenData = screen.getPrimaryDisplay();
|
||||||
|
return new Store<StoreType>({
|
||||||
|
defaults: {
|
||||||
|
window: {
|
||||||
|
width: 1280,
|
||||||
|
height: 800,
|
||||||
|
},
|
||||||
|
lyric: {
|
||||||
|
x: screenData.workAreaSize.width / 2 - 400,
|
||||||
|
y: screenData.workAreaSize.height - 90,
|
||||||
|
width: 800,
|
||||||
|
height: 136,
|
||||||
|
config: defaultLyricConfig,
|
||||||
|
},
|
||||||
|
proxy: "",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { BrowserWindow, nativeImage, nativeTheme, ThumbarButton } from "electron";
|
import { BrowserWindow, nativeImage, nativeTheme, ThumbarButton } from "electron";
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
import { isWin } from "./utils";
|
import { isWin } from "../utils/config";
|
||||||
import log from "./logger";
|
import { thumbarLog } from "../logger";
|
||||||
|
|
||||||
enum ThumbarKeys {
|
enum ThumbarKeys {
|
||||||
Play = "play",
|
Play = "play",
|
||||||
@@ -14,8 +14,12 @@ type ThumbarMap = Map<ThumbarKeys, ThumbarButton>;
|
|||||||
|
|
||||||
export interface Thumbar {
|
export interface Thumbar {
|
||||||
clearThumbar(): void;
|
clearThumbar(): void;
|
||||||
|
updateThumbar(playing: boolean, clean?: boolean): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 缩略图单例
|
||||||
|
let thumbar: Thumbar | null = null;
|
||||||
|
|
||||||
// 工具栏图标
|
// 工具栏图标
|
||||||
const thumbarIcon = (filename: string) => {
|
const thumbarIcon = (filename: string) => {
|
||||||
// 是否为暗色
|
// 是否为暗色
|
||||||
@@ -32,12 +36,12 @@ const createThumbarButtons = (win: BrowserWindow): ThumbarMap => {
|
|||||||
.set(ThumbarKeys.Prev, {
|
.set(ThumbarKeys.Prev, {
|
||||||
tooltip: "上一曲",
|
tooltip: "上一曲",
|
||||||
icon: thumbarIcon("prev"),
|
icon: thumbarIcon("prev"),
|
||||||
click: () => win.webContents.send("play-prev"),
|
click: () => win.webContents.send("playPrev"),
|
||||||
})
|
})
|
||||||
.set(ThumbarKeys.Next, {
|
.set(ThumbarKeys.Next, {
|
||||||
tooltip: "下一曲",
|
tooltip: "下一曲",
|
||||||
icon: thumbarIcon("next"),
|
icon: thumbarIcon("next"),
|
||||||
click: () => win.webContents.send("play-next"),
|
click: () => win.webContents.send("playNext"),
|
||||||
})
|
})
|
||||||
.set(ThumbarKeys.Play, {
|
.set(ThumbarKeys.Play, {
|
||||||
tooltip: "播放",
|
tooltip: "播放",
|
||||||
@@ -47,7 +51,7 @@ const createThumbarButtons = (win: BrowserWindow): ThumbarMap => {
|
|||||||
.set(ThumbarKeys.Pause, {
|
.set(ThumbarKeys.Pause, {
|
||||||
tooltip: "暂停",
|
tooltip: "暂停",
|
||||||
icon: thumbarIcon("pause"),
|
icon: thumbarIcon("pause"),
|
||||||
click: () => win.webContents.send("play-pause"),
|
click: () => win.webContents.send("pause"),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -62,6 +66,9 @@ class createThumbar implements Thumbar {
|
|||||||
private _next: ThumbarButton;
|
private _next: ThumbarButton;
|
||||||
private _play: ThumbarButton;
|
private _play: ThumbarButton;
|
||||||
private _pause: ThumbarButton;
|
private _pause: ThumbarButton;
|
||||||
|
// 当前播放状态
|
||||||
|
private _isPlaying: boolean = false;
|
||||||
|
|
||||||
constructor(win: BrowserWindow) {
|
constructor(win: BrowserWindow) {
|
||||||
// 初始化数据
|
// 初始化数据
|
||||||
this._win = win;
|
this._win = win;
|
||||||
@@ -73,26 +80,62 @@ class createThumbar implements Thumbar {
|
|||||||
this._next = this._thumbar.get(ThumbarKeys.Next)!;
|
this._next = this._thumbar.get(ThumbarKeys.Next)!;
|
||||||
// 初始化工具栏
|
// 初始化工具栏
|
||||||
this.updateThumbar();
|
this.updateThumbar();
|
||||||
|
// 监听主题变化
|
||||||
|
this.initThemeListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 初始化主题监听器
|
||||||
|
private initThemeListener() {
|
||||||
|
nativeTheme.on("updated", () => {
|
||||||
|
this.refreshThumbarButtons();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 刷新工具栏按钮(主题变化时)
|
||||||
|
private refreshThumbarButtons() {
|
||||||
|
// 重新创建按钮
|
||||||
|
this._thumbar = createThumbarButtons(this._win);
|
||||||
|
this._play = this._thumbar.get(ThumbarKeys.Play)!;
|
||||||
|
this._pause = this._thumbar.get(ThumbarKeys.Pause)!;
|
||||||
|
this._prev = this._thumbar.get(ThumbarKeys.Prev)!;
|
||||||
|
this._next = this._thumbar.get(ThumbarKeys.Next)!;
|
||||||
|
// 更新工具栏
|
||||||
|
this.updateThumbar(this._isPlaying);
|
||||||
|
}
|
||||||
|
|
||||||
// 更新工具栏
|
// 更新工具栏
|
||||||
private updateThumbar(playing: boolean = false, clean: boolean = false) {
|
updateThumbar(playing: boolean = false, clean: boolean = false) {
|
||||||
|
this._isPlaying = playing;
|
||||||
if (clean) return this.clearThumbar();
|
if (clean) return this.clearThumbar();
|
||||||
this._win.setThumbarButtons([this._prev, playing ? this._pause : this._play, this._next]);
|
this._win.setThumbarButtons([this._prev, playing ? this._pause : this._play, this._next]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 清除工具栏
|
// 清除工具栏
|
||||||
clearThumbar() {
|
clearThumbar() {
|
||||||
this._win.setThumbarButtons([]);
|
this._win.setThumbarButtons([]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化缩略图工具栏
|
||||||
|
* @param win 窗口
|
||||||
|
* @returns 缩略图工具栏
|
||||||
|
*/
|
||||||
export const initThumbar = (win: BrowserWindow) => {
|
export const initThumbar = (win: BrowserWindow) => {
|
||||||
try {
|
try {
|
||||||
// 若非 Win
|
// 若非 Win
|
||||||
if (!isWin) return null;
|
if (!isWin) return null;
|
||||||
log.info("🚀 ThumbarButtons Startup");
|
thumbarLog.info("🚀 ThumbarButtons Startup");
|
||||||
return new createThumbar(win);
|
thumbar = new createThumbar(win);
|
||||||
|
return thumbar;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error("❌ ThumbarButtons Error", error);
|
thumbarLog.error("❌ ThumbarButtons Error", error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取缩略图工具栏
|
||||||
|
* @returns 缩略图工具栏
|
||||||
|
*/
|
||||||
|
export const getThumbar = () => thumbar;
|
||||||
@@ -7,9 +7,11 @@ import {
|
|||||||
nativeImage,
|
nativeImage,
|
||||||
nativeTheme,
|
nativeTheme,
|
||||||
} from "electron";
|
} from "electron";
|
||||||
import { isWin, isLinux, isDev, appName } from "./utils";
|
import { isWin, appName } from "../utils/config";
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
import log from "./logger";
|
import { trayLog } from "../logger";
|
||||||
|
import { useStore } from "../store";
|
||||||
|
import lyricWindow from "../windows/lyric-window";
|
||||||
|
|
||||||
// 播放模式
|
// 播放模式
|
||||||
type PlayMode = "repeat" | "repeat-once" | "shuffle";
|
type PlayMode = "repeat" | "repeat-once" | "shuffle";
|
||||||
@@ -34,6 +36,9 @@ export interface MainTray {
|
|||||||
destroyTray(): void;
|
destroyTray(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 托盘单例
|
||||||
|
let mainTrayInstance: MainTray | null = null;
|
||||||
|
|
||||||
// 托盘图标
|
// 托盘图标
|
||||||
const trayIcon = (filename: string) => {
|
const trayIcon = (filename: string) => {
|
||||||
// const rootPath = isDev
|
// const rootPath = isDev
|
||||||
@@ -44,10 +49,7 @@ const trayIcon = (filename: string) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 托盘菜单
|
// 托盘菜单
|
||||||
const createTrayMenu = (
|
const createTrayMenu = (win: BrowserWindow): MenuItemConstructorOptions[] => {
|
||||||
win: BrowserWindow,
|
|
||||||
lyricWin: BrowserWindow,
|
|
||||||
): MenuItemConstructorOptions[] => {
|
|
||||||
// 区分明暗图标
|
// 区分明暗图标
|
||||||
const showIcon = (iconName: string) => {
|
const showIcon = (iconName: string) => {
|
||||||
const isDark = nativeTheme.shouldUseDarkColors;
|
const isDark = nativeTheme.shouldUseDarkColors;
|
||||||
@@ -143,7 +145,16 @@ const createTrayMenu = (
|
|||||||
label: `${desktopLyricLock ? "解锁" : "锁定"}桌面歌词`,
|
label: `${desktopLyricLock ? "解锁" : "锁定"}桌面歌词`,
|
||||||
icon: showIcon(desktopLyricLock ? "lock" : "unlock"),
|
icon: showIcon(desktopLyricLock ? "lock" : "unlock"),
|
||||||
visible: desktopLyricShow,
|
visible: desktopLyricShow,
|
||||||
click: () => lyricWin.webContents.send("toogleDesktopLyricLock", !desktopLyricLock),
|
click: () => {
|
||||||
|
const store = useStore();
|
||||||
|
// 更新锁定状态
|
||||||
|
store.set("lyric.config", { ...store.get("lyric.config"), isLock: !desktopLyricLock });
|
||||||
|
// 触发窗口更新
|
||||||
|
const config = store.get("lyric.config");
|
||||||
|
const lyricWin = lyricWindow.getWin();
|
||||||
|
if (!lyricWin) return;
|
||||||
|
lyricWin.webContents.send("update-desktop-lyric-option", config);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "separator",
|
type: "separator",
|
||||||
@@ -166,8 +177,8 @@ const createTrayMenu = (
|
|||||||
label: "退出",
|
label: "退出",
|
||||||
icon: showIcon("power"),
|
icon: showIcon("power"),
|
||||||
click: () => {
|
click: () => {
|
||||||
win.close();
|
// win.close();
|
||||||
// app.exit(0);
|
app.exit(0);
|
||||||
app.quit();
|
app.quit();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -179,14 +190,13 @@ const createTrayMenu = (
|
|||||||
class CreateTray implements MainTray {
|
class CreateTray implements MainTray {
|
||||||
// 窗口
|
// 窗口
|
||||||
private _win: BrowserWindow;
|
private _win: BrowserWindow;
|
||||||
private _lyricWin: BrowserWindow;
|
|
||||||
// 托盘
|
// 托盘
|
||||||
private _tray: Tray;
|
private _tray: Tray;
|
||||||
// 菜单
|
// 菜单
|
||||||
private _menu: MenuItemConstructorOptions[];
|
private _menu: MenuItemConstructorOptions[];
|
||||||
private _contextMenu: Menu;
|
private _contextMenu: Menu;
|
||||||
|
|
||||||
constructor(win: BrowserWindow, lyricWin: BrowserWindow) {
|
constructor(win: BrowserWindow) {
|
||||||
// 托盘图标
|
// 托盘图标
|
||||||
const icon = trayIcon(isWin ? "tray.ico" : "tray@32.png").resize({
|
const icon = trayIcon(isWin ? "tray.ico" : "tray@32.png").resize({
|
||||||
height: 32,
|
height: 32,
|
||||||
@@ -194,9 +204,8 @@ class CreateTray implements MainTray {
|
|||||||
});
|
});
|
||||||
// 初始化数据
|
// 初始化数据
|
||||||
this._win = win;
|
this._win = win;
|
||||||
this._lyricWin = lyricWin;
|
|
||||||
this._tray = new Tray(icon);
|
this._tray = new Tray(icon);
|
||||||
this._menu = createTrayMenu(this._win, this._lyricWin);
|
this._menu = createTrayMenu(this._win);
|
||||||
this._contextMenu = Menu.buildFromTemplate(this._menu);
|
this._contextMenu = Menu.buildFromTemplate(this._menu);
|
||||||
// 初始化事件
|
// 初始化事件
|
||||||
this.initTrayMenu();
|
this.initTrayMenu();
|
||||||
@@ -205,7 +214,7 @@ class CreateTray implements MainTray {
|
|||||||
}
|
}
|
||||||
// 托盘菜单
|
// 托盘菜单
|
||||||
private initTrayMenu() {
|
private initTrayMenu() {
|
||||||
this._menu = createTrayMenu(this._win, this._lyricWin);
|
this._menu = createTrayMenu(this._win);
|
||||||
this._contextMenu = Menu.buildFromTemplate(this._menu);
|
this._contextMenu = Menu.buildFromTemplate(this._menu);
|
||||||
this._tray.setContextMenu(this._contextMenu);
|
this._tray.setContextMenu(this._contextMenu);
|
||||||
}
|
}
|
||||||
@@ -219,11 +228,19 @@ class CreateTray implements MainTray {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
// 设置标题
|
// 设置标题
|
||||||
|
/**
|
||||||
|
* 设置标题
|
||||||
|
* @param title 标题
|
||||||
|
*/
|
||||||
setTitle(title: string) {
|
setTitle(title: string) {
|
||||||
|
this._win.setTitle(title);
|
||||||
this._tray.setTitle(title);
|
this._tray.setTitle(title);
|
||||||
this._tray.setToolTip(title);
|
this._tray.setToolTip(title);
|
||||||
}
|
}
|
||||||
// 设置播放名称
|
/**
|
||||||
|
* 设置播放名称
|
||||||
|
* @param name 播放名称
|
||||||
|
*/
|
||||||
setPlayName(name: string) {
|
setPlayName(name: string) {
|
||||||
// 超长处理
|
// 超长处理
|
||||||
if (name.length > 20) name = name.slice(0, 20) + "...";
|
if (name.length > 20) name = name.slice(0, 20) + "...";
|
||||||
@@ -231,52 +248,80 @@ class CreateTray implements MainTray {
|
|||||||
// 更新菜单
|
// 更新菜单
|
||||||
this.initTrayMenu();
|
this.initTrayMenu();
|
||||||
}
|
}
|
||||||
// 设置播放状态
|
/**
|
||||||
|
* 设置播放状态
|
||||||
|
* @param state 播放状态
|
||||||
|
*/
|
||||||
setPlayState(state: PlayState) {
|
setPlayState(state: PlayState) {
|
||||||
playState = state;
|
playState = state;
|
||||||
// 更新菜单
|
// 更新菜单
|
||||||
this.initTrayMenu();
|
this.initTrayMenu();
|
||||||
}
|
}
|
||||||
// 设置播放模式
|
/**
|
||||||
|
* 设置播放模式
|
||||||
|
* @param mode 播放模式
|
||||||
|
*/
|
||||||
setPlayMode(mode: PlayMode) {
|
setPlayMode(mode: PlayMode) {
|
||||||
playMode = mode;
|
playMode = mode;
|
||||||
// 更新菜单
|
// 更新菜单
|
||||||
this.initTrayMenu();
|
this.initTrayMenu();
|
||||||
}
|
}
|
||||||
// 设置喜欢状态
|
/**
|
||||||
|
* 设置喜欢状态
|
||||||
|
* @param like 喜欢状态
|
||||||
|
*/
|
||||||
setLikeState(like: boolean) {
|
setLikeState(like: boolean) {
|
||||||
likeSong = like;
|
likeSong = like;
|
||||||
// 更新菜单
|
// 更新菜单
|
||||||
this.initTrayMenu();
|
this.initTrayMenu();
|
||||||
}
|
}
|
||||||
// 桌面歌词开关
|
/**
|
||||||
|
* 桌面歌词开关
|
||||||
|
* @param show 桌面歌词开关状态
|
||||||
|
*/
|
||||||
setDesktopLyricShow(show: boolean) {
|
setDesktopLyricShow(show: boolean) {
|
||||||
desktopLyricShow = show;
|
desktopLyricShow = show;
|
||||||
// 更新菜单
|
// 更新菜单
|
||||||
this.initTrayMenu();
|
this.initTrayMenu();
|
||||||
}
|
}
|
||||||
// 锁定桌面歌词
|
/**
|
||||||
|
* 锁定桌面歌词
|
||||||
|
* @param lock 锁定桌面歌词状态
|
||||||
|
*/
|
||||||
setDesktopLyricLock(lock: boolean) {
|
setDesktopLyricLock(lock: boolean) {
|
||||||
desktopLyricLock = lock;
|
desktopLyricLock = lock;
|
||||||
// 更新菜单
|
// 更新菜单
|
||||||
this.initTrayMenu();
|
this.initTrayMenu();
|
||||||
}
|
}
|
||||||
// 销毁托盘
|
/**
|
||||||
|
* 销毁托盘
|
||||||
|
*/
|
||||||
destroyTray() {
|
destroyTray() {
|
||||||
this._tray.destroy();
|
this._tray.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const initTray = (win: BrowserWindow, lyricWin: BrowserWindow) => {
|
/**
|
||||||
|
* 初始化托盘
|
||||||
|
* @param win 主窗口
|
||||||
|
* @param lyricWin 歌词窗口
|
||||||
|
* @returns 托盘实例
|
||||||
|
*/
|
||||||
|
export const initTray = (win: BrowserWindow) => {
|
||||||
try {
|
try {
|
||||||
// 若为 MacOS
|
trayLog.info("🚀 Tray Process Startup");
|
||||||
if (isWin || isLinux || isDev) {
|
const tray = new CreateTray(win);
|
||||||
log.info("🚀 Tray Process Startup");
|
// 保存单例实例
|
||||||
return new CreateTray(win, lyricWin);
|
mainTrayInstance = tray;
|
||||||
}
|
return tray;
|
||||||
return null;
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error("❌ Tray Process Error", error);
|
trayLog.error("❌ Tray Process Error", error);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取托盘实例
|
||||||
|
* @returns 托盘实例
|
||||||
|
*/
|
||||||
|
export const getMainTray = (): MainTray | null => mainTrayInstance;
|
||||||
@@ -1,10 +1,18 @@
|
|||||||
import { type BrowserWindow } from "electron";
|
import { app, type BrowserWindow } from "electron";
|
||||||
|
import { updateLog } from "../logger";
|
||||||
import electronUpdater from "electron-updater";
|
import electronUpdater from "electron-updater";
|
||||||
import log from "./logger";
|
import { isDev } from "../utils/config";
|
||||||
|
|
||||||
// import
|
// import
|
||||||
const { autoUpdater } = electronUpdater;
|
const { autoUpdater } = electronUpdater;
|
||||||
|
|
||||||
|
// 开发环境启用
|
||||||
|
if (isDev) {
|
||||||
|
Object.defineProperty(app, "isPackaged", {
|
||||||
|
get: () => true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// 更新源
|
// 更新源
|
||||||
autoUpdater.setFeedURL({
|
autoUpdater.setFeedURL({
|
||||||
provider: "github",
|
provider: "github",
|
||||||
@@ -28,19 +36,19 @@ const initUpdaterListeners = (win: BrowserWindow) => {
|
|||||||
// 当有新版本可用时
|
// 当有新版本可用时
|
||||||
autoUpdater.on("update-available", (info) => {
|
autoUpdater.on("update-available", (info) => {
|
||||||
win.webContents.send("update-available", info);
|
win.webContents.send("update-available", info);
|
||||||
log.info(`🚀 New version available: ${info.version}`);
|
updateLog.info(`🚀 New version available: ${info.version}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 更新下载进度
|
// 更新下载进度
|
||||||
autoUpdater.on("download-progress", (progress) => {
|
autoUpdater.on("download-progress", (progress) => {
|
||||||
win.webContents.send("download-progress", progress);
|
win.webContents.send("download-progress", progress);
|
||||||
log.info(`🚀 Downloading: ${progress.percent}%`);
|
updateLog.info(`🚀 Downloading: ${progress.percent}%`);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 当下载完成时
|
// 当下载完成时
|
||||||
autoUpdater.on("update-downloaded", (info) => {
|
autoUpdater.on("update-downloaded", (info) => {
|
||||||
win.webContents.send("update-downloaded", info);
|
win.webContents.send("update-downloaded", info);
|
||||||
log.info(`🚀 Update downloaded: ${info.version}`);
|
updateLog.info(`🚀 Update downloaded: ${info.version}`);
|
||||||
// 安装更新
|
// 安装更新
|
||||||
autoUpdater.quitAndInstall();
|
autoUpdater.quitAndInstall();
|
||||||
});
|
});
|
||||||
@@ -48,13 +56,13 @@ const initUpdaterListeners = (win: BrowserWindow) => {
|
|||||||
// 当没有新版本时
|
// 当没有新版本时
|
||||||
autoUpdater.on("update-not-available", (info) => {
|
autoUpdater.on("update-not-available", (info) => {
|
||||||
if (isShowTip) win.webContents.send("update-not-available", info);
|
if (isShowTip) win.webContents.send("update-not-available", info);
|
||||||
log.info(`✅ No new version available: ${info.version}`);
|
updateLog.info(`✅ No new version available: ${info.version}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 更新错误
|
// 更新错误
|
||||||
autoUpdater.on("error", (err) => {
|
autoUpdater.on("error", (err) => {
|
||||||
win.webContents.send("update-error", err);
|
win.webContents.send("update-error", err);
|
||||||
log.error(`❌ Update error: ${err.message}`);
|
updateLog.error(`❌ Update error: ${err.message}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
isInit = true;
|
isInit = true;
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
import { app } from "electron";
|
|
||||||
import { is } from "@electron-toolkit/utils";
|
|
||||||
import fs from "fs/promises";
|
|
||||||
import crypto from "crypto";
|
|
||||||
|
|
||||||
// 系统判断
|
|
||||||
export const isDev = is.dev;
|
|
||||||
export const isWin = process.platform === "win32";
|
|
||||||
export const isMac = process.platform === "darwin";
|
|
||||||
export const isLinux = process.platform === "linux";
|
|
||||||
|
|
||||||
// 程序名称
|
|
||||||
export const appName = app.getName() || "SPlayer";
|
|
||||||
|
|
||||||
// 生成唯一ID
|
|
||||||
export const getFileID = (filePath: string): number => {
|
|
||||||
// SHA-256
|
|
||||||
const hash = crypto.createHash("sha256");
|
|
||||||
hash.update(filePath);
|
|
||||||
const digest = hash.digest("hex");
|
|
||||||
// 将哈希值的前 16 位转换为十进制数字
|
|
||||||
const uniqueId = parseInt(digest.substring(0, 16), 16);
|
|
||||||
return Number(uniqueId.toString().padStart(16, "0"));
|
|
||||||
};
|
|
||||||
|
|
||||||
// 生成文件 MD5
|
|
||||||
export const getFileMD5 = async (path: string): Promise<string> => {
|
|
||||||
const data = await fs.readFile(path);
|
|
||||||
const hash = crypto.createHash("md5");
|
|
||||||
hash.update(data);
|
|
||||||
return hash.digest("hex");
|
|
||||||
};
|
|
||||||
60
electron/main/utils/config.ts
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
import { is } from "@electron-toolkit/utils";
|
||||||
|
import { app } from "electron";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为开发环境
|
||||||
|
* @returns boolean
|
||||||
|
*/
|
||||||
|
export const isDev = is.dev;
|
||||||
|
|
||||||
|
/** 是否为 Windows 系统 */
|
||||||
|
export const isWin = process.platform === "win32";
|
||||||
|
/** 是否为 macOS 系统 */
|
||||||
|
export const isMac = process.platform === "darwin";
|
||||||
|
/** 是否为 Linux 系统 */
|
||||||
|
export const isLinux = process.platform === "linux";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 软件版本
|
||||||
|
* @returns string
|
||||||
|
*/
|
||||||
|
export const appVersion = app.getVersion();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 程序名称
|
||||||
|
* @returns string
|
||||||
|
*/
|
||||||
|
export const appName = app.getName() || "SPlayer";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务器端口
|
||||||
|
* @returns number
|
||||||
|
*/
|
||||||
|
export const port = Number(import.meta.env["VITE_SERVER_PORT"] || 25884);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主窗口加载地址
|
||||||
|
* @returns string
|
||||||
|
*/
|
||||||
|
export const mainWinUrl =
|
||||||
|
isDev && process.env["ELECTRON_RENDERER_URL"]
|
||||||
|
? process.env["ELECTRON_RENDERER_URL"]
|
||||||
|
: `http://localhost:${port}`;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 歌词窗口加载地址
|
||||||
|
* @returns string
|
||||||
|
*/
|
||||||
|
export const lyricWinUrl =
|
||||||
|
isDev && process.env["ELECTRON_RENDERER_URL"]
|
||||||
|
? `${process.env["ELECTRON_RENDERER_URL"]}/#/desktop-lyric`
|
||||||
|
: `http://localhost:${port}/#/desktop-lyric`;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加载窗口地址
|
||||||
|
* @returns string
|
||||||
|
*/
|
||||||
|
export const loadWinUrl =
|
||||||
|
isDev && process.env["ELECTRON_RENDERER_URL"]
|
||||||
|
? `${process.env["ELECTRON_RENDERER_URL"]}/web/loading/index.html`
|
||||||
|
: `http://localhost:${port}/web/loading/index.html`;
|
||||||
58
electron/main/utils/helper.ts
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
import { createHash } from "crypto";
|
||||||
|
import { readFile } from "fs/promises";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成文件唯一ID
|
||||||
|
* @param filePath 文件路径
|
||||||
|
* @returns 唯一ID
|
||||||
|
*/
|
||||||
|
export const getFileID = (filePath: string): number => {
|
||||||
|
// SHA-256
|
||||||
|
const hash = createHash("sha256");
|
||||||
|
hash.update(filePath);
|
||||||
|
const digest = hash.digest("hex");
|
||||||
|
// 将哈希值的前 16 位转换为十进制数字
|
||||||
|
const uniqueId = parseInt(digest.substring(0, 16), 16);
|
||||||
|
return Number(uniqueId.toString().padStart(16, "0"));
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成文件 MD5
|
||||||
|
* @param path 文件路径
|
||||||
|
* @returns MD5值
|
||||||
|
*/
|
||||||
|
export const getFileMD5 = async (path: string): Promise<string> => {
|
||||||
|
const data = await readFile(path);
|
||||||
|
const hash = createHash("md5");
|
||||||
|
hash.update(data);
|
||||||
|
return hash.digest("hex");
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将 music-metadata 库中的歌词数组转换为LRC格式字符串
|
||||||
|
* @param lyrics 歌词数组,每个元素包含时间戳(毫秒)和歌词文本
|
||||||
|
* @returns LRC格式的字符串
|
||||||
|
*/
|
||||||
|
export const metaDataLyricsArrayToLrc = (
|
||||||
|
lyrics: {
|
||||||
|
text: string;
|
||||||
|
timestamp?: number;
|
||||||
|
}[],
|
||||||
|
): string => {
|
||||||
|
return lyrics
|
||||||
|
.map(({ timestamp, text }) => {
|
||||||
|
if (!timestamp) return "";
|
||||||
|
const totalSeconds = Math.floor(timestamp / 1000);
|
||||||
|
const minutes = Math.floor(totalSeconds / 60);
|
||||||
|
const seconds = totalSeconds % 60;
|
||||||
|
const centiseconds = Math.floor((timestamp % 1000) / 10);
|
||||||
|
|
||||||
|
// 格式化为两位数字
|
||||||
|
const mm = String(minutes).padStart(2, "0");
|
||||||
|
const ss = String(seconds).padStart(2, "0");
|
||||||
|
const cs = String(centiseconds).padStart(2, "0");
|
||||||
|
|
||||||
|
return `[${mm}:${ss}.${cs}]${text}`;
|
||||||
|
})
|
||||||
|
.join("\n");
|
||||||
|
};
|
||||||
25
electron/main/utils/single-lock.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { app } from "electron";
|
||||||
|
import { systemLog } from "../logger";
|
||||||
|
import mainWindow from "../windows/main-window";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化单实例锁
|
||||||
|
* @returns 如果当前实例获得了锁,返回 true;否则返回 false
|
||||||
|
*/
|
||||||
|
export const initSingleLock = (): boolean => {
|
||||||
|
const gotTheLock = app.requestSingleInstanceLock();
|
||||||
|
// 如果未获得锁,退出当前实例
|
||||||
|
if (!gotTheLock) {
|
||||||
|
app.quit();
|
||||||
|
systemLog.warn("❌ 已有一个实例正在运行");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// 当第二个实例启动时触发
|
||||||
|
else {
|
||||||
|
app.on("second-instance", () => {
|
||||||
|
systemLog.warn("❌ 第二个实例将要启动");
|
||||||
|
mainWindow.getWin()?.show();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
43
electron/main/windows/index.ts
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
import { BrowserWindow, BrowserWindowConstructorOptions } from "electron";
|
||||||
|
import { windowsLog } from "../logger";
|
||||||
|
import { appName } from "../utils/config";
|
||||||
|
import { join } from "path";
|
||||||
|
import icon from "../../../public/icons/favicon.png?asset";
|
||||||
|
|
||||||
|
export const createWindow = (
|
||||||
|
options: BrowserWindowConstructorOptions = {},
|
||||||
|
): BrowserWindow | null => {
|
||||||
|
try {
|
||||||
|
const defaultOptions: BrowserWindowConstructorOptions = {
|
||||||
|
title: appName,
|
||||||
|
width: 1280,
|
||||||
|
height: 720,
|
||||||
|
frame: false, // 是否显示窗口边框
|
||||||
|
center: true, // 窗口居中
|
||||||
|
icon, // 窗口图标
|
||||||
|
autoHideMenuBar: true, // 隐藏菜单栏
|
||||||
|
webPreferences: {
|
||||||
|
preload: join(__dirname, "../preload/index.mjs"),
|
||||||
|
// 禁用渲染器沙盒
|
||||||
|
sandbox: false,
|
||||||
|
// 禁用同源策略
|
||||||
|
webSecurity: false,
|
||||||
|
// 允许 HTTP
|
||||||
|
allowRunningInsecureContent: true,
|
||||||
|
// 禁用拼写检查
|
||||||
|
spellcheck: false,
|
||||||
|
// 启用 Node.js
|
||||||
|
nodeIntegration: true,
|
||||||
|
nodeIntegrationInWorker: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
// 合并参数
|
||||||
|
options = Object.assign(defaultOptions, options);
|
||||||
|
// 创建窗口
|
||||||
|
const win = new BrowserWindow(options);
|
||||||
|
return win;
|
||||||
|
} catch (error) {
|
||||||
|
windowsLog.error(error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
60
electron/main/windows/load-window.ts
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
import { BrowserWindow } from "electron";
|
||||||
|
import { createWindow } from "./index";
|
||||||
|
import { loadWinUrl } from "../utils/config";
|
||||||
|
|
||||||
|
class LoadWindow {
|
||||||
|
private win: BrowserWindow | null = null;
|
||||||
|
private winURL: string;
|
||||||
|
constructor() {
|
||||||
|
this.winURL = loadWinUrl;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 主窗口事件
|
||||||
|
* @returns void
|
||||||
|
*/
|
||||||
|
private event(): void {
|
||||||
|
if (!this.win) return;
|
||||||
|
// 准备好显示
|
||||||
|
this.win.on("ready-to-show", () => {
|
||||||
|
this.win?.show();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 创建窗口
|
||||||
|
* @returns BrowserWindow | null
|
||||||
|
*/
|
||||||
|
create(): BrowserWindow | null {
|
||||||
|
this.win = createWindow({
|
||||||
|
width: 800,
|
||||||
|
height: 560,
|
||||||
|
maxWidth: 800,
|
||||||
|
maxHeight: 560,
|
||||||
|
resizable: false,
|
||||||
|
alwaysOnTop: true,
|
||||||
|
// 不在任务栏显示
|
||||||
|
skipTaskbar: true,
|
||||||
|
// 窗口不能最小化
|
||||||
|
minimizable: false,
|
||||||
|
// 窗口不能最大化
|
||||||
|
maximizable: false,
|
||||||
|
// 窗口不能进入全屏状态
|
||||||
|
fullscreenable: false,
|
||||||
|
show: false,
|
||||||
|
});
|
||||||
|
if (!this.win) return null;
|
||||||
|
// 加载地址
|
||||||
|
this.win.loadURL(this.winURL);
|
||||||
|
// 窗口事件
|
||||||
|
this.event();
|
||||||
|
return this.win;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取窗口
|
||||||
|
* @returns BrowserWindow | null
|
||||||
|
*/
|
||||||
|
getWin(): BrowserWindow | null {
|
||||||
|
return this.win;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default new LoadWindow();
|
||||||
99
electron/main/windows/login-window.ts
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
import { app, BrowserWindow, session } from "electron";
|
||||||
|
import { createWindow } from "./index";
|
||||||
|
import { join } from "path";
|
||||||
|
|
||||||
|
class LoginWindow {
|
||||||
|
private win: BrowserWindow | null = null;
|
||||||
|
private loginTimer: NodeJS.Timeout | null = null;
|
||||||
|
private loginSession: Electron.Session | null = null;
|
||||||
|
|
||||||
|
constructor() {}
|
||||||
|
|
||||||
|
private getLoginSession(): Electron.Session {
|
||||||
|
if (!this.loginSession) {
|
||||||
|
this.loginSession = session.fromPartition("persist:login");
|
||||||
|
}
|
||||||
|
return this.loginSession;
|
||||||
|
}
|
||||||
|
// 事件绑定
|
||||||
|
private event(mainWin: BrowserWindow): void {
|
||||||
|
if (!this.win) return;
|
||||||
|
// 阻止新窗口创建
|
||||||
|
this.win.webContents.setWindowOpenHandler(() => ({ action: "deny" }));
|
||||||
|
// 加载完成后显示并开始轮询登录状态
|
||||||
|
this.win.webContents.once("did-finish-load", () => {
|
||||||
|
this.win?.show();
|
||||||
|
this.loginTimer = setInterval(() => this.checkLogin(mainWin), 1000);
|
||||||
|
this.win?.on("closed", () => {
|
||||||
|
if (this.loginTimer) clearInterval(this.loginTimer);
|
||||||
|
this.loginTimer = null;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查是否已登录
|
||||||
|
private async checkLogin(mainWin: BrowserWindow) {
|
||||||
|
if (!this.win) return;
|
||||||
|
try {
|
||||||
|
this.win.webContents.executeJavaScript(
|
||||||
|
"document.title = '登录网易云音乐( 若遇到无响应请关闭后重试 )'",
|
||||||
|
);
|
||||||
|
// 判断 MUSIC_U
|
||||||
|
const MUSIC_U = await this.getLoginSession().cookies.get({ name: "MUSIC_U" });
|
||||||
|
if (MUSIC_U && MUSIC_U.length > 0) {
|
||||||
|
if (this.loginTimer) clearInterval(this.loginTimer);
|
||||||
|
this.loginTimer = null;
|
||||||
|
const value = `MUSIC_U=${MUSIC_U[0].value};`;
|
||||||
|
// 发送回主进程
|
||||||
|
mainWin?.webContents.send("send-cookies", value);
|
||||||
|
this.win.destroy();
|
||||||
|
this.win = null;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建登录窗口
|
||||||
|
async create(mainWin: BrowserWindow): Promise<BrowserWindow | null> {
|
||||||
|
await app.whenReady();
|
||||||
|
const loginSession = this.getLoginSession();
|
||||||
|
// 清理登录会话存储
|
||||||
|
await loginSession.clearStorageData({
|
||||||
|
storages: ["cookies", "localstorage"],
|
||||||
|
});
|
||||||
|
|
||||||
|
this.win = createWindow({
|
||||||
|
parent: mainWin,
|
||||||
|
title: "登录网易云音乐( 若遇到无响应请关闭后重试 )",
|
||||||
|
width: 1280,
|
||||||
|
height: 800,
|
||||||
|
center: true,
|
||||||
|
autoHideMenuBar: true,
|
||||||
|
webPreferences: {
|
||||||
|
preload: join(__dirname, "../preload/index.mjs"),
|
||||||
|
sandbox: false,
|
||||||
|
webSecurity: false,
|
||||||
|
allowRunningInsecureContent: true,
|
||||||
|
spellcheck: false,
|
||||||
|
nodeIntegration: true,
|
||||||
|
nodeIntegrationInWorker: true,
|
||||||
|
session: loginSession,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!this.win) return null;
|
||||||
|
// 加载登录地址
|
||||||
|
this.win.loadURL("https://music.163.com/#/login/");
|
||||||
|
// 绑定事件
|
||||||
|
this.event(mainWin);
|
||||||
|
return this.win;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取窗口
|
||||||
|
getWin(): BrowserWindow | null {
|
||||||
|
return this.win;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default new LoginWindow();
|
||||||
89
electron/main/windows/lyric-window.ts
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
import { BrowserWindow } from "electron";
|
||||||
|
import { createWindow } from "./index";
|
||||||
|
import { useStore } from "../store";
|
||||||
|
import { lyricWinUrl } from "../utils/config";
|
||||||
|
import mainWindow from "./main-window";
|
||||||
|
|
||||||
|
class LyricWindow {
|
||||||
|
private win: BrowserWindow | null = null;
|
||||||
|
constructor() {}
|
||||||
|
/**
|
||||||
|
* 主窗口事件
|
||||||
|
* @returns void
|
||||||
|
*/
|
||||||
|
private event(): void {
|
||||||
|
if (!this.win) return;
|
||||||
|
// 准备好显示
|
||||||
|
this.win.on("ready-to-show", () => {
|
||||||
|
this.win?.show();
|
||||||
|
});
|
||||||
|
// 歌词窗口缩放
|
||||||
|
this.win?.on("resized", () => {
|
||||||
|
const store = useStore();
|
||||||
|
const bounds = this.win?.getBounds();
|
||||||
|
if (bounds) {
|
||||||
|
const { width, height } = bounds;
|
||||||
|
store.set("lyric", { ...store.get("lyric"), width, height });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// 歌词窗口关闭
|
||||||
|
this.win?.on("close", () => {
|
||||||
|
this.win = null;
|
||||||
|
const mainWin = mainWindow?.getWin();
|
||||||
|
if (mainWin) {
|
||||||
|
mainWin?.webContents.send("closeDesktopLyric");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 创建主窗口
|
||||||
|
* @returns BrowserWindow | null
|
||||||
|
*/
|
||||||
|
create(): BrowserWindow | null {
|
||||||
|
const store = useStore();
|
||||||
|
const { width, height, x, y } = store.get("lyric");
|
||||||
|
this.win = createWindow({
|
||||||
|
width: width || 800,
|
||||||
|
height: height || 180,
|
||||||
|
minWidth: 640,
|
||||||
|
minHeight: 140,
|
||||||
|
maxWidth: 1400,
|
||||||
|
maxHeight: 360,
|
||||||
|
// 没有指定位置时居中显示
|
||||||
|
center: !(x && y),
|
||||||
|
// 窗口位置
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
transparent: true,
|
||||||
|
backgroundColor: "rgba(0, 0, 0, 0)",
|
||||||
|
alwaysOnTop: true,
|
||||||
|
resizable: true,
|
||||||
|
movable: true,
|
||||||
|
show: false,
|
||||||
|
// 不在任务栏显示
|
||||||
|
skipTaskbar: true,
|
||||||
|
// 窗口不能最小化
|
||||||
|
minimizable: false,
|
||||||
|
// 窗口不能最大化
|
||||||
|
maximizable: false,
|
||||||
|
// 窗口不能进入全屏状态
|
||||||
|
fullscreenable: false,
|
||||||
|
});
|
||||||
|
if (!this.win) return null;
|
||||||
|
// 加载地址
|
||||||
|
this.win.loadURL(lyricWinUrl);
|
||||||
|
// 窗口事件
|
||||||
|
this.event();
|
||||||
|
return this.win;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取窗口
|
||||||
|
* @returns BrowserWindow | null
|
||||||
|
*/
|
||||||
|
getWin(): BrowserWindow | null {
|
||||||
|
if (this.win && !this.win?.isDestroyed()) return this.win;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default new LyricWindow();
|
||||||
134
electron/main/windows/main-window.ts
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
import { BrowserWindow, shell } from "electron";
|
||||||
|
import { createWindow } from "./index";
|
||||||
|
import { mainWinUrl } from "../utils/config";
|
||||||
|
import { useStore } from "../store";
|
||||||
|
import { isLinux } from "../utils/config";
|
||||||
|
|
||||||
|
class MainWindow {
|
||||||
|
private win: BrowserWindow | null = null;
|
||||||
|
private winURL: string;
|
||||||
|
constructor() {
|
||||||
|
this.winURL = mainWinUrl;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 保存窗口大小和状态
|
||||||
|
*/
|
||||||
|
private saveBounds() {
|
||||||
|
if (this.win?.isFullScreen()) return;
|
||||||
|
const store = useStore();
|
||||||
|
const bounds = this.win?.getBounds();
|
||||||
|
if (bounds) {
|
||||||
|
const maximized = this.win?.isMaximized();
|
||||||
|
store.set("window", { ...bounds, maximized });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 主窗口事件
|
||||||
|
* @returns void
|
||||||
|
*/
|
||||||
|
private event(): void {
|
||||||
|
if (!this.win) return;
|
||||||
|
const store = useStore();
|
||||||
|
// 配置网络代理
|
||||||
|
if (store.get("proxy")) {
|
||||||
|
this.win.webContents.session.setProxy({ proxyRules: store.get("proxy") });
|
||||||
|
}
|
||||||
|
|
||||||
|
// 窗口打开处理程序
|
||||||
|
this.win.webContents.setWindowOpenHandler((details) => {
|
||||||
|
const { url } = details;
|
||||||
|
if (url.startsWith("https://") || url.startsWith("http://")) {
|
||||||
|
shell.openExternal(url);
|
||||||
|
}
|
||||||
|
return { action: "deny" };
|
||||||
|
});
|
||||||
|
// 窗口显示时
|
||||||
|
this.win?.on("show", () => {
|
||||||
|
this.win?.webContents.send("lyricsScroll");
|
||||||
|
});
|
||||||
|
// 窗口获得焦点时
|
||||||
|
this.win?.on("focus", () => {
|
||||||
|
this.saveBounds();
|
||||||
|
});
|
||||||
|
// 窗口大小改变时
|
||||||
|
this.win?.on("resized", () => {
|
||||||
|
// 若处于全屏则不保存
|
||||||
|
if (this.win?.isFullScreen()) return;
|
||||||
|
this.saveBounds();
|
||||||
|
});
|
||||||
|
// 窗口位置改变时
|
||||||
|
this.win?.on("moved", () => {
|
||||||
|
this.saveBounds();
|
||||||
|
});
|
||||||
|
// 窗口最大化时
|
||||||
|
this.win?.on("maximize", () => {
|
||||||
|
this.saveBounds();
|
||||||
|
this.win?.webContents.send("win-state-change", true);
|
||||||
|
});
|
||||||
|
// 窗口取消最大化时
|
||||||
|
this.win?.on("unmaximize", () => {
|
||||||
|
this.saveBounds();
|
||||||
|
this.win?.webContents.send("win-state-change", false);
|
||||||
|
});
|
||||||
|
// Linux 无法使用 resized 和 moved
|
||||||
|
if (isLinux) {
|
||||||
|
this.win?.on("resize", () => {
|
||||||
|
// 若处于全屏则不保存
|
||||||
|
if (this.win?.isFullScreen()) return;
|
||||||
|
this.saveBounds();
|
||||||
|
});
|
||||||
|
this.win?.on("move", () => {
|
||||||
|
this.saveBounds();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 窗口关闭
|
||||||
|
this.win?.on("close", (event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
this.win?.hide();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 创建窗口
|
||||||
|
* @returns BrowserWindow | null
|
||||||
|
*/
|
||||||
|
create(): BrowserWindow | null {
|
||||||
|
const store = useStore();
|
||||||
|
const { width, height } = store.get("window");
|
||||||
|
this.win = createWindow({
|
||||||
|
// 菜单栏
|
||||||
|
titleBarStyle: "customButtonsOnHover",
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
minHeight: 600,
|
||||||
|
minWidth: 800,
|
||||||
|
show: false,
|
||||||
|
});
|
||||||
|
if (!this.win) return null;
|
||||||
|
// 加载地址
|
||||||
|
this.win.loadURL(this.winURL);
|
||||||
|
// 窗口事件
|
||||||
|
this.event();
|
||||||
|
return this.win;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取窗口
|
||||||
|
* @returns BrowserWindow | null
|
||||||
|
*/
|
||||||
|
getWin(): BrowserWindow | null {
|
||||||
|
if (this.win && !this.win.isDestroyed()) {
|
||||||
|
return this.win;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 显示主窗口
|
||||||
|
*/
|
||||||
|
showWindow() {
|
||||||
|
if (this.win) {
|
||||||
|
this.win.show();
|
||||||
|
if (this.win.isMinimized()) this.win.restore();
|
||||||
|
this.win.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export default new MainWindow();
|
||||||
11
electron/preload/index.d.ts
vendored
@@ -1,8 +1,17 @@
|
|||||||
import { ElectronAPI } from "@electron-toolkit/preload";
|
import { ElectronAPI } from "@electron-toolkit/preload";
|
||||||
|
import type { StoreType } from "../main/store";
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
electron: ElectronAPI;
|
electron: ElectronAPI;
|
||||||
api: unknown;
|
api: {
|
||||||
|
store: {
|
||||||
|
get<K extends keyof StoreType>(key: K): Promise<StoreType[K]>;
|
||||||
|
set<K extends keyof StoreType>(key: K, value: StoreType[K]): Promise<boolean>;
|
||||||
|
has(key: keyof StoreType): Promise<boolean>;
|
||||||
|
delete(key: keyof StoreType): Promise<boolean>;
|
||||||
|
reset(keys?: (keyof StoreType)[]): Promise<boolean>;
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { contextBridge } from "electron";
|
import { contextBridge, ipcRenderer } from "electron";
|
||||||
import { electronAPI } from "@electron-toolkit/preload";
|
import { electronAPI } from "@electron-toolkit/preload";
|
||||||
|
|
||||||
// Use `contextBridge` APIs to expose Electron APIs to
|
// Use `contextBridge` APIs to expose Electron APIs to
|
||||||
@@ -7,10 +7,17 @@ import { electronAPI } from "@electron-toolkit/preload";
|
|||||||
if (process.contextIsolated) {
|
if (process.contextIsolated) {
|
||||||
try {
|
try {
|
||||||
contextBridge.exposeInMainWorld("electron", electronAPI);
|
contextBridge.exposeInMainWorld("electron", electronAPI);
|
||||||
|
// Expose store API via preload
|
||||||
|
contextBridge.exposeInMainWorld("api", {
|
||||||
|
store: {
|
||||||
|
get: (key: string) => ipcRenderer.invoke("store-get", key),
|
||||||
|
set: (key: string, value: unknown) => ipcRenderer.invoke("store-set", key, value),
|
||||||
|
has: (key: string) => ipcRenderer.invoke("store-has", key),
|
||||||
|
delete: (key: string) => ipcRenderer.invoke("store-delete", key),
|
||||||
|
reset: (keys?: string[]) => ipcRenderer.invoke("store-reset", keys),
|
||||||
|
},
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// @ts-expect-error (define in dts)
|
|
||||||
window.electron = electronAPI;
|
|
||||||
}
|
}
|
||||||
|
|||||||
187
electron/server/control/index.ts
Normal file
@@ -0,0 +1,187 @@
|
|||||||
|
import { FastifyInstance } from "fastify";
|
||||||
|
import mainWindow from "../../main/windows/main-window";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 播放控制接口
|
||||||
|
* @param fastify Fastify 实例
|
||||||
|
*/
|
||||||
|
export const initControlAPI = async (fastify: FastifyInstance) => {
|
||||||
|
// 播放控制路由前缀
|
||||||
|
await fastify.register(
|
||||||
|
async (fastify) => {
|
||||||
|
// 播放
|
||||||
|
fastify.get("/play", async (_request, reply) => {
|
||||||
|
try {
|
||||||
|
const mainWin = mainWindow.getWin();
|
||||||
|
if (!mainWin) {
|
||||||
|
return reply.code(500).send({
|
||||||
|
code: 500,
|
||||||
|
message: "主窗口未找到",
|
||||||
|
data: null,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
mainWin.webContents.send("play");
|
||||||
|
|
||||||
|
return reply.send({
|
||||||
|
code: 200,
|
||||||
|
message: "播放命令已发送",
|
||||||
|
data: null,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
return reply.code(500).send({
|
||||||
|
code: 500,
|
||||||
|
message: "播放失败",
|
||||||
|
data: error,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 暂停
|
||||||
|
fastify.get("/pause", async (_request, reply) => {
|
||||||
|
try {
|
||||||
|
const mainWin = mainWindow.getWin();
|
||||||
|
if (!mainWin) {
|
||||||
|
return reply.code(500).send({
|
||||||
|
code: 500,
|
||||||
|
message: "主窗口未找到",
|
||||||
|
data: null,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
mainWin.webContents.send("pause");
|
||||||
|
|
||||||
|
return reply.send({
|
||||||
|
code: 200,
|
||||||
|
message: "暂停命令已发送",
|
||||||
|
data: null,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
return reply.code(500).send({
|
||||||
|
code: 500,
|
||||||
|
message: "暂停失败",
|
||||||
|
data: error,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 播放/暂停切换
|
||||||
|
fastify.get("/toggle", async (_request, reply) => {
|
||||||
|
try {
|
||||||
|
const mainWin = mainWindow.getWin();
|
||||||
|
if (!mainWin) {
|
||||||
|
return reply.code(500).send({
|
||||||
|
code: 500,
|
||||||
|
message: "主窗口未找到",
|
||||||
|
data: null,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 这里可以根据当前播放状态来决定发送 play 还是 pause
|
||||||
|
// 暂时先发送 toggle 事件,如果渲染进程支持的话
|
||||||
|
mainWin.webContents.send("toggle");
|
||||||
|
|
||||||
|
return reply.send({
|
||||||
|
code: 200,
|
||||||
|
message: "播放/暂停切换命令已发送",
|
||||||
|
data: null,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
return reply.code(500).send({
|
||||||
|
code: 500,
|
||||||
|
message: "播放/暂停切换失败",
|
||||||
|
data: error,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 下一曲
|
||||||
|
fastify.get("/next", async (_request, reply) => {
|
||||||
|
try {
|
||||||
|
const mainWin = mainWindow.getWin();
|
||||||
|
if (!mainWin) {
|
||||||
|
return reply.code(500).send({
|
||||||
|
code: 500,
|
||||||
|
message: "主窗口未找到",
|
||||||
|
data: null,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
mainWin.webContents.send("playNext");
|
||||||
|
|
||||||
|
return reply.send({
|
||||||
|
code: 200,
|
||||||
|
message: "下一曲命令已发送",
|
||||||
|
data: null,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
return reply.code(500).send({
|
||||||
|
code: 500,
|
||||||
|
message: "下一曲失败",
|
||||||
|
data: error,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 上一曲
|
||||||
|
fastify.get("/prev", async (_request, reply) => {
|
||||||
|
try {
|
||||||
|
const mainWin = mainWindow.getWin();
|
||||||
|
if (!mainWin) {
|
||||||
|
return reply.code(500).send({
|
||||||
|
code: 500,
|
||||||
|
message: "主窗口未找到",
|
||||||
|
data: null,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
mainWin.webContents.send("playPrev");
|
||||||
|
|
||||||
|
return reply.send({
|
||||||
|
code: 200,
|
||||||
|
message: "上一曲命令已发送",
|
||||||
|
data: null,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
return reply.code(500).send({
|
||||||
|
code: 500,
|
||||||
|
message: "上一曲失败",
|
||||||
|
data: error,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 获取播放状态(可选功能)
|
||||||
|
fastify.get("/status", async (_request, reply) => {
|
||||||
|
try {
|
||||||
|
const mainWin = mainWindow.getWin();
|
||||||
|
if (!mainWin) {
|
||||||
|
return reply.code(500).send({
|
||||||
|
code: 500,
|
||||||
|
message: "主窗口未找到",
|
||||||
|
data: null,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 这里可以通过 IPC 获取当前播放状态
|
||||||
|
// 暂时返回基本信息
|
||||||
|
return reply.send({
|
||||||
|
code: 200,
|
||||||
|
message: "获取状态成功",
|
||||||
|
data: {
|
||||||
|
connected: true,
|
||||||
|
window: "available",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
return reply.code(500).send({
|
||||||
|
code: 500,
|
||||||
|
message: "获取状态失败",
|
||||||
|
data: error,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
{ prefix: "/control" },
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -1,25 +1,28 @@
|
|||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
import { isDev } from "../main/utils";
|
import { isDev } from "../main/utils/config";
|
||||||
import initNcmAPI from "./netease";
|
import { serverLog } from "../main/logger";
|
||||||
import initUnblockAPI from "./unblock";
|
import { initNcmAPI } from "./netease";
|
||||||
|
import { initUnblockAPI } from "./unblock";
|
||||||
|
import { initControlAPI } from "./control";
|
||||||
import fastifyCookie from "@fastify/cookie";
|
import fastifyCookie from "@fastify/cookie";
|
||||||
import fastifyMultipart from "@fastify/multipart";
|
import fastifyMultipart from "@fastify/multipart";
|
||||||
import fastifyStatic from "@fastify/static";
|
import fastifyStatic from "@fastify/static";
|
||||||
import fastify from "fastify";
|
import fastify from "fastify";
|
||||||
import log from "../main/logger";
|
|
||||||
|
|
||||||
const initAppServer = async () => {
|
const initAppServer = async () => {
|
||||||
try {
|
try {
|
||||||
const server = fastify({
|
const server = fastify({
|
||||||
// 忽略尾随斜杠
|
routerOptions: {
|
||||||
ignoreTrailingSlash: true,
|
// 忽略尾随斜杠
|
||||||
|
ignoreTrailingSlash: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
// 注册插件
|
// 注册插件
|
||||||
server.register(fastifyCookie);
|
server.register(fastifyCookie);
|
||||||
server.register(fastifyMultipart);
|
server.register(fastifyMultipart);
|
||||||
// 生产环境启用静态文件
|
// 生产环境启用静态文件
|
||||||
if (!isDev) {
|
if (!isDev) {
|
||||||
log.info("📂 Serving static files from /renderer");
|
serverLog.info("📂 Serving static files from /renderer");
|
||||||
server.register(fastifyStatic, {
|
server.register(fastifyStatic, {
|
||||||
root: join(__dirname, "../renderer"),
|
root: join(__dirname, "../renderer"),
|
||||||
});
|
});
|
||||||
@@ -45,13 +48,14 @@ const initAppServer = async () => {
|
|||||||
// 注册接口
|
// 注册接口
|
||||||
server.register(initNcmAPI, { prefix: "/api" });
|
server.register(initNcmAPI, { prefix: "/api" });
|
||||||
server.register(initUnblockAPI, { prefix: "/api" });
|
server.register(initUnblockAPI, { prefix: "/api" });
|
||||||
|
server.register(initControlAPI, { prefix: "/api" });
|
||||||
// 启动端口
|
// 启动端口
|
||||||
const port = Number(import.meta.env["VITE_SERVER_PORT"] || 25884);
|
const port = Number(process.env["VITE_SERVER_PORT"] || 25884);
|
||||||
await server.listen({ port });
|
await server.listen({ port });
|
||||||
log.info(`🌐 Starting AppServer on port ${port}`);
|
serverLog.info(`🌐 Starting AppServer on port ${port}`);
|
||||||
return server;
|
return server;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error("🚫 AppServer failed to start");
|
serverLog.error("🚫 AppServer failed to start");
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { FastifyInstance, FastifyRequest, FastifyReply } from "fastify";
|
import { FastifyInstance, FastifyRequest, FastifyReply } from "fastify";
|
||||||
import { pathCase } from "change-case";
|
import { pathCase } from "change-case";
|
||||||
import NeteaseCloudMusicApi from "NeteaseCloudMusicApi";
|
import { serverLog } from "../../main/logger";
|
||||||
import log from "../../main/logger";
|
import NeteaseCloudMusicApi from "@neteasecloudmusicapienhanced/api";
|
||||||
|
|
||||||
// 获取数据
|
// 获取数据
|
||||||
const getHandler = (name: string, neteaseApi: (params: any) => any) => {
|
const getHandler = (name: string, neteaseApi: (params: any) => any) => {
|
||||||
@@ -9,7 +9,7 @@ const getHandler = (name: string, neteaseApi: (params: any) => any) => {
|
|||||||
req: FastifyRequest<{ Querystring: { [key: string]: string } }>,
|
req: FastifyRequest<{ Querystring: { [key: string]: string } }>,
|
||||||
reply: FastifyReply,
|
reply: FastifyReply,
|
||||||
) => {
|
) => {
|
||||||
log.info("🌐 Request NcmAPI:", name);
|
serverLog.log("🌐 Request NcmAPI:", name);
|
||||||
// 获取 NcmAPI 数据
|
// 获取 NcmAPI 数据
|
||||||
try {
|
try {
|
||||||
const result = await neteaseApi({
|
const result = await neteaseApi({
|
||||||
@@ -19,7 +19,7 @@ const getHandler = (name: string, neteaseApi: (params: any) => any) => {
|
|||||||
});
|
});
|
||||||
return reply.send(result.body);
|
return reply.send(result.body);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
log.error("❌ NcmAPI Error:", error);
|
serverLog.error("❌ NcmAPI Error:", error);
|
||||||
if ([400, 301].includes(error.status)) {
|
if ([400, 301].includes(error.status)) {
|
||||||
return reply.status(error.status).send(error.body);
|
return reply.status(error.status).send(error.body);
|
||||||
}
|
}
|
||||||
@@ -29,16 +29,16 @@ const getHandler = (name: string, neteaseApi: (params: any) => any) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 初始化 NcmAPI
|
// 初始化 NcmAPI
|
||||||
const initNcmAPI = async (fastify: FastifyInstance) => {
|
export const initNcmAPI = async (fastify: FastifyInstance) => {
|
||||||
// 主信息
|
// 主信息
|
||||||
fastify.get("/netease", (_, reply) => {
|
fastify.get("/netease", (_, reply) => {
|
||||||
reply.send({
|
reply.send({
|
||||||
name: "NeteaseCloudMusicApi",
|
name: "@neteaseapireborn/api",
|
||||||
version: "4.20.0",
|
version: "4.29.2",
|
||||||
description: "网易云音乐 Node.js API service",
|
description: "网易云音乐 API Enhanced",
|
||||||
author: "@binaryify",
|
author: "@MoeFurina",
|
||||||
license: "MIT",
|
license: "MIT",
|
||||||
url: "https://gitlab.com/Binaryify/neteasecloudmusicapi",
|
url: "https://github.com/NeteaseCloudMusicApiEnhanced/api-enhanced",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -60,7 +60,28 @@ const initNcmAPI = async (fastify: FastifyInstance) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
log.info("🌐 Register NcmAPI successfully");
|
// 获取 TTML 歌词
|
||||||
};
|
fastify.get(
|
||||||
|
"/netease/lyric/ttml",
|
||||||
|
async (req: FastifyRequest<{ Querystring: { id: string } }>, reply: FastifyReply) => {
|
||||||
|
const { id } = req.query;
|
||||||
|
if (!id) {
|
||||||
|
return reply.status(400).send({ error: "id is required" });
|
||||||
|
}
|
||||||
|
const url = `https://amll-ttml-db.stevexmh.net/ncm/${id}`;
|
||||||
|
try {
|
||||||
|
const response = await fetch(url);
|
||||||
|
if (response.status !== 200) {
|
||||||
|
return reply.send(null);
|
||||||
|
}
|
||||||
|
const data = await response.text();
|
||||||
|
return reply.send(data);
|
||||||
|
} catch (error) {
|
||||||
|
serverLog.error("❌ TTML Lyric Fetch Error:", error);
|
||||||
|
return reply.send(null);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
export default initNcmAPI;
|
serverLog.info("🌐 Register NcmAPI successfully");
|
||||||
|
};
|
||||||
|
|||||||
14
electron/server/port.ts
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import getPort from "get-port";
|
||||||
|
|
||||||
|
// 默认端口
|
||||||
|
let webPort: number;
|
||||||
|
let servePort: number;
|
||||||
|
|
||||||
|
const getSafePort = async () => {
|
||||||
|
if (webPort && servePort) return { webPort, servePort };
|
||||||
|
webPort = await getPort({ port: 14558 });
|
||||||
|
servePort = await getPort({ port: 25884 });
|
||||||
|
return { webPort, servePort };
|
||||||
|
};
|
||||||
|
|
||||||
|
export default getSafePort;
|
||||||
161
electron/server/unblock/bodian.ts
Normal file
@@ -0,0 +1,161 @@
|
|||||||
|
import { SongUrlResult } from "./unblock";
|
||||||
|
import { serverLog } from "../../main/logger";
|
||||||
|
import { createHash } from "crypto";
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成随机设备 ID
|
||||||
|
* @returns 随机设备 ID
|
||||||
|
*/
|
||||||
|
const getRandomDeviceId = () => {
|
||||||
|
const min = 0;
|
||||||
|
const max = 100000000000;
|
||||||
|
const randomNum = Math.floor(Math.random() * (max - min + 1)) + min;
|
||||||
|
return randomNum.toString();
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 随机设备 ID */
|
||||||
|
const deviceId = getRandomDeviceId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 格式化歌曲信息
|
||||||
|
* @param song 歌曲信息
|
||||||
|
* @returns 格式化后的歌曲信息
|
||||||
|
*/
|
||||||
|
const format = (song: any) => ({
|
||||||
|
id: song.MUSICRID.split("_").pop(),
|
||||||
|
name: song.SONGNAME,
|
||||||
|
duration: song.DURATION * 1000,
|
||||||
|
album: { id: song.ALBUMID, name: song.ALBUM },
|
||||||
|
artists: song.ARTIST.split("&").map((name: any, index: any) => ({
|
||||||
|
id: index ? null : song.ARTISTID,
|
||||||
|
name,
|
||||||
|
})),
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成签名
|
||||||
|
* @param str 请求字符串
|
||||||
|
* @returns 包含签名的请求字符串
|
||||||
|
*/
|
||||||
|
const generateSign = (str: string) => {
|
||||||
|
const url = new URL(str);
|
||||||
|
|
||||||
|
const currentTime = Date.now();
|
||||||
|
str += `×tamp=${currentTime}`;
|
||||||
|
|
||||||
|
const filteredChars = str
|
||||||
|
.substring(str.indexOf("?") + 1)
|
||||||
|
.replace(/[^a-zA-Z0-9]/g, "")
|
||||||
|
.split("")
|
||||||
|
.sort();
|
||||||
|
|
||||||
|
const dataToEncrypt = `kuwotest${filteredChars.join("")}${url.pathname}`;
|
||||||
|
const md5 = createHash("md5").update(dataToEncrypt).digest("hex");
|
||||||
|
return `${str}&sign=${md5}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 搜索歌曲
|
||||||
|
* @param keyword 搜索关键词
|
||||||
|
* @returns 歌曲 ID 或 null
|
||||||
|
*/
|
||||||
|
const search = async (info: string): Promise<string | null> => {
|
||||||
|
try {
|
||||||
|
const keyword = encodeURIComponent(info.replace(" - ", " "));
|
||||||
|
const url =
|
||||||
|
"http://search.kuwo.cn/r.s?&correct=1&vipver=1&stype=comprehensive&encoding=utf8" +
|
||||||
|
"&rformat=json&mobi=1&show_copyright_off=1&searchapi=6&all=" +
|
||||||
|
keyword;
|
||||||
|
const result = await axios.get(url);
|
||||||
|
if (
|
||||||
|
!result.data ||
|
||||||
|
result.data.content.length < 2 ||
|
||||||
|
!result.data.content[1].musicpage ||
|
||||||
|
result.data.content[1].musicpage.abslist.length < 1
|
||||||
|
) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// 获取歌曲信息
|
||||||
|
const list = result.data.content[1].musicpage.abslist.map(format);
|
||||||
|
if (list[0] && !list[0]?.id) return null;
|
||||||
|
return list[0].id;
|
||||||
|
} catch (error) {
|
||||||
|
serverLog.error("❌ Get BodianSongId Error:", error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送广告免费请求
|
||||||
|
* @returns 包含广告免费响应的 Promise
|
||||||
|
*/
|
||||||
|
const sendAdFreeRequest = () => {
|
||||||
|
try {
|
||||||
|
const adurl =
|
||||||
|
"http://bd-api.kuwo.cn/api/service/advert/watch?uid=-1&token=×tamp=1724306124436&sign=15a676d66285117ad714e8c8371691da";
|
||||||
|
|
||||||
|
const headers = {
|
||||||
|
"user-agent": "Dart/2.19 (dart:io)",
|
||||||
|
plat: "ar",
|
||||||
|
channel: "aliopen",
|
||||||
|
devid: deviceId,
|
||||||
|
ver: "3.9.0",
|
||||||
|
host: "bd-api.kuwo.cn",
|
||||||
|
qimei36: "1e9970cbcdc20a031dee9f37100017e1840e",
|
||||||
|
"content-type": "application/json; charset=utf-8",
|
||||||
|
};
|
||||||
|
|
||||||
|
const data = JSON.stringify({
|
||||||
|
type: 5,
|
||||||
|
subType: 5,
|
||||||
|
musicId: 0,
|
||||||
|
adToken: "",
|
||||||
|
});
|
||||||
|
return axios.post(adurl, data, { headers });
|
||||||
|
} catch (error) {
|
||||||
|
serverLog.error("❌ Get Bodian Ad Free Error:", error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取波点音乐歌曲 URL
|
||||||
|
* @param keyword 搜索关键词
|
||||||
|
* @returns 包含歌曲 URL 的结果对象
|
||||||
|
*/
|
||||||
|
const getBodianSongUrl = async (keyword: string): Promise<SongUrlResult> => {
|
||||||
|
try {
|
||||||
|
if (!keyword) return { code: 404, url: null };
|
||||||
|
const songId = await search(keyword);
|
||||||
|
if (!songId) return { code: 404, url: null };
|
||||||
|
// 请求地址
|
||||||
|
const headers = {
|
||||||
|
"user-agent": "Dart/2.19 (dart:io)",
|
||||||
|
plat: "ar",
|
||||||
|
channel: "aliopen",
|
||||||
|
devid: deviceId,
|
||||||
|
ver: "3.9.0",
|
||||||
|
host: "bd-api.kuwo.cn",
|
||||||
|
"X-Forwarded-For": "1.0.1.114",
|
||||||
|
};
|
||||||
|
let audioUrl = `http://bd-api.kuwo.cn/api/play/music/v2/audioUrl?&br=${"320kmp3"}&musicId=${songId}`;
|
||||||
|
// 生成签名
|
||||||
|
audioUrl = generateSign(audioUrl);
|
||||||
|
// 获取广告
|
||||||
|
await sendAdFreeRequest();
|
||||||
|
// 获取歌曲地址
|
||||||
|
const result = await axios.get(audioUrl, { headers });
|
||||||
|
if (typeof result.data === "object") {
|
||||||
|
const urlMatch = result.data.data.audioUrl;
|
||||||
|
serverLog.log("🔗 BodianSong URL:", urlMatch);
|
||||||
|
return { code: 200, url: urlMatch };
|
||||||
|
}
|
||||||
|
return { code: 404, url: null };
|
||||||
|
} catch (error) {
|
||||||
|
serverLog.error("❌ Get BodianSong URL Error:", error);
|
||||||
|
return { code: 404, url: null };
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default getBodianSongUrl;
|
||||||
107
electron/server/unblock/gequbao.ts
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
import { SongUrlResult } from "./unblock";
|
||||||
|
import { serverLog } from "../../main/logger";
|
||||||
|
import axios from "axios";
|
||||||
|
import { randomBytes } from "crypto";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 搜索歌曲获取 ID
|
||||||
|
* @param keyword 搜索关键词
|
||||||
|
* @returns 歌曲 ID 或 null
|
||||||
|
*/
|
||||||
|
const search = async (keyword: string): Promise<string | null> => {
|
||||||
|
try {
|
||||||
|
const searchUrl = `https://www.gequbao.com/s/${encodeURIComponent(keyword)}`;
|
||||||
|
const { data } = await axios.get(searchUrl);
|
||||||
|
|
||||||
|
// 匹配第一个歌曲链接 /music/12345
|
||||||
|
// <a href="/music/17165" target="_blank" class="music-link d-block">
|
||||||
|
const match = data.match(
|
||||||
|
/<a href="\/music\/(\d+)" target="_blank" class="music-link d-block">/,
|
||||||
|
);
|
||||||
|
if (match && match[1]) {
|
||||||
|
return match[1];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
} catch (error) {
|
||||||
|
serverLog.error("❌ Get GequbaoSongId Error:", error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取播放 ID
|
||||||
|
* @param id 歌曲 ID
|
||||||
|
* @returns 播放 ID 或 null
|
||||||
|
*/
|
||||||
|
const getPlayId = async (id: string): Promise<string | null> => {
|
||||||
|
try {
|
||||||
|
const url = `https://www.gequbao.com/music/${id}`;
|
||||||
|
const { data } = await axios.get(url);
|
||||||
|
|
||||||
|
// 匹配 window.appData 中的 play_id
|
||||||
|
// "play_id":"EFwMVSQDBgsBQV5WBCUDAVkCSQ9WX3kFXV9XEl0KBSEaVldTR19NVndQVlhXRl5cUA=="
|
||||||
|
const match = data.match(/"play_id":"(.*?)"/);
|
||||||
|
if (match && match[1]) {
|
||||||
|
return match[1];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
} catch (error) {
|
||||||
|
serverLog.error("❌ Get GequbaoPlayId Error:", error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取歌曲 URL
|
||||||
|
* @param keyword 搜索关键词
|
||||||
|
* @returns 包含歌曲 URL 的结果对象
|
||||||
|
*/
|
||||||
|
const getGequbaoSongUrl = async (keyword: string): Promise<SongUrlResult> => {
|
||||||
|
try {
|
||||||
|
if (!keyword) return { code: 404, url: null };
|
||||||
|
|
||||||
|
// 1. 获取 ID
|
||||||
|
const id = await search(keyword);
|
||||||
|
if (!id) return { code: 404, url: null };
|
||||||
|
|
||||||
|
// 2. 获取 play_id
|
||||||
|
const playId = await getPlayId(id);
|
||||||
|
if (!playId) return { code: 404, url: null };
|
||||||
|
|
||||||
|
// 3. 获取播放链接
|
||||||
|
const url = "https://www.gequbao.com/api/play-url";
|
||||||
|
const headers = {
|
||||||
|
accept: "application/json, text/javascript, */*; q=0.01",
|
||||||
|
"accept-language": "zh-CN,zh;q=0.9",
|
||||||
|
"cache-control": "no-cache",
|
||||||
|
"content-type": "application/x-www-form-urlencoded; charset=UTF-8",
|
||||||
|
pragma: "no-cache",
|
||||||
|
priority: "u=1, i",
|
||||||
|
"sec-ch-ua": '"Chromium";v="142", "Google Chrome";v="142", "Not_A Brand";v="99"',
|
||||||
|
"sec-ch-ua-mobile": "?0",
|
||||||
|
"sec-ch-ua-platform": '"Windows"',
|
||||||
|
"sec-fetch-dest": "empty",
|
||||||
|
"sec-fetch-mode": "cors",
|
||||||
|
"sec-fetch-site": "same-origin",
|
||||||
|
"x-requested-with": "XMLHttpRequest",
|
||||||
|
cookie: `server_name_session=${randomBytes(16).toString("hex")}`,
|
||||||
|
Referer: `https://www.gequbao.com/music/${id}`,
|
||||||
|
};
|
||||||
|
|
||||||
|
const body = `id=${encodeURIComponent(playId)}`;
|
||||||
|
|
||||||
|
const { data } = await axios.post(url, body, { headers });
|
||||||
|
|
||||||
|
if (data.code === 1 && data.data && data.data.url) {
|
||||||
|
serverLog.log("🔗 GequbaoSong URL:", data.data.url);
|
||||||
|
return { code: 200, url: data.data.url };
|
||||||
|
}
|
||||||
|
|
||||||
|
return { code: 404, url: null };
|
||||||
|
} catch (error) {
|
||||||
|
serverLog.error("❌ Get GequbaoSong URL Error:", error);
|
||||||
|
return { code: 404, url: null };
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default getGequbaoSongUrl;
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
import { FastifyInstance, FastifyRequest, FastifyReply } from "fastify";
|
import { FastifyInstance, FastifyRequest, FastifyReply } from "fastify";
|
||||||
import { SongUrlResult } from "./unblock";
|
import { SongUrlResult } from "./unblock";
|
||||||
import getKuwoSongUrl from "./kuwo";
|
import { serverLog } from "../../main/logger";
|
||||||
import log from "../../main/logger";
|
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
import getKuwoSongUrl from "./kuwo";
|
||||||
|
import getBodianSongUrl from "./bodian";
|
||||||
|
import getGequbaoSongUrl from "./gequbao";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 直接获取 网易云云盘 链接
|
* 直接获取 网易云云盘 链接
|
||||||
@@ -17,16 +19,16 @@ const getNeteaseSongUrl = async (id: number | string): Promise<SongUrlResult> =>
|
|||||||
params: { types: "url", id },
|
params: { types: "url", id },
|
||||||
});
|
});
|
||||||
const songUrl = result.data.url;
|
const songUrl = result.data.url;
|
||||||
log.info("🔗 NeteaseSongUrl URL:", songUrl);
|
serverLog.log("🔗 NeteaseSongUrl URL:", songUrl);
|
||||||
return { code: 200, url: songUrl };
|
return { code: 200, url: songUrl };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error("❌ Get NeteaseSongUrl Error:", error);
|
serverLog.error("❌ Get NeteaseSongUrl Error:", error);
|
||||||
return { code: 404, url: null };
|
return { code: 404, url: null };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 初始化 UnblockAPI
|
// 初始化 UnblockAPI
|
||||||
const UnblockAPI = async (fastify: FastifyInstance) => {
|
export const initUnblockAPI = async (fastify: FastifyInstance) => {
|
||||||
// 主信息
|
// 主信息
|
||||||
fastify.get("/unblock", (_, reply) => {
|
fastify.get("/unblock", (_, reply) => {
|
||||||
reply.send({
|
reply.send({
|
||||||
@@ -61,8 +63,30 @@ const UnblockAPI = async (fastify: FastifyInstance) => {
|
|||||||
return reply.send(result);
|
return reply.send(result);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
// bodian
|
||||||
|
fastify.get(
|
||||||
|
"/unblock/bodian",
|
||||||
|
async (
|
||||||
|
req: FastifyRequest<{ Querystring: { [key: string]: string } }>,
|
||||||
|
reply: FastifyReply,
|
||||||
|
) => {
|
||||||
|
const { keyword } = req.query;
|
||||||
|
const result = await getBodianSongUrl(keyword);
|
||||||
|
return reply.send(result);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
// gequbao
|
||||||
|
fastify.get(
|
||||||
|
"/unblock/gequbao",
|
||||||
|
async (
|
||||||
|
req: FastifyRequest<{ Querystring: { [key: string]: string } }>,
|
||||||
|
reply: FastifyReply,
|
||||||
|
) => {
|
||||||
|
const { keyword } = req.query;
|
||||||
|
const result = await getGequbaoSongUrl(keyword);
|
||||||
|
return reply.send(result);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
log.info("🌐 Register UnblockAPI successfully");
|
serverLog.info("🌐 Register UnblockAPI successfully");
|
||||||
};
|
};
|
||||||
|
|
||||||
export default UnblockAPI;
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { encryptQuery } from "./kwDES";
|
import { encryptQuery } from "./kwDES";
|
||||||
import { SongUrlResult } from "./unblock";
|
import { SongUrlResult } from "./unblock";
|
||||||
import log from "../../main/logger";
|
import { serverLog } from "../../main/logger";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
|
||||||
// 获取酷我音乐歌曲 ID
|
// 获取酷我音乐歌曲 ID
|
||||||
@@ -26,7 +26,7 @@ const getKuwoSongId = async (keyword: string): Promise<string | null> => {
|
|||||||
if (songName && !songName?.includes(originalName[0])) return null;
|
if (songName && !songName?.includes(originalName[0])) return null;
|
||||||
return songId.slice("MUSIC_".length);
|
return songId.slice("MUSIC_".length);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error("❌ Get KuwoSongId Error:", error);
|
serverLog.error("❌ Get KuwoSongId Error:", error);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -53,12 +53,12 @@ const getKuwoSongUrl = async (keyword: string): Promise<SongUrlResult> => {
|
|||||||
});
|
});
|
||||||
if (result.data) {
|
if (result.data) {
|
||||||
const urlMatch = result.data.match(/http[^\s$"]+/)[0];
|
const urlMatch = result.data.match(/http[^\s$"]+/)[0];
|
||||||
log.info("🔗 KuwoSong URL:", urlMatch);
|
serverLog.log("🔗 KuwoSong URL:", urlMatch);
|
||||||
return { code: 200, url: urlMatch };
|
return { code: 200, url: urlMatch };
|
||||||
}
|
}
|
||||||
return { code: 404, url: null };
|
return { code: 404, url: null };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error("❌ Get KuwoSong URL Error:", error);
|
serverLog.error("❌ Get KuwoSong URL Error:", error);
|
||||||
return { code: 404, url: null };
|
return { code: 404, url: null };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -26,11 +26,7 @@ export default [
|
|||||||
"**/components.d.ts",
|
"**/components.d.ts",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
...compat.extends(
|
...compat.extends("eslint:recommended", "plugin:@typescript-eslint/recommended"),
|
||||||
"eslint:recommended",
|
|
||||||
"plugin:@typescript-eslint/recommended",
|
|
||||||
"plugin:vue/vue3-essential",
|
|
||||||
),
|
|
||||||
{
|
{
|
||||||
plugins: {
|
plugins: {
|
||||||
"@typescript-eslint": typescriptEslint,
|
"@typescript-eslint": typescriptEslint,
|
||||||
|
|||||||
23
nginx.conf
@@ -15,6 +15,23 @@ server {
|
|||||||
rewrite ^(.*)$ /index.html last;
|
rewrite ^(.*)$ /index.html last;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
location /api/netease/song/url/v1 {
|
||||||
|
proxy_buffers 16 64k;
|
||||||
|
proxy_buffer_size 128k;
|
||||||
|
proxy_busy_buffers_size 256k;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-Host $remote_addr;
|
||||||
|
proxy_set_header X-NginX-Proxy true;
|
||||||
|
proxy_pass http://localhost:3000/song/url/v1;
|
||||||
|
|
||||||
|
sub_filter '"url":"http://music.163.com' '"url":"/music/unblock';
|
||||||
|
sub_filter '"url":"https://music.163.com' '"url":"/music/unblock';
|
||||||
|
sub_filter_types application/json;
|
||||||
|
sub_filter_once off;
|
||||||
|
}
|
||||||
|
|
||||||
location /api/netease/ {
|
location /api/netease/ {
|
||||||
proxy_buffers 16 64k;
|
proxy_buffers 16 64k;
|
||||||
proxy_buffer_size 128k;
|
proxy_buffer_size 128k;
|
||||||
@@ -26,4 +43,10 @@ server {
|
|||||||
proxy_set_header X-NginX-Proxy true;
|
proxy_set_header X-NginX-Proxy true;
|
||||||
proxy_pass http://localhost:3000/;
|
proxy_pass http://localhost:3000/;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
location /music/unblock/ {
|
||||||
|
proxy_pass https://music.163.com/;
|
||||||
|
proxy_buffering off;
|
||||||
|
proxy_request_buffering off;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
147
package.json
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "splayer",
|
"name": "splayer",
|
||||||
"productName": "SPlayer",
|
"productName": "SPlayer",
|
||||||
"version": "3.0.0-alpha.4",
|
"version": "3.0.0-beta.6",
|
||||||
"description": "A minimalist music player",
|
"description": "A minimalist music player",
|
||||||
"main": "./out/main/index.js",
|
"main": "./out/main/index.js",
|
||||||
"author": "imsyy",
|
"author": "imsyy",
|
||||||
@@ -23,92 +23,117 @@
|
|||||||
"typecheck:web": "vue-tsc --noEmit -p tsconfig.web.json --composite false",
|
"typecheck:web": "vue-tsc --noEmit -p tsconfig.web.json --composite false",
|
||||||
"typecheck": "npm run typecheck:node && npm run typecheck:web",
|
"typecheck": "npm run typecheck:node && npm run typecheck:web",
|
||||||
"start": "electron-vite preview",
|
"start": "electron-vite preview",
|
||||||
"dev": "electron-vite dev",
|
"dev": "node scripts/dev.mjs",
|
||||||
"build": "npm run typecheck && electron-vite build",
|
"build": "npx rimraf dist && npm run typecheck && electron-vite build",
|
||||||
"postinstall": "electron-builder install-app-deps",
|
"postinstall": "electron-builder install-app-deps",
|
||||||
"build:web": "npm run build",
|
"build:web": "npm run build",
|
||||||
"build:unpack": "npm run build && electron-builder --dir",
|
"build:unpack": "npm run build && electron-builder --dir",
|
||||||
"build:win": "npm run build && electron-builder --win",
|
"build:win": "npm run build && electron-builder --win --config electron-builder.config.ts",
|
||||||
"build:mac": "npm run build && electron-builder --mac",
|
"build:mac": "npm run build && electron-builder --mac --config electron-builder.config.ts",
|
||||||
"build:linux": "npm run build && electron-builder --linux"
|
"build:linux": "npm run build && electron-builder --linux --config electron-builder.config.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@applemusic-like-lyrics/core": "^0.1.3",
|
"@applemusic-like-lyrics/core": "^0.1.3",
|
||||||
"@applemusic-like-lyrics/lyric": "^0.2.4",
|
"@applemusic-like-lyrics/lyric": "^0.3.0",
|
||||||
"@applemusic-like-lyrics/vue": "^0.1.5",
|
"@applemusic-like-lyrics/vue": "^0.1.5",
|
||||||
"@electron-toolkit/preload": "^3.0.1",
|
"@electron-toolkit/preload": "^3.0.2",
|
||||||
"@electron-toolkit/utils": "^3.0.0",
|
"@electron-toolkit/utils": "^4.0.0",
|
||||||
"@imsyy/color-utils": "^1.0.2",
|
"@imsyy/color-utils": "^1.0.2",
|
||||||
"@material/material-color-utilities": "^0.3.0",
|
"@material/material-color-utilities": "^0.3.0",
|
||||||
"@pixi/app": "^7.4.2",
|
"@neteasecloudmusicapienhanced/api": "^4.29.17",
|
||||||
"@pixi/core": "^7.4.2",
|
"@pixi/app": "^7.4.3",
|
||||||
"@pixi/display": "^7.4.2",
|
"@pixi/core": "^7.4.3",
|
||||||
"@pixi/filter-blur": "^7.4.2",
|
"@pixi/display": "^7.4.3",
|
||||||
|
"@pixi/filter-blur": "^7.4.3",
|
||||||
"@pixi/filter-bulge-pinch": "^5.1.1",
|
"@pixi/filter-bulge-pinch": "^5.1.1",
|
||||||
"@pixi/filter-color-matrix": "^7.4.2",
|
"@pixi/filter-color-matrix": "^7.4.3",
|
||||||
"@pixi/sprite": "^7.4.2",
|
"@pixi/sprite": "^7.4.3",
|
||||||
"@vueuse/core": "^10.11.1",
|
"@vueuse/core": "^13.9.0",
|
||||||
"NeteaseCloudMusicApi": "^4.23.1",
|
"@vueuse/integrations": "^14.0.0",
|
||||||
"axios": "^1.7.7",
|
"axios": "^1.13.2",
|
||||||
|
"axios-retry": "^4.5.0",
|
||||||
"change-case": "^5.4.4",
|
"change-case": "^5.4.4",
|
||||||
"dayjs": "^1.11.13",
|
"dayjs": "^1.11.19",
|
||||||
"electron-dl": "^3.5.2",
|
"electron-dl": "^4.0.0",
|
||||||
"electron-store": "^8.2.0",
|
"electron-store": "^11.0.2",
|
||||||
"electron-updater": "^6.3.9",
|
"electron-updater": "^6.6.2",
|
||||||
"file-saver": "^2.0.5",
|
"file-saver": "^2.0.5",
|
||||||
"font-list": "^1.5.1",
|
"font-list": "^2.0.1",
|
||||||
"github-markdown-css": "^5.7.0",
|
"get-port": "^7.1.0",
|
||||||
|
"github-markdown-css": "^5.8.1",
|
||||||
"howler": "^2.2.4",
|
"howler": "^2.2.4",
|
||||||
"js-cookie": "^3.0.5",
|
"js-cookie": "^3.0.5",
|
||||||
"jss": "^10.10.0",
|
"jss": "^10.10.0",
|
||||||
"jss-preset-default": "^10.10.0",
|
"jss-preset-default": "^10.10.0",
|
||||||
"localforage": "^1.10.0",
|
"localforage": "^1.10.0",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
"marked": "^14.1.2",
|
"marked": "^16.4.2",
|
||||||
"music-metadata": "7.14.0",
|
"md5": "^2.3.0",
|
||||||
"pinia": "^2.2.4",
|
"music-metadata": "^11.10.0",
|
||||||
"pinia-plugin-persistedstate": "^3.2.3",
|
"pinia": "^3.0.4",
|
||||||
"plyr": "^3.7.8",
|
"pinia-plugin-persistedstate": "^4.7.1",
|
||||||
"vue-virt-list": "^1.5.2"
|
"plyr": "^3.8.3",
|
||||||
|
"sortablejs": "^1",
|
||||||
|
"vue-virt-list": "^1.6.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@electron-toolkit/preload": "^3.0.1",
|
"@electron-toolkit/preload": "^3.0.1",
|
||||||
"@electron-toolkit/tsconfig": "^1.0.1",
|
"@electron-toolkit/tsconfig": "^2.0.0",
|
||||||
"@electron-toolkit/utils": "^3.0.0",
|
"@electron-toolkit/utils": "^4",
|
||||||
"@fastify/cookie": "^9.4.0",
|
"@fastify/cookie": "^11.0.2",
|
||||||
"@fastify/http-proxy": "^9.5.0",
|
"@fastify/http-proxy": "^11.3.0",
|
||||||
"@fastify/multipart": "^8.3.0",
|
"@fastify/multipart": "^9.3.0",
|
||||||
"@fastify/static": "^7.0.4",
|
"@fastify/static": "^8.3.0",
|
||||||
"@types/file-saver": "^2.0.7",
|
"@types/file-saver": "^2.0.7",
|
||||||
"@types/howler": "^2.2.12",
|
"@types/howler": "^2.2.12",
|
||||||
"@types/js-cookie": "^3.0.6",
|
"@types/js-cookie": "^3.0.6",
|
||||||
"@types/node": "^22.7.5",
|
"@types/md5": "^2.3.6",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.8.1",
|
"@types/node": "^24.10.1",
|
||||||
"@typescript-eslint/parser": "^8.8.1",
|
"@typescript-eslint/eslint-plugin": "^8.46.4",
|
||||||
"@vitejs/plugin-vue": "^5.1.4",
|
"@typescript-eslint/parser": "^8.46.4",
|
||||||
|
"@vitejs/plugin-vue": "^6.0.1",
|
||||||
"ajv": "^8.17.1",
|
"ajv": "^8.17.1",
|
||||||
"crypto-js": "^4.2.0",
|
"crypto-js": "^4.2.0",
|
||||||
"electron": "^28.3.3",
|
"electron": "38.2.2",
|
||||||
"electron-builder": "^25.1.7",
|
"electron-builder": "^26.0.12",
|
||||||
"electron-log": "^5.2.0",
|
"electron-log": "^5.4.3",
|
||||||
"electron-vite": "^2.3.0",
|
"electron-vite": "^4.0.1",
|
||||||
"eslint": "^9.12.0",
|
"eslint": "^9.39.1",
|
||||||
"eslint-plugin-vue": "^9.29.0",
|
"eslint-plugin-vue": "^10.5.1",
|
||||||
"fast-glob": "^3.3.2",
|
"fast-glob": "^3.3.3",
|
||||||
"fastify": "^4.28.1",
|
"fastify": "^5.6.2",
|
||||||
"naive-ui": "^2.40.1",
|
"naive-ui": "^2.43.1",
|
||||||
"node-taglib-sharp": "^5.2.3",
|
"node-taglib-sharp": "^6.0.1",
|
||||||
"prettier": "^3.3.3",
|
"prettier": "^3.6.2",
|
||||||
"sass": "^1.79.5",
|
"sass": "^1.94.0",
|
||||||
"terser": "^5.34.1",
|
"terser": "^5.44.1",
|
||||||
"typescript": "^5.6.3",
|
"typescript": "^5.9.3",
|
||||||
"unplugin-auto-import": "^0.18.3",
|
"unplugin-auto-import": "^20.2.0",
|
||||||
"unplugin-vue-components": "^0.27.4",
|
"unplugin-vue-components": "^29.2.0",
|
||||||
"vite": "^5.4.8",
|
"vite": "^7.2.2",
|
||||||
"vite-plugin-compression": "^0.5.1",
|
"vite-plugin-compression": "^0.5.1",
|
||||||
"vite-plugin-wasm": "^3.3.0",
|
"vite-plugin-vue-devtools": "^8.0.3",
|
||||||
"vue": "3.5.10",
|
"vite-plugin-wasm": "^3.5.0",
|
||||||
"vue-router": "^4.4.5",
|
"vue": "^3.5.24",
|
||||||
"vue-tsc": "^2.1.6"
|
"vue-router": "^4.6.3",
|
||||||
|
"vue-tsc": "^3.1.3"
|
||||||
|
},
|
||||||
|
"pnpm": {
|
||||||
|
"overrides": {
|
||||||
|
"dmg-builder": "26.0.12",
|
||||||
|
"electron-builder-squirrel-windows": "26.0.12"
|
||||||
|
},
|
||||||
|
"onlyBuiltDependencies": [
|
||||||
|
"@applemusic-like-lyrics/core",
|
||||||
|
"@applemusic-like-lyrics/lyric",
|
||||||
|
"@applemusic-like-lyrics/vue",
|
||||||
|
"@parcel/watcher",
|
||||||
|
"core-js",
|
||||||
|
"electron",
|
||||||
|
"electron-winstaller",
|
||||||
|
"esbuild",
|
||||||
|
"sharp",
|
||||||
|
"vue-demi"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
6389
pnpm-lock.yaml
generated
BIN
public/icons/logo-icon.png
Normal file
|
After Width: | Height: | Size: 5.6 KiB |
BIN
public/icons/logo.ico
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
public/logo.ico
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
screenshots/welcome.png
Normal file
|
After Width: | Height: | Size: 43 KiB |
90
scripts/dev.mjs
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跨平台开发启动脚本
|
||||||
|
* 自动检测操作系统并设置相应的字符编码
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { spawn } from "child_process";
|
||||||
|
import os from "os";
|
||||||
|
|
||||||
|
// 检测操作系统平台
|
||||||
|
const platform = os.platform();
|
||||||
|
const isWindows = platform === "win32";
|
||||||
|
const isMacOS = platform === "darwin";
|
||||||
|
|
||||||
|
console.log(`🚀 检测到操作系统: ${platform}`);
|
||||||
|
|
||||||
|
// 设置环境变量
|
||||||
|
const env = { ...process.env };
|
||||||
|
|
||||||
|
if (isWindows) {
|
||||||
|
console.log("Windows 环境 - 正在设置代码页为 UTF-8");
|
||||||
|
// Windows 环境下先执行 chcp 65001
|
||||||
|
const chcp = spawn("chcp", ["65001"], {
|
||||||
|
stdio: "inherit",
|
||||||
|
shell: true,
|
||||||
|
env,
|
||||||
|
});
|
||||||
|
|
||||||
|
chcp.on("close", (code) => {
|
||||||
|
if (code === 0) {
|
||||||
|
console.log("✅ 代码页设置成功");
|
||||||
|
startElectronVite();
|
||||||
|
} else {
|
||||||
|
console.warn("⚠️ 代码页设置失败,继续启动...");
|
||||||
|
startElectronVite();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// macOS 和 Linux 环境
|
||||||
|
console.log(`🐧 ${isMacOS ? "macOS" : "Linux"} 环境 - 正在设置 UTF-8 编码`);
|
||||||
|
const langVar = env.LC_ALL || env.LANG;
|
||||||
|
if (langVar.endsWith("UTF-8")) {
|
||||||
|
console.log("✅ 当前环境已设置 UTF-8 编码");
|
||||||
|
} else {
|
||||||
|
if (langVar.startsWith("zh_CN")) {
|
||||||
|
env.LC_ALL = "zh_CN.UTF-8";
|
||||||
|
env.LANG = "zh_CN.UTF-8";
|
||||||
|
} else {
|
||||||
|
env.LC_ALL = "en_US.UTF-8";
|
||||||
|
env.LANG = "en_US.UTF-8";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setTimeout(() => startElectronVite(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const startElectronVite = () => {
|
||||||
|
console.log("🔧 正在启动 Electron Vite 开发服务器...");
|
||||||
|
|
||||||
|
// 设置 Node.js 选项
|
||||||
|
env.NODE_OPTIONS = "--max-old-space-size=4096";
|
||||||
|
|
||||||
|
const electronVite = spawn("electron-vite", ["dev"], {
|
||||||
|
stdio: "inherit",
|
||||||
|
shell: true,
|
||||||
|
env,
|
||||||
|
});
|
||||||
|
|
||||||
|
electronVite.on("close", (code) => {
|
||||||
|
console.log(`\n🏁 开发服务器已停止 (退出码: ${code})`);
|
||||||
|
process.exit(code);
|
||||||
|
});
|
||||||
|
|
||||||
|
electronVite.on("error", (err) => {
|
||||||
|
console.error("❌ 启动失败:", err.message);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 优雅退出处理
|
||||||
|
process.on("SIGINT", () => {
|
||||||
|
console.log("\n🛑 正在停止开发服务器...");
|
||||||
|
electronVite.kill("SIGINT");
|
||||||
|
});
|
||||||
|
|
||||||
|
process.on("SIGTERM", () => {
|
||||||
|
console.log("\n🛑 正在停止开发服务器...");
|
||||||
|
electronVite.kill("SIGTERM");
|
||||||
|
});
|
||||||
|
};
|
||||||
148
src/App.vue
@@ -1,151 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<Provider>
|
<Provider>
|
||||||
<!-- 主框架 -->
|
<router-view />
|
||||||
<n-layout
|
|
||||||
id="main"
|
|
||||||
:class="{
|
|
||||||
'show-player': musicStore.isHasPlayer && statusStore.showPlayBar,
|
|
||||||
'show-full-player': statusStore.showFullPlayer,
|
|
||||||
}"
|
|
||||||
has-sider
|
|
||||||
>
|
|
||||||
<!-- 侧边栏 -->
|
|
||||||
<n-layout-sider
|
|
||||||
id="main-sider"
|
|
||||||
:style="{
|
|
||||||
height:
|
|
||||||
musicStore.isHasPlayer && statusStore.showPlayBar ? 'calc(100vh - 80px)' : '100vh',
|
|
||||||
}"
|
|
||||||
:content-style="{
|
|
||||||
overflow: 'hidden',
|
|
||||||
height: '100%',
|
|
||||||
padding: '0',
|
|
||||||
}"
|
|
||||||
:native-scrollbar="false"
|
|
||||||
:collapsed="statusStore.menuCollapsed"
|
|
||||||
:collapsed-width="64"
|
|
||||||
:width="240"
|
|
||||||
collapse-mode="width"
|
|
||||||
show-trigger="bar"
|
|
||||||
bordered
|
|
||||||
@collapse="statusStore.menuCollapsed = true"
|
|
||||||
@expand="statusStore.menuCollapsed = false"
|
|
||||||
>
|
|
||||||
<Sider />
|
|
||||||
</n-layout-sider>
|
|
||||||
<n-layout id="main-layout">
|
|
||||||
<!-- 导航栏 -->
|
|
||||||
<Nav id="main-header" />
|
|
||||||
<n-layout
|
|
||||||
ref="contentRef"
|
|
||||||
id="main-content"
|
|
||||||
:native-scrollbar="false"
|
|
||||||
:style="{
|
|
||||||
'--layout-height': contentHeight,
|
|
||||||
}"
|
|
||||||
:content-style="{
|
|
||||||
display: 'grid',
|
|
||||||
gridTemplateRows: '1fr',
|
|
||||||
minHeight: '100%',
|
|
||||||
padding: '0 24px',
|
|
||||||
}"
|
|
||||||
position="absolute"
|
|
||||||
embedded
|
|
||||||
>
|
|
||||||
<!-- 路由页面 -->
|
|
||||||
<RouterView v-slot="{ Component }">
|
|
||||||
<Transition :name="`router-${settingStore.routeAnimation}`" mode="out-in">
|
|
||||||
<KeepAlive :max="20" :exclude="['layout']">
|
|
||||||
<component :is="Component" class="router-view" />
|
|
||||||
</KeepAlive>
|
|
||||||
</Transition>
|
|
||||||
</RouterView>
|
|
||||||
<!-- 回顶 -->
|
|
||||||
<n-back-top :right="40" :bottom="120">
|
|
||||||
<SvgIcon :size="22" name="Up" />
|
|
||||||
</n-back-top>
|
|
||||||
</n-layout>
|
|
||||||
</n-layout>
|
|
||||||
</n-layout>
|
|
||||||
<!-- 播放列表 -->
|
|
||||||
<MainPlayList />
|
|
||||||
<!-- 全局播放器 -->
|
|
||||||
<MainPlayer />
|
|
||||||
<!-- 全屏播放器 -->
|
|
||||||
<Teleport to="body">
|
|
||||||
<Transition name="up" mode="out-in">
|
|
||||||
<FullPlayer
|
|
||||||
v-if="
|
|
||||||
statusStore.showFullPlayer ||
|
|
||||||
(statusStore.fullPlayerActive && settingStore.fullPlayerCache)
|
|
||||||
"
|
|
||||||
/>
|
|
||||||
</Transition>
|
|
||||||
</Teleport>
|
|
||||||
</Provider>
|
</Provider>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { useMusicStore, useStatusStore, useSettingStore } from "@/stores";
|
|
||||||
import init from "@/utils/init";
|
|
||||||
|
|
||||||
const musicStore = useMusicStore();
|
|
||||||
const statusStore = useStatusStore();
|
|
||||||
const settingStore = useSettingStore();
|
|
||||||
|
|
||||||
// 主内容
|
|
||||||
const contentRef = ref<HTMLElement | null>(null);
|
|
||||||
|
|
||||||
// 主内容高度
|
|
||||||
const { height: contentHeight } = useElementSize(contentRef);
|
|
||||||
|
|
||||||
watchEffect(() => {
|
|
||||||
statusStore.mainContentHeight = contentHeight.value;
|
|
||||||
});
|
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
await init();
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
#main {
|
|
||||||
flex: 1;
|
|
||||||
height: 100%;
|
|
||||||
transition:
|
|
||||||
transform 0.3s var(--n-bezier),
|
|
||||||
opacity 0.3s var(--n-bezier);
|
|
||||||
#main-layout {
|
|
||||||
background-color: rgba(var(--background), 0.58);
|
|
||||||
}
|
|
||||||
#main-content {
|
|
||||||
top: 70px;
|
|
||||||
background-color: transparent;
|
|
||||||
transition: bottom 0.3s;
|
|
||||||
.router-view {
|
|
||||||
position: relative;
|
|
||||||
height: 100%;
|
|
||||||
&.n-result {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
&.show-player {
|
|
||||||
// #main-sider {
|
|
||||||
// margin-bottom: 80px;
|
|
||||||
// }
|
|
||||||
#main-content {
|
|
||||||
bottom: 80px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
&.show-full-player {
|
|
||||||
opacity: 0;
|
|
||||||
transform: scale(0.9);
|
|
||||||
#main-header {
|
|
||||||
-webkit-app-region: no-drag;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|||||||
@@ -12,6 +12,16 @@ export const dailyRecommend = (type: "songs" | "resource" = "songs") => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 每日推荐 - 不感兴趣
|
||||||
|
*/
|
||||||
|
export const dailyRecommendDislike = (id: number) => {
|
||||||
|
return request({
|
||||||
|
url: "/recommend/songs/dislike",
|
||||||
|
params: { id, timestamp: Date.now() },
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 推荐内容
|
* 推荐内容
|
||||||
* @param {string} [type] - 推荐类型
|
* @param {string} [type] - 推荐类型
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
import { isElectron } from "@/utils/env";
|
||||||
import { songLevelData } from "@/utils/meta";
|
import { songLevelData } from "@/utils/meta";
|
||||||
|
import { SongUnlockServer } from "@/utils/songManager";
|
||||||
import request from "@/utils/request";
|
import request from "@/utils/request";
|
||||||
|
|
||||||
// 获取歌曲详情
|
// 获取歌曲详情
|
||||||
@@ -46,12 +48,12 @@ export const songUrl = (
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 获取解锁歌曲 URL
|
// 获取解锁歌曲 URL
|
||||||
export const unlockSongUrl = (id: number, keyword: string, server: "netease" | "kuwo") => {
|
export const unlockSongUrl = (id: number, keyword: string, server: SongUnlockServer) => {
|
||||||
const params = server === "netease" ? { id } : { keyword };
|
const params = server === SongUnlockServer.NETEASE ? { id } : { keyword };
|
||||||
return request({
|
return request({
|
||||||
baseURL: "/api/unblock",
|
baseURL: "/api/unblock",
|
||||||
url: `/${server}`,
|
url: `/${server}`,
|
||||||
params,
|
params: { ...params, noCookie: true },
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -65,6 +67,29 @@ export const songLyric = (id: number) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取歌曲 TTML 歌词
|
||||||
|
* @param id 音乐 id
|
||||||
|
* @returns TTML 格式歌词
|
||||||
|
*/
|
||||||
|
export const songLyricTTML = async (id: number) => {
|
||||||
|
if (isElectron) {
|
||||||
|
return request({ url: "/lyric/ttml", params: { id, noCookie: true } });
|
||||||
|
} else {
|
||||||
|
const url = `https://amll-ttml-db.stevexmh.net/ncm/${id}`;
|
||||||
|
try {
|
||||||
|
const response = await fetch(url);
|
||||||
|
if (response === null || response.status !== 200) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const data = await response.text();
|
||||||
|
return data;
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取歌曲下载链接
|
* 获取歌曲下载链接
|
||||||
* @param id 音乐 id
|
* @param id 音乐 id
|
||||||
@@ -114,10 +139,20 @@ export const matchSong = (
|
|||||||
* 歌曲动态封面
|
* 歌曲动态封面
|
||||||
* @param {number} id - 歌曲 id
|
* @param {number} id - 歌曲 id
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export const songDynamicCover = (id: number) => {
|
export const songDynamicCover = (id: number) => {
|
||||||
return request({
|
return request({
|
||||||
url: "/song/dynamic/cover",
|
url: "/song/dynamic/cover",
|
||||||
params: { id },
|
params: { id },
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 副歌时间
|
||||||
|
* @param {number} id - 歌曲 id
|
||||||
|
*/
|
||||||
|
export const songChorus = (id: number) => {
|
||||||
|
return request({
|
||||||
|
url: "/song/chorus",
|
||||||
|
params: { id },
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|||||||
@@ -66,12 +66,13 @@ export const keywords = [
|
|||||||
"缩混",
|
"缩混",
|
||||||
"音乐总监",
|
"音乐总监",
|
||||||
"音乐制作",
|
"音乐制作",
|
||||||
"OP",
|
|
||||||
"SP",
|
|
||||||
"op",
|
|
||||||
"sp",
|
|
||||||
"Talkbox",
|
"Talkbox",
|
||||||
"Producers",
|
"Producers",
|
||||||
"Producer",
|
"Producer",
|
||||||
"Produced",
|
"Produced",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export const regexes = [
|
||||||
|
/^[Oo][Pp]\s*[::]/,
|
||||||
|
/^[Ss][Pp]\s*[::]/,
|
||||||
|
].map((regex) => regex.source);
|
||||||
|
|||||||
@@ -4,6 +4,10 @@
|
|||||||
"id": 3136952023,
|
"id": 3136952023,
|
||||||
"name": "私人雷达"
|
"name": "私人雷达"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": 8402996200,
|
||||||
|
"name": "会员雷达"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": 5320167908,
|
"id": 5320167908,
|
||||||
"name": "时光雷达"
|
"name": "时光雷达"
|
||||||
|
|||||||
18
src/assets/data/lyricConfig.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import type { LyricConfig } from "../../types/desktop-lyric";
|
||||||
|
|
||||||
|
const config: LyricConfig = {
|
||||||
|
isLock: false,
|
||||||
|
playedColor: "#fe7971",
|
||||||
|
unplayedColor: "#ccc",
|
||||||
|
shadowColor: "rgba(0, 0, 0, 0.5)",
|
||||||
|
fontFamily: "system-ui",
|
||||||
|
fontSize: 24,
|
||||||
|
fontIsBold: false,
|
||||||
|
showTran: true,
|
||||||
|
showYrc: true,
|
||||||
|
isDoubleLine: true,
|
||||||
|
position: "both",
|
||||||
|
limitBounds: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default config;
|
||||||
1
src/assets/icons/Close.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><!-- Icon from Material Symbols by Google - https://github.com/google/material-design-icons/blob/master/LICENSE --><path fill="currentColor" d="m12 13.4l-4.9 4.9q-.275.275-.7.275t-.7-.275t-.275-.7t.275-.7l4.9-4.9l-4.9-4.9q-.275-.275-.275-.7t.275-.7t.7-.275t.7.275l4.9 4.9l4.9-4.9q.275-.275.7-.275t.7.275t.275.7t-.275.7L13.4 12l4.9 4.9q.275.275.275.7t-.275.7t-.7.275t-.7-.275z"/></svg>
|
||||||
|
After Width: | Height: | Size: 467 B |
1
src/assets/icons/Collapse.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><!-- Icon from Material Symbols by Google - https://github.com/google/material-design-icons/blob/master/LICENSE --><path fill="currentColor" d="M9 15H6q-.425 0-.712-.288T5 14t.288-.712T6 13h4q.425 0 .713.288T11 14v4q0 .425-.288.713T10 19t-.712-.288T9 18zm6-6h3q.425 0 .713.288T19 10t-.288.713T18 11h-4q-.425 0-.712-.288T13 10V6q0-.425.288-.712T14 5t.713.288T15 6z"/></svg>
|
||||||
|
After Width: | Height: | Size: 455 B |
1
src/assets/icons/Controls.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><!-- Icon from MingCute Icon by MingCute Design - https://github.com/Richard9394/MingCute/blob/main/LICENSE --><g fill="none" fill-rule="evenodd"><path d="m12.593 23.258l-.011.002l-.071.035l-.02.004l-.014-.004l-.071-.035q-.016-.005-.024.005l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.017-.018m.265-.113l-.013.002l-.185.093l-.01.01l-.003.011l.018.43l.005.012l.008.007l.201.093q.019.005.029-.008l.004-.014l-.034-.614q-.005-.018-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.004-.011l.017-.43l-.003-.012l-.01-.01z"/><path fill="currentColor" d="M18 4a1 1 0 1 0-2 0v1H4a1 1 0 0 0 0 2h12v1a1 1 0 1 0 2 0V7h2a1 1 0 1 0 0-2h-2zM4 11a1 1 0 1 0 0 2h2v1a1 1 0 1 0 2 0v-1h12a1 1 0 1 0 0-2H8v-1a1 1 0 0 0-2 0v1zm-1 7a1 1 0 0 1 1-1h12v-1a1 1 0 1 1 2 0v1h2a1 1 0 1 1 0 2h-2v1a1 1 0 1 1-2 0v-1H4a1 1 0 0 1-1-1"/></g></svg>
|
||||||
|
After Width: | Height: | Size: 1.0 KiB |
6
src/assets/icons/DesktopLyric2.svg
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<svg t="1760890100888" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1549"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<path
|
||||||
|
d="M192 240a112 112 0 0 1 111.616 102.784l0.384 9.216V832a16 16 0 0 0 12.352 15.552L320 848h66.816a48 48 0 0 1 6.528 95.552l-6.528 0.448H320a112 112 0 0 1-111.616-102.784L208 832V352a16 16 0 0 0-12.352-15.552L192 336H128a48 48 0 0 1-6.528-95.552L128 240h64z m640-157.568a112 112 0 0 1 111.616 102.848l0.384 9.152V832a112 112 0 0 1-102.784 111.616L832 944h-67.84a48 48 0 0 1-6.464-95.552l6.464-0.448H832a16 16 0 0 0 15.552-12.352L848 832V194.432a16 16 0 0 0-12.352-15.552L832 178.432H480a48 48 0 0 1-6.528-95.552l6.528-0.448H832z m-160 315.136c61.824 0 112 50.112 112 112v147.648a112 112 0 0 1-112 112h-128a112 112 0 0 1-112-112V509.568c0-61.888 50.176-112 112-112z m0 96h-128a16 16 0 0 0-16 16v147.648c0 8.832 7.168 16 16 16h128a16 16 0 0 0 16-16V509.568a16 16 0 0 0-16-16z m64-253.568a48 48 0 0 1 6.528 95.552l-6.528 0.448h-256a48 48 0 0 1-6.528-95.552L480 240h256zM256 82.432a48 48 0 0 1 6.528 95.616L256 178.432H128a48 48 0 0 1-6.528-95.552L128 82.432h128z"
|
||||||
|
fill="currentColor" p-id="1550"></path>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.2 KiB |
1
src/assets/icons/Eq.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><!-- Icon from Material Symbols by Google - https://github.com/google/material-design-icons/blob/master/LICENSE --><path fill="currentColor" d="M7 17V7q0-.425.288-.712T8 6t.713.288T9 7v10q0 .425-.288.713T8 18t-.712-.288T7 17m4 4V3q0-.425.288-.712T12 2t.713.288T13 3v18q0 .425-.288.713T12 22t-.712-.288T11 21m-8-8v-2q0-.425.288-.712T4 10t.713.288T5 11v2q0 .425-.288.713T4 14t-.712-.288T3 13m12 4V7q0-.425.288-.712T16 6t.713.288T17 7v10q0 .425-.288.713T16 18t-.712-.288T15 17m4-4v-2q0-.425.288-.712T20 10t.713.288T21 11v2q0 .425-.288.713T20 14t-.712-.288T19 13"/></svg>
|
||||||
|
After Width: | Height: | Size: 650 B |
1
src/assets/icons/Expand.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><!-- Icon from Material Symbols by Google - https://github.com/google/material-design-icons/blob/master/LICENSE --><path fill="currentColor" d="M7 17h3q.425 0 .713.288T11 18t-.288.713T10 19H6q-.425 0-.712-.288T5 18v-4q0-.425.288-.712T6 13t.713.288T7 14zM17 7h-3q-.425 0-.712-.288T13 6t.288-.712T14 5h4q.425 0 .713.288T19 6v4q0 .425-.288.713T18 11t-.712-.288T17 10z"/></svg>
|
||||||
|
After Width: | Height: | Size: 456 B |
1
src/assets/icons/HeartBroken.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><!-- Icon from Material Symbols by Google - https://github.com/google/material-design-icons/blob/master/LICENSE --><path fill="currentColor" d="M12.025 20.35q-.35 0-.687-.125t-.613-.375Q8 17.45 6.3 15.812t-2.662-2.874t-1.3-2.263T2 8.5q0-2.3 1.6-3.9T7.5 3q1.65 0 2.9.637t.9 1.838l-.925 3.25q-.125.5.163.888t.787.387H13l-.65 6.35q-.025.2.163.225t.237-.15L14.6 10.3q.15-.5-.15-.9t-.8-.4H12l1.525-4.525Q13.8 3.6 14.675 3.3T16.5 3q2.3 0 3.9 1.6T22 8.5q0 1.1-.4 2.175t-1.388 2.375t-2.65 2.938t-4.212 3.862q-.275.25-.625.375t-.7.125"/></svg>
|
||||||
|
After Width: | Height: | Size: 617 B |
4
src/assets/icons/Lock.svg
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24">
|
||||||
|
<path fill="currentColor"
|
||||||
|
d="M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2M9 6c0-1.66 1.34-3 3-3s3 1.34 3 3v2H9zm9 14H6V10h12zm-6-3c1.1 0 2-.9 2-2s-.9-2-2-2s-2 .9-2 2s.9 2 2 2" />
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 349 B |
1
src/assets/icons/LockOpen.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><!-- Icon from Material Symbols by Google - https://github.com/google/material-design-icons/blob/master/LICENSE --><path fill="currentColor" d="M6 20h12V10H6zm6-3q.825 0 1.413-.587T14 15t-.587-1.412T12 13t-1.412.588T10 15t.588 1.413T12 17m-6 3V10zm0 2q-.825 0-1.412-.587T4 20V10q0-.825.588-1.412T6 8h7V6q0-2.075 1.463-3.537T18 1q1.775 0 3.1 1.075t1.75 2.7q.125.425-.162.825T22 6q-.425 0-.7-.175t-.4-.575q-.275-.95-1.062-1.6T18 3q-1.25 0-2.125.875T15 6v2h3q.825 0 1.413.588T20 10v10q0 .825-.587 1.413T18 22z"/></svg>
|
||||||
|
After Width: | Height: | Size: 598 B |
1
src/assets/icons/Logo.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg class="prefix__icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M511.764 131.708A446.146 446.146 0 10957.91 577.854a446.146 446.146 0 00-446.146-446.146zm0 519.76a71.83 71.83 0 1171.83-70.937 72.276 72.276 0 01-71.83 70.937z" fill="#F55E55"/><path d="M802.205.541l-168.197 37.03a67.814 67.814 0 00-53.091 66.03v120.013l3.569 349.779h114.213V223.614h108.86a26.323 26.323 0 0026.769-26.322V26.864A26.769 26.769 0 00802.205.54z" fill="#F9BBB8"/><path d="M511.764 386.457A186.935 186.935 0 10698.7 572.947a186.935 186.935 0 00-186.935-186.49zm0 264.565a71.383 71.383 0 1171.383-71.383 71.383 71.383 0 01-71.383 71.383z" fill="#F9BBB8"/></svg>
|
||||||
|
After Width: | Height: | Size: 693 B |
1
src/assets/icons/PlayRate.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><!-- Icon from Material Symbols by Google - https://github.com/google/material-design-icons/blob/master/LICENSE --><path fill="currentColor" d="M10.45 15.5q.625.625 1.575.588T13.4 15.4L19 7l-8.4 5.6q-.65.45-.712 1.362t.562 1.538M5.1 20q-.55 0-1.012-.238t-.738-.712q-.65-1.175-1-2.437T2 14q0-2.075.788-3.9t2.137-3.175T8.1 4.788T12 4q2.05 0 3.85.775T19 6.888t2.15 3.125t.825 3.837q.025 1.375-.312 2.688t-1.038 2.512q-.275.475-.737.713T18.874 20z"/></svg>
|
||||||
|
After Width: | Height: | Size: 535 B |
1
src/assets/icons/QQ.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><!-- Icon from Remix Icon by Remix Design - https://github.com/Remix-Design/RemixIcon/blob/master/License --><path fill="currentColor" d="M19.914 14.529a32 32 0 0 0-.676-1.886l-.91-2.246c.002-.026.013-.468.013-.696C18.34 5.86 16.508 2 12 2S5.66 5.86 5.66 9.7c0 .229.011.671.012.697l-.91 2.246a32 32 0 0 0-.675 1.886c-.86 2.737-.581 3.87-.369 3.895c.455.054 1.771-2.06 1.771-2.06c0 1.224.637 2.822 2.016 3.976c-.515.157-1.147.399-1.554.695c-.365.267-.319.54-.253.65c.289.481 4.955.307 6.303.157c1.347.15 6.014.324 6.302-.158c.066-.11.112-.382-.253-.649c-.407-.296-1.039-.538-1.555-.695c1.379-1.154 2.016-2.752 2.016-3.977c0 0 1.316 2.115 1.771 2.06c.212-.025.49-1.157-.37-3.894"/></svg>
|
||||||
|
After Width: | Height: | Size: 768 B |
4
src/assets/icons/TextSizeAdd.svg
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24">
|
||||||
|
<path fill="currentColor"
|
||||||
|
d="M8.5 7h2L16 21h-2.4l-1.1-3H6.3l-1.1 3H3zm-1.4 9h4.8L9.5 9.7zM22 5v2h-3v3h-2V7h-3V5h3V2h2v3z" />
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 227 B |
3
src/assets/icons/TextSizeReduce.svg
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24">
|
||||||
|
<path fill="currentColor" d="M10.5 7h-2L3 21h2.2l1.1-3h6.2l1.1 3H16zm-3.4 9l2.4-6.3l2.4 6.3zM22 7h-8V5h8z" />
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 204 B |
1
src/assets/icons/TimeAuto.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><!-- Icon from Material Symbols by Google - https://github.com/google/material-design-icons/blob/master/LICENSE --><path fill="currentColor" d="M10.425 15.25h3.1l.375 1.15q.1.275.325.438t.5.162q.475 0 .738-.387t.112-.813l-2.35-6.625q-.1-.275-.35-.45t-.55-.175h-.65q-.3 0-.55.175t-.35.45L8.4 15.85q-.15.425.113.788t.712.362q.275 0 .5-.162t.325-.438zm.475-1.45l1.1-3.3l1.075 3.3zM10 3q-.425 0-.712-.288T9 2t.288-.712T10 1h4q.425 0 .713.288T15 2t-.288.713T14 3zm2 19q-1.85 0-3.488-.712T5.65 19.35t-1.937-2.863T3 13t.713-3.488T5.65 6.65t2.863-1.937T12 4q1.55 0 2.975.5t2.675 1.45l.7-.7q.275-.275.7-.275t.7.275t.275.7t-.275.7l-.7.7Q20 8.6 20.5 10.025T21 13q0 1.85-.713 3.488T18.35 19.35t-2.863 1.938T12 22"/></svg>
|
||||||
|
After Width: | Height: | Size: 792 B |
@@ -43,26 +43,33 @@
|
|||||||
</n-ellipsis>
|
</n-ellipsis>
|
||||||
<!-- 音质 -->
|
<!-- 音质 -->
|
||||||
<n-tag
|
<n-tag
|
||||||
v-if="song?.path && song?.quality"
|
v-if="song?.quality && settingStore.showSongQuality"
|
||||||
:bordered="false"
|
:type="qualityColor"
|
||||||
:type="song.quality === 'Hi-Res' ? 'warning' : 'info'"
|
|
||||||
class="quality"
|
class="quality"
|
||||||
round
|
round
|
||||||
>
|
>
|
||||||
{{ song.quality }}
|
{{ song.quality }}
|
||||||
</n-tag>
|
</n-tag>
|
||||||
|
<!-- 原唱翻唱 -->
|
||||||
|
<template>
|
||||||
|
<n-tag v-if="song.originCoverType === 1" :bordered="false" type="primary" round>
|
||||||
|
原
|
||||||
|
</n-tag>
|
||||||
|
<n-tag v-if="song.originCoverType === 2" :bordered="false" type="info" round>
|
||||||
|
翻唱
|
||||||
|
</n-tag>
|
||||||
|
</template>
|
||||||
<!-- 特权 -->
|
<!-- 特权 -->
|
||||||
<n-tag v-if="song.originCoverType === 1" :bordered="false" type="primary" round>
|
<template v-if="settingStore.showSongPrivilegeTag">
|
||||||
原
|
<n-tag v-if="song.free === 1" :bordered="false" type="error" round> VIP </n-tag>
|
||||||
</n-tag>
|
<n-tag v-if="song.free === 4" :bordered="false" type="error" round> EP </n-tag>
|
||||||
<n-tag v-if="song.free === 1" :bordered="false" type="error" round> VIP </n-tag>
|
<!-- 云盘 -->
|
||||||
<n-tag v-if="song.free === 4" :bordered="false" type="error" round> EP </n-tag>
|
<n-tag v-if="song?.pc" :bordered="false" class="cloud" type="info" round>
|
||||||
<!-- 云盘 -->
|
<template #icon>
|
||||||
<n-tag v-if="song?.pc" :bordered="false" class="cloud" type="info" round>
|
<SvgIcon name="Cloud" />
|
||||||
<template #icon>
|
</template>
|
||||||
<SvgIcon name="Cloud" />
|
</n-tag>
|
||||||
</template>
|
</template>
|
||||||
</n-tag>
|
|
||||||
<!-- MV -->
|
<!-- MV -->
|
||||||
<n-tag
|
<n-tag
|
||||||
v-if="song?.mv"
|
v-if="song?.mv"
|
||||||
@@ -98,7 +105,7 @@
|
|||||||
<n-text class="ar"> {{ song.artists || "未知艺术家" }} </n-text>
|
<n-text class="ar"> {{ song.artists || "未知艺术家" }} </n-text>
|
||||||
</div>
|
</div>
|
||||||
<!-- 别名 -->
|
<!-- 别名 -->
|
||||||
<n-text v-if="song.alia" class="alia" depth="3">{{ song.alia }}</n-text>
|
<n-text v-if="song.alia" class="alia text-hidden" depth="3">{{ song.alia }}</n-text>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- 专辑 -->
|
<!-- 专辑 -->
|
||||||
@@ -148,14 +155,15 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { SongType } from "@/types/main";
|
import { QualityType, type SongType } from "@/types/main";
|
||||||
import { useStatusStore, useMusicStore, useDataStore } from "@/stores";
|
import { useStatusStore, useMusicStore, useDataStore, useSettingStore } from "@/stores";
|
||||||
import { formatNumber, isElectron } from "@/utils/helper";
|
import { formatNumber } from "@/utils/helper";
|
||||||
import { openJumpArtist } from "@/utils/modal";
|
import { openJumpArtist } from "@/utils/modal";
|
||||||
import { toLikeSong } from "@/utils/auth";
|
import { toLikeSong } from "@/utils/auth";
|
||||||
import { isObject } from "lodash-es";
|
import { isObject } from "lodash-es";
|
||||||
import { formatTimestamp, msToTime } from "@/utils/time";
|
import { formatTimestamp, msToTime } from "@/utils/time";
|
||||||
import player from "@/utils/player";
|
import { usePlayer } from "@/utils/player";
|
||||||
|
import { isElectron } from "@/utils/env";
|
||||||
import blob from "@/utils/blob";
|
import blob from "@/utils/blob";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
@@ -170,13 +178,23 @@ const props = defineProps<{
|
|||||||
}>();
|
}>();
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const player = usePlayer();
|
||||||
const dataStore = useDataStore();
|
const dataStore = useDataStore();
|
||||||
const musicStore = useMusicStore();
|
const musicStore = useMusicStore();
|
||||||
const statusStore = useStatusStore();
|
const statusStore = useStatusStore();
|
||||||
|
const settingStore = useSettingStore();
|
||||||
|
|
||||||
// 歌曲数据
|
// 歌曲数据
|
||||||
const song = toRef(props, "song");
|
const song = toRef(props, "song");
|
||||||
|
|
||||||
|
// 音质颜色
|
||||||
|
const qualityColor = computed(() => {
|
||||||
|
if (song.value.quality === QualityType.HiRes) return "warning";
|
||||||
|
if (song.value.quality === QualityType.SQ) return "warning";
|
||||||
|
if (song.value.quality === QualityType.HQ) return "info";
|
||||||
|
return "primary";
|
||||||
|
});
|
||||||
|
|
||||||
// 加载本地歌曲封面
|
// 加载本地歌曲封面
|
||||||
const localCover = async (show: boolean) => {
|
const localCover = async (show: boolean) => {
|
||||||
if (!isElectron || !show || !song.value.path) return;
|
if (!isElectron || !show || !song.value.path) return;
|
||||||
@@ -204,10 +222,10 @@ const localCover = async (show: boolean) => {
|
|||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
border: 2px solid rgba(var(--primary), 0.12);
|
border: 2px solid rgba(var(--primary), 0.12);
|
||||||
background-color: var(--surface-container-hex);
|
background-color: var(--surface-container-hex);
|
||||||
transition:
|
// transition:
|
||||||
transform 0.1s,
|
// transform 0.1s,
|
||||||
background-color 0.3s var(--n-bezier),
|
// background-color 0.3s var(--n-bezier),
|
||||||
border-color 0.3s var(--n-bezier);
|
// border-color 0.3s var(--n-bezier);
|
||||||
&.play {
|
&.play {
|
||||||
border-color: rgba(var(--primary), 0.58);
|
border-color: rgba(var(--primary), 0.58);
|
||||||
background-color: rgba(var(--primary), 0.28);
|
background-color: rgba(var(--primary), 0.28);
|
||||||
@@ -253,6 +271,9 @@ const localCover = async (show: boolean) => {
|
|||||||
transition:
|
transition:
|
||||||
opacity 0.3s,
|
opacity 0.3s,
|
||||||
transform 0.3s;
|
transform 0.3s;
|
||||||
|
:deep(.svg-container) {
|
||||||
|
color: var(--primary-hex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.status,
|
.status,
|
||||||
.play {
|
.play {
|
||||||
|
|||||||
@@ -49,8 +49,12 @@ const settingStore = useSettingStore();
|
|||||||
// 操作系统主题
|
// 操作系统主题
|
||||||
const osTheme = useOsTheme();
|
const osTheme = useOsTheme();
|
||||||
|
|
||||||
// 全局主题
|
// 全局主题(使用 shallowRef 避免深层追踪开销)
|
||||||
const themeOverrides = ref<GlobalThemeOverrides>({});
|
const themeOverrides = shallowRef<GlobalThemeOverrides>({});
|
||||||
|
// 轻量的 rgba 构造器
|
||||||
|
const toRGBA = (rgb: string, alpha: number) => `rgba(${rgb}, ${alpha})`;
|
||||||
|
// 主题缓存键
|
||||||
|
let lastThemeCacheKey: string | null = null;
|
||||||
|
|
||||||
// 获取明暗模式
|
// 获取明暗模式
|
||||||
const theme = computed(() => {
|
const theme = computed(() => {
|
||||||
@@ -88,121 +92,136 @@ const changeGlobalTheme = () => {
|
|||||||
themeOverrides.value = {};
|
themeOverrides.value = {};
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 修改主题
|
// 构造主题缓存 Key
|
||||||
themeOverrides.value = settingStore.themeGlobalColor
|
const themeModeLabel = theme.value ? "dark" : "light";
|
||||||
? {
|
const themeCacheKey = `${themeModeLabel}|${settingStore.themeGlobalColor ? 1 : 0}|${settingStore.globalFont}|${colorSchemes.primary}|${colorSchemes.background}|${colorSchemes["surface-container"]}`;
|
||||||
common: {
|
if (lastThemeCacheKey === themeCacheKey) return;
|
||||||
fontFamily: `${settingStore.globalFont === "default" ? "v-sans" : settingStore.globalFont}, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"`,
|
lastThemeCacheKey = themeCacheKey;
|
||||||
primaryColor: `rgb(${colorSchemes.primary})`,
|
|
||||||
primaryColorHover: `rgba(${colorSchemes.primary}, 0.78)`,
|
// 关键颜色
|
||||||
primaryColorPressed: `rgba(${colorSchemes.primary}, 0.26)`,
|
const primaryRGB = colorSchemes.primary as string;
|
||||||
primaryColorSuppl: `rgba(${colorSchemes.primary}, 0.12)`,
|
const surfaceContainerRGB = colorSchemes["surface-container"] as string;
|
||||||
textColorBase: colorSchemes.primary,
|
|
||||||
textColor1: `rgb(${colorSchemes.primary})`,
|
// 全局字体
|
||||||
textColor2: `rgba(${colorSchemes.primary}, 0.82)`,
|
const fontFamily = `${settingStore.globalFont === "default" ? "v-sans" : settingStore.globalFont}, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"`;
|
||||||
textColor3: `rgba(${colorSchemes.primary}, 0.52)`,
|
|
||||||
bodyColor: `rgb(${colorSchemes.background})`,
|
// 通用样式基座
|
||||||
cardColor: `rgb(${colorSchemes["surface-container"]})`,
|
const commonBase = {
|
||||||
tagColor: `rgb(${colorSchemes["surface-container"]})`,
|
fontFamily,
|
||||||
modalColor: `rgb(${colorSchemes["surface-container"]})`,
|
primaryColor: `rgb(${primaryRGB})`,
|
||||||
popoverColor: `rgb(${colorSchemes["surface-container"]})`,
|
primaryColorHover: toRGBA(primaryRGB, 0.78),
|
||||||
buttonColor2: `rgba(${colorSchemes.primary}, 0.08)`,
|
primaryColorPressed: toRGBA(primaryRGB, 0.26),
|
||||||
buttonColor2Hover: `rgba(${colorSchemes.primary}, 0.12)`,
|
primaryColorSuppl: toRGBA(primaryRGB, 0.12),
|
||||||
buttonColor2Pressed: `rgba(${colorSchemes.primary}, 0.08)`,
|
} as GlobalThemeOverrides["common"];
|
||||||
iconColor: `rgb(${colorSchemes.primary})`,
|
|
||||||
iconColorHover: `rgba(${colorSchemes.primary}, 0.475)`,
|
if (settingStore.themeGlobalColor) {
|
||||||
closeIconColor: `rgba(${colorSchemes.primary}, 0.58)`,
|
themeOverrides.value = {
|
||||||
hoverColor: `rgba(${colorSchemes.primary}, 0.09)`,
|
common: {
|
||||||
borderColor: `rgba(${colorSchemes.primary}, 0.09)`,
|
...commonBase,
|
||||||
textColorDisabled: `rgba(${colorSchemes.primary}, 0.3)`,
|
textColorBase: primaryRGB,
|
||||||
placeholderColorDisabled: `rgba(${colorSchemes.primary}, 0.3)`,
|
textColor1: `rgb(${primaryRGB})`,
|
||||||
iconColorDisabled: `rgba(${colorSchemes.primary}, 0.3)`,
|
textColor2: toRGBA(primaryRGB, 0.82),
|
||||||
},
|
textColor3: toRGBA(primaryRGB, 0.52),
|
||||||
Card: {
|
bodyColor: `rgb(${colorSchemes.background})`,
|
||||||
borderColor: `rgba(${colorSchemes.primary}, 0.09)`,
|
cardColor: `rgb(${surfaceContainerRGB})`,
|
||||||
},
|
tagColor: `rgb(${surfaceContainerRGB})`,
|
||||||
Button: {
|
modalColor: `rgb(${surfaceContainerRGB})`,
|
||||||
textColorHover: `rgba(${colorSchemes.primary}, 0.78)`,
|
popoverColor: `rgb(${surfaceContainerRGB})`,
|
||||||
textColorFocus: `rgba(${colorSchemes.primary}, 0.58)`,
|
buttonColor2: toRGBA(primaryRGB, 0.08),
|
||||||
colorPrimary: `rgba(${colorSchemes.primary}, 0.9)`,
|
buttonColor2Hover: toRGBA(primaryRGB, 0.12),
|
||||||
colorHoverPrimary: `rgb(${colorSchemes.primary})`,
|
buttonColor2Pressed: toRGBA(primaryRGB, 0.08),
|
||||||
colorPressedPrimary: `rgba(${colorSchemes.primary}, 0.8)`,
|
iconColor: `rgb(${primaryRGB})`,
|
||||||
colorFocusPrimary: `rgb(${colorSchemes.primary})`,
|
iconColorHover: toRGBA(primaryRGB, 0.475),
|
||||||
},
|
closeIconColor: toRGBA(primaryRGB, 0.58),
|
||||||
Slider: {
|
hoverColor: toRGBA(primaryRGB, 0.09),
|
||||||
handleColor: `rgb(${colorSchemes.primary})`,
|
borderColor: toRGBA(primaryRGB, 0.09),
|
||||||
fillColor: `rgb(${colorSchemes.primary})`,
|
textColorDisabled: toRGBA(primaryRGB, 0.3),
|
||||||
fillColorHover: `rgb(${colorSchemes.primary})`,
|
placeholderColorDisabled: toRGBA(primaryRGB, 0.3),
|
||||||
railColor: `rgba(${colorSchemes.primary}, 0.2)`,
|
iconColorDisabled: toRGBA(primaryRGB, 0.3),
|
||||||
railColorHover: `rgba(${colorSchemes.primary}, 0.3)`,
|
},
|
||||||
},
|
Card: {
|
||||||
Switch: {
|
borderColor: toRGBA(primaryRGB, 0.09),
|
||||||
railColorActive: `rgba(${colorSchemes.primary}, 0.8)`,
|
},
|
||||||
},
|
Button: {
|
||||||
Input: {
|
textColorHover: toRGBA(primaryRGB, 0.78),
|
||||||
color: `rgba(${colorSchemes.primary}, 0.1)`,
|
textColorFocus: toRGBA(primaryRGB, 0.58),
|
||||||
colorFocus: `rgb(${colorSchemes["surface-container"]})`,
|
colorPrimary: toRGBA(primaryRGB, 0.9),
|
||||||
placeholderColor: `rgba(${colorSchemes.primary}, 0.58)`,
|
colorHoverPrimary: `rgb(${primaryRGB})`,
|
||||||
border: `1px solid rgba(${colorSchemes.primary}, 0.1)`,
|
colorPressedPrimary: toRGBA(primaryRGB, 0.8),
|
||||||
clearColor: `rgba(${colorSchemes.primary}, 0.38)`,
|
colorFocusPrimary: `rgb(${primaryRGB})`,
|
||||||
clearColorHover: `rgba(${colorSchemes.primary}, 0.48)`,
|
},
|
||||||
clearColorPressed: `rgba(${colorSchemes.primary}, 0.3)`,
|
Slider: {
|
||||||
},
|
handleColor: `rgb(${primaryRGB})`,
|
||||||
Icon: {
|
fillColor: `rgb(${primaryRGB})`,
|
||||||
color: `rgb(${colorSchemes.primary})`,
|
fillColorHover: `rgb(${primaryRGB})`,
|
||||||
},
|
railColor: toRGBA(primaryRGB, 0.2),
|
||||||
Empty: {
|
railColorHover: toRGBA(primaryRGB, 0.3),
|
||||||
textColor: `rgba(${colorSchemes.primary}, 0.38)`,
|
},
|
||||||
},
|
Switch: {
|
||||||
Divider: {
|
railColorActive: toRGBA(primaryRGB, 0.8),
|
||||||
color: `rgba(${colorSchemes.primary}, 0.09)`,
|
},
|
||||||
},
|
Input: {
|
||||||
Dropdown: {
|
color: toRGBA(primaryRGB, 0.1),
|
||||||
dividerColor: `rgba(${colorSchemes.primary}, 0.09)`,
|
colorFocus: `rgb(${surfaceContainerRGB})`,
|
||||||
},
|
placeholderColor: toRGBA(primaryRGB, 0.58),
|
||||||
Layout: {
|
border: `1px solid ${toRGBA(primaryRGB, 0.1)}`,
|
||||||
siderBorderColor: `rgba(${colorSchemes.primary}, 0.09)`,
|
clearColor: toRGBA(primaryRGB, 0.38),
|
||||||
},
|
clearColorHover: toRGBA(primaryRGB, 0.48),
|
||||||
Tabs: {
|
clearColorPressed: toRGBA(primaryRGB, 0.3),
|
||||||
colorSegment: `rgba(${colorSchemes.primary}, 0.08)`,
|
},
|
||||||
tabColorSegment: `rgba(${colorSchemes.primary}, 0.12)`,
|
Icon: {
|
||||||
},
|
color: `rgb(${primaryRGB})`,
|
||||||
Drawer: {
|
},
|
||||||
headerBorderBottom: `1px solid rgba(${colorSchemes.primary}, 0.09)`,
|
Empty: {
|
||||||
footerBorderTop: `1px solid rgba(${colorSchemes.primary}, 0.09)`,
|
textColor: toRGBA(primaryRGB, 0.38),
|
||||||
},
|
},
|
||||||
Menu: {
|
Divider: {
|
||||||
dividerColor: `rgba(${colorSchemes.primary}, 0.09)`,
|
color: toRGBA(primaryRGB, 0.09),
|
||||||
},
|
},
|
||||||
Progress: {
|
Dropdown: {
|
||||||
railColor: `rgba(${colorSchemes.primary}, 0.16)`,
|
dividerColor: toRGBA(primaryRGB, 0.09),
|
||||||
},
|
},
|
||||||
Popover: {
|
Layout: {
|
||||||
color: `rgb(${colorSchemes["surface-container"]})`,
|
siderBorderColor: toRGBA(primaryRGB, 0.09),
|
||||||
},
|
},
|
||||||
}
|
Tabs: {
|
||||||
: {
|
colorSegment: toRGBA(primaryRGB, 0.08),
|
||||||
common: {
|
tabColorSegment: toRGBA(primaryRGB, 0.12),
|
||||||
fontFamily: `${settingStore.globalFont === "default" ? "v-sans" : settingStore.globalFont}, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"`,
|
},
|
||||||
primaryColor: `rgb(${colorSchemes.primary})`,
|
Drawer: {
|
||||||
primaryColorHover: `rgba(${colorSchemes.primary}, 0.78)`,
|
headerBorderBottom: `1px solid ${toRGBA(primaryRGB, 0.09)}`,
|
||||||
primaryColorPressed: `rgba(${colorSchemes.primary}, 0.26)`,
|
footerBorderTop: `1px solid ${toRGBA(primaryRGB, 0.09)}`,
|
||||||
primaryColorSuppl: `rgba(${colorSchemes.primary}, 0.12)`,
|
},
|
||||||
},
|
Menu: {
|
||||||
Icon: {
|
dividerColor: toRGBA(primaryRGB, 0.09),
|
||||||
color: `rgb(${colorSchemes.primary})`,
|
},
|
||||||
},
|
Progress: {
|
||||||
Slider: {
|
railColor: toRGBA(primaryRGB, 0.16),
|
||||||
handleColor: `rgb(${colorSchemes.primary})`,
|
},
|
||||||
fillColor: `rgb(${colorSchemes.primary})`,
|
Popover: {
|
||||||
fillColorHover: `rgb(${colorSchemes.primary})`,
|
color: `rgb(${surfaceContainerRGB})`,
|
||||||
railColor: `rgba(${colorSchemes.primary}, 0.2)`,
|
},
|
||||||
railColorHover: `rgba(${colorSchemes.primary}, 0.3)`,
|
};
|
||||||
},
|
} else {
|
||||||
Popover: {
|
themeOverrides.value = {
|
||||||
color: `rgb(${colorSchemes["surface-container"]})`,
|
common: {
|
||||||
},
|
...commonBase,
|
||||||
};
|
},
|
||||||
|
Icon: {
|
||||||
|
color: `rgb(${primaryRGB})`,
|
||||||
|
},
|
||||||
|
Slider: {
|
||||||
|
handleColor: `rgb(${primaryRGB})`,
|
||||||
|
fillColor: `rgb(${primaryRGB})`,
|
||||||
|
fillColorHover: `rgb(${primaryRGB})`,
|
||||||
|
railColor: toRGBA(primaryRGB, 0.2),
|
||||||
|
railColorHover: toRGBA(primaryRGB, 0.3),
|
||||||
|
},
|
||||||
|
Popover: {
|
||||||
|
color: `rgb(${surfaceContainerRGB})`,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
themeOverrides.value = {};
|
themeOverrides.value = {};
|
||||||
console.error("切换主题色出现错误:", error);
|
console.error("切换主题色出现错误:", error);
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
<!-- 全局图标 -->
|
<!-- 全局图标 -->
|
||||||
<template>
|
<template>
|
||||||
<n-icon v-if="name" :size="size" :color="color" :depth="depth">
|
<n-icon v-if="name" :size="size" :color="color" :depth="depth">
|
||||||
<div ref="svgContainer" class="svg-container" />
|
<div
|
||||||
|
ref="svgContainer"
|
||||||
|
:style="{ transform: offset ? `translateY(${offset}px)` : undefined }"
|
||||||
|
class="svg-container"
|
||||||
|
/>
|
||||||
</n-icon>
|
</n-icon>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -10,6 +14,7 @@ const props = defineProps<{
|
|||||||
name: string;
|
name: string;
|
||||||
size?: string | number;
|
size?: string | number;
|
||||||
color?: string;
|
color?: string;
|
||||||
|
offset?: number;
|
||||||
depth?: 1 | 2 | 3 | 4 | 5;
|
depth?: 1 | 2 | 3 | 4 | 5;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
|||||||
@@ -28,14 +28,16 @@ const isTextOverflowing = ref(false);
|
|||||||
|
|
||||||
// 容器宽度
|
// 容器宽度
|
||||||
const { width: textContainerWidth } = useElementSize(textContainerRef);
|
const { width: textContainerWidth } = useElementSize(textContainerRef);
|
||||||
|
// 文本宽度
|
||||||
|
const { width: textWidth } = useElementSize(textRef);
|
||||||
|
|
||||||
// 检查文本是否超出宽度
|
// 检查文本是否超出宽度
|
||||||
const checkTextWidth = () => {
|
const checkTextWidth = () => {
|
||||||
if (textRef.value && textContainerRef.value) {
|
if (textRef.value && textContainerRef.value) {
|
||||||
const textWidth = textRef.value.offsetWidth;
|
const currentTextWidth = textRef.value.offsetWidth;
|
||||||
const containerWidth = textContainerWidth.value;
|
const currentContainerWidth = textContainerWidth.value;
|
||||||
// 判断阈值
|
// 判断阈值
|
||||||
isTextOverflowing.value = textWidth > containerWidth + 2;
|
isTextOverflowing.value = currentTextWidth > currentContainerWidth + 2;
|
||||||
}
|
}
|
||||||
// 更新状态
|
// 更新状态
|
||||||
updateScroll();
|
updateScroll();
|
||||||
@@ -56,6 +58,8 @@ let scrollTimeoutId: ReturnType<typeof setTimeout> | null = null;
|
|||||||
|
|
||||||
// 开始滚动
|
// 开始滚动
|
||||||
const startScrolling = () => {
|
const startScrolling = () => {
|
||||||
|
// 先停止之前的滚动
|
||||||
|
stopScrolling();
|
||||||
if (!textRef.value || !textContainerRef.value || !scrollWrapperRef.value || !textCloneRef.value)
|
if (!textRef.value || !textContainerRef.value || !scrollWrapperRef.value || !textCloneRef.value)
|
||||||
return;
|
return;
|
||||||
// 设置滚动速度( 单位:像素/帧 )
|
// 设置滚动速度( 单位:像素/帧 )
|
||||||
@@ -97,7 +101,7 @@ const stopScrolling = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => [props.text, textContainerWidth.value, textCloneRef.value],
|
() => [props.text, textContainerWidth.value, textWidth.value, textCloneRef.value],
|
||||||
() => {
|
() => {
|
||||||
nextTick(checkTextWidth);
|
nextTick(checkTextWidth);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -29,13 +29,15 @@ import {
|
|||||||
import type { CoverType } from "@/types/main";
|
import type { CoverType } from "@/types/main";
|
||||||
import { useStatusStore, useSettingStore, useDataStore, useMusicStore } from "@/stores";
|
import { useStatusStore, useSettingStore, useDataStore, useMusicStore } from "@/stores";
|
||||||
import { useRouter, RouterLink } from "vue-router";
|
import { useRouter, RouterLink } from "vue-router";
|
||||||
import { isElectron, renderIcon } from "@/utils/helper";
|
import { renderIcon } from "@/utils/helper";
|
||||||
import { openCreatePlaylist } from "@/utils/modal";
|
import { openCreatePlaylist } from "@/utils/modal";
|
||||||
import { debounce } from "lodash-es";
|
import { debounce } from "lodash-es";
|
||||||
import { isLogin } from "@/utils/auth";
|
import { isLogin } from "@/utils/auth";
|
||||||
import player from "@/utils/player";
|
import { isElectron } from "@/utils/env";
|
||||||
|
import { usePlayer } from "@/utils/player";
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const player = usePlayer();
|
||||||
const dataStore = useDataStore();
|
const dataStore = useDataStore();
|
||||||
const musicStore = useMusicStore();
|
const musicStore = useMusicStore();
|
||||||
const statusStore = useStatusStore();
|
const statusStore = useStatusStore();
|
||||||
@@ -122,7 +124,7 @@ const menuOptions = computed<MenuOption[] | MenuGroupOption[]>(() => {
|
|||||||
key: "cloud",
|
key: "cloud",
|
||||||
link: "cloud",
|
link: "cloud",
|
||||||
label: "我的云盘",
|
label: "我的云盘",
|
||||||
show: isElectron && dataStore.loginType !== "uid",
|
show: isLogin() === 1,
|
||||||
icon: renderIcon("Cloud"),
|
icon: renderIcon("Cloud"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -176,11 +178,20 @@ const menuOptions = computed<MenuOption[] | MenuGroupOption[]>(() => {
|
|||||||
children: [...likedPlaylist.value],
|
children: [...likedPlaylist.value],
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
: [];
|
: [
|
||||||
|
{
|
||||||
|
key: "local",
|
||||||
|
link: "local",
|
||||||
|
label: "本地歌曲",
|
||||||
|
show: isElectron,
|
||||||
|
icon: renderIcon("FolderMusic"),
|
||||||
|
},
|
||||||
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
// 生成歌单列表
|
// 生成歌单列表
|
||||||
const renderPlaylist = (playlist: CoverType[], showCover: boolean) => {
|
const renderPlaylist = (playlist: CoverType[], showCover: boolean) => {
|
||||||
|
if (!isLogin()) return [];
|
||||||
return playlist.map((playlist) => ({
|
return playlist.map((playlist) => ({
|
||||||
key: playlist.id,
|
key: playlist.id,
|
||||||
label: () =>
|
label: () =>
|
||||||
|
|||||||
@@ -91,8 +91,10 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { DropdownOption } from "naive-ui";
|
import type { DropdownOption } from "naive-ui";
|
||||||
import { useSettingStore } from "@/stores";
|
import { useSettingStore } from "@/stores";
|
||||||
import { isElectron, isDev, renderIcon } from "@/utils/helper";
|
import { openLink, renderIcon } from "@/utils/helper";
|
||||||
import { openSetting } from "@/utils/modal";
|
import { openSetting } from "@/utils/modal";
|
||||||
|
import { isDev, isElectron } from "@/utils/env";
|
||||||
|
import packageJson from "@/../package.json";
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const settingStore = useSettingStore();
|
const settingStore = useSettingStore();
|
||||||
@@ -110,10 +112,8 @@ const min = () => window.electron.ipcRenderer.send("win-min");
|
|||||||
// 最大化或还原
|
// 最大化或还原
|
||||||
const maxOrRes = () => {
|
const maxOrRes = () => {
|
||||||
if (window.electron.ipcRenderer.sendSync("win-state")) {
|
if (window.electron.ipcRenderer.sendSync("win-state")) {
|
||||||
isMax.value = false;
|
|
||||||
window.electron.ipcRenderer.send("win-restore");
|
window.electron.ipcRenderer.send("win-restore");
|
||||||
} else {
|
} else {
|
||||||
isMax.value = true;
|
|
||||||
window.electron.ipcRenderer.send("win-max");
|
window.electron.ipcRenderer.send("win-max");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -125,7 +125,7 @@ const hideOrClose = (action: "hide" | "exit") => {
|
|||||||
settingStore.closeAppMethod = action;
|
settingStore.closeAppMethod = action;
|
||||||
}
|
}
|
||||||
showCloseModal.value = false;
|
showCloseModal.value = false;
|
||||||
window.electron.ipcRenderer.send(action === "hide" ? "win-hide" : "win-close");
|
window.electron.ipcRenderer.send(action === "hide" ? "win-hide" : "quit-app");
|
||||||
};
|
};
|
||||||
|
|
||||||
// 尝试关闭软件
|
// 尝试关闭软件
|
||||||
@@ -156,7 +156,30 @@ const setOptions = computed<DropdownOption[]>(() => [
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "header-divider",
|
key: "divider-1",
|
||||||
|
type: "divider",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// 交流群
|
||||||
|
key: "qq",
|
||||||
|
label: "加入交流群",
|
||||||
|
props: {
|
||||||
|
onClick: () =>
|
||||||
|
openLink(
|
||||||
|
"https://qm.qq.com/cgi-bin/qm/qr?k=2-cVSf1bE0AvAehCib00qFEFdUvPaJ_k&jump_from=webapi&authKey=1NEhib9+GsmsXVo2rCc0IbRaVHeeRXJJ0gbsyKDcIwDdAzYySOubkFCvkV32+7Cw",
|
||||||
|
),
|
||||||
|
},
|
||||||
|
icon: renderIcon("QQ"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// 交流群
|
||||||
|
key: "github",
|
||||||
|
label: "开源仓库",
|
||||||
|
props: { onClick: () => openLink(packageJson.github) },
|
||||||
|
icon: renderIcon("Github"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "divider-2",
|
||||||
type: "divider",
|
type: "divider",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -198,9 +221,12 @@ const setSelect = (key: string) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
// 获取窗口状态
|
// 获取窗口状态并监听主进程的状态变更
|
||||||
if (isElectron) {
|
if (isElectron) {
|
||||||
isMax.value = window.electron.ipcRenderer.sendSync("win-state");
|
isMax.value = window.electron.ipcRenderer.sendSync("win-state");
|
||||||
|
window.electron.ipcRenderer.on("win-state-change", (_event, value: boolean) => {
|
||||||
|
isMax.value = value;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -218,6 +218,9 @@ const likeComment = debounce(async (data: CommentType) => {
|
|||||||
color: var(--primary-hex);
|
color: var(--primary-hex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.text {
|
||||||
|
white-space: pre-wrap;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.reply {
|
.reply {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@@ -226,6 +229,9 @@ const likeComment = debounce(async (data: CommentType) => {
|
|||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
margin-top: 6px;
|
margin-top: 6px;
|
||||||
background-color: rgba(var(--primary), 0.12);
|
background-color: rgba(var(--primary), 0.12);
|
||||||
|
.text {
|
||||||
|
white-space: pre-wrap;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.meta {
|
.meta {
|
||||||
padding-top: 12px;
|
padding-top: 12px;
|
||||||
|
|||||||
@@ -121,8 +121,8 @@ import { formatSongsList } from "@/utils/format";
|
|||||||
import { songDetail } from "@/api/song";
|
import { songDetail } from "@/api/song";
|
||||||
import { playlistAllSongs } from "@/api/playlist";
|
import { playlistAllSongs } from "@/api/playlist";
|
||||||
import { radioAllProgram } from "@/api/radio";
|
import { radioAllProgram } from "@/api/radio";
|
||||||
|
import { usePlayer } from "@/utils/player";
|
||||||
import CoverMenu from "@/components/Menu/CoverMenu.vue";
|
import CoverMenu from "@/components/Menu/CoverMenu.vue";
|
||||||
import player from "@/utils/player";
|
|
||||||
import { formatTimestamp } from "@/utils/time";
|
import { formatTimestamp } from "@/utils/time";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -145,6 +145,7 @@ const emit = defineEmits<{
|
|||||||
}>();
|
}>();
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const player = usePlayer();
|
||||||
const musicStore = useMusicStore();
|
const musicStore = useMusicStore();
|
||||||
const statusStore = useStatusStore();
|
const statusStore = useStatusStore();
|
||||||
|
|
||||||
@@ -363,7 +364,6 @@ const getListData = async (id: number): Promise<SongType[]> => {
|
|||||||
&:hover {
|
&:hover {
|
||||||
background-color: rgba(var(--primary), 0.12);
|
background-color: rgba(var(--primary), 0.12);
|
||||||
.cover {
|
.cover {
|
||||||
border-radius: 16px 16px 0 0;
|
|
||||||
.cover-img {
|
.cover-img {
|
||||||
transform: scale(1.1);
|
transform: scale(1.1);
|
||||||
filter: brightness(0.8);
|
filter: brightness(0.8);
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<Transition name="fade" mode="out-in">
|
<Transition name="fade" mode="out-in">
|
||||||
<VirtList
|
<VirtList
|
||||||
ref="listRef"
|
ref="listRef"
|
||||||
:key="listData?.[0]?.id"
|
:key="listKey"
|
||||||
:list="listData"
|
:list="listData"
|
||||||
:minSize="94"
|
:minSize="94"
|
||||||
:buffer="2"
|
:buffer="2"
|
||||||
@@ -60,9 +60,21 @@
|
|||||||
:hiddenCover="hiddenCover"
|
:hiddenCover="hiddenCover"
|
||||||
:hiddenAlbum="hiddenAlbum"
|
:hiddenAlbum="hiddenAlbum"
|
||||||
:hiddenSize="hiddenSize"
|
:hiddenSize="hiddenSize"
|
||||||
@dblclick.stop="player.updatePlayList(listData, itemData, playListId)"
|
@dblclick.stop="
|
||||||
|
doubleClickAction === 'add'
|
||||||
|
? player.addNextSong(itemData, true)
|
||||||
|
: player.updatePlayList(listData, itemData, playListId)
|
||||||
|
"
|
||||||
@contextmenu.stop="
|
@contextmenu.stop="
|
||||||
songListMenuRef?.openDropdown($event, listData, itemData, index, type, playListId)
|
songListMenuRef?.openDropdown(
|
||||||
|
$event,
|
||||||
|
listData,
|
||||||
|
itemData,
|
||||||
|
index,
|
||||||
|
type,
|
||||||
|
playListId,
|
||||||
|
isDailyRecommend,
|
||||||
|
)
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
@@ -111,14 +123,14 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { DropdownOption } from "naive-ui";
|
import type { DropdownOption } from "naive-ui";
|
||||||
import type { SongType, SortType } from "@/types/main";
|
import { SongType, SortType } from "@/types/main";
|
||||||
import { useMusicStore, useStatusStore } from "@/stores";
|
import { useMusicStore, useStatusStore } from "@/stores";
|
||||||
import { VirtList } from "vue-virt-list";
|
import { VirtList } from "vue-virt-list";
|
||||||
import { cloneDeep, entries, isEmpty } from "lodash-es";
|
import { entries, isEmpty } from "lodash-es";
|
||||||
import { sortOptions } from "@/utils/meta";
|
import { sortOptions } from "@/utils/meta";
|
||||||
import { renderIcon } from "@/utils/helper";
|
import { renderIcon } from "@/utils/helper";
|
||||||
|
import { usePlayer } from "@/utils/player";
|
||||||
import SongListMenu from "@/components/Menu/SongListMenu.vue";
|
import SongListMenu from "@/components/Menu/SongListMenu.vue";
|
||||||
import player from "@/utils/player";
|
|
||||||
|
|
||||||
const props = withDefaults(
|
const props = withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
@@ -143,11 +155,16 @@ const props = withDefaults(
|
|||||||
disabledSort?: boolean;
|
disabledSort?: boolean;
|
||||||
// 播放歌单 ID
|
// 播放歌单 ID
|
||||||
playListId?: number;
|
playListId?: number;
|
||||||
|
// 是否为每日推荐
|
||||||
|
isDailyRecommend?: boolean;
|
||||||
|
// 双击播放操作
|
||||||
|
doubleClickAction?: "all" | "add";
|
||||||
}>(),
|
}>(),
|
||||||
{
|
{
|
||||||
type: "song",
|
type: "song",
|
||||||
loadingText: "努力加载中...",
|
loadingText: "努力加载中...",
|
||||||
playListId: 0,
|
playListId: 0,
|
||||||
|
isDailyRecommend: false,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -160,6 +177,7 @@ const emit = defineEmits<{
|
|||||||
removeSong: [id: number[]];
|
removeSong: [id: number[]];
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
const player = usePlayer();
|
||||||
const musicStore = useMusicStore();
|
const musicStore = useMusicStore();
|
||||||
const statusStore = useStatusStore();
|
const statusStore = useStatusStore();
|
||||||
|
|
||||||
@@ -179,8 +197,9 @@ const songListMenuRef = ref<InstanceType<typeof SongListMenu> | null>(null);
|
|||||||
|
|
||||||
// 列表数据
|
// 列表数据
|
||||||
const listData = computed<SongType[]>(() => {
|
const listData = computed<SongType[]>(() => {
|
||||||
const data = cloneDeep(props.data);
|
if (props.disabledSort) return props.data;
|
||||||
if (props.disabledSort) return data;
|
// 创建副本用于排序(避免修改原数组)
|
||||||
|
const data = [...props.data];
|
||||||
// 排序
|
// 排序
|
||||||
switch (statusStore.listSort) {
|
switch (statusStore.listSort) {
|
||||||
case "titleAZ":
|
case "titleAZ":
|
||||||
@@ -212,6 +231,19 @@ const listData = computed<SongType[]>(() => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 虚拟列表 key
|
||||||
|
const listKey = computed(() => {
|
||||||
|
// 每日推荐
|
||||||
|
if (props.isDailyRecommend) {
|
||||||
|
return `daily-${musicStore.dailySongsData.timestamp || 0}`;
|
||||||
|
}
|
||||||
|
// 使用 playListId 作为主要 key
|
||||||
|
if (props.playListId) {
|
||||||
|
return `playlist-${props.playListId}`;
|
||||||
|
}
|
||||||
|
return `type-${props.type}`;
|
||||||
|
});
|
||||||
|
|
||||||
// 列表是否具有播放歌曲
|
// 列表是否具有播放歌曲
|
||||||
const hasPlaySong = computed(() => {
|
const hasPlaySong = computed(() => {
|
||||||
return listData.value.findIndex((item) => item.id === musicStore.playSong.id);
|
return listData.value.findIndex((item) => item.id === musicStore.playSong.id);
|
||||||
@@ -233,7 +265,9 @@ const sortMenuOptions = computed<DropdownOption[]>(() =>
|
|||||||
// 列表滚动
|
// 列表滚动
|
||||||
const onScroll = (e: Event) => {
|
const onScroll = (e: Event) => {
|
||||||
emit("scroll", e);
|
emit("scroll", e);
|
||||||
scrollTop.value = (e.target as HTMLElement).scrollTop;
|
const top = (e.target as HTMLElement).scrollTop;
|
||||||
|
scrollTop.value = top;
|
||||||
|
offset.value = top;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 列表触底
|
// 列表触底
|
||||||
@@ -281,9 +315,11 @@ onBeforeUnmount(() => {
|
|||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.song-list {
|
.song-list {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
border-radius: 12px 0 0 12px;
|
||||||
|
overflow: hidden;
|
||||||
.song-card {
|
.song-card {
|
||||||
padding-bottom: 12px;
|
padding-bottom: 12px;
|
||||||
padding-right: 4px;
|
// padding-right: 4px;
|
||||||
}
|
}
|
||||||
// 悬浮顶栏
|
// 悬浮顶栏
|
||||||
.list-header {
|
.list-header {
|
||||||
@@ -293,8 +329,8 @@ onBeforeUnmount(() => {
|
|||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
padding: 8px 18px 8px 12px;
|
padding: 8px 12px;
|
||||||
margin-right: 4px;
|
// margin-right: 4px;
|
||||||
border: 1px solid transparent;
|
border: 1px solid transparent;
|
||||||
background-color: var(--background-hex);
|
background-color: var(--background-hex);
|
||||||
.n-text {
|
.n-text {
|
||||||
@@ -358,7 +394,6 @@ onBeforeUnmount(() => {
|
|||||||
}
|
}
|
||||||
.meta {
|
.meta {
|
||||||
width: 50px;
|
width: 50px;
|
||||||
font-size: 13px;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
&.size {
|
&.size {
|
||||||
width: 60px;
|
width: 60px;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { SongType } from "@/types/main";
|
import type { SongType } from "@/types/main";
|
||||||
import { NAlert, type DropdownOption } from "naive-ui";
|
import { NAlert, type DropdownOption } from "naive-ui";
|
||||||
import { useStatusStore, useLocalStore, useDataStore } from "@/stores";
|
import { useStatusStore, useLocalStore, useDataStore, useMusicStore } from "@/stores";
|
||||||
import { renderIcon, copyData } from "@/utils/helper";
|
import { renderIcon, copyData } from "@/utils/helper";
|
||||||
import { deleteCloudSong, importCloudSong } from "@/api/cloud";
|
import { deleteCloudSong, importCloudSong } from "@/api/cloud";
|
||||||
import {
|
import {
|
||||||
@@ -27,16 +27,20 @@ import {
|
|||||||
openPlaylistAdd,
|
openPlaylistAdd,
|
||||||
openSongInfoEditor,
|
openSongInfoEditor,
|
||||||
} from "@/utils/modal";
|
} from "@/utils/modal";
|
||||||
import { deleteSongs } from "@/utils/auth";
|
import { deleteSongs, isLogin } from "@/utils/auth";
|
||||||
import { songUrl } from "@/api/song";
|
import { songUrl } from "@/api/song";
|
||||||
import player from "@/utils/player";
|
import { dailyRecommendDislike } from "@/api/rec";
|
||||||
|
import { formatSongsList } from "@/utils/format";
|
||||||
|
import { usePlayer } from "@/utils/player";
|
||||||
|
|
||||||
const emit = defineEmits<{ removeSong: [index: number[]] }>();
|
const emit = defineEmits<{ removeSong: [index: number[]] }>();
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const player = usePlayer();
|
||||||
const dataStore = useDataStore();
|
const dataStore = useDataStore();
|
||||||
const localStore = useLocalStore();
|
const localStore = useLocalStore();
|
||||||
const statusStore = useStatusStore();
|
const statusStore = useStatusStore();
|
||||||
|
const musicStore = useMusicStore();
|
||||||
|
|
||||||
// 右键菜单数据
|
// 右键菜单数据
|
||||||
const dropdownX = ref<number>(0);
|
const dropdownX = ref<number>(0);
|
||||||
@@ -52,6 +56,7 @@ const openDropdown = (
|
|||||||
index: number,
|
index: number,
|
||||||
type: "song" | "radio",
|
type: "song" | "radio",
|
||||||
playListId?: number,
|
playListId?: number,
|
||||||
|
isDailyRecommend: boolean = false,
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -64,6 +69,7 @@ const openDropdown = (
|
|||||||
const isHasMv = !!song?.mv && song.mv !== 0;
|
const isHasMv = !!song?.mv && song.mv !== 0;
|
||||||
const isCloud = router.currentRoute.value.name === "cloud";
|
const isCloud = router.currentRoute.value.name === "cloud";
|
||||||
const isLocal = !!song?.path;
|
const isLocal = !!song?.path;
|
||||||
|
const isLoginNormal = isLogin() === 1;
|
||||||
// 是否当前播放
|
// 是否当前播放
|
||||||
const isCurrent = statusStore.playIndex === index;
|
const isCurrent = statusStore.playIndex === index;
|
||||||
// 是否为用户歌单
|
// 是否为用户歌单
|
||||||
@@ -109,6 +115,15 @@ const openDropdown = (
|
|||||||
key: "line-1",
|
key: "line-1",
|
||||||
type: "divider",
|
type: "divider",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: "dislike",
|
||||||
|
label: "不感兴趣",
|
||||||
|
show: isDailyRecommend && isLoginNormal,
|
||||||
|
props: {
|
||||||
|
onClick: () => dislikeSong(song, index),
|
||||||
|
},
|
||||||
|
icon: renderIcon("HeartBroken"),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: "more",
|
key: "more",
|
||||||
label: "更多操作",
|
label: "更多操作",
|
||||||
@@ -169,7 +184,7 @@ const openDropdown = (
|
|||||||
{
|
{
|
||||||
key: "cloud-import",
|
key: "cloud-import",
|
||||||
label: "导入至云盘",
|
label: "导入至云盘",
|
||||||
show: !isCloud && type === "song" && !isLocal,
|
show: !isCloud && isLoginNormal && type === "song" && !isLocal,
|
||||||
props: {
|
props: {
|
||||||
onClick: () => importSongToCloud(song),
|
onClick: () => importSongToCloud(song),
|
||||||
},
|
},
|
||||||
@@ -178,7 +193,7 @@ const openDropdown = (
|
|||||||
{
|
{
|
||||||
key: "delete",
|
key: "delete",
|
||||||
label: "从歌单中删除",
|
label: "从歌单中删除",
|
||||||
show: isUserPlaylist && !isCloud,
|
show: isUserPlaylist && isLoginNormal && !isCloud,
|
||||||
props: {
|
props: {
|
||||||
onClick: () => deleteSongs(playListId!, [song.id], () => emit("removeSong", [song.id])),
|
onClick: () => deleteSongs(playListId!, [song.id], () => emit("removeSong", [song.id])),
|
||||||
},
|
},
|
||||||
@@ -321,6 +336,41 @@ const importSongToCloud = async (song: SongType) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 每日推荐 - 不感兴趣
|
||||||
|
const dislikeSong = async (song: SongType, index: number) => {
|
||||||
|
if (!song?.id) return;
|
||||||
|
const loadingMessage = window.$message.loading("正在不感兴趣...", { duration: 0 });
|
||||||
|
try {
|
||||||
|
const result = await dailyRecommendDislike(song.id);
|
||||||
|
// 关闭 loading
|
||||||
|
loadingMessage.destroy();
|
||||||
|
if (result.code === 200) {
|
||||||
|
// 创建新数组以触发响应式更新
|
||||||
|
const currentList = [...musicStore.dailySongsData.list];
|
||||||
|
// 从列表中移除当前歌曲
|
||||||
|
currentList.splice(index, 1);
|
||||||
|
// 替换原歌曲
|
||||||
|
if (result.data) {
|
||||||
|
const formattedSong = formatSongsList([result.data])[0];
|
||||||
|
currentList.splice(index, 0, formattedSong);
|
||||||
|
}
|
||||||
|
// 更新列表(同时更新 timestamp 触发完整响应式更新)
|
||||||
|
musicStore.dailySongsData = {
|
||||||
|
list: currentList,
|
||||||
|
timestamp: Date.now(),
|
||||||
|
};
|
||||||
|
window.$message.success("已标记为不感兴趣");
|
||||||
|
} else {
|
||||||
|
window.$message.error("操作失败,请重试");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
// 关闭 loading
|
||||||
|
loadingMessage.destroy();
|
||||||
|
window.$message.error("操作失败,请重试");
|
||||||
|
console.error("不感兴趣操作失败:", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
defineExpose({ openDropdown });
|
defineExpose({ openDropdown });
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
99
src/components/Modal/AutoClose.vue
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
<template>
|
||||||
|
<n-flex :size="20" class="auto-close" align="center" vertical>
|
||||||
|
<n-card class="open">
|
||||||
|
<n-flex align="center" justify="space-between">
|
||||||
|
<n-flex size="small" align="center">
|
||||||
|
<SvgIcon name="TimeAuto" size="22" />
|
||||||
|
<Transition name="fade" mode="out-in">
|
||||||
|
<n-text v-if="!statusStore.autoClose.enable"> 未开启 </n-text>
|
||||||
|
<n-text v-else strong>
|
||||||
|
{{ convertSecondsToTime(statusStore.autoClose.remainTime) }}
|
||||||
|
</n-text>
|
||||||
|
</Transition>
|
||||||
|
</n-flex>
|
||||||
|
<n-switch
|
||||||
|
v-model:value="statusStore.autoClose.enable"
|
||||||
|
:round="false"
|
||||||
|
@update:value="handleUpdate"
|
||||||
|
/>
|
||||||
|
</n-flex>
|
||||||
|
</n-card>
|
||||||
|
<!-- 时间选择 -->
|
||||||
|
<n-flex size="large" align="center" justify="center">
|
||||||
|
<n-tag
|
||||||
|
v-for="(item, index) in [10, 20, 30, 45, 60, 90, 120]"
|
||||||
|
:bordered="false"
|
||||||
|
:key="index"
|
||||||
|
type="primary"
|
||||||
|
size="large"
|
||||||
|
round
|
||||||
|
@click="player.startAutoCloseTimer(item, item * 60)"
|
||||||
|
>
|
||||||
|
{{ item }}min
|
||||||
|
</n-tag>
|
||||||
|
<!-- 自定义 -->
|
||||||
|
<n-popconfirm
|
||||||
|
:negative-text="null"
|
||||||
|
:positive-button-props="{
|
||||||
|
strong: true,
|
||||||
|
secondary: true,
|
||||||
|
type: 'primary',
|
||||||
|
}"
|
||||||
|
:show-icon="false"
|
||||||
|
@positive-click="player.startAutoCloseTimer(customTime, customTime * 60)"
|
||||||
|
>
|
||||||
|
<template #trigger>
|
||||||
|
<n-tag :bordered="false" type="primary" size="large" round> 自定义时长 </n-tag>
|
||||||
|
</template>
|
||||||
|
<n-flex vertical>
|
||||||
|
<n-text>自定义时长(分钟)</n-text>
|
||||||
|
<n-input-number
|
||||||
|
v-model:value="customTime"
|
||||||
|
:min="1"
|
||||||
|
:max="120"
|
||||||
|
placeholder="请输入自定义时长"
|
||||||
|
/>
|
||||||
|
</n-flex>
|
||||||
|
</n-popconfirm>
|
||||||
|
</n-flex>
|
||||||
|
<!-- 是否播放完 -->
|
||||||
|
<n-checkbox v-model:checked="statusStore.autoClose.waitSongEnd">
|
||||||
|
等待整首歌曲播放完成再停止播放
|
||||||
|
</n-checkbox>
|
||||||
|
</n-flex>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { useStatusStore } from "@/stores";
|
||||||
|
import { convertSecondsToTime } from "@/utils/time";
|
||||||
|
import { usePlayer } from "@/utils/player";
|
||||||
|
|
||||||
|
const player = usePlayer();
|
||||||
|
const statusStore = useStatusStore();
|
||||||
|
|
||||||
|
// 自定义时长
|
||||||
|
const customTime = ref(1);
|
||||||
|
|
||||||
|
// 是否开启
|
||||||
|
const handleUpdate = (value: boolean) => {
|
||||||
|
if (value) {
|
||||||
|
player.startAutoCloseTimer(statusStore.autoClose.time, statusStore.autoClose.remainTime);
|
||||||
|
} else {
|
||||||
|
statusStore.autoClose.enable = false;
|
||||||
|
statusStore.autoClose.remainTime = statusStore.autoClose.time * 60;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.auto-close {
|
||||||
|
width: 100%;
|
||||||
|
.open {
|
||||||
|
width: 100%;
|
||||||
|
border-radius: 8px;
|
||||||
|
.n-text {
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
39
src/components/Modal/ChangeRate.vue
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<template>
|
||||||
|
<n-flex align="center" size="large" vertical>
|
||||||
|
<n-flex align="center" justify="center">
|
||||||
|
<n-tag
|
||||||
|
v-for="(item, index) in [0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2]"
|
||||||
|
:type="statusStore.playRate === item ? 'primary' : 'default'"
|
||||||
|
:bordered="statusStore.playRate === item"
|
||||||
|
:key="index"
|
||||||
|
size="large"
|
||||||
|
round
|
||||||
|
@click="player.setRate(item)"
|
||||||
|
>
|
||||||
|
{{ item }}x
|
||||||
|
</n-tag>
|
||||||
|
</n-flex>
|
||||||
|
<n-text :depth="3"> 当前播放速度: {{ statusStore.playRate }}x </n-text>
|
||||||
|
<n-slider
|
||||||
|
v-model:value="statusStore.playRate"
|
||||||
|
:step="0.1"
|
||||||
|
:min="0.2"
|
||||||
|
:max="2"
|
||||||
|
:tooltip="false"
|
||||||
|
:marks="{
|
||||||
|
0.2: '0.2x',
|
||||||
|
1: '1x',
|
||||||
|
2: '2x',
|
||||||
|
}"
|
||||||
|
@update:value="(value) => player.setRate(value)"
|
||||||
|
/>
|
||||||
|
</n-flex>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { useStatusStore } from "@/stores";
|
||||||
|
import { usePlayer } from "@/utils/player";
|
||||||
|
|
||||||
|
const player = usePlayer();
|
||||||
|
const statusStore = useStatusStore();
|
||||||
|
</script>
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="create-playlist">
|
<div class="create-playlist">
|
||||||
<n-tabs v-model:value="playlistType" type="segment" animated>
|
<n-tabs v-model:value="playlistType" type="segment" animated>
|
||||||
<n-tab-pane name="online" tab="在线歌单">
|
<n-tab-pane :disabled="isLogin() !== 1" name="online" tab="在线歌单">
|
||||||
<n-form ref="onlineFormRef" :model="onlineFormData" :rules="onlineFormRules">
|
<n-form ref="onlineFormRef" :model="onlineFormData" :rules="onlineFormRules">
|
||||||
<n-form-item label="歌单名称" path="name">
|
<n-form-item label="歌单名称" path="name">
|
||||||
<n-input v-model:value="onlineFormData.name" placeholder="请输入歌单名称" />
|
<n-input v-model:value="onlineFormData.name" placeholder="请输入歌单名称" />
|
||||||
@@ -28,7 +28,7 @@ import { useDataStore } from "@/stores";
|
|||||||
import { textRule } from "@/utils/rules";
|
import { textRule } from "@/utils/rules";
|
||||||
import { debounce } from "lodash-es";
|
import { debounce } from "lodash-es";
|
||||||
import { createPlaylist } from "@/api/playlist";
|
import { createPlaylist } from "@/api/playlist";
|
||||||
import { updateUserLikePlaylist } from "@/utils/auth";
|
import { isLogin, updateUserLikePlaylist } from "@/utils/auth";
|
||||||
|
|
||||||
const emit = defineEmits<{ close: [] }>();
|
const emit = defineEmits<{ close: [] }>();
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ interface OnlineFormType {
|
|||||||
const dataStore = useDataStore();
|
const dataStore = useDataStore();
|
||||||
|
|
||||||
// 歌单类别
|
// 歌单类别
|
||||||
const playlistType = ref<"online" | "local">("online");
|
const playlistType = ref<"online" | "local">(isLogin() === 1 ? "online" : "local");
|
||||||
|
|
||||||
// 在线歌单数据
|
// 在线歌单数据
|
||||||
const onlineFormRef = ref<FormInst | null>(null);
|
const onlineFormRef = ref<FormInst | null>(null);
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
</n-flex>
|
</n-flex>
|
||||||
</n-radio-group>
|
</n-radio-group>
|
||||||
</n-collapse-item>
|
</n-collapse-item>
|
||||||
<n-collapse-item v-if="isElectron" title="下载路径" name="path">
|
<n-collapse-item v-if="isElectron" title="本次下载路径" name="path">
|
||||||
<n-input-group>
|
<n-input-group>
|
||||||
<n-input :value="downloadPath || '未配置下载目录'" disabled>
|
<n-input :value="downloadPath || '未配置下载目录'" disabled>
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
@@ -67,10 +67,11 @@ import { useSettingStore } from "@/stores";
|
|||||||
import { songLevelData, getLevelsUpTo } from "@/utils/meta";
|
import { songLevelData, getLevelsUpTo } from "@/utils/meta";
|
||||||
import { formatSongsList } from "@/utils/format";
|
import { formatSongsList } from "@/utils/format";
|
||||||
import { cloneDeep, reduce } from "lodash-es";
|
import { cloneDeep, reduce } from "lodash-es";
|
||||||
import { formatFileSize, isElectron } from "@/utils/helper";
|
import { formatFileSize } from "@/utils/helper";
|
||||||
|
import { getPlayerInfo } from "@/utils/player-utils/song";
|
||||||
import { openSetting } from "@/utils/modal";
|
import { openSetting } from "@/utils/modal";
|
||||||
import { saveAs } from "file-saver";
|
import { saveAs } from "file-saver";
|
||||||
import player from "@/utils/player";
|
import { isElectron } from "@/utils/env";
|
||||||
|
|
||||||
const props = defineProps<{ id: number }>();
|
const props = defineProps<{ id: number }>();
|
||||||
const emit = defineEmits<{ close: [] }>();
|
const emit = defineEmits<{ close: [] }>();
|
||||||
@@ -137,7 +138,7 @@ const changeDownloadPath = async () => {
|
|||||||
const download = async () => {
|
const download = async () => {
|
||||||
if (!songData.value) return;
|
if (!songData.value) return;
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
downloadPath.value = settingStore.downloadPath;
|
if (settingStore.downloadPath) downloadPath.value = settingStore.downloadPath;
|
||||||
try {
|
try {
|
||||||
// 获取下载链接
|
// 获取下载链接
|
||||||
const result = await songDownloadUrl(props.id, songLevelChoosed.value);
|
const result = await songDownloadUrl(props.id, songLevelChoosed.value);
|
||||||
@@ -156,7 +157,7 @@ const download = async () => {
|
|||||||
}
|
}
|
||||||
// 下载相关数据
|
// 下载相关数据
|
||||||
const { url, type = "mp3" } = result.data;
|
const { url, type = "mp3" } = result.data;
|
||||||
const songName = player.getPlayerInfo(songData.value) || "未知曲目";
|
const songName = getPlayerInfo(songData.value) || "未知曲目";
|
||||||
// 区分设备下载
|
// 区分设备下载
|
||||||
if (isElectron) {
|
if (isElectron) {
|
||||||
await electronDownload(url, songName, type.toLowerCase());
|
await electronDownload(url, songName, type.toLowerCase());
|
||||||
@@ -184,7 +185,7 @@ const electronDownload = async (url: string, songName: string, fileType: string)
|
|||||||
}
|
}
|
||||||
// 下载歌曲
|
// 下载歌曲
|
||||||
const config = {
|
const config = {
|
||||||
fileName: songName,
|
fileName: songName.replace(/[/:*?"<>|]/g, "&"),
|
||||||
fileType,
|
fileType,
|
||||||
path: downloadPath.value,
|
path: downloadPath.value,
|
||||||
downloadMeta,
|
downloadMeta,
|
||||||
|
|||||||