mirror of
https://github.com/imsyy/SPlayer.git
synced 2025-11-25 19:37:35 +08:00
Compare commits
46 Commits
v3.0.0-bet
...
v3.0.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fc49b7ad00 | ||
|
|
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 | ||
|
|
143e8e29d7 | ||
|
|
c702e6e01a |
93
.github/workflows/build.yml
vendored
93
.github/workflows/build.yml
vendored
@@ -1,5 +1,5 @@
|
||||
# Dev 分支推送部署预览
|
||||
## 仅部署 Win 端
|
||||
## 部署 Windows x64 和 ARM64 版本
|
||||
name: Build Dev
|
||||
|
||||
on:
|
||||
@@ -8,8 +8,9 @@ on:
|
||||
- dev
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Build and electron app
|
||||
# Windows x64 架构
|
||||
release-x64:
|
||||
name: Build Electron App for Windows (x64)
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
@@ -35,30 +36,76 @@ jobs:
|
||||
# 安装项目依赖
|
||||
- name: Install Dependencies
|
||||
run: pnpm install
|
||||
# 构建 Electron App
|
||||
- name: Build Electron App
|
||||
run: pnpm run build:win
|
||||
# 清理旧的构建产物
|
||||
- name: Clean dist folder
|
||||
run: |
|
||||
if (Test-Path dist) {
|
||||
Remove-Item -Recurse -Force dist
|
||||
}
|
||||
# 构建 Electron App (x64)
|
||||
- name: Build Electron App for Windows x64
|
||||
run: pnpm run build:win -- --x64 || true
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
||||
# 清理不必要的构建产物
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
# 清理不必要的构建产物(保留 .exe 和 .blockmap 文件)
|
||||
- name: Cleanup Artifacts
|
||||
run: npx del-cli "dist/**/*" "!dist/*.exe"
|
||||
# 上传构建产物
|
||||
run: npx del-cli "dist/**/*.yaml" "dist/**/*.yml"
|
||||
# 上传构建产物(仅上传 x64 架构的 .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')
|
||||
name: SPlayer-dev-x64
|
||||
path: |
|
||||
dist/*x64*.exe
|
||||
dist/*x64*.exe.blockmap
|
||||
|
||||
# Windows ARM64 架构
|
||||
release-arm64:
|
||||
name: Build Electron App for Windows (ARM64)
|
||||
runs-on: windows-11-arm
|
||||
|
||||
steps:
|
||||
# 检出 Git 仓库
|
||||
- name: Check out git repository
|
||||
uses: actions/checkout@v4
|
||||
# 安装 Node.js
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v4
|
||||
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
|
||||
node-version: "22.x"
|
||||
# 安装 pnpm
|
||||
- name: Install pnpm
|
||||
run: npm install -g 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 (ARM64)
|
||||
- name: Build Electron App for Windows ARM64
|
||||
run: pnpm run build:win -- --arm64 || true
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
# 清理不必要的构建产物(保留 .exe 和 .blockmap 文件)
|
||||
- name: Cleanup Artifacts
|
||||
run: npx del-cli "dist/**/*.yaml" "dist/**/*.yml"
|
||||
# 上传构建产物(仅上传 ARM64 架构的 .exe 文件)
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: SPlayer-dev-arm64
|
||||
path: |
|
||||
dist/*arm64*.exe
|
||||
dist/*arm64*.exe.blockmap
|
||||
|
||||
248
.github/workflows/release.yml
vendored
248
.github/workflows/release.yml
vendored
@@ -1,175 +1,169 @@
|
||||
# Release 发行版本部署
|
||||
## 多端部署
|
||||
name: Build Release
|
||||
name: Build & Release SPlayer
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- v*
|
||||
- v* # 只在 tag v* 时触发
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
NODE_VERSION: 22.x
|
||||
PNPM_VERSION: 8
|
||||
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }}
|
||||
|
||||
jobs:
|
||||
# Windows
|
||||
build-windows:
|
||||
name: Build for Windows
|
||||
runs-on: windows-latest
|
||||
# ===================================================================
|
||||
# 并行构建所有平台和架构
|
||||
# ===================================================================
|
||||
build:
|
||||
name: Build on ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
# 矩阵策略
|
||||
# 即使一个矩阵任务失败,其他任务也会继续运行
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
# 开始步骤
|
||||
steps:
|
||||
# 检出 Git 仓库
|
||||
- name: Check out git repository
|
||||
uses: actions/checkout@v4
|
||||
# 安装 Node.js
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v4
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v3
|
||||
with:
|
||||
node-version: "22.x"
|
||||
# 安装 pnpm
|
||||
- name: Install pnpm
|
||||
run: npm install -g pnpm
|
||||
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: |
|
||||
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
|
||||
# 构建 Electron App
|
||||
- name: Build Electron App for Windows
|
||||
run: pnpm 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:
|
||||
files: dist/*.*
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
||||
# Mac
|
||||
build-macos:
|
||||
name: Build for macOS
|
||||
runs-on: macos-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"
|
||||
# 安装 pnpm
|
||||
- name: Install pnpm
|
||||
run: npm install -g pnpm
|
||||
# 复制环境变量文件
|
||||
- name: Copy .env.example
|
||||
- name: Copy .env file on macOS & Linux
|
||||
if: runner.os == 'macOS' || runner.os == 'Linux'
|
||||
run: |
|
||||
if [ ! -f .env ]; then
|
||||
cp .env.example .env
|
||||
else
|
||||
echo ".env file already exists. Skipping the copy step."
|
||||
fi
|
||||
# 安装项目依赖
|
||||
- name: Install Dependencies
|
||||
run: pnpm install
|
||||
# 构建 Electron App
|
||||
- name: Build Electron App for macOS
|
||||
run: pnpm 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:
|
||||
files: dist/*.*
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
||||
# Linux
|
||||
build-linux:
|
||||
name: Build for Linux
|
||||
runs-on: ubuntu-22.04
|
||||
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"
|
||||
# 安装 pnpm
|
||||
- name: Install pnpm
|
||||
run: npm install -g pnpm
|
||||
# 更新 Ubuntu 软件源
|
||||
- name: Ubuntu Update with sudo
|
||||
if: runner.os == 'Linux'
|
||||
run: sudo apt-get update
|
||||
# 安装依赖
|
||||
- name: Install RPM & Pacman
|
||||
if: runner.os == 'Linux'
|
||||
run: |
|
||||
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 libopenjp2-tools
|
||||
# 安装 Snapcraft
|
||||
# 安裝 Snapcraft
|
||||
- name: Install Snapcraft
|
||||
if: runner.os == 'Linux'
|
||||
uses: samuelmeuli/action-snapcraft@v2
|
||||
with:
|
||||
snapcraft_token: ${{ secrets.SNAPCRAFT_TOKEN }}
|
||||
# 复制环境变量文件
|
||||
- name: Copy .env.example
|
||||
run: |
|
||||
if [ ! -f .env ]; then
|
||||
cp .env.example .env
|
||||
else
|
||||
echo ".env file already exists. Skipping the copy step."
|
||||
fi
|
||||
# 安装项目依赖
|
||||
- name: Install Dependencies
|
||||
run: pnpm install
|
||||
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }}
|
||||
# 构建 Electron App
|
||||
- name: Build Electron App for Linux
|
||||
run: pnpm run build:linux || true
|
||||
- name: Build Windows x64 & ARM64 App
|
||||
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
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
||||
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }}
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Build Linux x64 & ARM64 App
|
||||
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
|
||||
env:
|
||||
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }}
|
||||
# 上传构建产物
|
||||
- name: Upload Linux artifact
|
||||
# 合并所有构建
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: SPlarer-Linux
|
||||
if-no-files-found: ignore
|
||||
name: SPlayer-${{ runner.os }}
|
||||
path: dist/*.*
|
||||
# 创建 GitHub Release
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
|
||||
# ===================================================================
|
||||
# 收集并发布 Release
|
||||
# ===================================================================
|
||||
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:
|
||||
files: dist/*.*
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
||||
path: artifacts
|
||||
# 创建 GitHub Release 并上传所有产物
|
||||
- name: Create GitHub Release and Upload Assets
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
# 自动生成 Release 说明
|
||||
generate_release_notes: true
|
||||
# 发布为草稿
|
||||
draft: false
|
||||
# 发布为预发布
|
||||
prerelease: false
|
||||
# 全部上传
|
||||
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
|
||||
|
||||
@@ -13,6 +13,9 @@ export default {
|
||||
"MaybeRefOrGetter": true,
|
||||
"PropType": true,
|
||||
"Ref": true,
|
||||
"ShallowRef": true,
|
||||
"Slot": true,
|
||||
"Slots": true,
|
||||
"VNode": true,
|
||||
"WritableComputedRef": true,
|
||||
"asyncComputed": true,
|
||||
@@ -44,6 +47,7 @@ export default {
|
||||
"extendRef": true,
|
||||
"getCurrentInstance": true,
|
||||
"getCurrentScope": true,
|
||||
"getCurrentWatcher": true,
|
||||
"h": true,
|
||||
"ignorableWatch": true,
|
||||
"inject": true,
|
||||
@@ -53,6 +57,7 @@ export default {
|
||||
"isReactive": true,
|
||||
"isReadonly": true,
|
||||
"isRef": true,
|
||||
"isShallow": true,
|
||||
"makeDestructurable": true,
|
||||
"markRaw": true,
|
||||
"nextTick": true,
|
||||
@@ -266,6 +271,7 @@ export default {
|
||||
"useThrottleFn": true,
|
||||
"useThrottledRefHistory": true,
|
||||
"useTimeAgo": true,
|
||||
"useTimeAgoIntl": true,
|
||||
"useTimeout": true,
|
||||
"useTimeoutFn": true,
|
||||
"useTimeoutPoll": true,
|
||||
|
||||
5
auto-imports.d.ts
vendored
5
auto-imports.d.ts
vendored
@@ -36,6 +36,7 @@ declare global {
|
||||
const extendRef: typeof import('@vueuse/core')['extendRef']
|
||||
const getCurrentInstance: typeof import('vue')['getCurrentInstance']
|
||||
const getCurrentScope: typeof import('vue')['getCurrentScope']
|
||||
const getCurrentWatcher: typeof import('vue')['getCurrentWatcher']
|
||||
const h: typeof import('vue')['h']
|
||||
const ignorableWatch: typeof import('@vueuse/core')['ignorableWatch']
|
||||
const inject: typeof import('vue')['inject']
|
||||
@@ -45,6 +46,7 @@ declare global {
|
||||
const isReactive: typeof import('vue')['isReactive']
|
||||
const isReadonly: typeof import('vue')['isReadonly']
|
||||
const isRef: typeof import('vue')['isRef']
|
||||
const isShallow: typeof import('vue')['isShallow']
|
||||
const makeDestructurable: typeof import('@vueuse/core')['makeDestructurable']
|
||||
const markRaw: typeof import('vue')['markRaw']
|
||||
const nextTick: typeof import('vue')['nextTick']
|
||||
@@ -258,6 +260,7 @@ declare global {
|
||||
const useThrottleFn: typeof import('@vueuse/core')['useThrottleFn']
|
||||
const useThrottledRefHistory: typeof import('@vueuse/core')['useThrottledRefHistory']
|
||||
const useTimeAgo: typeof import('@vueuse/core')['useTimeAgo']
|
||||
const useTimeAgoIntl: typeof import('@vueuse/core')['useTimeAgoIntl']
|
||||
const useTimeout: typeof import('@vueuse/core')['useTimeout']
|
||||
const useTimeoutFn: typeof import('@vueuse/core')['useTimeoutFn']
|
||||
const useTimeoutPoll: typeof import('@vueuse/core')['useTimeoutPoll']
|
||||
@@ -301,6 +304,6 @@ declare global {
|
||||
// for type re-export
|
||||
declare global {
|
||||
// @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')
|
||||
}
|
||||
|
||||
2
components.d.ts
vendored
2
components.d.ts
vendored
@@ -92,9 +92,11 @@ declare module 'vue' {
|
||||
NOl: typeof import('naive-ui')['NOl']
|
||||
NP: typeof import('naive-ui')['NP']
|
||||
NPopover: typeof import('naive-ui')['NPopover']
|
||||
NProgress: typeof import('naive-ui')['NProgress']
|
||||
NQrCode: typeof import('naive-ui')['NQrCode']
|
||||
NRadio: typeof import('naive-ui')['NRadio']
|
||||
NRadioGroup: typeof import('naive-ui')['NRadioGroup']
|
||||
NResult: typeof import('naive-ui')['NResult']
|
||||
NScrollbar: typeof import('naive-ui')['NScrollbar']
|
||||
NSelect: typeof import('naive-ui')['NSelect']
|
||||
NSkeleton: typeof import('naive-ui')['NSkeleton']
|
||||
|
||||
170
electron-builder.config.ts
Normal file
170
electron-builder.config.ts
Normal file
@@ -0,0 +1,170 @@
|
||||
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",
|
||||
},
|
||||
// AppImage 特定配置
|
||||
appImage: {
|
||||
// AppImage 文件的生成名称
|
||||
artifactName: "${name}-${version}-${arch}.${ext}",
|
||||
},
|
||||
// 是否在构建之前重新编译原生模块
|
||||
npmRebuild: false,
|
||||
// Electron 下载镜像配置
|
||||
electronDownload: {
|
||||
mirror: "https://npmmirror.com/mirrors/electron/",
|
||||
},
|
||||
};
|
||||
|
||||
export default config;
|
||||
@@ -1,115 +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
|
||||
- snap
|
||||
- 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"
|
||||
@@ -88,7 +88,7 @@ export default defineConfig(({ command, mode }) => {
|
||||
"/api": {
|
||||
target: `http://127.0.0.1:${servePort}`,
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/api/, "/api/"),
|
||||
rewrite: (path) => path.replace(/^\/api/, "/api"),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -116,8 +116,8 @@ class MainProcess {
|
||||
const options: BrowserWindowConstructorOptions = {
|
||||
width: this.store?.get("window").width,
|
||||
height: this.store?.get("window").height,
|
||||
minHeight: 800,
|
||||
minWidth: 1280,
|
||||
minHeight: 600,
|
||||
minWidth: 800,
|
||||
// 菜单栏
|
||||
titleBarStyle: "customButtonsOnHover",
|
||||
// 立即显示窗口
|
||||
|
||||
@@ -11,8 +11,10 @@ import log from "../main/logger";
|
||||
const initAppServer = async () => {
|
||||
try {
|
||||
const server = fastify({
|
||||
// 忽略尾随斜杠
|
||||
ignoreTrailingSlash: true,
|
||||
routerOptions: {
|
||||
// 忽略尾随斜杠
|
||||
ignoreTrailingSlash: true,
|
||||
},
|
||||
});
|
||||
// 注册插件
|
||||
server.register(fastifyCookie);
|
||||
|
||||
@@ -26,11 +26,7 @@ export default [
|
||||
"**/components.d.ts",
|
||||
],
|
||||
},
|
||||
...compat.extends(
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"plugin:vue/vue3-essential",
|
||||
),
|
||||
...compat.extends("eslint:recommended", "plugin:@typescript-eslint/recommended"),
|
||||
{
|
||||
plugins: {
|
||||
"@typescript-eslint": typescriptEslint,
|
||||
|
||||
96
package.json
96
package.json
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "splayer",
|
||||
"productName": "SPlayer",
|
||||
"version": "3.0.0-beta.2",
|
||||
"version": "3.0.0-beta.3",
|
||||
"description": "A minimalist music player",
|
||||
"main": "./out/main/index.js",
|
||||
"author": "imsyy",
|
||||
@@ -24,23 +24,23 @@
|
||||
"typecheck": "npm run typecheck:node && npm run typecheck:web",
|
||||
"start": "electron-vite preview",
|
||||
"dev": "electron-vite dev",
|
||||
"build": "npm run typecheck && electron-vite build",
|
||||
"build": "npx rimraf dist && npm run typecheck && electron-vite build",
|
||||
"postinstall": "electron-builder install-app-deps",
|
||||
"build:web": "npm run build",
|
||||
"build:unpack": "npm run build && electron-builder --dir",
|
||||
"build:win": "npm run build && electron-builder --win",
|
||||
"build:mac": "npm run build && electron-builder --mac",
|
||||
"build:linux": "npm run build && electron-builder --linux"
|
||||
"build:win": "npm run build && electron-builder --win --config electron-builder.config.ts",
|
||||
"build:mac": "npm run build && electron-builder --mac --config electron-builder.config.ts",
|
||||
"build:linux": "npm run build && electron-builder --linux --config electron-builder.config.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@applemusic-like-lyrics/core": "^0.1.3",
|
||||
"@applemusic-like-lyrics/lyric": "^0.2.4",
|
||||
"@applemusic-like-lyrics/vue": "^0.1.5",
|
||||
"@electron-toolkit/preload": "^3.0.1",
|
||||
"@electron-toolkit/utils": "^3.0.0",
|
||||
"@electron-toolkit/preload": "^3.0.2",
|
||||
"@electron-toolkit/utils": "^4.0.0",
|
||||
"@imsyy/color-utils": "^1.0.2",
|
||||
"@material/material-color-utilities": "^0.3.0",
|
||||
"@neteaseapireborn/api": "^4.29.2",
|
||||
"@neteaseapireborn/api": "^4.29.9",
|
||||
"@pixi/app": "^7.4.3",
|
||||
"@pixi/core": "^7.4.3",
|
||||
"@pixi/display": "^7.4.3",
|
||||
@@ -48,15 +48,15 @@
|
||||
"@pixi/filter-bulge-pinch": "^5.1.1",
|
||||
"@pixi/filter-color-matrix": "^7.4.3",
|
||||
"@pixi/sprite": "^7.4.3",
|
||||
"@vueuse/core": "^12.8.2",
|
||||
"axios": "^1.11.0",
|
||||
"@vueuse/core": "^13.9.0",
|
||||
"axios": "^1.12.2",
|
||||
"change-case": "^5.4.4",
|
||||
"dayjs": "^1.11.13",
|
||||
"dayjs": "^1.11.18",
|
||||
"electron-dl": "^4.0.0",
|
||||
"electron-store": "^8.2.0",
|
||||
"electron-updater": "^6.6.2",
|
||||
"file-saver": "^2.0.5",
|
||||
"font-list": "^1.5.1",
|
||||
"font-list": "^2.0.1",
|
||||
"get-port": "^7.1.0",
|
||||
"github-markdown-css": "^5.8.1",
|
||||
"howler": "^2.2.4",
|
||||
@@ -65,65 +65,67 @@
|
||||
"jss-preset-default": "^10.10.0",
|
||||
"localforage": "^1.10.0",
|
||||
"lodash-es": "^4.17.21",
|
||||
"marked": "^15.0.8",
|
||||
"marked": "^16.4.0",
|
||||
"md5": "^2.3.0",
|
||||
"music-metadata": "10.5.1",
|
||||
"pinia": "^2.3.1",
|
||||
"pinia-plugin-persistedstate": "^4.2.0",
|
||||
"plyr": "^3.7.8",
|
||||
"vue-virt-list": "^1.5.10"
|
||||
"music-metadata": "^11.9.0",
|
||||
"pinia": "^3.0.3",
|
||||
"pinia-plugin-persistedstate": "^4.5.0",
|
||||
"plyr": "^3.8.3",
|
||||
"vue-virt-list": "^1.6.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@electron-toolkit/preload": "^3.0.1",
|
||||
"@electron-toolkit/tsconfig": "^1.0.1",
|
||||
"@electron-toolkit/utils": "^3.0.0",
|
||||
"@electron-toolkit/tsconfig": "^2.0.0",
|
||||
"@electron-toolkit/utils": "^4",
|
||||
"@fastify/cookie": "^11.0.2",
|
||||
"@fastify/http-proxy": "^11.1.2",
|
||||
"@fastify/multipart": "^9.0.3",
|
||||
"@fastify/static": "^8.1.1",
|
||||
"@fastify/http-proxy": "^11.3.0",
|
||||
"@fastify/multipart": "^9.2.1",
|
||||
"@fastify/static": "^8.2.0",
|
||||
"@types/file-saver": "^2.0.7",
|
||||
"@types/howler": "^2.2.12",
|
||||
"@types/js-cookie": "^3.0.6",
|
||||
"@types/md5": "^2.3.5",
|
||||
"@types/node": "^22.14.1",
|
||||
"@typescript-eslint/eslint-plugin": "^8.30.1",
|
||||
"@typescript-eslint/parser": "^8.30.1",
|
||||
"@vitejs/plugin-vue": "^5.2.3",
|
||||
"@types/node": "^24.7.2",
|
||||
"@typescript-eslint/eslint-plugin": "^8.46.0",
|
||||
"@typescript-eslint/parser": "^8.46.0",
|
||||
"@vitejs/plugin-vue": "^6.0.1",
|
||||
"ajv": "^8.17.1",
|
||||
"crypto-js": "^4.2.0",
|
||||
"electron": "^35.1.5",
|
||||
"electron": "^38.2.2",
|
||||
"electron-builder": "^26.0.12",
|
||||
"electron-log": "^5.3.4",
|
||||
"electron-vite": "^3.1.0",
|
||||
"eslint": "^9.24.0",
|
||||
"eslint-plugin-vue": "^9.33.0",
|
||||
"electron-log": "^5.4.3",
|
||||
"electron-vite": "^4.0.1",
|
||||
"eslint": "^9.37.0",
|
||||
"eslint-plugin-vue": "^10.5.0",
|
||||
"fast-glob": "^3.3.3",
|
||||
"fastify": "^5.3.1",
|
||||
"naive-ui": "^2.42.0",
|
||||
"fastify": "^5.6.1",
|
||||
"naive-ui": "^2.43.1",
|
||||
"node-taglib-sharp": "^6.0.1",
|
||||
"prettier": "^3.5.3",
|
||||
"sass": "^1.86.3",
|
||||
"terser": "^5.39.0",
|
||||
"typescript": "^5.8.3",
|
||||
"unplugin-auto-import": "^0.19.0",
|
||||
"unplugin-vue-components": "^28.5.0",
|
||||
"vite": "^5.4.18",
|
||||
"prettier": "^3.6.2",
|
||||
"sass": "^1.93.2",
|
||||
"terser": "^5.44.0",
|
||||
"typescript": "^5.9.3",
|
||||
"unplugin-auto-import": "^20.2.0",
|
||||
"unplugin-vue-components": "^29.1.0",
|
||||
"vite": "^7.1.9",
|
||||
"vite-plugin-compression": "^0.5.1",
|
||||
"vite-plugin-wasm": "^3.4.1",
|
||||
"vue": "^3.5.18",
|
||||
"vue-router": "^4.5.0",
|
||||
"vue-tsc": "^3.0.5"
|
||||
"vite-plugin-wasm": "^3.5.0",
|
||||
"vue": "^3.5.22",
|
||||
"vue-router": "^4.5.1",
|
||||
"vue-tsc": "^3.1.1"
|
||||
},
|
||||
"pnpm": {
|
||||
"overrides": {
|
||||
"dmg-builder": "25.1.8",
|
||||
"electron-builder-squirrel-windows": "25.1.8"
|
||||
"dmg-builder": "26.0.12",
|
||||
"electron-builder-squirrel-windows": "26.0.12"
|
||||
},
|
||||
"onlyBuiltDependencies": [
|
||||
"@applemusic-like-lyrics/lyric",
|
||||
"@parcel/watcher",
|
||||
"core-js",
|
||||
"electron",
|
||||
"esbuild",
|
||||
"sharp",
|
||||
"vue-demi"
|
||||
]
|
||||
}
|
||||
|
||||
4253
pnpm-lock.yaml
generated
4253
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
BIN
public/icons/logo.ico
Normal file
BIN
public/icons/logo.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
BIN
public/logo.ico
Normal file
BIN
public/logo.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@@ -65,6 +65,23 @@ export const songLyric = (id: number) => {
|
||||
});
|
||||
};
|
||||
|
||||
// 获取格式TTML的歌词
|
||||
export const songLyricTTML = async (id: number) => {
|
||||
const url = `https://amll-ttml-db.stevexmh.net/ncm/${id}`;
|
||||
try {
|
||||
const response = await fetch(url);
|
||||
if (response === null || response.status !== 200) {
|
||||
console.error(`TTML API请求失败或TTML仓库没有歌词, 将会使用默认歌词`);
|
||||
return null;
|
||||
}
|
||||
const data = await response.text();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error('TTML API请求出错:', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取歌曲下载链接
|
||||
* @param id 音乐 id
|
||||
|
||||
@@ -262,7 +262,7 @@ const onlineMatch = debounce(
|
||||
const changeCover = async () => {
|
||||
const newPath = await window.electron.ipcRenderer.invoke("choose-image");
|
||||
if (!newPath) return;
|
||||
coverData.value = newPath;
|
||||
coverData.value = `file://${newPath}`;
|
||||
};
|
||||
|
||||
// 实时修改列表
|
||||
@@ -300,7 +300,9 @@ const saveSongInfo = debounce(async (song: SongType) => {
|
||||
cover:
|
||||
coverData.value.startsWith("blob:") || coverData.value === "/images/song.jpg?assest"
|
||||
? null
|
||||
: coverData.value,
|
||||
: coverData.value.startsWith("file://")
|
||||
? coverData.value.replace(/^file:\/\//, "")
|
||||
: coverData.value,
|
||||
};
|
||||
console.log(song.path, metadata);
|
||||
await window.electron.ipcRenderer.invoke("set-music-metadata", song.path, metadata);
|
||||
|
||||
@@ -1,27 +1,17 @@
|
||||
<template>
|
||||
<Transition>
|
||||
<div
|
||||
:key="amLyricsData?.[0]?.startTime"
|
||||
:class="['lyric-am', { pure: statusStore.pureLyricMode }]"
|
||||
>
|
||||
<LyricPlayer
|
||||
ref="lyricPlayerRef"
|
||||
:lyricLines="amLyricsData"
|
||||
:currentTime="playSeek"
|
||||
:playing="statusStore.playStatus"
|
||||
:enableSpring="settingStore.useAMSpring"
|
||||
<div :key="amLyricsData?.[0]?.startTime" :class="['lyric-am', { pure: statusStore.pureLyricMode }]">
|
||||
<LyricPlayer ref="lyricPlayerRef" :lyricLines="amLyricsData" :currentTime="playSeek"
|
||||
:playing="statusStore.playStatus" :enableSpring="settingStore.useAMSpring"
|
||||
:enableScale="settingStore.useAMSpring"
|
||||
:alignPosition="settingStore.lyricsScrollPosition === 'center' ? 0.5 : 0.2"
|
||||
:enableBlur="settingStore.lyricsBlur"
|
||||
:style="{
|
||||
:enableBlur="settingStore.lyricsBlur" :style="{
|
||||
'--amll-lyric-view-color': mainColor,
|
||||
'--amll-lyric-player-font-size': settingStore.lyricFontSize + 'px',
|
||||
'--ja-font-family': settingStore.japaneseLyricFont !== 'follow' ? settingStore.japaneseLyricFont : '',
|
||||
'font-weight': settingStore.lyricFontBold ? 'bold' : 'normal',
|
||||
'font-family': settingStore.LyricFont !== 'follow' ? settingStore.LyricFont : '',
|
||||
}"
|
||||
class="am-lyric"
|
||||
@line-click="jumpSeek"
|
||||
/>
|
||||
}" class="am-lyric" @line-click="jumpSeek" />
|
||||
</div>
|
||||
</Transition>
|
||||
</template>
|
||||
@@ -31,7 +21,9 @@ import { LyricPlayer } from "@applemusic-like-lyrics/vue";
|
||||
import { LyricLine } from "@applemusic-like-lyrics/core";
|
||||
import { useMusicStore, useSettingStore, useStatusStore } from "@/stores";
|
||||
import { msToS } from "@/utils/time";
|
||||
import { getLyricLanguage } from "@/utils/lyric";
|
||||
import player from "@/utils/player";
|
||||
import { watch } from "vue";
|
||||
|
||||
const musicStore = useMusicStore();
|
||||
const statusStore = useStatusStore();
|
||||
@@ -54,10 +46,39 @@ const mainColor = computed(() => {
|
||||
return `rgb(${statusStore.mainColor})`;
|
||||
});
|
||||
|
||||
// 检查是否为纯音乐歌词
|
||||
const isPureInstrumental = (lyrics: LyricLine[]): boolean => {
|
||||
if (!lyrics || lyrics.length === 0) return false;
|
||||
const instrumentalKeywords = ['纯音乐', 'instrumental', '请欣赏'];
|
||||
|
||||
if (lyrics.length === 1) {
|
||||
const content = lyrics[0].words?.[0]?.word || '';
|
||||
return instrumentalKeywords.some(keyword => content.toLowerCase().includes(keyword.toLowerCase()));
|
||||
}
|
||||
|
||||
if (lyrics.length <= 3) {
|
||||
const allContent = lyrics.map(line => line.words?.[0]?.word || '').join('');
|
||||
return instrumentalKeywords.some(keyword => allContent.toLowerCase().includes(keyword.toLowerCase()));
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
// 当前歌词
|
||||
const amLyricsData = computed<LyricLine[]>(() => {
|
||||
const isYrc = musicStore.songLyric.yrcData?.length && settingStore.showYrc;
|
||||
return isYrc ? musicStore.songLyric.yrcAMData : musicStore.songLyric.lrcAMData;
|
||||
const { songLyric } = musicStore;
|
||||
if (!songLyric) return [];
|
||||
|
||||
// 优先使用逐字歌词(YRC/TTML)
|
||||
const useYrc = songLyric.yrcAMData?.length && settingStore.showYrc;
|
||||
const lyrics = useYrc ? songLyric.yrcAMData : songLyric.lrcAMData;
|
||||
|
||||
// 简单检查歌词有效性
|
||||
if (!Array.isArray(lyrics) || lyrics.length === 0) return [];
|
||||
|
||||
// 检查是否为纯音乐
|
||||
if (isPureInstrumental(lyrics)) return [];
|
||||
|
||||
return lyrics;
|
||||
});
|
||||
|
||||
// 进度跳转
|
||||
@@ -68,9 +89,30 @@ const jumpSeek = (line: any) => {
|
||||
player.play();
|
||||
};
|
||||
|
||||
// 处理歌词语言
|
||||
const processLyricLanguage = () => {
|
||||
const lyricLinesEl = lyricPlayerRef.value?.lyricPlayer?.lyricLinesEl ?? [];
|
||||
// 遍历歌词行
|
||||
for (let e of lyricLinesEl) {
|
||||
// 获取歌词行内容 (合并逐字歌词为一句)
|
||||
const content = e.lyricLine.words.map((word: any) => word.word).join("");
|
||||
// 获取歌词语言
|
||||
const lang = getLyricLanguage(content);
|
||||
// 为主歌词设置 lang 属性 (firstChild 获取主歌词 不为翻译和音译设置属性)
|
||||
e.element.firstChild.setAttribute("lang", lang);
|
||||
}
|
||||
};
|
||||
|
||||
// 切换歌曲时处理歌词语言
|
||||
watch(amLyricsData, () => {
|
||||
nextTick(() => processLyricLanguage());
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
// 恢复进度
|
||||
resumeSeek();
|
||||
// 处理歌词语言
|
||||
nextTick(() => processLyricLanguage());
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
@@ -85,15 +127,14 @@ onBeforeUnmount(() => {
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
filter: drop-shadow(0px 4px 6px rgba(0, 0, 0, 0.2));
|
||||
mask: linear-gradient(
|
||||
180deg,
|
||||
hsla(0, 0%, 100%, 0) 0,
|
||||
hsla(0, 0%, 100%, 0.6) 5%,
|
||||
#fff 10%,
|
||||
#fff 75%,
|
||||
hsla(0, 0%, 100%, 0.6) 85%,
|
||||
hsla(0, 0%, 100%, 0)
|
||||
);
|
||||
mask: linear-gradient(180deg,
|
||||
hsla(0, 0%, 100%, 0) 0,
|
||||
hsla(0, 0%, 100%, 0.6) 5%,
|
||||
#fff 10%,
|
||||
#fff 75%,
|
||||
hsla(0, 0%, 100%, 0.6) 85%,
|
||||
hsla(0, 0%, 100%, 0));
|
||||
|
||||
:deep(.am-lyric) {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
@@ -104,15 +145,22 @@ onBeforeUnmount(() => {
|
||||
padding-right: 80px;
|
||||
margin-left: -2rem;
|
||||
}
|
||||
|
||||
&.pure {
|
||||
text-align: center;
|
||||
|
||||
:deep(.am-lyric) {
|
||||
margin: 0;
|
||||
padding: 0 80px;
|
||||
|
||||
div {
|
||||
transform-origin: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:lang(ja) {
|
||||
font-family: var(--ja-font-family);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
'--lrc-tran-size': settingStore.lyricTranFontSize + 'px',
|
||||
'--lrc-roma-size': settingStore.lyricRomaFontSize + 'px',
|
||||
'--lrc-bold': settingStore.lyricFontBold ? 'bold' : 'normal',
|
||||
'--ja-font-family':
|
||||
settingStore.japaneseLyricFont !== 'follow' ? settingStore.japaneseLyricFont : '',
|
||||
'font-family': settingStore.LyricFont !== 'follow' ? settingStore.LyricFont : '',
|
||||
cursor: statusStore.playerMetaShow ? 'auto' : 'none',
|
||||
}"
|
||||
@@ -41,7 +43,19 @@
|
||||
v-for="(item, index) in musicStore.songLyric.yrcData"
|
||||
:key="index"
|
||||
:id="`lrc-${index}`"
|
||||
:class="['lrc-line', 'is-yrc', { on: statusStore.lyricIndex === index }]"
|
||||
:class="[
|
||||
'lrc-line',
|
||||
'is-yrc',
|
||||
{
|
||||
// on: statusStore.lyricIndex === index,
|
||||
// 当播放时间大于等于当前歌词的开始时间
|
||||
on:
|
||||
(playSeek >= item.time && playSeek < item.endTime) ||
|
||||
statusStore.lyricIndex === index,
|
||||
'is-bg': item.isBG,
|
||||
'is-duet': item.isDuet,
|
||||
},
|
||||
]"
|
||||
:style="{
|
||||
filter: settingStore.lyricsBlur
|
||||
? `blur(${Math.min(Math.abs(statusStore.lyricIndex - index) * 1.8, 10)}px)`
|
||||
@@ -60,16 +74,26 @@
|
||||
'end-with-space': text.endsWithSpace,
|
||||
}"
|
||||
>
|
||||
<span class="word">{{ text.content }}</span>
|
||||
<span class="filler" :style="getYrcStyle(text, index)">
|
||||
<span class="word" :lang="getLyricLanguage(text.content)">
|
||||
{{ text.content }}
|
||||
</span>
|
||||
<span
|
||||
class="filler"
|
||||
:style="getYrcStyle(text, index)"
|
||||
:lang="getLyricLanguage(text.content)"
|
||||
>
|
||||
{{ text.content }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 翻译 -->
|
||||
<span v-if="item.tran && settingStore.showTran" class="tran">{{ item.tran }}</span>
|
||||
<span v-if="item.tran && settingStore.showTran" class="tran" lang="en">
|
||||
{{ item.tran }}
|
||||
</span>
|
||||
<!-- 音译 -->
|
||||
<span v-if="item.roma && settingStore.showRoma" class="roma">{{ item.roma }}</span>
|
||||
<span v-if="item.roma && settingStore.showRoma" class="roma" lang="en">
|
||||
{{ item.roma }}
|
||||
</span>
|
||||
<!-- 倒计时 -->
|
||||
<div
|
||||
v-if="
|
||||
@@ -113,11 +137,15 @@
|
||||
@click="jumpSeek(item.time)"
|
||||
>
|
||||
<!-- 歌词 -->
|
||||
<span class="content">{{ item.content }}</span>
|
||||
<span class="content" :lang="getLyricLanguage(item.content)">{{ item.content }}</span>
|
||||
<!-- 翻译 -->
|
||||
<span v-if="item.tran && settingStore.showTran" class="tran">{{ item.tran }}</span>
|
||||
<span v-if="item.tran && settingStore.showTran" class="tran" lang="en">
|
||||
{{ item.tran }}
|
||||
</span>
|
||||
<!-- 音译 -->
|
||||
<span v-if="item.roma && settingStore.showRoma" class="roma">{{ item.roma }}</span>
|
||||
<span v-if="item.roma && settingStore.showRoma" class="roma" lang="en">
|
||||
{{ item.roma }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="placeholder" />
|
||||
</template>
|
||||
@@ -151,6 +179,7 @@ import { NScrollbar } from "naive-ui";
|
||||
import { useMusicStore, useSettingStore, useStatusStore } from "@/stores";
|
||||
import { openSetting } from "@/utils/modal";
|
||||
import player from "@/utils/player";
|
||||
import { getLyricLanguage } from "@/utils/lyric";
|
||||
|
||||
const musicStore = useMusicStore();
|
||||
const statusStore = useStatusStore();
|
||||
@@ -200,12 +229,12 @@ const lyricsScroll = (index: number) => {
|
||||
const getYrcStyle = (wordData: LyricContentType, lyricIndex: number) => {
|
||||
if (settingStore.showYrcAnimation) {
|
||||
// 如果当前歌词索引与播放歌曲的歌词索引不匹配
|
||||
if (statusStore.lyricIndex !== lyricIndex) {
|
||||
return {
|
||||
transitionDuration: `0ms, 0ms, 0.35s`,
|
||||
transitionDelay: `0ms`,
|
||||
};
|
||||
}
|
||||
// if (statusStore.lyricIndex !== lyricIndex) {
|
||||
// return {
|
||||
// transitionDuration: `0ms, 0ms, 0.35s`,
|
||||
// transitionDelay: `0ms`,
|
||||
// };
|
||||
// }
|
||||
// 如果播放状态不是加载中,且当前单词的时间加上持续时间减去播放进度大于 0
|
||||
if (
|
||||
statusStore.playLoading === false &&
|
||||
@@ -217,11 +246,6 @@ const getYrcStyle = (wordData: LyricContentType, lyricIndex: number) => {
|
||||
WebkitMaskPositionX: `${
|
||||
100 - Math.max(((playSeek.value - wordData.time) / wordData.duration) * 100, 0)
|
||||
}%`,
|
||||
// 最大上移2px
|
||||
// transform: `translateY(-${Math.min(
|
||||
// ((playSeek.value - wordData.time) / wordData.duration) * 2,
|
||||
// 2,
|
||||
// )}px)`,
|
||||
};
|
||||
}
|
||||
// 如果以上条件都不满足
|
||||
@@ -230,7 +254,6 @@ const getYrcStyle = (wordData: LyricContentType, lyricIndex: number) => {
|
||||
transitionDelay: `${wordData.time - playSeek.value}ms, ${
|
||||
wordData.time - playSeek.value + wordData.duration * 0.5
|
||||
}ms, 0ms`,
|
||||
// transform: "translateY(-2px)",
|
||||
};
|
||||
} else {
|
||||
// 如果当前歌词索引与播放歌曲的歌词索引不匹配,或者播放状态不是加载中且当前单词的时间大于等于播放进度
|
||||
@@ -299,6 +322,8 @@ onBeforeUnmount(() => {
|
||||
:deep(.n-scrollbar-content) {
|
||||
padding-left: 10px;
|
||||
padding-right: 80px;
|
||||
max-width: 100%; /* 新增:防止宽度溢出 */
|
||||
box-sizing: border-box; /* 新增:确保 padding 不影响宽度 */
|
||||
}
|
||||
.placeholder {
|
||||
width: 100%;
|
||||
@@ -315,6 +340,7 @@ onBeforeUnmount(() => {
|
||||
.lyric-content {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
box-sizing: border-box; /* 新增:确保宽度计算正确 */
|
||||
}
|
||||
.lrc-line {
|
||||
position: relative;
|
||||
@@ -330,16 +356,23 @@ onBeforeUnmount(() => {
|
||||
opacity 0.35s,
|
||||
transform 0.5s cubic-bezier(0.25, 0.1, 0.25, 1);
|
||||
cursor: pointer;
|
||||
// 歌词
|
||||
width: 100%;
|
||||
box-sizing: border-box; /* 新增:确保 padding 不影响宽度 */
|
||||
.content {
|
||||
display: block;
|
||||
font-size: var(--lrc-size);
|
||||
font-weight: var(--lrc-bold);
|
||||
word-wrap: break-word;
|
||||
// 逐字歌词
|
||||
width: 100%;
|
||||
overflow-wrap: anywhere; /* 支持超长单词换行 */
|
||||
word-break: break-word; /* 优先空格或连字符换行,超长单词强制换行 */
|
||||
white-space: normal; /* 新增:明确文本换行行为 */
|
||||
hyphens: auto; /* 英文自动连字符 */
|
||||
.content-text {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
overflow-wrap: anywhere; /* 新增:逐字歌词单词支持换行 */
|
||||
word-break: break-word; /* 新增:单词内换行 */
|
||||
white-space: normal; /* 新增:确保逐字歌词换行 */
|
||||
.word {
|
||||
opacity: 0.3;
|
||||
display: inline-block;
|
||||
@@ -385,22 +418,32 @@ onBeforeUnmount(() => {
|
||||
}
|
||||
}
|
||||
}
|
||||
&:lang(ja) {
|
||||
font-family: var(--ja-font-family);
|
||||
}
|
||||
}
|
||||
// 翻译
|
||||
.tran {
|
||||
margin-top: 8px;
|
||||
opacity: 0.6;
|
||||
font-size: var(--lrc-tran-size);
|
||||
transition: opacity 0.35s;
|
||||
width: 100%;
|
||||
overflow-wrap: anywhere; /* 支持超长单词换行 */
|
||||
word-break: break-word; /* 优先空格或连字符换行,超长单词强制换行 */
|
||||
white-space: normal; /* 新增:明确文本换行行为 */
|
||||
hyphens: auto; /* 英文自动连字符 */
|
||||
}
|
||||
// 音译
|
||||
.roma {
|
||||
margin-top: 4px;
|
||||
opacity: 0.5;
|
||||
font-size: var(--lrc-roma-size);
|
||||
transition: opacity 0.35s;
|
||||
width: 100%;
|
||||
overflow-wrap: anywhere; /* 支持超长单词换行 */
|
||||
word-break: break-word; /* 优先空格或连字符换行,超长单词强制换行 */
|
||||
white-space: normal; /* 新增:明确文本换行行为 */
|
||||
hyphens: auto; /* 英文自动连字符 */
|
||||
}
|
||||
// 倒计时
|
||||
.count-down-content {
|
||||
height: 50px;
|
||||
margin-top: 40px;
|
||||
@@ -416,16 +459,33 @@ onBeforeUnmount(() => {
|
||||
.content {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
width: 100%;
|
||||
overflow-wrap: anywhere; /* 逐字歌词支持超长单词换行 */
|
||||
word-break: break-word; /* 优先空格或连字符换行 */
|
||||
white-space: normal; /* 确保换行行为 */
|
||||
}
|
||||
.tran,
|
||||
.roma {
|
||||
opacity: 0.3;
|
||||
}
|
||||
&.is-bg {
|
||||
opacity: 0.4;
|
||||
transform: scale(0.5);
|
||||
padding: 0px 32px;
|
||||
}
|
||||
&.is-duet {
|
||||
transform-origin: right;
|
||||
.content,
|
||||
.tran,
|
||||
.roma {
|
||||
text-align: right;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
}
|
||||
}
|
||||
&.on {
|
||||
opacity: 1;
|
||||
opacity: 1 !important;
|
||||
transform: scale(1);
|
||||
// 逐字歌词
|
||||
.content-text {
|
||||
.filler {
|
||||
opacity: 1;
|
||||
@@ -438,6 +498,9 @@ onBeforeUnmount(() => {
|
||||
.roma {
|
||||
opacity: 0.6;
|
||||
}
|
||||
&.is-bg {
|
||||
opacity: 0.6 !important;
|
||||
}
|
||||
}
|
||||
&::before {
|
||||
content: "";
|
||||
@@ -542,7 +605,6 @@ onBeforeUnmount(() => {
|
||||
}
|
||||
.lrc-line {
|
||||
transform-origin: right;
|
||||
align-items: flex-end;
|
||||
.content {
|
||||
text-align: right;
|
||||
}
|
||||
@@ -562,7 +624,6 @@ onBeforeUnmount(() => {
|
||||
}
|
||||
.lrc-line {
|
||||
transform-origin: center !important;
|
||||
align-items: center !important;
|
||||
.content {
|
||||
text-align: center !important;
|
||||
}
|
||||
@@ -575,6 +636,8 @@ onBeforeUnmount(() => {
|
||||
&.pure {
|
||||
:deep(.n-scrollbar-content) {
|
||||
padding: 0 80px;
|
||||
max-width: 100%; /* 新增:防止宽度溢出 */
|
||||
box-sizing: border-box; /* 新增:确保 padding 不影响宽度 */
|
||||
}
|
||||
.lyric-content {
|
||||
.placeholder {
|
||||
|
||||
@@ -191,6 +191,33 @@
|
||||
/>
|
||||
</n-flex>
|
||||
</n-card>
|
||||
<n-card class="set-item">
|
||||
<div class="label">
|
||||
<n-text class="name">日语歌词字体</n-text>
|
||||
<n-text class="tip" :depth="3"> 是否在歌词为日语时单独设置字体 </n-text>
|
||||
</div>
|
||||
<n-flex>
|
||||
<Transition name="fade" mode="out-in">
|
||||
<n-button
|
||||
v-if="settingStore.japaneseLyricFont !== 'follow'"
|
||||
type="primary"
|
||||
strong
|
||||
secondary
|
||||
@click="settingStore.japaneseLyricFont = 'follow'"
|
||||
>
|
||||
恢复默认
|
||||
</n-button>
|
||||
</Transition>
|
||||
<n-select
|
||||
v-model:value="settingStore.japaneseLyricFont"
|
||||
:options="[
|
||||
{ label: '跟随全局', value: 'follow' },
|
||||
...allFontsData.filter((v) => v.value !== 'default'),
|
||||
]"
|
||||
class="set"
|
||||
/>
|
||||
</n-flex>
|
||||
</n-card>
|
||||
<n-card class="set-item">
|
||||
<div class="label">
|
||||
<n-text class="name">关闭软件时</n-text>
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
<n-card class="set-item">
|
||||
<div class="label">
|
||||
<n-text class="name">歌词字体大小</n-text>
|
||||
<n-text class="tip" :depth="3">单位 px,最小 30,最大 60</n-text>
|
||||
<n-text class="tip" :depth="3">单位 px,最小 12,最大 60</n-text>
|
||||
</div>
|
||||
<n-flex>
|
||||
<Transition name="fade" mode="out-in">
|
||||
@@ -45,7 +45,7 @@
|
||||
</Transition>
|
||||
<n-input-number
|
||||
v-model:value="settingStore.lyricFontSize"
|
||||
:min="30"
|
||||
:min="12"
|
||||
:max="60"
|
||||
class="set"
|
||||
placeholder="请输入歌词字体大小"
|
||||
@@ -58,7 +58,7 @@
|
||||
<n-card class="set-item">
|
||||
<div class="label">
|
||||
<n-text class="name">翻译歌词大小</n-text>
|
||||
<n-text class="tip" :depth="3">单位 px,最小 12,最大 40</n-text>
|
||||
<n-text class="tip" :depth="3">单位 px,最小 5,最大 40</n-text>
|
||||
</div>
|
||||
<n-flex>
|
||||
<Transition name="fade" mode="out-in">
|
||||
@@ -74,7 +74,7 @@
|
||||
</Transition>
|
||||
<n-input-number
|
||||
v-model:value="settingStore.lyricTranFontSize"
|
||||
:min="12"
|
||||
:min="5"
|
||||
:max="40"
|
||||
:disabled="settingStore.useAMLyrics"
|
||||
class="set"
|
||||
@@ -90,7 +90,7 @@
|
||||
<n-card class="set-item">
|
||||
<div class="label">
|
||||
<n-text class="name">音译歌词大小</n-text>
|
||||
<n-text class="tip" :depth="3">单位 px,最小 12,最大 40</n-text>
|
||||
<n-text class="tip" :depth="3">单位 px,最小 5,最大 40</n-text>
|
||||
</div>
|
||||
<n-flex>
|
||||
<Transition name="fade" mode="out-in">
|
||||
@@ -106,7 +106,7 @@
|
||||
</Transition>
|
||||
<n-input-number
|
||||
v-model:value="settingStore.lyricRomaFontSize"
|
||||
:min="12"
|
||||
:min="5"
|
||||
:max="40"
|
||||
:disabled="settingStore.useAMLyrics"
|
||||
class="set"
|
||||
@@ -260,6 +260,15 @@
|
||||
</div>
|
||||
<n-switch v-model:value="settingStore.useAMSpring" class="set" :round="false" />
|
||||
</n-card>
|
||||
<n-card class="set-item">
|
||||
<div class="label">
|
||||
<n-text class="name">启用 TTML 歌词</n-text>
|
||||
<n-text class="tip" :depth="3">
|
||||
是否启用 TTML 歌词(如有),TTML 歌词支持逐字、翻译、音译等功能, 将会在下一首歌生效
|
||||
</n-text>
|
||||
</div>
|
||||
<n-switch v-model:value="settingStore.enableTTMLLyric" class="set" :round="false" />
|
||||
</n-card>
|
||||
</div>
|
||||
<div v-if="isElectron" class="set-list">
|
||||
<n-h3 prefix="bar"> 桌面歌词 </n-h3>
|
||||
@@ -285,8 +294,8 @@
|
||||
:options="
|
||||
Array.from({ length: 41 }, (_, i) => {
|
||||
return {
|
||||
label: `${20 + i} px`,
|
||||
value: 20 + i,
|
||||
label: `${10 + i} px`,
|
||||
value: 10 + i,
|
||||
};
|
||||
})
|
||||
"
|
||||
|
||||
@@ -20,6 +20,7 @@ interface SettingState {
|
||||
themeFollowCover: boolean;
|
||||
globalFont: "default" | string;
|
||||
LyricFont: "follow" | string;
|
||||
japaneseLyricFont: "follow" | string;
|
||||
showCloseAppTip: boolean;
|
||||
closeAppMethod: "exit" | "hide";
|
||||
showTaskbarProgress: boolean;
|
||||
@@ -73,6 +74,7 @@ interface SettingState {
|
||||
showSearchHistory: boolean;
|
||||
useAMLyrics: boolean;
|
||||
useAMSpring: boolean;
|
||||
enableTTMLLyric: boolean;
|
||||
menuShowCover: boolean;
|
||||
preventSleep: boolean;
|
||||
localFilesPath: string[];
|
||||
@@ -99,6 +101,7 @@ export const useSettingStore = defineStore("setting", {
|
||||
themeGlobalColor: false, // 全局着色
|
||||
globalFont: "default", // 全局字体
|
||||
LyricFont: "follow", // 歌词区域字体
|
||||
japaneseLyricFont: "follow", // 日语歌词字体
|
||||
hideVipTag: false, // 隐藏 VIP 标签
|
||||
showSearchHistory: true, // 显示搜索历史
|
||||
menuShowCover: true, // 菜单显示封面
|
||||
@@ -138,6 +141,7 @@ export const useSettingStore = defineStore("setting", {
|
||||
lyricFontBold: true, // 歌词字体加粗
|
||||
useAMLyrics: false, // 是否使用 AM 歌词
|
||||
useAMSpring: false, // 是否使用 AM 歌词弹簧效果
|
||||
enableTTMLLyric: true, // 启用 TTML 歌词
|
||||
showYrc: true, // 显示逐字歌词
|
||||
showYrcAnimation: true, // 显示逐字歌词动画
|
||||
showTran: true, // 显示歌词翻译
|
||||
|
||||
109
src/types/amll.d.ts
vendored
Normal file
109
src/types/amll.d.ts
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
/**
|
||||
* AMLL (Apple Music-like Lyrics) 相关类型定义
|
||||
*/
|
||||
|
||||
/**
|
||||
* 歌词播放器引用类型
|
||||
*/
|
||||
export interface LyricPlayerRef {
|
||||
setCurrentTime?: (time: number) => void;
|
||||
setPlaying?: (playing: boolean) => void;
|
||||
lyricPlayer?: { value?: any };
|
||||
}
|
||||
|
||||
/**
|
||||
* 歌词单词类型
|
||||
*/
|
||||
export interface LyricWord {
|
||||
word: string;
|
||||
startTime: number;
|
||||
endTime: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 歌词行类型
|
||||
*/
|
||||
export interface LyricLine {
|
||||
startTime: number;
|
||||
endTime: number;
|
||||
words: LyricWord[];
|
||||
translatedLyric?: string;
|
||||
romanLyric?: string;
|
||||
isBG?: boolean;
|
||||
isDuet?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 歌词点击事件类型
|
||||
*/
|
||||
export interface LyricClickEvent {
|
||||
line: {
|
||||
getLine: () => LyricLine;
|
||||
lyricLine?: LyricLine;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 弹簧参数类型
|
||||
*/
|
||||
export interface SpringParam {
|
||||
mass: number; // 质量,影响弹簧的惯性
|
||||
damping: number; // 阻尼,影响弹簧的减速速度
|
||||
stiffness: number; // 刚度,影响弹簧的弹力
|
||||
soft: boolean; // 是否使用软弹簧模式
|
||||
}
|
||||
|
||||
/**
|
||||
* 弹簧参数集合
|
||||
*/
|
||||
export interface SpringParams {
|
||||
posX?: SpringParam;
|
||||
posY?: SpringParam;
|
||||
scale?: SpringParam;
|
||||
rotation?: SpringParam;
|
||||
}
|
||||
|
||||
/**
|
||||
* 背景渲染器引用类型
|
||||
*/
|
||||
export interface BackgroundRenderRef {
|
||||
bgRender: any;
|
||||
wrapperEl?: HTMLDivElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* 背景渲染器属性类型
|
||||
*/
|
||||
export interface BackgroundRenderProps {
|
||||
album?: string;
|
||||
albumIsVideo?: boolean;
|
||||
fps?: number;
|
||||
playing?: boolean;
|
||||
flowSpeed?: number;
|
||||
hasLyric?: boolean;
|
||||
lowFreqVolume?: number;
|
||||
renderScale?: number;
|
||||
staticMode?: boolean;
|
||||
renderer?: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* 歌词处理器设置类型
|
||||
*/
|
||||
export interface LyricsProcessorSettings {
|
||||
showYrc: boolean;
|
||||
showRoma: boolean;
|
||||
showTransl: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 歌曲歌词类型
|
||||
*/
|
||||
export interface SongLyric {
|
||||
lrc?: Array<{time: number, content: string, tran?: string, roma?: string}>;
|
||||
yrc?: Array<{time: number, endTime?: number, content: any[], tran?: string, roma?: string}>;
|
||||
ttml?: string;
|
||||
hasYrc?: boolean;
|
||||
lrcAMData?: LyricLine[];
|
||||
yrcAMData?: LyricLine[];
|
||||
}
|
||||
8
src/types/main.d.ts
vendored
8
src/types/main.d.ts
vendored
@@ -131,10 +131,18 @@ export type LyricContentType = {
|
||||
};
|
||||
|
||||
export type LyricType = {
|
||||
/** 歌词开始时间 */
|
||||
time: number;
|
||||
/** 歌词结束时间 */
|
||||
endTime: number;
|
||||
/** 翻译歌词 */
|
||||
tran?: string;
|
||||
/** 音译歌词 */
|
||||
roma?: string;
|
||||
/** 是否为背景歌词 */
|
||||
isBG?: boolean;
|
||||
/** 是否为对唱歌词 */
|
||||
isDuet?: boolean;
|
||||
content: string;
|
||||
contents: LyricContentType[];
|
||||
};
|
||||
|
||||
@@ -18,7 +18,7 @@ class BlobURLManager {
|
||||
// console.log("🌱 Blob URL already exists:", key);
|
||||
return this.blobURLs.get(key)!;
|
||||
}
|
||||
const blob = new Blob([data], { type: format });
|
||||
const blob = new Blob([new Uint8Array(data)], { type: format });
|
||||
const blobURL = URL.createObjectURL(blob);
|
||||
// 存储 Blob URL
|
||||
this.blobURLs.set(key, blobURL);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { LyricLine, parseLrc, parseYrc } from "@applemusic-like-lyrics/lyric";
|
||||
import { LyricLine, parseLrc, parseYrc, TTMLLyric } from "@applemusic-like-lyrics/lyric";
|
||||
import type { LyricType } from "@/types/main";
|
||||
import { useMusicStore, useSettingStore } from "@/stores";
|
||||
import { msToS } from "./time";
|
||||
@@ -207,3 +207,108 @@ const parseAMData = (lrcData: LyricLine[], tranData?: LyricLine[], romaData?: Ly
|
||||
isDuet: line.isDuet ?? false,
|
||||
}));
|
||||
};
|
||||
|
||||
/**
|
||||
* 从TTML格式解析歌词并转换为AMLL格式
|
||||
* @param ttmlContent TTML格式的歌词内容
|
||||
* @returns AMLL格式的歌词行数组
|
||||
*/
|
||||
export const parseTTMLToAMLL = (ttmlContent: TTMLLyric): LyricLine[] => {
|
||||
if (!ttmlContent) return [];
|
||||
|
||||
try {
|
||||
const validLines = ttmlContent.lines
|
||||
.filter((line): line is any => line && typeof line === "object" && Array.isArray(line.words))
|
||||
.map((line) => {
|
||||
const words = line.words
|
||||
.filter((word: any) => word && typeof word === "object")
|
||||
.map((word: any) => ({
|
||||
word: String(word.word || " "),
|
||||
startTime: Number(word.startTime) || 0,
|
||||
endTime: Number(word.endTime) || 0,
|
||||
}));
|
||||
|
||||
if (!words.length) return null;
|
||||
|
||||
const startTime = words[0].startTime;
|
||||
const endTime = words[words.length - 1].endTime;
|
||||
|
||||
return {
|
||||
words,
|
||||
startTime,
|
||||
endTime,
|
||||
translatedLyric: String(line.translatedLyric || ""),
|
||||
romanLyric: String(line.romanLyric || ""),
|
||||
isBG: Boolean(line.isBG),
|
||||
isDuet: Boolean(line.isDuet),
|
||||
};
|
||||
})
|
||||
.filter((line): line is LyricLine => line !== null);
|
||||
|
||||
return validLines;
|
||||
} catch (error) {
|
||||
console.error("TTML parsing error:", error);
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 从TTML格式解析歌词并转换为默认Yrc格式
|
||||
* @param ttmlContent TTML格式的歌词内容
|
||||
* @returns 默认Yrc格式的歌词行数组
|
||||
*/
|
||||
export const parseTTMLToYrc = (ttmlContent: TTMLLyric): LyricType[] => {
|
||||
if (!ttmlContent) return [];
|
||||
|
||||
try {
|
||||
// 数据处理
|
||||
const yrcList = ttmlContent.lines
|
||||
.map((line) => {
|
||||
const words = line.words;
|
||||
const time = msToS(words[0].startTime);
|
||||
const endTime = msToS(words[words.length - 1].endTime);
|
||||
const contents = words.map((word) => {
|
||||
return {
|
||||
time: msToS(word.startTime),
|
||||
endTime: msToS(word.endTime),
|
||||
duration: msToS(word.endTime - word.startTime),
|
||||
content: word.word.trim(),
|
||||
endsWithSpace: word.word.endsWith(" "),
|
||||
};
|
||||
});
|
||||
// 完整歌词
|
||||
const contentStr = contents
|
||||
.map((word) => word.content + (word.endsWithSpace ? " " : ""))
|
||||
.join("");
|
||||
// 排除内容
|
||||
if (!contentStr || getExcludeKeywords().some((keyword) => contentStr.includes(keyword))) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
time,
|
||||
endTime,
|
||||
content: contentStr,
|
||||
contents,
|
||||
tran: line.translatedLyric || "",
|
||||
roma: line.romanLyric || "",
|
||||
isBG: line.isBG,
|
||||
isDuet: line.isDuet,
|
||||
};
|
||||
})
|
||||
.filter((line) => line !== null);
|
||||
return yrcList;
|
||||
} catch (error) {
|
||||
console.error("TTML parsing to yrc error:", error);
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
// 检测语言
|
||||
export const getLyricLanguage = (lyric: string): string => {
|
||||
// 判断日语 根据平假名和片假名
|
||||
if (/[\u3040-\u309f\u30a0-\u30ff]/.test(lyric)) return "ja";
|
||||
// 判断简体中文 根据中日韩统一表意文字基本区
|
||||
if (/[\u4e00-\u9fa5]/.test(lyric)) return "zh-CN";
|
||||
// 默认英语
|
||||
return "en";
|
||||
};
|
||||
|
||||
@@ -90,6 +90,7 @@ export const openSongInfoEditor = (song: SongType) => {
|
||||
preset: "card",
|
||||
transformOrigin: "center",
|
||||
autoFocus: false,
|
||||
trapFocus: false,
|
||||
// contentStyle: { padding: 0 },
|
||||
style: { width: "600px" },
|
||||
title: "编辑歌曲信息",
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
import type { SongType, PlayModeType } from "@/types/main";
|
||||
import type { SongType, PlayModeType, LyricType } from "@/types/main";
|
||||
import type { MessageReactive } from "naive-ui";
|
||||
import { Howl, Howler } from "howler";
|
||||
import { cloneDeep } from "lodash-es";
|
||||
import { useMusicStore, useStatusStore, useDataStore, useSettingStore } from "@/stores";
|
||||
import { parsedLyricsData, resetSongLyric, parseLocalLyric } from "./lyric";
|
||||
import { songUrl, unlockSongUrl, songLyric, songChorus } from "@/api/song";
|
||||
import {
|
||||
parsedLyricsData,
|
||||
resetSongLyric,
|
||||
parseLocalLyric,
|
||||
parseTTMLToAMLL,
|
||||
parseTTMLToYrc,
|
||||
} from "./lyric";
|
||||
import { songUrl, unlockSongUrl, songLyric, songChorus, songLyricTTML } from "@/api/song";
|
||||
import { getCoverColorData } from "@/utils/color";
|
||||
import { calculateProgress } from "./time";
|
||||
import { isElectron, isDev } from "./helper";
|
||||
@@ -14,6 +20,8 @@ import { isLogin } from "./auth";
|
||||
import { openUserLogin } from "./modal";
|
||||
import { personalFm, personalFmToTrash } from "@/api/rec";
|
||||
import blob from "./blob";
|
||||
import { parseTTML } from "@applemusic-like-lyrics/lyric";
|
||||
import { LyricLine } from "@applemusic-like-lyrics/core";
|
||||
|
||||
// 播放器核心
|
||||
// Howler.js
|
||||
@@ -29,11 +37,13 @@ class Player {
|
||||
// 频谱数据
|
||||
private audioContext: AudioContext | null = null;
|
||||
private analyser: AnalyserNode | null = null;
|
||||
private dataArray: Uint8Array | null = null;
|
||||
private dataArray: Uint8Array<ArrayBuffer> | null = null;
|
||||
private source: MediaElementAudioSourceNode | null = null;
|
||||
// 其他数据
|
||||
private testNumber: number = 0;
|
||||
private message: MessageReactive | null = null;
|
||||
// 预载下一首歌曲播放地址缓存(仅存 URL,不创建 Howl)
|
||||
private nextPrefetch: { id: number; url: string | null; ublock: boolean } | null = null;
|
||||
constructor() {
|
||||
// 创建播放器实例
|
||||
this.player = new Howl({ src: [""], format: allowPlayFormat, autoplay: false });
|
||||
@@ -103,7 +113,7 @@ class Player {
|
||||
* 处理播放状态
|
||||
*/
|
||||
private handlePlayStatus() {
|
||||
const musicStore = useMusicStore();
|
||||
// const musicStore = useMusicStore();
|
||||
const statusStore = useStatusStore();
|
||||
const settingStore = useSettingStore();
|
||||
// 清理定时器
|
||||
@@ -115,14 +125,8 @@ class Player {
|
||||
const duration = this.player.duration();
|
||||
// 计算进度条距离
|
||||
const progress = calculateProgress(currentTime, duration);
|
||||
// 计算歌词索引
|
||||
const hasYrc = !musicStore.songLyric.yrcData.length || !settingStore.showYrc;
|
||||
const lyrics = hasYrc ? musicStore.songLyric.lrcData : musicStore.songLyric.yrcData;
|
||||
// 歌词实时偏移量
|
||||
const currentTimeOffset = statusStore.currentTimeOffset;
|
||||
const index = lyrics?.findIndex((v) => v?.time >= currentTime + currentTimeOffset);
|
||||
// 歌词跨界处理
|
||||
const lyricIndex = index === -1 ? lyrics.length - 1 : index - 1;
|
||||
// 计算歌词索引(支持 LRC 与逐字 YRC,对唱重叠处理)
|
||||
const { index: lyricIndex, lyrics } = this.calculateLyricIndex(currentTime);
|
||||
// 更新状态
|
||||
statusStore.$patch({ currentTime, duration, progress, lyricIndex });
|
||||
// 客户端事件
|
||||
@@ -130,11 +134,7 @@ class Player {
|
||||
// 歌词变化
|
||||
window.electron.ipcRenderer.send("play-lyric-change", {
|
||||
index: lyricIndex,
|
||||
lyric: cloneDeep(
|
||||
settingStore.showYrc && musicStore.songLyric.yrcData?.length
|
||||
? musicStore.songLyric.yrcData
|
||||
: musicStore.songLyric.lrcData,
|
||||
),
|
||||
lyric: cloneDeep(lyrics),
|
||||
});
|
||||
// 进度条
|
||||
if (settingStore.showTaskbarProgress) {
|
||||
@@ -143,6 +143,66 @@ class Player {
|
||||
}
|
||||
}, 250);
|
||||
}
|
||||
/**
|
||||
* 计算歌词索引
|
||||
* - 普通歌词(LRC):沿用当前按开始时间定位的算法
|
||||
* - 逐字歌词(YRC):当播放时间位于某句 [time, endTime) 区间内时,索引为该句;
|
||||
* 若下一句开始时间落在上一句区间(对唱重叠),仍保持上一句索引,直到上一句结束。
|
||||
*/
|
||||
private calculateLyricIndex(currentTime: number): { index: number; lyrics: LyricType[] } {
|
||||
const musicStore = useMusicStore();
|
||||
const statusStore = useStatusStore();
|
||||
const settingStore = useSettingStore();
|
||||
// 应用实时偏移 + 0.3s(解决对唱时歌词延迟问题)
|
||||
const playSeek = currentTime + statusStore.currentTimeOffset + 0.3;
|
||||
// 选择歌词类型
|
||||
const useYrc = !!(settingStore.showYrc && musicStore.songLyric.yrcData.length);
|
||||
const lyrics = useYrc ? musicStore.songLyric.yrcData : musicStore.songLyric.lrcData;
|
||||
// 无歌词时
|
||||
if (!lyrics || !lyrics.length) return { index: -1, lyrics: [] };
|
||||
|
||||
// 普通歌词:保持原有计算方式
|
||||
if (!useYrc) {
|
||||
const idx = lyrics.findIndex((v) => (v?.time ?? 0) >= playSeek);
|
||||
const index = idx === -1 ? lyrics.length - 1 : idx - 1;
|
||||
return { index, lyrics };
|
||||
}
|
||||
|
||||
// 逐字歌词(对唱最多两句同时存在):
|
||||
// - 计算在播放进度下处于激活区间的句子集合 activeIndices([time, endTime))
|
||||
// - 若激活数 >= 2,仅保留最后两句作为对唱对(不允许三句同时有效)
|
||||
// - 索引取该对唱对中较早的一句(保持“上一句”高亮)
|
||||
// - 若无激活句:首句之前返回 -1;否则回退到最近一句
|
||||
|
||||
const firstStart = lyrics[0]?.time ?? 0;
|
||||
if (playSeek < firstStart) {
|
||||
return { index: -1, lyrics };
|
||||
}
|
||||
|
||||
const activeIndices: number[] = [];
|
||||
for (let i = 0; i < lyrics.length; i++) {
|
||||
const start = lyrics[i]?.time ?? 0;
|
||||
const end = lyrics[i]?.endTime ?? Infinity;
|
||||
if (playSeek >= start && playSeek < end) {
|
||||
activeIndices.push(i);
|
||||
}
|
||||
}
|
||||
|
||||
if (activeIndices.length === 0) {
|
||||
// 不在任何句子的区间里:退回到最近一句(按开始时间)
|
||||
const nextIdx = lyrics.findIndex((v) => (v?.time ?? 0) > playSeek);
|
||||
const index = nextIdx === -1 ? lyrics.length - 1 : nextIdx - 1;
|
||||
return { index, lyrics };
|
||||
}
|
||||
|
||||
if (activeIndices.length === 1) {
|
||||
return { index: activeIndices[0], lyrics };
|
||||
}
|
||||
|
||||
// 激活句 >= 2:限制为最后两句对唱
|
||||
const pair = activeIndices.slice(-2);
|
||||
return { index: pair[0], lyrics };
|
||||
}
|
||||
/**
|
||||
* 获取在线播放链接
|
||||
* @param id 歌曲id
|
||||
@@ -162,8 +222,14 @@ class Player {
|
||||
} else return null;
|
||||
}
|
||||
// 返回歌曲地址
|
||||
// 客户端直接返回,网页端转 https
|
||||
const url = isElectron ? songData.url : songData.url.replace(/^http:/, "https:");
|
||||
// 客户端直接返回,网页端转 https, 并转换url以便解决音乐链接cors问题
|
||||
const url = isElectron
|
||||
? songData.url
|
||||
: songData.url
|
||||
.replace(/^http:/, "https:")
|
||||
.replace(/m804\.music\.126\.net/g, "m801.music.126.net")
|
||||
.replace(/m704\.music\.126\.net/g, "m701.music.126.net");
|
||||
console.log(`🎧 ${id} music url:`, url);
|
||||
return url;
|
||||
}
|
||||
/**
|
||||
@@ -200,6 +266,65 @@ class Player {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 预载下一首歌曲的播放地址(优先官方,失败则并发尝试解灰)
|
||||
* 仅缓存 URL,不实例化播放器
|
||||
*/
|
||||
private async prefetchNextSongUrl() {
|
||||
try {
|
||||
const dataStore = useDataStore();
|
||||
const statusStore = useStatusStore();
|
||||
// const musicStore = useMusicStore();
|
||||
const settingStore = useSettingStore();
|
||||
|
||||
// 无列表或私人FM模式直接跳过
|
||||
const playList = dataStore.playList;
|
||||
if (!playList?.length || statusStore.personalFmMode) {
|
||||
this.nextPrefetch = null;
|
||||
return;
|
||||
}
|
||||
|
||||
// 计算下一首(循环到首)
|
||||
let nextIndex = statusStore.playIndex + 1;
|
||||
if (nextIndex >= playList.length) nextIndex = 0;
|
||||
const nextSong = playList[nextIndex];
|
||||
if (!nextSong) {
|
||||
this.nextPrefetch = null;
|
||||
return;
|
||||
}
|
||||
|
||||
// 本地歌曲:直接缓存 file URL
|
||||
if (nextSong.path) {
|
||||
const songId = nextSong.type === "radio" ? nextSong.dj?.id : nextSong.id;
|
||||
this.nextPrefetch = {
|
||||
id: Number(songId || nextSong.id),
|
||||
url: `file://${nextSong.path}`,
|
||||
ublock: false,
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
// 在线歌曲:优先官方,其次解灰
|
||||
const songId = nextSong.type === "radio" ? nextSong.dj?.id : nextSong.id;
|
||||
if (!songId) {
|
||||
this.nextPrefetch = null;
|
||||
return;
|
||||
}
|
||||
const canUnlock = isElectron && nextSong.type !== "radio" && settingStore.useSongUnlock;
|
||||
const unlockUrlPromise = canUnlock ? this.getUnlockSongUrl(nextSong) : null;
|
||||
const url = await this.getOnlineUrl(songId);
|
||||
if (url) {
|
||||
this.nextPrefetch = { id: songId, url, ublock: false };
|
||||
} else if (unlockUrlPromise) {
|
||||
const unlockUrl = await unlockUrlPromise;
|
||||
this.nextPrefetch = { id: songId, url: unlockUrl || null, ublock: !!unlockUrl };
|
||||
} else {
|
||||
this.nextPrefetch = { id: songId, url: null, ublock: false };
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error prefetching next song url:", error);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 创建播放器
|
||||
* @param src 播放地址
|
||||
@@ -248,6 +373,8 @@ class Player {
|
||||
if (!path) this.updateMediaSession();
|
||||
// 开发模式
|
||||
if (isDev) window.player = this.player;
|
||||
// 异步预载下一首播放地址(不阻塞当前播放)
|
||||
void this.prefetchNextSongUrl();
|
||||
}
|
||||
/**
|
||||
* 播放器事件
|
||||
@@ -420,8 +547,42 @@ class Player {
|
||||
resetSongLyric();
|
||||
return;
|
||||
}
|
||||
const lyricRes = await songLyric(id);
|
||||
parsedLyricsData(lyricRes);
|
||||
|
||||
try {
|
||||
const musicStore = useMusicStore();
|
||||
const settingStore = useSettingStore();
|
||||
const [lyricRes, ttmlContent] = await Promise.all([
|
||||
songLyric(id),
|
||||
settingStore.enableTTMLLyric && songLyricTTML(id),
|
||||
]);
|
||||
parsedLyricsData(lyricRes);
|
||||
if (ttmlContent) {
|
||||
const parsedResult = parseTTML(ttmlContent);
|
||||
if (!parsedResult?.lines?.length) return;
|
||||
const ttmlLyric = parseTTMLToAMLL(parsedResult);
|
||||
const ttmlYrcLyric = parseTTMLToYrc(parsedResult);
|
||||
console.log("TTML lyrics:", ttmlLyric, ttmlYrcLyric);
|
||||
// 合并数据
|
||||
const updates: Partial<{ yrcAMData: LyricLine[]; yrcData: LyricType[] }> = {};
|
||||
if (ttmlLyric?.length) {
|
||||
updates.yrcAMData = ttmlLyric;
|
||||
console.log("✅ TTML AMLL lyrics success");
|
||||
}
|
||||
if (ttmlYrcLyric?.length) {
|
||||
updates.yrcData = ttmlYrcLyric;
|
||||
console.log("✅ TTML Yrc lyrics success");
|
||||
}
|
||||
if (Object.keys(updates).length) {
|
||||
musicStore.songLyric = {
|
||||
...musicStore.songLyric,
|
||||
...updates,
|
||||
};
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("❌ Error loading lyrics:", error);
|
||||
resetSongLyric();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 获取副歌时间
|
||||
@@ -549,7 +710,7 @@ class Player {
|
||||
statusStore.playLoading = true;
|
||||
// 本地歌曲
|
||||
if (path) {
|
||||
await this.createPlayer(path, autoPlay, seek);
|
||||
await this.createPlayer(`file://${path}`, autoPlay, seek);
|
||||
// 获取歌曲元信息
|
||||
await this.parseLocalMusicInfo(path);
|
||||
}
|
||||
@@ -557,39 +718,51 @@ class Player {
|
||||
else if (id && dataStore.playList.length) {
|
||||
const songId = type === "radio" ? dj?.id : id;
|
||||
if (!songId) throw new Error("Get song id error");
|
||||
const url = await this.getOnlineUrl(songId);
|
||||
// 正常播放地址
|
||||
if (url) {
|
||||
statusStore.playUblock = false;
|
||||
await this.createPlayer(url, autoPlay, seek);
|
||||
}
|
||||
// 尝试解灰
|
||||
else if (isElectron && type !== "radio" && settingStore.useSongUnlock) {
|
||||
const unlockUrl = await this.getUnlockSongUrl(playSongData);
|
||||
if (unlockUrl) {
|
||||
statusStore.playUblock = true;
|
||||
console.log("🎼 Song unlock successfully:", unlockUrl);
|
||||
await this.createPlayer(unlockUrl, autoPlay, seek);
|
||||
} else {
|
||||
statusStore.playUblock = false;
|
||||
// 是否为最后一首
|
||||
if (statusStore.playIndex === dataStore.playList.length - 1) {
|
||||
statusStore.$patch({ playStatus: false, playLoading: false });
|
||||
window.$message.warning("当前列表歌曲无法播放,请更换歌曲");
|
||||
} else {
|
||||
window.$message.error("该歌曲暂无音源,跳至下一首");
|
||||
this.nextOrPrev("next");
|
||||
}
|
||||
}
|
||||
// 优先使用预载的下一首 URL(若命中缓存)
|
||||
const cached = this.nextPrefetch;
|
||||
if (cached && cached.id === songId && cached.url) {
|
||||
statusStore.playUblock = cached.ublock;
|
||||
await this.createPlayer(cached.url, autoPlay, seek);
|
||||
} else {
|
||||
if (dataStore.playList.length === 1) {
|
||||
this.resetStatus();
|
||||
window.$message.warning("当前播放列表已无可播放歌曲,请更换");
|
||||
return;
|
||||
// 并发启动解灰请求(仅在 Electron 且非电台且开启解灰时)
|
||||
const canUnlock = isElectron && type !== "radio" && settingStore.useSongUnlock;
|
||||
const unlockUrlPromise = canUnlock ? this.getUnlockSongUrl(playSongData) : null;
|
||||
// 先请求正常播放地址
|
||||
const url = await this.getOnlineUrl(songId);
|
||||
// 正常播放地址
|
||||
if (url) {
|
||||
statusStore.playUblock = false;
|
||||
await this.createPlayer(url, autoPlay, seek);
|
||||
}
|
||||
// 尝试解灰
|
||||
else if (unlockUrlPromise) {
|
||||
// 若正常地址不可用,则等待并使用并发中的解灰结果
|
||||
const unlockUrl = await unlockUrlPromise;
|
||||
if (unlockUrl) {
|
||||
statusStore.playUblock = true;
|
||||
console.log("🎼 Song unlock successfully:", unlockUrl);
|
||||
await this.createPlayer(unlockUrl, autoPlay, seek);
|
||||
} else {
|
||||
statusStore.playUblock = false;
|
||||
// 是否为最后一首
|
||||
if (statusStore.playIndex === dataStore.playList.length - 1) {
|
||||
statusStore.$patch({ playStatus: false, playLoading: false });
|
||||
window.$message.warning("当前列表歌曲无法播放,请更换歌曲");
|
||||
} else {
|
||||
window.$message.error("该歌曲暂无音源,跳至下一首");
|
||||
this.nextOrPrev("next");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
window.$message.error("该歌曲无法播放,跳至下一首");
|
||||
this.nextOrPrev();
|
||||
return;
|
||||
if (dataStore.playList.length === 1) {
|
||||
this.resetStatus();
|
||||
window.$message.warning("当前播放列表已无可播放歌曲,请更换");
|
||||
return;
|
||||
} else {
|
||||
window.$message.error("该歌曲无法播放,跳至下一首");
|
||||
this.nextOrPrev();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -634,7 +807,7 @@ class Player {
|
||||
|
||||
// 立即设置播放状态
|
||||
if (changeStatus) statusStore.playStatus = false;
|
||||
|
||||
|
||||
// 淡出
|
||||
await new Promise<void>((resolve) => {
|
||||
this.player.fade(statusStore.playVolume, 0, this.getFadeTime());
|
||||
@@ -908,7 +1081,7 @@ class Player {
|
||||
const statusStore = useStatusStore();
|
||||
// 获取配置
|
||||
const { showTip, play } = options;
|
||||
|
||||
|
||||
// 处理随机播放模式
|
||||
let processedData = cloneDeep(data);
|
||||
if (statusStore.playSongMode === "shuffle") {
|
||||
@@ -917,7 +1090,7 @@ class Player {
|
||||
// 随机排序
|
||||
processedData = this.shuffleArray(processedData);
|
||||
}
|
||||
|
||||
|
||||
// 更新列表
|
||||
await dataStore.setPlayList(processedData);
|
||||
// 关闭特殊模式
|
||||
@@ -937,7 +1110,9 @@ class Player {
|
||||
}
|
||||
} else {
|
||||
statusStore.playIndex =
|
||||
statusStore.playSongMode === "shuffle" ? Math.floor(Math.random() * processedData.length) : 0;
|
||||
statusStore.playSongMode === "shuffle"
|
||||
? Math.floor(Math.random() * processedData.length)
|
||||
: 0;
|
||||
// 播放
|
||||
await this.pause(false);
|
||||
await this.initPlayer();
|
||||
|
||||
@@ -83,13 +83,15 @@ server.interceptors.response.use(
|
||||
// 处理其他状态码或错误条件
|
||||
console.error("未处理的错误:", error.message);
|
||||
}
|
||||
window.$notification.error({
|
||||
title: "请求错误",
|
||||
description: `状态码: ${response?.status || ""}`,
|
||||
content: (response && (response.data as { message?: string }).message) || error.message,
|
||||
meta: "若持续发生,可尝试软件热重载",
|
||||
duration: 5000,
|
||||
});
|
||||
// window.$notification.error({
|
||||
// title: "请求错误",
|
||||
// description: `状态码: ${response?.status || ""}`,
|
||||
// content: (response && (response.data as { message?: string }).message) || error.message,
|
||||
// meta: "若持续发生,可尝试软件热重载",
|
||||
// duration: 5000,
|
||||
// });
|
||||
// 控制台输出
|
||||
window.$message.warning("请求出错,若持续发生,可尝试软件热重载");
|
||||
// 返回错误
|
||||
return Promise.reject(error);
|
||||
},
|
||||
|
||||
@@ -178,7 +178,7 @@ import { debounce, isObject } from "lodash-es";
|
||||
import { useDataStore, useStatusStore } from "@/stores";
|
||||
import { openBatchList, openUpdatePlaylist } from "@/utils/modal";
|
||||
import { formatTimestamp } from "@/utils/time";
|
||||
import { isLogin } from "@/utils/auth";
|
||||
import { isLogin, updateUserLikePlaylist } from "@/utils/auth";
|
||||
import player from "@/utils/player";
|
||||
|
||||
const router = useRouter();
|
||||
@@ -408,9 +408,32 @@ onDeactivated(() => loadingMsgShow(false));
|
||||
onUnmounted(() => loadingMsgShow(false));
|
||||
|
||||
onMounted(async () => {
|
||||
const data: any = await dataStore.getUserLikePlaylist();
|
||||
const id = data?.detail?.id;
|
||||
if (id) getPlaylistDetail(id);
|
||||
// 首先确保用户歌单数据已加载
|
||||
if (!dataStore.userLikeData.playlists?.length) {
|
||||
try {
|
||||
await updateUserLikePlaylist();
|
||||
} catch (error) {
|
||||
console.error("Failed to update user playlist data:", error);
|
||||
loading.value = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 获取我喜欢的音乐歌单ID
|
||||
const likedPlaylistId = dataStore.userLikeData.playlists?.[0]?.id;
|
||||
if (likedPlaylistId) {
|
||||
getPlaylistDetail(likedPlaylistId);
|
||||
} else {
|
||||
// 如果没有找到我喜欢的音乐歌单,尝试从缓存获取
|
||||
const data: any = await dataStore.getUserLikePlaylist();
|
||||
const id = data?.detail?.id;
|
||||
if (id) {
|
||||
getPlaylistDetail(id);
|
||||
} else {
|
||||
loading.value = false;
|
||||
window.$message.error("无法获取我喜欢的音乐歌单");
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -11,11 +11,14 @@
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"esModuleInterop": true,
|
||||
"moduleResolution": "bundler",
|
||||
"maxNodeModuleJsDepth": 2,
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["src/*"]
|
||||
},
|
||||
"types": ["node", "electron", "electron-vite/node", "./auto-imports.d.ts", "./components.d.ts"]
|
||||
"types": ["node", "electron", "electron-vite/node", "./auto-imports.d.ts", "./components.d.ts"],
|
||||
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
||||
"target": "es2022"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -365,7 +365,7 @@
|
||||
}
|
||||
case "font-size-reduce": {
|
||||
let fontSize = options.fontSize;
|
||||
if (fontSize > 20) {
|
||||
if (fontSize > 10) {
|
||||
fontSize--;
|
||||
this.changeOptions({ ...options, fontSize });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user