From dc119654a2dc5e92ac77a5f62136275c94dd518e Mon Sep 17 00:00:00 2001 From: imsyy Date: Wed, 29 Nov 2023 17:03:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E6=B5=81=20&=20builder=20=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/ISSUE_TEMPLATE/bug.yml | 6 ++ .github/workflows/build.yml | 28 +++---- .github/workflows/release.yml | 135 +++++++++++++++++++++------------ README.md | 40 ++++++++-- electron-builder.yml | 26 +++++-- electron/main/index.js | 11 +-- 6 files changed, 161 insertions(+), 85 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml index 7b18bc82..60109703 100644 --- a/.github/ISSUE_TEMPLATE/bug.yml +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -14,6 +14,12 @@ body: attributes: label: "当前系统环境" placeholder: "win11" + - type: input + validations: + required: true + attributes: + label: "当前 Node.js 及 npm 版本" + placeholder: "v18.16.0 / v9.6.7" - type: input validations: required: true diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6487e46b..5e5d9de8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,3 +1,5 @@ +# Dev 分支推送部署预览 +## 仅部署 Win 端 name: Build Dev on: @@ -11,35 +13,29 @@ jobs: runs-on: windows-latest steps: + # 检出 Git 仓库 - name: Check out git repository - uses: actions/checkout@v3.0.0 - + uses: actions/checkout@v4.1.1 + # 安装 Node.js - name: Install Node.js - uses: actions/setup-node@v3.0.0 + uses: actions/setup-node@v4.0.0 with: - node-version: "16.x" - + node-version: "18.x" + # 安装项目依赖 - 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 rimraf "dist/!(*.exe)" - + # 上传构建产物 - name: Upload artifacts - uses: actions/upload-artifact@v3.0.0 + uses: actions/upload-artifact@v3.1.3 with: name: SPlayer-dev path: dist - - - name: Create a release - uses: softprops/action-gh-release@v0.1.14 - if: startsWith(github.ref, 'refs/tags/v') - with: - draft: true - files: "dist/**" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f1876834..8fcb797c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,3 +1,5 @@ +# Release 发行版本部署 +## 多端部署 name: Build Release on: @@ -6,95 +8,134 @@ on: - v* jobs: + # Windows build-windows: name: Build for Windows runs-on: windows-latest steps: + # 检出 Git 仓库 - name: Check out git repository - uses: actions/checkout@v3.0.0 - + uses: actions/checkout@v4.1.1 + # 安装 Node.js - name: Install Node.js - uses: actions/setup-node@v3.0.0 + uses: actions/setup-node@v4.0.0 with: - node-version: "16.x" - + node-version: "18.x" + # 安装项目依赖 - name: Install Dependencies run: npm install - + # 构建 Electron App - name: Build Electron App for Windows - run: npm run build:win + run: npm run build:win || true + shell: bash env: GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} - + # 上传构建产物 - name: Upload Windows artifact - uses: actions/upload-artifact@v3.0.0 + uses: actions/upload-artifact@v3.1.3 with: - name: SPlayer-Windows - path: dist/*.exe - + name: SPlarer-Win + if-no-files-found: ignore + path: | + dist/*.exe + dist/*.msi + # 创建 GitHub Release + - name: Release + uses: softprops/action-gh-release@v0.1.14 + if: startsWith(github.ref, 'refs/tags/v') + with: + draft: true + files: | + dist/*.exe + dist/*.msi + 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@v3.0.0 - + uses: actions/checkout@v4.1.1 + # 安装 Node.js - name: Install Node.js - uses: actions/setup-node@v3.0.0 + uses: actions/setup-node@v4.0.0 with: - node-version: "16.x" - + node-version: "18.x" + # 安装项目依赖 - name: Install Dependencies run: npm install - + # 构建 Electron App - name: Build Electron App for macOS - run: npm run build:mac + run: npm run build:mac || true + shell: bash env: GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} - + # 上传构建产物 - name: Upload macOS artifact - uses: actions/upload-artifact@v3.0.0 + uses: actions/upload-artifact@v3.1.3 with: - name: SPlayer-macOS - path: dist/*.dmg - + name: SPlarer-Macos + if-no-files-found: ignore + path: | + dist/*.dmg + dist/*.zip + # 创建 GitHub Release + - name: Release + uses: softprops/action-gh-release@v0.1.14 + if: startsWith(github.ref, 'refs/tags/v') + with: + draft: true + files: | + dist/*.dmg + dist/*.zip + env: + GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} + # Linux build-linux: name: Build for Linux - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: + # 检出 Git 仓库 - name: Check out git repository - uses: actions/checkout@v3.0.0 - + uses: actions/checkout@v4.1.1 + # 安装 Node.js - name: Install Node.js - uses: actions/setup-node@v3.0.0 + uses: actions/setup-node@v4.0.0 with: - node-version: "16.x" - + node-version: "18.x" + # 更新 Ubuntu 软件源 + - name: Ubuntu Update with sudo + run: sudo apt-get update + # 安装项目依赖 - name: Install Dependencies run: npm install - + # 构建 Electron App - name: Build Electron App for Linux - run: npm run build:linux + run: npm run build:linux || true + shell: bash env: GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} - + # 上传构建产物 - name: Upload Linux artifact - uses: actions/upload-artifact@v3.0.0 + uses: actions/upload-artifact@v3.1.3 with: - name: SPlayer-Linux - path: dist/*.AppImage - - create-release: - needs: [build-windows, build-macos, build-linux] - runs-on: ubuntu-latest - steps: - - name: Download all artifacts - uses: actions/download-artifact@v3.0.0 - - - name: Create a release - uses: softprops/action-gh-release@v1 + name: SPlarer-Linux + if-no-files-found: ignore + path: | + dist/*.AppImage + dist/*.deb + dist/*.rpm + # 创建 GitHub Release + - name: Release + uses: softprops/action-gh-release@v0.1.14 + if: startsWith(github.ref, 'refs/tags/v') with: draft: true - files: "dist/**" + files: | + dist/*.AppImage + dist/*.deb + dist/*.rpm env: GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} diff --git a/README.md b/README.md index dd2defce..a8643706 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,11 @@ +> [!IMPORTANT] +> ## 🎉 当前项目正在重构中 🎉 +> +> - 目前版本进入维护模式,仅在遇到重大问题时会进行修复 +> - 支持客户端与网页端 +> - 支持现有版本所有功能 +> - 新增支持播放与管理本地歌曲 +
logo

SPlayer

@@ -8,11 +16,6 @@ ## 说明 -> **当前项目正在重构中,目前版本进入维护模式,仅在遇到重大问题时会进行修复** -> - 支持客户端与网页端 -> - 支持现有版本所有功能 -> - 新增支持播放与管理本地歌曲 -> - 本项目采用 [Vue 3](https://cn.vuejs.org/) 全家桶和 [Naïve UI](https://www.naiveui.com/) 组件库及 [Electron](https://www.electronjs.org/zh/docs/latest/) 开发 - 支持网页端与客户端,由于设备有限,目前仅适配 `Win`,其他平台可自行构建 - ~~仅对移动端做了基础适配,**不保证功能全部可用**~~ @@ -57,7 +60,7 @@ - [ ] 多种布局方式 - [ ] 发表评论 -## 😍 Screenshots +## 🖼️ Screenshots > 开发中,仅供参考 @@ -103,6 +106,18 @@ +## 📦️ 获取 + +### 稳定版 + +通常情况下,可以在 [Releases](https://github.com/imsyy/SPlayer/releases) 中获取稳定版 + +### 开发版 + +可以通过 `GitHub Actions` 工作流获取最新的开发版,目前开发版仅提供 `Win` 版本 + +[Dev Workflow](https://github.com/imsyy/SPlayer/actions/workflows/build.yml) + ## ⚙️ 部署 > Vercel 等托管平台可在 Fork 后一键导入并自动部署 @@ -179,12 +194,21 @@ pnpm build:mac ## 📜 开源许可 - **本项目仅供个人学习研究使用,禁止用于商业及非法用途** -- 本项目基于 [MIT license](https://opensource.org/license/mit/) 许可进行开源 +- 本项目基于 [GNU General Public License version 3](https://opensource.org/license/gpl-3-0/) 许可进行开源 + 1. **修改和分发:** 任何对本项目的修改和分发都必须基于 GPL Version 3 进行,源代码必须一并提供 + 2. **派生作品:** 任何派生作品必须同样采用 GPL Version 3,并在适当的地方注明原始项目的许可证 + 3. **免责声明:** 根据 GPL Version 3,本项目不提供任何明示或暗示的担保。请详细阅读 GPL Version 3以了解完整的免责声明内容 + 4. **社区参与:** 欢迎社区的参与和贡献,我们鼓励开发者一同改进和维护本项目 + 5. **许可证链接:** 请阅读 [GNU General Public License version 3](https://opensource.org/license/gpl-3-0/) 了解更多详情 ## 📢 免责声明 -本项目使用了网易云音乐的第三方 API 服务,**仅供个人学习研究使用,禁止用于商业及非法用途。** 本项目旨在提供一个前端练手的实战项目,用于帮助开发者提升技能水平和对前端技术的理解 +本项目部分功能使用了网易云音乐的第三方 API 服务,**仅供个人学习研究使用,禁止用于商业及非法用途** 同时,本项目开发者承诺 **严格遵守相关法律法规和网易云音乐 API 使用协议,不会利用本项目进行任何违法活动。** 如因使用本项目而引起的任何纠纷或责任,均由使用者自行承担。**本项目开发者不承担任何因使用本项目而导致的任何直接或间接责任,并保留追究使用者违法行为的权利** 请使用者在使用本项目时遵守相关法律法规,**不要将本项目用于任何商业及非法用途。如有违反,一切后果由使用者自负。** 同时,使用者应该自行承担因使用本项目而带来的风险和责任。本项目开发者不对本项目所提供的服务和内容做出任何保证 + +**任何未经授权的商业用途,以及对网易云音乐 API 使用协议的违反,将导致对用户采取法律行动的可能性** + +感谢您的理解与合作 diff --git a/electron-builder.yml b/electron-builder.yml index e47467e1..9fdb55cd 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -1,11 +1,11 @@ # 应用程序的唯一标识符 appId: com.imsyy.splayer # 应用程序的产品名称 -productName: SPlayer-desktop -copyright: 'Copyright © imsyy 2023' +productName: SPlayer +copyright: Copyright © imsyy 2023 # 构建资源所在的目录 directories: - buildResources: public + buildResources: build # 包含在最终应用程序构建中的文件列表,这里使用通配符 ! 表示排除不需要的文件 files: - "!**/.vscode/*" @@ -22,8 +22,11 @@ win: executableName: splayer-desktop # 应用程序的图标文件路径 icon: public/images/logo/favicon_256.png - # 构建的目标类型 - # target: "portable" + # 构建类型 + target: + - nsis + - portable + # 管理员权限 requestedExecutionLevel: highestAvailable # NSIS 安装器配置 nsis: @@ -43,6 +46,10 @@ nsis: allowToChangeInstallationDirectory: true # macOS 平台配置 mac: + # 可执行文件名 + executableName: splayer-desktop + # 应用程序的图标文件路径 + icon: public/images/logo/favicon_256.png # 权限继承的文件路径 entitlementsInherit: build/entitlements.mac.plist # 扩展信息,如权限描述 @@ -61,9 +68,14 @@ dmg: artifactName: ${productName}-${version}.${ext} # Linux 平台配置 linux: - # 目标平台,例如 AppImage、snap、deb 等 + # 可执行文件名 + executableName: splayer-desktop + # 应用程序的图标文件路径 + icon: public/images/logo/favicon_256.png + # 构建类型 target: - AppImage + - portable - snap - deb - rpm @@ -85,4 +97,4 @@ publish: # 自动更新检查的 URL # url: https://example.com/auto-updates owner: "imsyy" - repo: "splayer" + repo: "SPlayer" diff --git a/electron/main/index.js b/electron/main/index.js index 30e66067..f1a3680c 100644 --- a/electron/main/index.js +++ b/electron/main/index.js @@ -1,5 +1,5 @@ import { join } from "path"; -import { app, protocol, shell, BrowserWindow, globalShortcut } from "electron"; +import { app, shell, BrowserWindow, globalShortcut } from "electron"; import { electronApp, optimizer, is } from "@electron-toolkit/utils"; import { startNcmServer } from "@main/startNcmServer"; import { startMainServer } from "@main/startMainServer"; @@ -18,11 +18,6 @@ process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = "true"; // 单例锁 const gotTheLock = app.requestSingleInstanceLock(); -// 注册自定义协议 -protocol.registerSchemesAsPrivileged([ - { scheme: "imsyy-splayer", privileges: { standard: true, secure: true } }, -]); - // 配置 log log.transports.file.resolvePathFn = () => join(app.getPath("documents"), "/SPlayer/splayer-log.txt"); @@ -98,6 +93,9 @@ app.whenReady().then(async () => { return false; } + // 注册应用协议 + app.setAsDefaultProtocolClient("splayer"); + // 初始化完成并准备创建浏览器窗口 // 为 Windows 设置应用程序用户模型 ID electronApp.setAppUserModelId("com.electron"); @@ -120,7 +118,6 @@ app.whenReady().then(async () => { // 自定义协议 app.on("open-url", (_, url) => { - // 在这里处理自定义协议的事件,比如打开相应的窗口或执行其他操作 console.log("Received custom protocol URL:", url); });