From 94dc358b61e341e5f7c1a7a4108f76f86251189c Mon Sep 17 00:00:00 2001 From: xiaozhu <809057480@qq.com> Date: Sat, 13 Mar 2021 02:58:58 +0800 Subject: [PATCH] test ci --- src/main/config.js | 4 +- src/main/main.js | 234 +++---- src/main/modules/ipcEvent.js | 294 ++++---- src/main/modules/tray.js | 30 +- src/main/vue-devtools/src/backend.js | 52 +- src/main/vue-devtools/src/background.js | 136 ++-- src/main/vue-devtools/src/detector.js | 44 +- .../vue-devtools/src/devtools-background.js | 118 ++-- src/main/vue-devtools/src/devtools.js | 52 +- src/main/vue-devtools/src/hook.js | 10 +- src/main/vue-devtools/src/proxy.js | 34 +- src/main/vue-devtools/webpack.config.js | 26 +- src/main/windows/desktopLyricWindow.js | 26 +- src/main/windows/miniWindow.js | 32 +- src/main/windows/trayWindow.js | 42 +- src/main/windows/updateWindow.js | 48 +- src/main/windows/welcomeWindow.js | 20 +- src/renderer/App.vue | 74 +-- src/renderer/api/album.js | 32 +- src/renderer/api/artist.js | 70 +- src/renderer/api/banner.js | 6 +- src/renderer/api/comment.js | 62 +- src/renderer/api/dj.js | 68 +- src/renderer/api/login.js | 30 +- src/renderer/api/mv.js | 84 +-- src/renderer/api/playlist.js | 82 +-- src/renderer/api/privatecontent.js | 6 +- src/renderer/api/rank.js | 20 +- src/renderer/api/search.js | 36 +- src/renderer/api/song.js | 86 +-- src/renderer/api/sublist.js | 32 +- src/renderer/api/user.js | 236 +++---- src/renderer/api/video.js | 34 +- .../components/BasicHeader/Controls.vue | 20 +- .../components/BasicHeader/FrameActions.vue | 50 +- .../components/BasicHeader/SeachBox.vue | 154 ++--- .../components/BasicHeader/ThemeSetting.vue | 128 ++-- .../components/BasicHeader/UserInfo.vue | 54 +- src/renderer/components/BasicHeader/index.vue | 308 ++++----- .../components/BasicSider/Created.vue | 100 +-- .../components/BasicSider/MiniCard.vue | 57 +- .../components/BasicSider/Subscribed.vue | 36 +- src/renderer/components/BasicSider/index.vue | 78 +-- .../components/Comment/CommentItem.vue | 16 +- src/renderer/components/Comment/index.vue | 18 +- src/renderer/components/Common/album-item.vue | 20 +- .../components/Common/artist-item.vue | 10 +- src/renderer/components/Common/artists.vue | 24 +- .../components/Common/debounce-btn.vue | 16 +- src/renderer/components/Common/dj-item.vue | 16 +- src/renderer/components/Common/drag.vue | 36 +- .../components/Common/infiniteError.vue | 2 +- .../components/Common/infiniteNoMore.vue | 4 +- .../components/Common/infiniteNoResults.vue | 4 +- src/renderer/components/Common/list-item.vue | 58 +- src/renderer/components/Common/loading.vue | 14 +- src/renderer/components/Common/musicView.vue | 290 ++++---- src/renderer/components/Common/mv-item.vue | 18 +- src/renderer/components/Common/playing.vue | 16 +- src/renderer/components/Common/preload.vue | 8 +- .../components/Common/progressBar.vue | 172 ++--- src/renderer/components/Common/song-heart.vue | 18 +- src/renderer/components/Common/song-item.vue | 26 +- src/renderer/components/Common/tabBar.vue | 38 +- src/renderer/components/Common/tags.vue | 30 +- .../Common/track-list/base/album.vue | 18 +- .../Common/track-list/base/artist.vue | 18 +- .../Common/track-list/base/contextMenu.vue | 20 +- .../Common/track-list/base/default.vue | 10 +- .../Common/track-list/base/duration.vue | 14 +- .../Common/track-list/base/songName.vue | 26 +- .../components/Common/track-list/index.js | 4 +- .../components/Common/track-list/index.vue | 276 ++++---- src/renderer/components/Common/video-item.vue | 24 +- src/renderer/components/DrapModal/index.vue | 60 +- .../LandingPage/SystemInformation.vue | 12 +- src/renderer/components/Login/index.vue | 84 +-- src/renderer/components/Lyric/index.vue | 30 +- src/renderer/components/Offline/index.vue | 12 +- .../components/PlayBar/CurrentPlayTable.vue | 16 +- .../components/PlayBar/HistoryPlayTable.vue | 16 +- src/renderer/components/PlayBar/index.vue | 574 ++++++++-------- src/renderer/components/Player/CollectBtn.vue | 74 +-- src/renderer/components/Player/index.vue | 305 ++++----- src/renderer/components/Playlist/Create.vue | 38 +- src/renderer/components/Slider/index.vue | 132 ++-- src/renderer/components/Toast/toast.js | 22 +- src/renderer/components/VirtualList/List.vue | 192 +++--- .../components/VirtualList/ListItem.vue | 16 +- src/renderer/components/ZIcon/index.vue | 18 +- .../components/base/notification/index.js | 30 +- .../base/notification/notification.vue | 56 +- src/renderer/config/config.js | 58 +- src/renderer/config/defaultSettings.js | 4 +- src/renderer/config/downloadSettings.js | 6 +- src/renderer/core/createdInit.js | 175 ++--- src/renderer/datastore/index.js | 28 +- src/renderer/directives/index.js | 26 +- src/renderer/filters/index.js | 88 +-- src/renderer/layouts/BasicLayout.vue | 102 +-- src/renderer/layouts/HomeLayout.vue | 40 +- src/renderer/main.js | 42 +- src/renderer/mixins/Play.js | 14 +- src/renderer/mixins/Search.js | 28 +- src/renderer/mixins/videoPlayer.js | 62 +- src/renderer/plugins/andt-design-vue.js | 114 ++-- src/renderer/plugins/infinite-loading.js | 18 +- src/renderer/plugins/vue-lazyload.js | 8 +- src/renderer/router/index.js | 128 ++-- src/renderer/router/modules/album.js | 40 +- src/renderer/router/modules/artist.js | 68 +- src/renderer/router/modules/dj.js | 50 +- src/renderer/router/modules/myMusic.js | 68 +- src/renderer/router/modules/playlist.js | 56 +- src/renderer/router/modules/rank.js | 40 +- src/renderer/router/modules/recommend.js | 68 +- src/renderer/router/modules/search.js | 12 +- src/renderer/router/modules/setting.js | 12 +- src/renderer/router/modules/user.js | 66 +- src/renderer/router/modules/video.js | 32 +- src/renderer/store/index.js | 30 +- src/renderer/store/modules/App.js | 58 +- src/renderer/store/modules/Download.js | 204 +++--- src/renderer/store/modules/Localsong.js | 136 ++-- src/renderer/store/modules/Search.js | 50 +- src/renderer/store/modules/Setting.js | 30 +- src/renderer/store/modules/Update.js | 20 +- src/renderer/store/modules/User.js | 230 +++---- src/renderer/store/modules/Video.js | 48 +- src/renderer/store/modules/index.js | 12 +- src/renderer/store/modules/play.js | 202 +++--- src/renderer/store/plugins/keep-state.js | 52 +- src/renderer/utils/assist.js | 78 +-- src/renderer/utils/calculate.js | 20 +- src/renderer/utils/card.js | 6 +- src/renderer/utils/class/Lyric.js | 140 ++-- src/renderer/utils/dom.js | 16 +- src/renderer/utils/eventBus.js | 4 +- src/renderer/utils/request.js | 98 +-- src/renderer/utils/sgy-request/error.js | 16 +- src/renderer/utils/sgy-request/helper.js | 30 +- src/renderer/utils/sgy-request/index.js | 242 +++---- src/renderer/utils/sgy-request/url.js | 62 +- src/renderer/utils/song.js | 40 +- src/renderer/utils/video.js | 26 +- src/renderer/views/Album/_id.vue | 156 ++--- src/renderer/views/Album/_id/comment.vue | 36 +- src/renderer/views/Album/_id/songs.vue | 40 +- .../views/Album/components/newalbum.vue | 36 +- .../views/Album/components/newsong.vue | 134 ++-- src/renderer/views/Album/index.vue | 22 +- src/renderer/views/Artist/_id.vue | 104 +-- src/renderer/views/Artist/_id/album.vue | 48 +- src/renderer/views/Artist/_id/desc.vue | 38 +- src/renderer/views/Artist/_id/mv.vue | 58 +- src/renderer/views/Artist/_id/simi.vue | 32 +- src/renderer/views/Artist/_id/songs.vue | 72 +- src/renderer/views/Artist/index.vue | 224 +++---- src/renderer/views/Artist/top.vue | 26 +- src/renderer/views/Daily/index.vue | 130 ++-- src/renderer/views/DesktopLyric.vue | 10 +- src/renderer/views/Dj/_id.vue | 72 +- src/renderer/views/Dj/_id/programs.vue | 90 +-- src/renderer/views/Dj/_id/sublist.vue | 8 +- src/renderer/views/Dj/index.vue | 110 +-- src/renderer/views/Dj/recommend.vue | 50 +- .../views/Download/components/downloaded.vue | 132 ++-- .../views/Download/components/downloading.vue | 104 +-- src/renderer/views/Download/index.vue | 22 +- src/renderer/views/Fm/index.vue | 188 +++--- src/renderer/views/Home/components/Banner.vue | 64 +- src/renderer/views/Home/components/dj.vue | 18 +- src/renderer/views/Home/components/mv.vue | 18 +- .../views/Home/components/newSong.vue | 34 +- .../views/Home/components/playlist.vue | 42 +- .../views/Home/components/private.vue | 18 +- .../views/Home/components/privateContent.vue | 22 +- src/renderer/views/Home/index.vue | 152 ++--- src/renderer/views/LocalMusic/index.vue | 130 ++-- src/renderer/views/Mini/index.vue | 122 ++-- src/renderer/views/MusicViewer.vue | 88 +-- src/renderer/views/Offline/index.vue | 12 +- src/renderer/views/Playlist/_id.vue | 130 ++-- src/renderer/views/Playlist/_id/comment.vue | 44 +- src/renderer/views/Playlist/_id/related.vue | 32 +- .../views/Playlist/_id/subscriber.vue | 32 +- src/renderer/views/Playlist/_id/tracks.vue | 20 +- src/renderer/views/Playlist/highquality.vue | 64 +- src/renderer/views/Playlist/index.vue | 100 +-- src/renderer/views/Rank/_id.vue | 158 ++--- src/renderer/views/Rank/_id/comment.vue | 48 +- src/renderer/views/Rank/_id/songs.vue | 40 +- src/renderer/views/Rank/index.vue | 98 +-- .../views/Search/components/album.vue | 24 +- src/renderer/views/Search/components/all.vue | 20 +- .../views/Search/components/artist.vue | 26 +- src/renderer/views/Search/components/dj.vue | 24 +- .../views/Search/components/lyric.vue | 56 +- .../views/Search/components/playlist.vue | 24 +- src/renderer/views/Search/components/song.vue | 34 +- src/renderer/views/Search/components/user.vue | 24 +- .../views/Search/components/video.vue | 28 +- src/renderer/views/Search/index.vue | 144 ++-- .../components/SettingDownloadFolder.vue | 44 +- .../views/Setting/components/SettingItem.vue | 8 +- .../Setting/components/SettingVersion.vue | 70 +- src/renderer/views/Setting/index.vue | 16 +- src/renderer/views/Tray.vue | 142 ++-- src/renderer/views/Update/index.vue | 156 ++--- src/renderer/views/User/Cloud.vue | 42 +- .../views/User/Collect/components/Album.vue | 34 +- .../views/User/Collect/components/Artist.vue | 34 +- .../views/User/Collect/components/Video.vue | 38 +- src/renderer/views/User/Collect/index.vue | 26 +- src/renderer/views/User/Events/UserEvent.vue | 133 ++-- .../views/User/Events/components/Album.vue | 14 +- .../views/User/Events/components/Playlist.vue | 8 +- .../views/User/Events/components/Song.vue | 28 +- .../views/User/Events/components/Video.vue | 138 ++-- src/renderer/views/User/Events/index.vue | 112 ++-- src/renderer/views/User/Follow/Followed.vue | 36 +- src/renderer/views/User/Follow/Follower.vue | 36 +- .../views/User/Follow/components/UserItem.vue | 8 +- src/renderer/views/User/index.vue | 74 +-- src/renderer/views/Video/_id/index.vue | 322 ++++----- src/renderer/views/Video/_id/mv.vue | 350 +++++----- src/renderer/views/Video/fullscreen.vue | 8 +- src/renderer/views/Video/index.vue | 94 +-- src/renderer/views/Video/mv.vue | 142 ++-- src/renderer/views/Video/player.vue | 629 +++++++++--------- 230 files changed, 7990 insertions(+), 7983 deletions(-) diff --git a/src/main/config.js b/src/main/config.js index 5763860..474a2e3 100644 --- a/src/main/config.js +++ b/src/main/config.js @@ -1,2 +1,2 @@ -export const ACHEME = 'app' -export const LOAD_URL = `${ACHEME}://./index.html` +export const ACHEME = "app"; +export const LOAD_URL = `${ACHEME}://./index.html`; diff --git a/src/main/main.js b/src/main/main.js index 51fae3b..7a0f402 100644 --- a/src/main/main.js +++ b/src/main/main.js @@ -1,192 +1,192 @@ -import { app, protocol, Tray, BrowserWindow, ipcMain, shell } from 'electron' -import path from 'path' -import pkg from './../../package.json' -import initIpcEvent from './modules/ipcEvent' -import createTray from './modules/tray' -import createTrayWindow from './windows/trayWindow' -import createLyricWindow from './windows/desktopLyricWindow' -import createMiniWindow from './windows/miniWindow' -import { createProtocol } from 'vue-cli-plugin-electron-builder/lib' -import { ACHEME, LOAD_URL } from './config' +import { app, protocol, Tray, BrowserWindow, ipcMain, shell } from "electron"; +import path from "path"; +import pkg from "./../../package.json"; +import initIpcEvent from "./modules/ipcEvent"; +import createTray from "./modules/tray"; +import createTrayWindow from "./windows/trayWindow"; +import createLyricWindow from "./windows/desktopLyricWindow"; +import createMiniWindow from "./windows/miniWindow"; +import { createProtocol } from "vue-cli-plugin-electron-builder/lib"; +import { ACHEME, LOAD_URL } from "./config"; -const isDevelopment = process.env.NODE_ENV !== 'production' -if (process.env.NODE_ENV === 'production') { - global.__img = path.join(__dirname, './img') - global.__images = path.join(__dirname, './images') +const isDevelopment = process.env.NODE_ENV !== "production"; +if (process.env.NODE_ENV === "production") { + global.__img = path.join(__dirname, "./img"); + global.__images = path.join(__dirname, "./images"); } -let mainWindow = null +let mainWindow = null; protocol.registerSchemesAsPrivileged([ - { scheme: ACHEME, privileges: { secure: true, standard: true } } -]) + { scheme: ACHEME, privileges: { secure: true, standard: true } }, +]); const previewIcon = - process.env.NODE_ENV === 'development' - ? 'public/images/tray.ico' - : `${global.__images}/tray.ico` + process.env.NODE_ENV === "development" + ? "public/images/tray.ico" + : `${global.__images}/tray.ico`; const prevIcon = - process.env.NODE_ENV === 'development' - ? 'public/images/prev.png' - : `${global.__images}/prev.png` + process.env.NODE_ENV === "development" + ? "public/images/prev.png" + : `${global.__images}/prev.png`; const nextIcon = - process.env.NODE_ENV === 'development' - ? 'public/images/next.png' - : `${global.__images}/next.png` + process.env.NODE_ENV === "development" + ? "public/images/next.png" + : `${global.__images}/next.png`; const playIcon = - process.env.NODE_ENV === 'development' - ? 'public/images/play.png' - : `${global.__images}/play.png` + process.env.NODE_ENV === "development" + ? "public/images/play.png" + : `${global.__images}/play.png`; const pauseIcon = - process.env.NODE_ENV === 'development' - ? 'public/images/pause.png' - : `${global.__images}/pause.png` + process.env.NODE_ENV === "development" + ? "public/images/pause.png" + : `${global.__images}/pause.png`; // 设置底部任务栏按钮和缩略图 const setThumbarButtons = function (mainWindow, playing) { mainWindow.setThumbarButtons([ { - tooltip: '上一曲', + tooltip: "上一曲", icon: prevIcon, - click () { - mainWindow.webContents.send('prev-play') - } + click() { + mainWindow.webContents.send("prev-play"); + }, }, { - tooltip: playing ? '暂停' : '播放', + tooltip: playing ? "暂停" : "播放", icon: playing ? pauseIcon : playIcon, - click () { - mainWindow.webContents.send('toggle-play', { - value: !playing - }) - } + click() { + mainWindow.webContents.send("toggle-play", { + value: !playing, + }); + }, }, { - tooltip: '下一曲', + tooltip: "下一曲", icon: nextIcon, - click () { - mainWindow.webContents.send('next-play') - } - } - ]) -} + click() { + mainWindow.webContents.send("next-play"); + }, + }, + ]); +}; -function createWindow () { +function createWindow() { mainWindow = new BrowserWindow({ width: 1000, height: 690, minWidth: 1000, minHeight: 690, - title: process.platform === 'win32' ? pkg.description : '', + title: process.platform === "win32" ? pkg.description : "", icon: previewIcon, - titleBarStyle: 'hiddenInset', - frame: process.platform !== 'win32', + titleBarStyle: "hiddenInset", + frame: process.platform !== "win32", show: false, webPreferences: { nodeIntegration: true, nodeIntegrationInWorker: true, webSecurity: false, navigateOnDragDrop: true, - devTools: true - } - }) + devTools: true, + }, + }); // 设置appId才能使用Notification - if (process.platform === 'win32') { - app.setAppUserModelId(pkg.appId) + if (process.platform === "win32") { + app.setAppUserModelId(pkg.appId); } // 去除原生顶部菜单栏 - mainWindow.setMenu(null) + mainWindow.setMenu(null); if (process.env.WEBPACK_DEV_SERVER_URL) { - mainWindow.loadURL(process.env.WEBPACK_DEV_SERVER_URL) + mainWindow.loadURL(process.env.WEBPACK_DEV_SERVER_URL); } else { - createProtocol(ACHEME) - mainWindow.loadURL(LOAD_URL) + createProtocol(ACHEME); + mainWindow.loadURL(LOAD_URL); } - mainWindow.on('close', (event) => { - event.preventDefault() - mainWindow.webContents.send('will-close') - }) + mainWindow.on("close", (event) => { + event.preventDefault(); + mainWindow.webContents.send("will-close"); + }); - mainWindow.on('closed', () => { - mainWindow = null - }) + mainWindow.on("closed", () => { + mainWindow = null; + }); - mainWindow.once('ready-to-show', () => { - mainWindow.show() + mainWindow.once("ready-to-show", () => { + mainWindow.show(); // 设置任务栏操作和缩略图 - if (process.platform === 'win32') { - setThumbarButtons(mainWindow, false) - mainWindow.setThumbnailClip({ x: 0, y: 0, width: 180, height: 50 }) + if (process.platform === "win32") { + setThumbarButtons(mainWindow, false); + mainWindow.setThumbnailClip({ x: 0, y: 0, width: 180, height: 50 }); } - global.lyricWindow = createLyricWindow(BrowserWindow) - global.miniWindow = createMiniWindow(BrowserWindow) - }) + global.lyricWindow = createLyricWindow(BrowserWindow); + global.miniWindow = createMiniWindow(BrowserWindow); + }); if (isDevelopment) { // 安装vue-devtools - let extensions = BrowserWindow.getDevToolsExtensions() - if (!extensions[ 'Vue.js devtools' ]) { + let extensions = BrowserWindow.getDevToolsExtensions(); + if (!extensions["Vue.js devtools"]) { BrowserWindow.addDevToolsExtension( - path.resolve(__dirname, './../../src/main/vue-devtools') - ) + path.resolve(__dirname, "./../../src/main/vue-devtools") + ); } // 打开调试窗口 // mainWindow.webContents.openDevTools() } - mainWindow.webContents.openDevTools() + mainWindow.webContents.openDevTools(); - global.mainWindow = mainWindow + global.mainWindow = mainWindow; // 初始化进程之间事件监听 - initIpcEvent() + initIpcEvent(); // 如果是windows系统模拟托盘菜单 - if (process.platform === 'win32') { - global.tray = createTray(Tray) - let trayBounds = global.tray.getBounds() - global.trayWindow = createTrayWindow(BrowserWindow, trayBounds) + if (process.platform === "win32") { + global.tray = createTray(Tray); + let trayBounds = global.tray.getBounds(); + global.trayWindow = createTrayWindow(BrowserWindow, trayBounds); } } -app.on('window-all-closed', () => { - if (process.platform !== 'darwin') { - app.quit() +app.on("window-all-closed", () => { + if (process.platform !== "darwin") { + app.quit(); } -}) +}); -app.on('activate', () => { +app.on("activate", () => { if (global.mainWindow === null || mainWindow === null) { - createWindow() + createWindow(); } -}) +}); -app.on('ready', () => { - global.execPath = process.execPath - global.argv = process.argv - createWindow() +app.on("ready", () => { + global.execPath = process.execPath; + global.argv = process.argv; + createWindow(); // protocalHandler() - ipcMain.on('thumbar-buttons', (e, data) => { - if (global.mainWindow === null || mainWindow === null) return - if (process.platform === 'win32') { - let { playing } = data - setThumbarButtons(mainWindow, playing) + ipcMain.on("thumbar-buttons", (e, data) => { + if (global.mainWindow === null || mainWindow === null) return; + if (process.platform === "win32") { + let { playing } = data; + setThumbarButtons(mainWindow, playing); } - }) -}) + }); +}); -app.on('quit', () => { +app.on("quit", () => { if (global.downloadFile) { - shell.openItem(global.downloadFile) + shell.openItem(global.downloadFile); } -}) +}); if (isDevelopment) { - if (process.platform === 'win32') { - process.on('message', (data) => { - if (data === 'graceful-exit') { - app.quit() + if (process.platform === "win32") { + process.on("message", (data) => { + if (data === "graceful-exit") { + app.quit(); } - }) + }); } else { - process.on('SIGTERM', () => { - app.quit() - }) + process.on("SIGTERM", () => { + app.quit(); + }); } } diff --git a/src/main/modules/ipcEvent.js b/src/main/modules/ipcEvent.js index e16dcd8..3a040b2 100644 --- a/src/main/modules/ipcEvent.js +++ b/src/main/modules/ipcEvent.js @@ -1,224 +1,224 @@ -import { ipcMain, dialog, app, BrowserWindow, shell } from 'electron' -import path from 'path' -import createMiniWindow from '../windows/miniWindow' -import createUpdateWindow from './../windows/updateWindow' -import { defaultDownloadFolder } from '../../renderer/config/downloadSettings' -let { download } = require('electron-dl') -let downloads = {} -let updateWindow +import { ipcMain, dialog, app, BrowserWindow, shell } from "electron"; +import path from "path"; +import createMiniWindow from "../windows/miniWindow"; +import createUpdateWindow from "./../windows/updateWindow"; +import { defaultDownloadFolder } from "../../renderer/config/downloadSettings"; +let { download } = require("electron-dl"); +let downloads = {}; +let updateWindow; export default function () { - ipcMain.on('resize-mini', (event, params) => { - let height = params.height - global.miniWindow.setBounds({ height }) - }) - - ipcMain.on('toggle-play', (event, params) => { - let value = params.value - global.mainWindow.webContents.send('toggle-play', { - value - }) - }) - - ipcMain.on('play-song', (event, params) => { - let value = params.value - global.mainWindow.webContents.send('play-song', { - value - }) - }) - - ipcMain.on('prev-play', (event, params) => { - let value = params.value - global.mainWindow.webContents.send('prev-play', { - value - }) - }) - - ipcMain.on('next-play', (event, params) => { - let value = params.value - global.mainWindow.webContents.send('next-play', { - value - }) - }) - - ipcMain.on('toggle-mini', (event, params) => { + ipcMain.on("resize-mini", (event, params) => { + let height = params.height; + global.miniWindow.setBounds({ height }); + }); + + ipcMain.on("toggle-play", (event, params) => { + let value = params.value; + global.mainWindow.webContents.send("toggle-play", { + value, + }); + }); + + ipcMain.on("play-song", (event, params) => { + let value = params.value; + global.mainWindow.webContents.send("play-song", { + value, + }); + }); + + ipcMain.on("prev-play", (event, params) => { + let value = params.value; + global.mainWindow.webContents.send("prev-play", { + value, + }); + }); + + ipcMain.on("next-play", (event, params) => { + let value = params.value; + global.mainWindow.webContents.send("next-play", { + value, + }); + }); + + ipcMain.on("toggle-mini", (event, params) => { if (params.value) { - global.miniWindow.show() - global.mainWindow.hide() + global.miniWindow.show(); + global.mainWindow.hide(); } else { - global.miniWindow.hide() - global.mainWindow.show() + global.miniWindow.hide(); + global.mainWindow.show(); } - }) + }); - ipcMain.on('show-window', () => { - global.mainWindow.show() - }) + ipcMain.on("show-window", () => { + global.mainWindow.show(); + }); - ipcMain.on('window-min', () => { - global.mainWindow.minimize() - }) + ipcMain.on("window-min", () => { + global.mainWindow.minimize(); + }); - ipcMain.on('window-max', () => { + ipcMain.on("window-max", () => { if (global.mainWindow.isMaximized()) { - global.mainWindow.restore() + global.mainWindow.restore(); } else { - global.mainWindow.maximize() + global.mainWindow.maximize(); } - }) + }); - ipcMain.on('window-close', () => { - let wins = BrowserWindow.getAllWindows() + ipcMain.on("window-close", () => { + let wins = BrowserWindow.getAllWindows(); for (let i = 0; i < wins.length; i++) { - wins[i].close() + wins[i].close(); } - }) + }); - ipcMain.on('app-exit', () => { + ipcMain.on("app-exit", () => { // 所有窗口都将立即被关闭,而不询问用户,而且 before-quit 和 will-quit 事件也不会被触发。 - app.exit() - }) + app.exit(); + }); - ipcMain.on('quit-and-open', (event, data) => { - global.downloadFile = data - app.quit() - }) + ipcMain.on("quit-and-open", (event, data) => { + global.downloadFile = data; + app.quit(); + }); - ipcMain.on('download-start', (e, args) => { - let downloadFolder = args.downloadFolder - let downloadUrl = args.url + ipcMain.on("download-start", (e, args) => { + let downloadFolder = args.downloadFolder; + let downloadUrl = args.url; download(global.mainWindow, downloadUrl, { filename: args.filename, directory: downloadFolder, // 本地若不存在该目录会自动创建 // saveAs: true - onStarted (downloadItem) { - global.mainWindow.webContents.send('download-onStarted', { + onStarted(downloadItem) { + global.mainWindow.webContents.send("download-onStarted", { id: args.id, song: args.song, - totalBytes: downloadItem.getTotalBytes() - }) - downloads[args.id] = downloadItem + totalBytes: downloadItem.getTotalBytes(), + }); + downloads[args.id] = downloadItem; }, - onProgress (progress) { - global.mainWindow.webContents.send('download-onProgress', { + onProgress(progress) { + global.mainWindow.webContents.send("download-onProgress", { id: args.id, progress: progress.percent * 100, - state: downloads[args.id].getState() - }) - } + state: downloads[args.id].getState(), + }); + }, }) .then((downloadItem) => { // console.log(downloadItem) - global.mainWindow.webContents.send('download-success', { + global.mainWindow.webContents.send("download-success", { id: args.id, song: args.song, downloadFolder, - downloadUrl - }) + downloadUrl, + }); }) .catch((e) => { - global.mainWindow.webContents.send('download-error', { + global.mainWindow.webContents.send("download-error", { id: args.id, - error: e - }) - }) - }) - - ipcMain.on('download-cancel', (e, data) => { - let { id } = data - downloads[id].cancel && downloads[id].cancel() - }) - - ipcMain.on('download-toggle', (e, data) => { - let { id } = data + error: e, + }); + }); + }); + + ipcMain.on("download-cancel", (e, data) => { + let { id } = data; + downloads[id].cancel && downloads[id].cancel(); + }); + + ipcMain.on("download-toggle", (e, data) => { + let { id } = data; if (downloads[id].isPaused()) { - downloads[id].resume && downloads[id].resume() + downloads[id].resume && downloads[id].resume(); } else { - downloads[id].pause && downloads[id].pause() + downloads[id].pause && downloads[id].pause(); } - }) + }); - ipcMain.on('open-directory-dialog', (event) => { + ipcMain.on("open-directory-dialog", (event) => { dialog.showOpenDialog( { defaultPath: defaultDownloadFolder, - properties: ['openDirectory', 'multiSelections'] + properties: ["openDirectory", "multiSelections"], // filters: [ // { name: 'Audio', extensions: ['mp3', 'wma'] } // ] }, function (files) { if (files) { - event.sender.send('selectedItem', files) + event.sender.send("selectedItem", files); } } - ) - }) + ); + }); - ipcMain.on('ondragstart', (event, e) => { + ipcMain.on("ondragstart", (event, e) => { event.sender.startDrag({ - file: 'images/play.png', - icon: 'images/play.png' - }) - }) + file: "images/play.png", + icon: "images/play.png", + }); + }); - ipcMain.on('set-tray-title', (event, data) => { + ipcMain.on("set-tray-title", (event, data) => { if (global.tray) { - global.tray.setToolTip(data) + global.tray.setToolTip(data); } - }) + }); - ipcMain.once('hide-welcome', () => { - global.welcomeWindow.hide() - global.mainWindow.focus() - }) + ipcMain.once("hide-welcome", () => { + global.welcomeWindow.hide(); + global.mainWindow.focus(); + }); - ipcMain.once('hide-tray', () => { - global.trayWindow.hide() - }) + ipcMain.once("hide-tray", () => { + global.trayWindow.hide(); + }); - ipcMain.on('restart', () => { - app.relaunch() - app.exit(0) - }) + ipcMain.on("restart", () => { + app.relaunch(); + app.exit(0); + }); - ipcMain.on('toggle-desktop-lyric', (event, flag) => { + ipcMain.on("toggle-desktop-lyric", (event, flag) => { if (flag) { - global.lyricWindow.showInactive() + global.lyricWindow.showInactive(); } else { - global.lyricWindow.hide() + global.lyricWindow.hide(); } - }) + }); - ipcMain.on('fix-desktop-lyric', (event, data) => { + ipcMain.on("fix-desktop-lyric", (event, data) => { global.lyricWindow.setIgnoreMouseEvents(data, { - forward: true - }) + forward: true, + }); if (data === false) { - global.lyricWindow.webContents.send('show-lock') + global.lyricWindow.webContents.send("show-lock"); } - }) + }); - ipcMain.on('close-updatewin', (event, data) => { - updateWindow.close() - updateWindow = null - }) + ipcMain.on("close-updatewin", (event, data) => { + updateWindow.close(); + updateWindow = null; + }); - ipcMain.on('toggle-updatewin', (event, data) => { + ipcMain.on("toggle-updatewin", (event, data) => { if (!updateWindow) { - updateWindow = createUpdateWindow(BrowserWindow) - updateWindow.show() + updateWindow = createUpdateWindow(BrowserWindow); + updateWindow.show(); } else { if (updateWindow.isVisible()) { - updateWindow.minimize() + updateWindow.minimize(); } else { - updateWindow.show() + updateWindow.show(); } } - }) + }); - ipcMain.on('update-version', (event, data) => { - let version = data - global.remoteVersion = version - }) + ipcMain.on("update-version", (event, data) => { + let version = data; + global.remoteVersion = version; + }); } diff --git a/src/main/modules/tray.js b/src/main/modules/tray.js index 8357762..5a1fb98 100644 --- a/src/main/modules/tray.js +++ b/src/main/modules/tray.js @@ -1,19 +1,19 @@ -const electron = require('electron') +const electron = require("electron"); const createTray = function (Tray) { - let { width: screenWidth } = electron.screen.getPrimaryDisplay().size - const trayIconPath = __static + '/images/tray.ico' - const appTray = new Tray(trayIconPath) - appTray.setToolTip('网易云音乐') - appTray.on('right-click', (event, bounds) => { - const [trayMenuWidth, trayMenuHeight] = global.trayWindow.getSize() - let { x, y } = electron.screen.getCursorScreenPoint() + let { width: screenWidth } = electron.screen.getPrimaryDisplay().size; + const trayIconPath = __static + "/images/tray.ico"; + const appTray = new Tray(trayIconPath); + appTray.setToolTip("网易云音乐"); + appTray.on("right-click", (event, bounds) => { + const [trayMenuWidth, trayMenuHeight] = global.trayWindow.getSize(); + let { x, y } = electron.screen.getCursorScreenPoint(); if (x + trayMenuWidth > screenWidth) { - global.trayWindow.setPosition(x - trayMenuWidth, y - trayMenuHeight) + global.trayWindow.setPosition(x - trayMenuWidth, y - trayMenuHeight); } else { - global.trayWindow.setPosition(x, y - trayMenuHeight) + global.trayWindow.setPosition(x, y - trayMenuHeight); } - global.trayWindow.show() - }) + global.trayWindow.show(); + }); // appTray.on('click', (event, bounds) => { // if (global.mainWindow.isVisible()) { // global.mainWindow.hide() @@ -21,7 +21,7 @@ const createTray = function (Tray) { // global.mainWindow.show() // } // }) - return appTray -} + return appTray; +}; -export default createTray +export default createTray; diff --git a/src/main/vue-devtools/src/backend.js b/src/main/vue-devtools/src/backend.js index f9630a1..c5c9ab0 100644 --- a/src/main/vue-devtools/src/backend.js +++ b/src/main/vue-devtools/src/backend.js @@ -1,43 +1,43 @@ // this is injected to the app page when the panel is activated. -import { initBackend } from 'src/backend' -import Bridge from 'src/bridge' +import { initBackend } from "src/backend"; +import Bridge from "src/bridge"; -window.addEventListener('message', handshake) +window.addEventListener("message", handshake); -function handshake (e) { - if (e.data.source === 'vue-devtools-proxy' && e.data.payload === 'init') { - window.removeEventListener('message', handshake) +function handshake(e) { + if (e.data.source === "vue-devtools-proxy" && e.data.payload === "init") { + window.removeEventListener("message", handshake); - let listeners = [] + let listeners = []; const bridge = new Bridge({ - listen (fn) { + listen(fn) { var listener = (evt) => { - if (evt.data.source === 'vue-devtools-proxy' && evt.data.payload) { - fn(evt.data.payload) + if (evt.data.source === "vue-devtools-proxy" && evt.data.payload) { + fn(evt.data.payload); } - } - window.addEventListener('message', listener) - listeners.push(listener) + }; + window.addEventListener("message", listener); + listeners.push(listener); }, - send (data) { + send(data) { window.postMessage( { - source: 'vue-devtools-backend', - payload: data + source: "vue-devtools-backend", + payload: data, }, - '*' - ) - } - }) + "*" + ); + }, + }); - bridge.on('shutdown', () => { + bridge.on("shutdown", () => { listeners.forEach((l) => { - window.removeEventListener('message', l) - }) - listeners = [] - }) + window.removeEventListener("message", l); + }); + listeners = []; + }); - initBackend(bridge) + initBackend(bridge); } } diff --git a/src/main/vue-devtools/src/background.js b/src/main/vue-devtools/src/background.js index c1aecfc..220f3c1 100644 --- a/src/main/vue-devtools/src/background.js +++ b/src/main/vue-devtools/src/background.js @@ -1,83 +1,83 @@ // the background script runs all the time and serves as a central message // hub for each vue devtools (panel + proxy + backend) instance. -const ports = {} +const ports = {}; chrome.runtime.onConnect.addListener((port) => { - let tab - let name + let tab; + let name; if (isNumeric(port.name)) { - tab = port.name - name = 'devtools' - installProxy(+port.name) + tab = port.name; + name = "devtools"; + installProxy(+port.name); } else { - tab = port.sender.tab.id - name = 'backend' + tab = port.sender.tab.id; + name = "backend"; } if (!ports[tab]) { ports[tab] = { devtools: null, - backend: null - } + backend: null, + }; } - ports[tab][name] = port + ports[tab][name] = port; if (ports[tab].devtools && ports[tab].backend) { - doublePipe(tab, ports[tab].devtools, ports[tab].backend) + doublePipe(tab, ports[tab].devtools, ports[tab].backend); } -}) +}); -function isNumeric (str) { - return +str + '' === str +function isNumeric(str) { + return +str + "" === str; } -function installProxy (tabId) { +function installProxy(tabId) { chrome.tabs.executeScript( tabId, { - file: '/build/proxy.js' + file: "/build/proxy.js", }, function (res) { if (!res) { - ports[tabId].devtools.postMessage('proxy-fail') + ports[tabId].devtools.postMessage("proxy-fail"); } else { - console.log('injected proxy to tab ' + tabId) + console.log("injected proxy to tab " + tabId); } } - ) + ); } -function doublePipe (id, one, two) { - one.onMessage.addListener(lOne) - function lOne (message) { - if (message.event === 'log') { - return console.log('tab ' + id, message.payload) +function doublePipe(id, one, two) { + one.onMessage.addListener(lOne); + function lOne(message) { + if (message.event === "log") { + return console.log("tab " + id, message.payload); } - console.log('devtools -> backend', message) - two.postMessage(message) + console.log("devtools -> backend", message); + two.postMessage(message); } - two.onMessage.addListener(lTwo) - function lTwo (message) { - if (message.event === 'log') { - return console.log('tab ' + id, message.payload) + two.onMessage.addListener(lTwo); + function lTwo(message) { + if (message.event === "log") { + return console.log("tab " + id, message.payload); } - console.log('backend -> devtools', message) - one.postMessage(message) + console.log("backend -> devtools", message); + one.postMessage(message); } - function shutdown () { - console.log('tab ' + id + ' disconnected.') - one.onMessage.removeListener(lOne) - two.onMessage.removeListener(lTwo) - one.disconnect() - two.disconnect() - ports[id] = null - updateContextMenuItem() + function shutdown() { + console.log("tab " + id + " disconnected."); + one.onMessage.removeListener(lOne); + two.onMessage.removeListener(lTwo); + one.disconnect(); + two.disconnect(); + ports[id] = null; + updateContextMenuItem(); } - one.onDisconnect.addListener(shutdown) - two.onDisconnect.addListener(shutdown) - console.log('tab ' + id + ' connected.') - updateContextMenuItem() + one.onDisconnect.addListener(shutdown); + two.onDisconnect.addListener(shutdown); + console.log("tab " + id + " connected."); + updateContextMenuItem(); } chrome.runtime.onMessage.addListener((req, sender) => { @@ -85,43 +85,43 @@ chrome.runtime.onMessage.addListener((req, sender) => { chrome.browserAction.setIcon({ tabId: sender.tab.id, path: { - 16: 'icons/16.png', - 48: 'icons/48.png', - 128: 'icons/128.png' - } - }) + 16: "icons/16.png", + 48: "icons/48.png", + 128: "icons/128.png", + }, + }); chrome.browserAction.setPopup({ tabId: sender.tab.id, popup: req.devtoolsEnabled - ? 'popups/enabled.html' - : 'popups/disabled.html' - }) + ? "popups/enabled.html" + : "popups/disabled.html", + }); } -}) +}); // Right-click inspect context menu entry -let activeTabId +let activeTabId; chrome.tabs.onActivated.addListener(({ tabId }) => { - activeTabId = tabId - updateContextMenuItem() -}) + activeTabId = tabId; + updateContextMenuItem(); +}); -function updateContextMenuItem () { +function updateContextMenuItem() { if (ports[activeTabId]) { chrome.contextMenus.create({ - id: 'vue-inspect-instance', - title: 'Inspect Vue component', - contexts: ['all'] - }) + id: "vue-inspect-instance", + title: "Inspect Vue component", + contexts: ["all"], + }); } else { - chrome.contextMenus.remove('vue-inspect-instance') + chrome.contextMenus.remove("vue-inspect-instance"); } } chrome.contextMenus.onClicked.addListener((info, tab) => { chrome.runtime.sendMessage({ vueContextMenu: { - id: info.menuItemId - } - }) -}) + id: info.menuItemId, + }, + }); +}); diff --git a/src/main/vue-devtools/src/detector.js b/src/main/vue-devtools/src/detector.js index 05b3b08..aada6ed 100644 --- a/src/main/vue-devtools/src/detector.js +++ b/src/main/vue-devtools/src/detector.js @@ -1,46 +1,46 @@ -import { installToast } from 'src/backend/toast' +import { installToast } from "src/backend/toast"; -window.addEventListener('message', (e) => { +window.addEventListener("message", (e) => { if (e.source === window && e.data.vueDetected) { - chrome.runtime.sendMessage(e.data) + chrome.runtime.sendMessage(e.data); } -}) +}); -function detect (win) { +function detect(win) { setTimeout(() => { - const all = document.querySelectorAll('*') - let el + const all = document.querySelectorAll("*"); + let el; for (let i = 0; i < all.length; i++) { if (all[i].__vue__) { - el = all[i] - break + el = all[i]; + break; } } if (el) { - let Vue = Object.getPrototypeOf(el.__vue__).constructor + let Vue = Object.getPrototypeOf(el.__vue__).constructor; while (Vue.super) { - Vue = Vue.super + Vue = Vue.super; } win.postMessage( { devtoolsEnabled: Vue.config.devtools, - vueDetected: true + vueDetected: true, }, - '*' - ) + "*" + ); } - }, 100) + }, 100); } // inject the hook if (document instanceof HTMLDocument) { - installScript(detect) - installScript(installToast) + installScript(detect); + installScript(installToast); } -function installScript (fn) { - const script = document.createElement('script') - script.textContent = ';(' + fn.toString() + ')(window)' - document.documentElement.appendChild(script) - script.parentNode.removeChild(script) +function installScript(fn) { + const script = document.createElement("script"); + script.textContent = ";(" + fn.toString() + ")(window)"; + document.documentElement.appendChild(script); + script.parentNode.removeChild(script); } diff --git a/src/main/vue-devtools/src/devtools-background.js b/src/main/vue-devtools/src/devtools-background.js index 0e52aa9..dd52420 100644 --- a/src/main/vue-devtools/src/devtools-background.js +++ b/src/main/vue-devtools/src/devtools-background.js @@ -3,125 +3,125 @@ // Vue presence on the page. If yes, create the Vue panel; otherwise poll // for 10 seconds. -let panelLoaded = false -let panelShown = false -let pendingAction -let created = false -let checkCount = 0 +let panelLoaded = false; +let panelShown = false; +let pendingAction; +let created = false; +let checkCount = 0; -chrome.devtools.network.onNavigated.addListener(createPanelIfHasVue) -const checkVueInterval = setInterval(createPanelIfHasVue, 1000) -createPanelIfHasVue() +chrome.devtools.network.onNavigated.addListener(createPanelIfHasVue); +const checkVueInterval = setInterval(createPanelIfHasVue, 1000); +createPanelIfHasVue(); -function createPanelIfHasVue () { +function createPanelIfHasVue() { if (created || checkCount++ > 10) { - return + return; } - panelLoaded = false - panelShown = false + panelLoaded = false; + panelShown = false; chrome.devtools.inspectedWindow.eval( - '!!(window.__VUE_DEVTOOLS_GLOBAL_HOOK__.Vue)', + "!!(window.__VUE_DEVTOOLS_GLOBAL_HOOK__.Vue)", function (hasVue) { if (!hasVue || created) { - return + return; } - clearInterval(checkVueInterval) - created = true + clearInterval(checkVueInterval); + created = true; chrome.devtools.panels.create( - 'Vue', - 'icons/128.png', - 'devtools.html', + "Vue", + "icons/128.png", + "devtools.html", (panel) => { // panel loaded - panel.onShown.addListener(onPanelShown) - panel.onHidden.addListener(onPanelHidden) + panel.onShown.addListener(onPanelShown); + panel.onHidden.addListener(onPanelHidden); } - ) + ); } - ) + ); } // Runtime messages chrome.runtime.onMessage.addListener((request) => { - if (request === 'vue-panel-load') { - onPanelLoad() + if (request === "vue-panel-load") { + onPanelLoad(); } else if (request.vueToast) { - toast(request.vueToast.message, request.vueToast.type) + toast(request.vueToast.message, request.vueToast.type); } else if (request.vueContextMenu) { - onContextMenu(request.vueContextMenu) + onContextMenu(request.vueContextMenu); } -}) +}); // Page context menu entry -function onContextMenu ({ id }) { - if (id === 'vue-inspect-instance') { - const src = `window.__VUE_DEVTOOLS_CONTEXT_MENU_HAS_TARGET__` +function onContextMenu({ id }) { + if (id === "vue-inspect-instance") { + const src = `window.__VUE_DEVTOOLS_CONTEXT_MENU_HAS_TARGET__`; chrome.devtools.inspectedWindow.eval(src, function (res, err) { if (err) { - console.log(err) + console.log(err); } - if (typeof res !== 'undefined' && res) { + if (typeof res !== "undefined" && res) { panelAction(() => { - chrome.runtime.sendMessage('vue-get-context-menu-target') - }, 'Open Vue devtools to see component details') + chrome.runtime.sendMessage("vue-get-context-menu-target"); + }, "Open Vue devtools to see component details"); } else { - pendingAction = null - toast('No Vue component was found', 'warn') + pendingAction = null; + toast("No Vue component was found", "warn"); } - }) + }); } } // Action that may execute immediatly // or later when the Vue panel is ready -function panelAction (cb, message = null) { +function panelAction(cb, message = null) { if (created && panelLoaded && panelShown) { - cb() + cb(); } else { - pendingAction = cb - message && toast(message) + pendingAction = cb; + message && toast(message); } } -function executePendingAction () { - pendingAction && pendingAction() - pendingAction = null +function executePendingAction() { + pendingAction && pendingAction(); + pendingAction = null; } // Execute pending action when Vue panel is ready -function onPanelLoad () { - executePendingAction() - panelLoaded = true +function onPanelLoad() { + executePendingAction(); + panelLoaded = true; } // Manage panel visibility -function onPanelShown () { - chrome.runtime.sendMessage('vue-panel-shown') - panelShown = true - panelLoaded && executePendingAction() +function onPanelShown() { + chrome.runtime.sendMessage("vue-panel-shown"); + panelShown = true; + panelLoaded && executePendingAction(); } -function onPanelHidden () { - chrome.runtime.sendMessage('vue-panel-hidden') - panelShown = false +function onPanelHidden() { + chrome.runtime.sendMessage("vue-panel-hidden"); + panelShown = false; } // Toasts -function toast (message, type = 'normal') { +function toast(message, type = "normal") { const src = `(function() { __VUE_DEVTOOLS_TOAST__(\`${message}\`, '${type}'); - })()` + })()`; chrome.devtools.inspectedWindow.eval(src, function (res, err) { if (err) { - console.log(err) + console.log(err); } - }) + }); } diff --git a/src/main/vue-devtools/src/devtools.js b/src/main/vue-devtools/src/devtools.js index 0d6f56c..65b8972 100644 --- a/src/main/vue-devtools/src/devtools.js +++ b/src/main/vue-devtools/src/devtools.js @@ -1,7 +1,7 @@ // this script is called when the VueDevtools panel is activated. -import { initDevTools } from 'src/devtools' -import Bridge from 'src/bridge' +import { initDevTools } from "src/devtools"; +import Bridge from "src/bridge"; initDevTools({ /** @@ -10,31 +10,31 @@ initDevTools({ * @param {Function} cb */ - connect (cb) { + connect(cb) { // 1. inject backend code into page - injectScript(chrome.runtime.getURL('build/backend.js'), () => { + injectScript(chrome.runtime.getURL("build/backend.js"), () => { // 2. connect to background to setup proxy const port = chrome.runtime.connect({ - name: '' + chrome.devtools.inspectedWindow.tabId - }) - let disconnected = false + name: "" + chrome.devtools.inspectedWindow.tabId, + }); + let disconnected = false; port.onDisconnect.addListener(() => { - disconnected = true - }) + disconnected = true; + }); const bridge = new Bridge({ - listen (fn) { - port.onMessage.addListener(fn) + listen(fn) { + port.onMessage.addListener(fn); }, - send (data) { + send(data) { if (!disconnected) { - port.postMessage(data) + port.postMessage(data); } - } - }) + }, + }); // 3. send a proxy API to the panel - cb(bridge) - }) + cb(bridge); + }); }, /** @@ -43,10 +43,10 @@ initDevTools({ * @param {Function} reloadFn */ - onReload (reloadFn) { - chrome.devtools.network.onNavigated.addListener(reloadFn) - } -}) + onReload(reloadFn) { + chrome.devtools.network.onNavigated.addListener(reloadFn); + }, +}); /** * Inject a globally evaluated script, in the same context with the actual @@ -56,7 +56,7 @@ initDevTools({ * @param {Function} cb */ -function injectScript (scriptName, cb) { +function injectScript(scriptName, cb) { const src = ` (function() { var script = document.constructor.prototype.createElement.call(document, 'script'); @@ -64,11 +64,11 @@ function injectScript (scriptName, cb) { document.documentElement.appendChild(script); script.parentNode.removeChild(script); })() - ` + `; chrome.devtools.inspectedWindow.eval(src, function (res, err) { if (err) { - console.log(err) + console.log(err); } - cb() - }) + cb(); + }); } diff --git a/src/main/vue-devtools/src/hook.js b/src/main/vue-devtools/src/hook.js index f07c75e..1852f09 100644 --- a/src/main/vue-devtools/src/hook.js +++ b/src/main/vue-devtools/src/hook.js @@ -1,10 +1,10 @@ // This script is injected into every page. -import { installHook } from 'src/backend/hook' +import { installHook } from "src/backend/hook"; // inject the hook if (document instanceof HTMLDocument) { - const script = document.createElement('script') - script.textContent = ';(' + installHook.toString() + ')(window)' - document.documentElement.appendChild(script) - script.parentNode.removeChild(script) + const script = document.createElement("script"); + script.textContent = ";(" + installHook.toString() + ")(window)"; + document.documentElement.appendChild(script); + script.parentNode.removeChild(script); } diff --git a/src/main/vue-devtools/src/proxy.js b/src/main/vue-devtools/src/proxy.js index ab37ab7..082245a 100644 --- a/src/main/vue-devtools/src/proxy.js +++ b/src/main/vue-devtools/src/proxy.js @@ -4,32 +4,32 @@ // backend and the Vue devtools panel. const port = chrome.runtime.connect({ - name: 'content-script' -}) + name: "content-script", +}); -port.onMessage.addListener(sendMessageToBackend) -window.addEventListener('message', sendMessageToDevtools) -port.onDisconnect.addListener(handleDisconnect) +port.onMessage.addListener(sendMessageToBackend); +window.addEventListener("message", sendMessageToDevtools); +port.onDisconnect.addListener(handleDisconnect); -sendMessageToBackend('init') +sendMessageToBackend("init"); -function sendMessageToBackend (payload) { +function sendMessageToBackend(payload) { window.postMessage( { - source: 'vue-devtools-proxy', - payload: payload + source: "vue-devtools-proxy", + payload: payload, }, - '*' - ) + "*" + ); } -function sendMessageToDevtools (e) { - if (e.data && e.data.source === 'vue-devtools-backend') { - port.postMessage(e.data.payload) +function sendMessageToDevtools(e) { + if (e.data && e.data.source === "vue-devtools-backend") { + port.postMessage(e.data.payload); } } -function handleDisconnect () { - window.removeEventListener('message', sendMessageToDevtools) - sendMessageToBackend('shutdown') +function handleDisconnect() { + window.removeEventListener("message", sendMessageToDevtools); + sendMessageToBackend("shutdown"); } diff --git a/src/main/vue-devtools/webpack.config.js b/src/main/vue-devtools/webpack.config.js index 0760590..75105d9 100644 --- a/src/main/vue-devtools/webpack.config.js +++ b/src/main/vue-devtools/webpack.config.js @@ -1,19 +1,19 @@ -const path = require('path') -const createConfig = require('../createConfig') +const path = require("path"); +const createConfig = require("../createConfig"); module.exports = createConfig({ entry: { - hook: './src/hook.js', - devtools: './src/devtools.js', - background: './src/background.js', - 'devtools-background': './src/devtools-background.js', - backend: './src/backend.js', - proxy: './src/proxy.js', - detector: './src/detector.js' + hook: "./src/hook.js", + devtools: "./src/devtools.js", + background: "./src/background.js", + "devtools-background": "./src/devtools-background.js", + backend: "./src/backend.js", + proxy: "./src/proxy.js", + detector: "./src/detector.js", }, output: { - path: path.join(__dirname, 'build'), - filename: '[name].js' + path: path.join(__dirname, "build"), + filename: "[name].js", }, - devtool: process.env.NODE_ENV !== 'production' ? '#inline-source-map' : false -}) + devtool: process.env.NODE_ENV !== "production" ? "#inline-source-map" : false, +}); diff --git a/src/main/windows/desktopLyricWindow.js b/src/main/windows/desktopLyricWindow.js index e59b471..ae95f25 100644 --- a/src/main/windows/desktopLyricWindow.js +++ b/src/main/windows/desktopLyricWindow.js @@ -1,12 +1,12 @@ -import { LOAD_URL } from './../config' -const electron = require('electron') +import { LOAD_URL } from "./../config"; +const electron = require("electron"); const winURL = - process.env.NODE_ENV === 'development' + process.env.NODE_ENV === "development" ? `http://localhost:9080/#desktop-lyric` - : `${LOAD_URL}#desktop-lyric` + : `${LOAD_URL}#desktop-lyric`; const createLyricWindow = function (BrowserWindow) { - const { width, height } = electron.screen.getPrimaryDisplay().workAreaSize + const { width, height } = electron.screen.getPrimaryDisplay().workAreaSize; const obj = { minWidth: 650, width, @@ -27,15 +27,15 @@ const createLyricWindow = function (BrowserWindow) { nodeIntegration: true, nodeIntegrationInWorker: true, backgroundThrottling: false, - devTools: false - } - } + devTools: false, + }, + }; - let lyricWindow = new BrowserWindow(obj) + let lyricWindow = new BrowserWindow(obj); - lyricWindow.loadURL(winURL) + lyricWindow.loadURL(winURL); // lyricWindow.setIgnoreMouseEvents(true) - return lyricWindow -} -export default createLyricWindow + return lyricWindow; +}; +export default createLyricWindow; diff --git a/src/main/windows/miniWindow.js b/src/main/windows/miniWindow.js index 25fdde9..18b6826 100644 --- a/src/main/windows/miniWindow.js +++ b/src/main/windows/miniWindow.js @@ -1,9 +1,9 @@ -import { LOAD_URL } from './../config' +import { LOAD_URL } from "./../config"; const miniWinURL = - process.env.NODE_ENV === 'development' + process.env.NODE_ENV === "development" ? `http://localhost:9080/#mini` - : `${LOAD_URL}#mini` + : `${LOAD_URL}#mini`; const createMiniWindow = function (BrowserWindow) { let obj = { height: 48, @@ -13,25 +13,25 @@ const createMiniWindow = function (BrowserWindow) { frame: false, fullscreenable: false, skipTaskbar: true, - resizable: process.env.NODE_ENV === 'development', - transparent: process.platform !== 'linux', + resizable: process.env.NODE_ENV === "development", + transparent: process.platform !== "linux", alwaysOnTop: true, webPreferences: { nodeIntegration: true, nodeIntegrationInWorker: true, backgroundThrottling: false, - webSecurity: false - } - } + webSecurity: false, + }, + }; - let miniWindow = new BrowserWindow(obj) + let miniWindow = new BrowserWindow(obj); - miniWindow.loadURL(miniWinURL) + miniWindow.loadURL(miniWinURL); - miniWindow.on('closed', () => { - miniWindow = null - }) + miniWindow.on("closed", () => { + miniWindow = null; + }); - return miniWindow -} -export default createMiniWindow + return miniWindow; +}; +export default createMiniWindow; diff --git a/src/main/windows/trayWindow.js b/src/main/windows/trayWindow.js index 8e0507c..c4026ff 100644 --- a/src/main/windows/trayWindow.js +++ b/src/main/windows/trayWindow.js @@ -1,11 +1,11 @@ -import { LOAD_URL } from './../config' +import { LOAD_URL } from "./../config"; const trayWinURL = - process.env.NODE_ENV === 'development' + process.env.NODE_ENV === "development" ? `http://localhost:9080/#tray` - : `${LOAD_URL}#tray` -let trayWindow = null + : `${LOAD_URL}#tray`; +let trayWindow = null; const createTrayWindow = function (BrowserWindow, bounds) { - if (trayWindow) return + if (trayWindow) return; const obj = { height: 350, width: 200, @@ -17,8 +17,8 @@ const createTrayWindow = function (BrowserWindow, bounds) { movable: false, minimizable: false, maximizable: false, - resizable: process.env.NODE_ENV === 'development', - transparent: process.platform !== 'linux', + resizable: process.env.NODE_ENV === "development", + transparent: process.platform !== "linux", alwaysOnTop: true, skipTaskbar: true, // parent: global.mainWindow, @@ -26,21 +26,21 @@ const createTrayWindow = function (BrowserWindow, bounds) { nodeIntegration: true, nodeIntegrationInWorker: true, backgroundThrottling: false, - devTools: false - } - } + devTools: false, + }, + }; - trayWindow = new BrowserWindow(obj) + trayWindow = new BrowserWindow(obj); - trayWindow.loadURL(trayWinURL) + trayWindow.loadURL(trayWinURL); - trayWindow.on('blur', () => { - trayWindow.hide() - }) + trayWindow.on("blur", () => { + trayWindow.hide(); + }); - trayWindow.on('closed', () => { - trayWindow = null - }) - return trayWindow -} -export default createTrayWindow + trayWindow.on("closed", () => { + trayWindow = null; + }); + return trayWindow; +}; +export default createTrayWindow; diff --git a/src/main/windows/updateWindow.js b/src/main/windows/updateWindow.js index d1f92b3..60616d4 100644 --- a/src/main/windows/updateWindow.js +++ b/src/main/windows/updateWindow.js @@ -1,15 +1,15 @@ -import { LOAD_URL } from './../config' +import { LOAD_URL } from "./../config"; const miniWinURL = - process.env.NODE_ENV === 'development' + process.env.NODE_ENV === "development" ? `http://localhost:9080/#update` - : `${LOAD_URL}#update` + : `${LOAD_URL}#update`; const previewIcon = - process.env.NODE_ENV === 'development' - ? '/images/tray.ico' - : `${global.__images}/images/tray.ico` -let updateWindow + process.env.NODE_ENV === "development" + ? "/images/tray.ico" + : `${global.__images}/images/tray.ico`; +let updateWindow; const createUpdateWindow = function (BrowserWindow) { - if (updateWindow) return false + if (updateWindow) return false; let obj = { icon: previewIcon, height: 420, @@ -19,25 +19,25 @@ const createUpdateWindow = function (BrowserWindow) { show: false, frame: false, fullscreenable: false, - resizable: process.env.NODE_ENV === 'development', - transparent: process.platform !== 'linux', + resizable: process.env.NODE_ENV === "development", + transparent: process.platform !== "linux", alwaysOnTop: true, webPreferences: { nodeIntegration: true, nodeIntegrationInWorker: true, webSecurity: false, - navigateOnDragDrop: true - } - } - updateWindow = new BrowserWindow(obj) - updateWindow.loadURL(miniWinURL) + navigateOnDragDrop: true, + }, + }; + updateWindow = new BrowserWindow(obj); + updateWindow.loadURL(miniWinURL); - updateWindow.on('ready-to-show', () => { - updateWindow.show() - }) - updateWindow.on('closed', () => { - updateWindow = null - }) - return updateWindow -} -export default createUpdateWindow + updateWindow.on("ready-to-show", () => { + updateWindow.show(); + }); + updateWindow.on("closed", () => { + updateWindow = null; + }); + return updateWindow; +}; +export default createUpdateWindow; diff --git a/src/main/windows/welcomeWindow.js b/src/main/windows/welcomeWindow.js index 529bf9c..6471d54 100644 --- a/src/main/windows/welcomeWindow.js +++ b/src/main/windows/welcomeWindow.js @@ -2,9 +2,9 @@ // ? `http://localhost:9080/welcome.html` // : `file://${__dirname}/welcome.html` const welcomeWinURL = - process.env.NODE_ENV === 'development' + process.env.NODE_ENV === "development" ? `http://localhost:9080/welcome.html` - : `file://${__dirname}/welcome.html` + : `file://${__dirname}/welcome.html`; const createWelcomeWindow = function (BrowserWindow) { const obj = { @@ -19,19 +19,19 @@ const createWelcomeWindow = function (BrowserWindow) { resizable: false, alwaysOnTop: true, // parent: global.mainWindow, - backgroundColor: '#fff', + backgroundColor: "#fff", skipTaskbar: true, webPreferences: { nodeIntegration: true, nodeIntegrationInWorker: true, backgroundThrottling: false, - webSecurity: false + webSecurity: false, // devTools: false - } - } + }, + }; - global.welcomeWindow = new BrowserWindow(obj) + global.welcomeWindow = new BrowserWindow(obj); - global.welcomeWindow.loadURL(welcomeWinURL) -} -export default createWelcomeWindow + global.welcomeWindow.loadURL(welcomeWinURL); +}; +export default createWelcomeWindow; diff --git a/src/renderer/App.vue b/src/renderer/App.vue index 8cd62e5..2be3f0d 100644 --- a/src/renderer/App.vue +++ b/src/renderer/App.vue @@ -8,64 +8,64 @@ diff --git a/src/renderer/api/album.js b/src/renderer/api/album.js index 9a7b515..370b275 100644 --- a/src/renderer/api/album.js +++ b/src/renderer/api/album.js @@ -1,27 +1,27 @@ -import request from '@/utils/request.js' +import request from "@/utils/request.js"; -export function getTopAlbum ({ limit, offset }) { - return request.get('/top/album', { +export function getTopAlbum({ limit, offset }) { + return request.get("/top/album", { params: { limit, - offset - } - }) + offset, + }, + }); } -export function getNewestAlbum ({ limit, offset }) { - return request.get('/album/newest', { +export function getNewestAlbum({ limit, offset }) { + return request.get("/album/newest", { params: { limit, - offset - } - }) + offset, + }, + }); } -export function getAlbum (id) { - return request.get('/album', { +export function getAlbum(id) { + return request.get("/album", { params: { - id - } - }) + id, + }, + }); } diff --git a/src/renderer/api/artist.js b/src/renderer/api/artist.js index 70ba60f..be2a222 100644 --- a/src/renderer/api/artist.js +++ b/src/renderer/api/artist.js @@ -1,72 +1,72 @@ -import request from '@/utils/request.js' +import request from "@/utils/request.js"; -export function getArtistList ({ - cat = '全部', +export function getArtistList({ + cat = "全部", limit = 30, offset = 0, - initial = '' + initial = "", }) { - return request.get('/artist/list', { + return request.get("/artist/list", { params: { cat, limit, offset, - initial - } - }) + initial, + }, + }); } -export function getArtistAlbum ({ id, limit = 30, offset = 0 }) { - return request.get('/artist/album', { +export function getArtistAlbum({ id, limit = 30, offset = 0 }) { + return request.get("/artist/album", { params: { id, limit, - offset - } - }) + offset, + }, + }); } -export function getArtistMV ({ id, limit = 10, offset = 0 }) { - return request.get('/artist/mv', { +export function getArtistMV({ id, limit = 10, offset = 0 }) { + return request.get("/artist/mv", { params: { id, limit, - offset - } - }) + offset, + }, + }); } -export function getArtistSongs ({ id, limit = 30, offset = 0 }) { - return request.get('/artists', { +export function getArtistSongs({ id, limit = 30, offset = 0 }) { + return request.get("/artists", { params: { id, limit, - offset - } - }) + offset, + }, + }); } -export function getArtistDesc ({ id, limit = 30, offset = 0 }) { - return request.get('/artist/desc', { +export function getArtistDesc({ id, limit = 30, offset = 0 }) { + return request.get("/artist/desc", { params: { id, limit, - offset - } - }) + offset, + }, + }); } // 相似歌手 -export function getArtistSimi ({ id, limit = 30, offset = 0 }) { - return request.get('/simi/artist', { +export function getArtistSimi({ id, limit = 30, offset = 0 }) { + return request.get("/simi/artist", { params: { id, limit, - offset - } - }) + offset, + }, + }); } // 歌手排行榜 -export function getTopArtist () { - return request.get('/toplist/artist') +export function getTopArtist() { + return request.get("/toplist/artist"); } diff --git a/src/renderer/api/banner.js b/src/renderer/api/banner.js index 928cb16..9a768f2 100644 --- a/src/renderer/api/banner.js +++ b/src/renderer/api/banner.js @@ -1,5 +1,5 @@ -import request from '@/utils/request.js' +import request from "@/utils/request.js"; -export function getBanner () { - return request.get('/banner') +export function getBanner() { + return request.get("/banner"); } diff --git a/src/renderer/api/comment.js b/src/renderer/api/comment.js index cd2984d..713fe0a 100644 --- a/src/renderer/api/comment.js +++ b/src/renderer/api/comment.js @@ -1,63 +1,63 @@ -import request from '@/utils/request.js' +import request from "@/utils/request.js"; -export function getPlaylistComment (id, limit = 20, offset = 0) { - return request.get('/comment/playlist', { +export function getPlaylistComment(id, limit = 20, offset = 0) { + return request.get("/comment/playlist", { params: { id, limit, - offset - } - }) + offset, + }, + }); } -export function getAlbumComment (id, limit = 20, offset = 0) { - return request.get('/comment/album', { +export function getAlbumComment(id, limit = 20, offset = 0) { + return request.get("/comment/album", { params: { id, limit, - offset - } - }) + offset, + }, + }); } -export function getMVComment (id, limit = 20, offset = 0) { - return request.get('/comment/mv', { +export function getMVComment(id, limit = 20, offset = 0) { + return request.get("/comment/mv", { params: { id, limit, - offset - } - }) + offset, + }, + }); } -export function getVideoComment (id, limit = 20, offset = 0) { - return request.get('/comment/video', { +export function getVideoComment(id, limit = 20, offset = 0) { + return request.get("/comment/video", { params: { id, limit, - offset - } - }) + offset, + }, + }); } -export function getSongComment (id, limit = 20, offset = 0, before = '') { - return request.get('/comment/music', { +export function getSongComment(id, limit = 20, offset = 0, before = "") { + return request.get("/comment/music", { params: { id, limit, offset, - before - } - }) + before, + }, + }); } -export function getDjComment (id, limit = 20, offset = 0, before = '') { - return request.get('/comment/dj', { +export function getDjComment(id, limit = 20, offset = 0, before = "") { + return request.get("/comment/dj", { params: { id, limit, offset, - before - } - }) + before, + }, + }); } diff --git a/src/renderer/api/dj.js b/src/renderer/api/dj.js index 2583ee3..036563a 100644 --- a/src/renderer/api/dj.js +++ b/src/renderer/api/dj.js @@ -1,61 +1,61 @@ -import request from '@/utils/request.js' +import request from "@/utils/request.js"; -export function getRecommendDjprogram () { - return request.get('/personalized/djprogram') +export function getRecommendDjprogram() { + return request.get("/personalized/djprogram"); } -export function getDjBanner () { - return request.get('/dj/banner') +export function getDjBanner() { + return request.get("/dj/banner"); } -export function getDjCatelist () { - return request.get('/dj/catelist') +export function getDjCatelist() { + return request.get("/dj/catelist"); } -export function getDjByCate ({ type, limit = 5, offset = 0 }) { - return request.get('/dj/recommend/type', { +export function getDjByCate({ type, limit = 5, offset = 0 }) { + return request.get("/dj/recommend/type", { params: { type, limit, - offset - } - }) + offset, + }, + }); } -export function getDjCatelistRecommend () { - return request.get('/dj/category/recommend') +export function getDjCatelistRecommend() { + return request.get("/dj/category/recommend"); } -export function getDjRecommend () { - return request.get('/dj/recommend') +export function getDjRecommend() { + return request.get("/dj/recommend"); } // 今日优选 -export function getDjPerfered () { - return request.get('/dj/today/perfered') +export function getDjPerfered() { + return request.get("/dj/today/perfered"); } // 推荐节目 -export function getProgramRecommend () { - return request.get('/program/recommend') +export function getProgramRecommend() { + return request.get("/program/recommend"); } // 付费精选 -export function getDjPaygift () { - return request.get('/dj/paygift') +export function getDjPaygift() { + return request.get("/dj/paygift"); } // 热门 -export function getDjHot () { - return request.get('/dj/hot') +export function getDjHot() { + return request.get("/dj/hot"); } // 电台详情 -export function getDjDetail (rid) { - return request.get('/dj/detail', { +export function getDjDetail(rid) { + return request.get("/dj/detail", { params: { - rid - } - }) + rid, + }, + }); } // 获取电台的节目 -export function getDjProgram ({ rid, limit, offset, asc = false }) { - return request.get('/dj/program', { +export function getDjProgram({ rid, limit, offset, asc = false }) { + return request.get("/dj/program", { params: { rid, limit, offset, - asc - } - }) + asc, + }, + }); } diff --git a/src/renderer/api/login.js b/src/renderer/api/login.js index db4babb..a5bd9da 100644 --- a/src/renderer/api/login.js +++ b/src/renderer/api/login.js @@ -1,21 +1,21 @@ -import request from '../utils/request.js' +import request from "../utils/request.js"; -export function login_cellphone (params) { - return request.get('/login/cellphone', { - params - }) +export function login_cellphone(params) { + return request.get("/login/cellphone", { + params, + }); } -export function login_email (params) { - return request.get('/login/cellphone', { - params - }) +export function login_email(params) { + return request.get("/login/cellphone", { + params, + }); } -export function login_refresh () { - return request.get('/login/refresh') +export function login_refresh() { + return request.get("/login/refresh"); } -export function login_status () { - return request.get('/login/status') +export function login_status() { + return request.get("/login/status"); } -export function logout () { - return request.get('/logout') +export function logout() { + return request.get("/logout"); } diff --git a/src/renderer/api/mv.js b/src/renderer/api/mv.js index 172bfec..e3a4090 100644 --- a/src/renderer/api/mv.js +++ b/src/renderer/api/mv.js @@ -1,7 +1,7 @@ -import request from '@/utils/request.js' +import request from "@/utils/request.js"; -export function getPersonalizedMV () { - return request.get('/personalized/mv') +export function getPersonalizedMV() { + return request.get("/personalized/mv"); } // area: 地区,可选值为全部,内地,港台,欧美,日本,韩国,不填则为全部 @@ -9,71 +9,71 @@ export function getPersonalizedMV () { // order: 排序,可选值为上升最快,最热,最新,不填则为上升最快 // limit: 取出数量 , 默认为 30 // offset: 偏移数量 , 用于分页 , 如 :( 页数 -1)*50, 其中 50 为 limit 的值 , 默认 为 0 -export function getAllMV ({ - area = '全部', - type = '全部', - order = '上升最快', +export function getAllMV({ + area = "全部", + type = "全部", + order = "上升最快", limit = 30, - offset = 0 + offset = 0, }) { - return request.get('/mv/all', { + return request.get("/mv/all", { params: { area, type, order, limit, - offset - } - }) + offset, + }, + }); } -export function getTopMV ({ limit = 30, offset = 0 }) { - return request.get('/top/mv', { +export function getTopMV({ limit = 30, offset = 0 }) { + return request.get("/top/mv", { params: { limit, - offset - } - }) + offset, + }, + }); } -export function getNewMV ({ limit = 10 }) { - return request.get('/mv/first', { +export function getNewMV({ limit = 10 }) { + return request.get("/mv/first", { params: { - limit - } - }) + limit, + }, + }); } -export function getMVInfo (mvid) { - return request.get('/mv/detail', { +export function getMVInfo(mvid) { + return request.get("/mv/detail", { params: { - mvid - } - }) + mvid, + }, + }); } -export function getMvUrl (id) { - return request.get('/mv/url', { +export function getMvUrl(id) { + return request.get("/mv/url", { params: { - id - } - }) + id, + }, + }); } -export function getSimiMV (id) { - return request.get('/simi/mv', { +export function getSimiMV(id) { + return request.get("/simi/mv", { params: { - mvid: id - } - }) + mvid: id, + }, + }); } // 收藏视频 t : 1 为收藏,其他为取消收藏 -export function subMV (mvid, t) { - return request.get('/mv/sub', { +export function subMV(mvid, t) { + return request.get("/mv/sub", { params: { mvid, - t - } - }) + t, + }, + }); } diff --git a/src/renderer/api/playlist.js b/src/renderer/api/playlist.js index 489aed0..9c363dd 100644 --- a/src/renderer/api/playlist.js +++ b/src/renderer/api/playlist.js @@ -1,79 +1,79 @@ -import request from '@/utils/request.js' +import request from "@/utils/request.js"; -export function getPlaylistTags () { - return request.get('/playlist/hot') +export function getPlaylistTags() { + return request.get("/playlist/hot"); } -export function getUserPlaylist (uid) { - return request.get('/user/playlist', { +export function getUserPlaylist(uid) { + return request.get("/user/playlist", { params: { - uid - } - }) + uid, + }, + }); } -export function getPlaylistDetail (id) { - return request.get('/playlist/detail', { +export function getPlaylistDetail(id) { + return request.get("/playlist/detail", { params: { id, - _: new Date().getTime() - } - }) + _: new Date().getTime(), + }, + }); } -export function getPlaylistCatlist () { - return request.get('/playlist/catlist') +export function getPlaylistCatlist() { + return request.get("/playlist/catlist"); } -export function getPersonalizedPlaylist () { - return request.get('/personalized') +export function getPersonalizedPlaylist() { + return request.get("/personalized"); } -export function getTopPlaylist ({ - cat = '全部', +export function getTopPlaylist({ + cat = "全部", limit = 10, offset = 0, - order = 'new' + order = "new", }) { - return request.get('/top/playlist', { + return request.get("/top/playlist", { params: { cat, limit, offset, - order - } - }) + order, + }, + }); } // 精品歌单 before: 分页参数,取上一页最后一个歌单的 updateTime 获取下一页数据 -export function getHighPlaylist ({ cat = '全部', limit = 20, before = '' }) { - return request.get('/top/playlist/highquality', { +export function getHighPlaylist({ cat = "全部", limit = 20, before = "" }) { + return request.get("/top/playlist/highquality", { params: { cat, limit, - before - } - }) + before, + }, + }); } -export function getRelatedPlaylist (id) { - return request.get('/related/playlist', { +export function getRelatedPlaylist(id) { + return request.get("/related/playlist", { params: { - id - } - }) + id, + }, + }); } -export function getRecommendPlaylist () { - return request.get('/personalized') +export function getRecommendPlaylist() { + return request.get("/personalized"); } -export function getPlaylistSubscribers ({ limit = 20, offset = 0, id }) { - return request.get('/playlist/subscribers', { +export function getPlaylistSubscribers({ limit = 20, offset = 0, id }) { + return request.get("/playlist/subscribers", { params: { id, limit, - offset - } - }) + offset, + }, + }); } diff --git a/src/renderer/api/privatecontent.js b/src/renderer/api/privatecontent.js index 820da0f..74f702f 100644 --- a/src/renderer/api/privatecontent.js +++ b/src/renderer/api/privatecontent.js @@ -1,5 +1,5 @@ -import request from '@/utils/request.js' +import request from "@/utils/request.js"; -export function getPrivateContent () { - return request.get('/personalized/privatecontent') +export function getPrivateContent() { + return request.get("/personalized/privatecontent"); } diff --git a/src/renderer/api/rank.js b/src/renderer/api/rank.js index f5b8399..e450418 100644 --- a/src/renderer/api/rank.js +++ b/src/renderer/api/rank.js @@ -1,18 +1,18 @@ -import request from '@/utils/request.js' +import request from "@/utils/request.js"; // 全球榜 -export function getToplist () { - return request.get('/toplist') +export function getToplist() { + return request.get("/toplist"); } -export function getTopDetail (idx) { - return request.get('/top/list', { +export function getTopDetail(idx) { + return request.get("/top/list", { params: { - idx - } - }) + idx, + }, + }); } -export function getToplistDetail () { - return request.get('/toplist/detail') +export function getToplistDetail() { + return request.get("/toplist/detail"); } diff --git a/src/renderer/api/search.js b/src/renderer/api/search.js index 3db504a..3c2d224 100644 --- a/src/renderer/api/search.js +++ b/src/renderer/api/search.js @@ -1,34 +1,34 @@ -import request from '@/utils/request.js' +import request from "@/utils/request.js"; // 搜索类型;默认为 1 即单曲 , 取值意义 : 1: 单曲, 10: 专辑, 100: 歌手, 1000: 歌单, 1002: 用户, 1004: MV, 1006: 歌词, 1009: 电台, 1014: 视频 -export function getSearch ({ keyword, limit = 30, offset = 0, type = 1 }) { - return request.get('/search', { +export function getSearch({ keyword, limit = 30, offset = 0, type = 1 }) { + return request.get("/search", { params: { keywords: keyword, limit, offset, - type - } - }) + type, + }, + }); } -export function getSearchHot () { - return request.get('/search/hot') +export function getSearchHot() { + return request.get("/search/hot"); } -export function getSearchSuggest (keywords) { - return request.get('/search/suggest', { +export function getSearchSuggest(keywords) { + return request.get("/search/suggest", { params: { - keywords - } - }) + keywords, + }, + }); } // 获取搜索匹配 -export function getSearchMultimatch (keywords) { - return request.get('/search/multimatch', { +export function getSearchMultimatch(keywords) { + return request.get("/search/multimatch", { params: { - keywords - } - }) + keywords, + }, + }); } diff --git a/src/renderer/api/song.js b/src/renderer/api/song.js index 5946f12..e46dc6f 100644 --- a/src/renderer/api/song.js +++ b/src/renderer/api/song.js @@ -1,71 +1,71 @@ -import request from '@/utils/request.js' +import request from "@/utils/request.js"; -export function getSongUrl (id) { - return request.get('/song/url', { +export function getSongUrl(id) { + return request.get("/song/url", { params: { - id - } - }) + id, + }, + }); } // 歌曲详情 -export function getSongDetail (ids) { - return request.get('/song/detail', { +export function getSongDetail(ids) { + return request.get("/song/detail", { params: { - ids - } - }) + ids, + }, + }); } // 获取歌词 -export function getLyric (id) { - return request.get('/lyric', { +export function getLyric(id) { + return request.get("/lyric", { params: { - id - } - }) + id, + }, + }); } -export function getNewSong () { - return request.get('/personalized/newsong') +export function getNewSong() { + return request.get("/personalized/newsong"); } // 心动模式 /playmode/intelligence/list?id=33894312&pid=24381616 -export function getIntelligence (id, pid) { - return request.get('/playmode/intelligence/list', { +export function getIntelligence(id, pid) { + return request.get("/playmode/intelligence/list", { params: { id, pid, - _: new Date().getTime() - } - }) + _: new Date().getTime(), + }, + }); } // 相似音乐 -export function getSimiSong (id) { - return request.get('/simi/song', { +export function getSimiSong(id) { + return request.get("/simi/song", { params: { - id - } - }) + id, + }, + }); } // 根据歌曲找到包含这首歌的歌单 -export function getSimiPlaylist (id) { - return request.get('/simi/playlist', { +export function getSimiPlaylist(id) { + return request.get("/simi/playlist", { params: { - id - } - }) + id, + }, + }); } // 获取最近 5 个听了这首歌的用户 -export function getSongUsers (id) { - return request.get('/simi/user', { +export function getSongUsers(id) { + return request.get("/simi/user", { params: { - id - } - }) + id, + }, + }); } // 新歌速递 @@ -74,10 +74,10 @@ export function getSongUsers (id) { // 欧美:96 // 日本:8 // 韩国:16 -export function getTopSong (type) { - return request.get('/top/song', { +export function getTopSong(type) { + return request.get("/top/song", { params: { - type - } - }) + type, + }, + }); } diff --git a/src/renderer/api/sublist.js b/src/renderer/api/sublist.js index 3b8a710..56d0b60 100644 --- a/src/renderer/api/sublist.js +++ b/src/renderer/api/sublist.js @@ -1,31 +1,31 @@ -import request from '@/utils/request.js' +import request from "@/utils/request.js"; -export function getArtist ({ limit = 20, offset = 0 }) { - return request.get('/artist/sublist', { +export function getArtist({ limit = 20, offset = 0 }) { + return request.get("/artist/sublist", { params: { limit, offset, - _: new Date().getTime() - } - }) + _: new Date().getTime(), + }, + }); } -export function getMv ({ limit = 50, offset = 0 }) { - return request.get('/mv/sublist', { +export function getMv({ limit = 50, offset = 0 }) { + return request.get("/mv/sublist", { params: { limit, offset, - _: new Date().getTime() - } - }) + _: new Date().getTime(), + }, + }); } -export function getSubAlbum ({ limit = 20, offset = 0 }) { - return request.get('/album/sublist', { +export function getSubAlbum({ limit = 20, offset = 0 }) { + return request.get("/album/sublist", { params: { limit, offset, - _: new Date().getTime() - } - }) + _: new Date().getTime(), + }, + }); } diff --git a/src/renderer/api/user.js b/src/renderer/api/user.js index 2e66f0f..0e46091 100644 --- a/src/renderer/api/user.js +++ b/src/renderer/api/user.js @@ -1,140 +1,140 @@ -import request from '../utils/request.js' +import request from "../utils/request.js"; -export function login_cellphone (params) { - return request.get('/login/cellphone', { - params - }) +export function login_cellphone(params) { + return request.get("/login/cellphone", { + params, + }); } // type: 签到类型 , 默认 0, 其中 0 为安卓端签到 ,1 为 web/PC 签到 -export function daily_signin (type) { - return request.get('/daily_signin', { +export function daily_signin(type) { + return request.get("/daily_signin", { params: { - type - } - }) + type, + }, + }); } // 用户详情 -export function user_detail (uid) { - return request.get('/user/detail', { +export function user_detail(uid) { + return request.get("/user/detail", { params: { uid, - _: new Date().getTime() - } - }) + _: new Date().getTime(), + }, + }); } // 获取用户信息 , 歌单,收藏,mv, dj 数量 -export function user_subcount (uid) { - return request.get('/user/subcount', { +export function user_subcount(uid) { + return request.get("/user/subcount", { params: { uid, - _: new Date().getTime() - } - }) + _: new Date().getTime(), + }, + }); } // 获取用户私信 -export function user_msg_private ({ limit = 10, offset = 0 }) { - return request.get('/msg/private', { - params: { limit, offset } - }) +export function user_msg_private({ limit = 10, offset = 0 }) { + return request.get("/msg/private", { + params: { limit, offset }, + }); } // 获取用户关注列表 -export function user_follower ({ uid, limit = 10, offset = 0 }) { - return request.get('/user/follows', { - params: { uid, limit, offset } - }) +export function user_follower({ uid, limit = 10, offset = 0 }) { + return request.get("/user/follows", { + params: { uid, limit, offset }, + }); } // 获取用户粉丝列表 -export function user_followed ({ uid, limit = 10, lasttime = -1 }) { - return request.get('/user/followeds', { - params: { uid, limit, lasttime } - }) +export function user_followed({ uid, limit = 10, lasttime = -1 }) { + return request.get("/user/followeds", { + params: { uid, limit, lasttime }, + }); } // 关注/取消关注用户 -export function user_follow ({ t, id }) { - return request.get('/follow', { - params: { t, id } - }) +export function user_follow({ t, id }) { + return request.get("/follow", { + params: { t, id }, + }); } // 获取用户歌单 -export function getUserPlaylist (uid) { +export function getUserPlaylist(uid) { let params = { uid, - limit: 10000 + limit: 10000, + }; + if (process.env.NODE_ENV !== "production") { + params.timestamp = new Date().getTime(); } - if (process.env.NODE_ENV !== 'production') { - params.timestamp = new Date().getTime() - } - return request.get('/user/playlist', { - params - }) + return request.get("/user/playlist", { + params, + }); } -export function getUserCloud (uid) { - return request.get('/user/cloud', { +export function getUserCloud(uid) { + return request.get("/user/cloud", { params: { - uid - } - }) + uid, + }, + }); } // 获取用户喜欢歌曲列表 -export function getUserLikeSongs (uid) { +export function getUserLikeSongs(uid) { let params = { - uid - } - if (process.env.NODE_ENV === 'production') { - params.timestamp = new Date().getTime() + uid, + }; + if (process.env.NODE_ENV === "production") { + params.timestamp = new Date().getTime(); } - return request.get('/likelist', { - params - }) + return request.get("/likelist", { + params, + }); } // 喜欢音乐 -export function likeMusic (musicId, isLike) { - return request.get('/like', { +export function likeMusic(musicId, isLike) { + return request.get("/like", { params: { id: musicId, - like: isLike - } - }) + like: isLike, + }, + }); } // 收藏专辑 t 1:收藏,2:取消收藏 -export function subAlbum ({ t, id }) { - return request.get('/album/sub', { +export function subAlbum({ t, id }) { + return request.get("/album/sub", { params: { t, - id - } - }) + id, + }, + }); } // 收藏歌单 t 1:收藏,2:取消收藏 -export function likePlaylist (t, pid) { - return request.get('/playlist/subscribe', { +export function likePlaylist(t, pid) { + return request.get("/playlist/subscribe", { params: { t, - id: pid - } - }) + id: pid, + }, + }); } // 删除创建的歌单 -export function deletePlaylist (id) { - return request.get('/playlist/delete', { +export function deletePlaylist(id) { + return request.get("/playlist/delete", { params: { - id - } - }) + id, + }, + }); } /** @@ -142,85 +142,85 @@ export function deletePlaylist (id) { * @param {*歌单名} name * @param {*privacy : 是否设置为隐私歌单,默认否,传'10'则设置成隐私歌单} privacy */ -export function createPlaylist ({ name, privacy }) { +export function createPlaylist({ name, privacy }) { let params = { - name - } + name, + }; if (privacy) { - params.privacy = 10 + params.privacy = 10; } - return request.get('/playlist/create', { - params - }) + return request.get("/playlist/create", { + params, + }); } // 对歌单添加或删除歌曲 -export function addSongToList ({ op, tracks, pid }) { - return request.get('/playlist/tracks', { +export function addSongToList({ op, tracks, pid }) { + return request.get("/playlist/tracks", { params: { op, tracks, - pid - } - }) + pid, + }, + }); } // 私人fm -export function getFm () { - return request.get('/personal_fm?_=' + new Date().getTime()) +export function getFm() { + return request.get("/personal_fm?_=" + new Date().getTime()); } // 每日推荐歌曲 -export function getRecommendSongs () { - return request.get('/recommend/songs') +export function getRecommendSongs() { + return request.get("/recommend/songs"); } // 用户动态 -export function getUserEvent ({ uid, limit = 30, lasttime = -1 }) { - return request.get('/user/event', { +export function getUserEvent({ uid, limit = 30, lasttime = -1 }) { + return request.get("/user/event", { params: { uid, limit, - lasttime - } - }) + lasttime, + }, + }); } // 动态 -export function getEvent ({ pagesize = 30, lasttime = -1 }) { - return request.get('/event', { +export function getEvent({ pagesize = 30, lasttime = -1 }) { + return request.get("/event", { params: { pagesize, - lasttime - } - }) + lasttime, + }, + }); } // 订阅电台 1订阅,0订阅 -export function subDj ({ t, rid }) { - return request.get('/dj/sub', { +export function subDj({ t, rid }) { + return request.get("/dj/sub", { params: { t, - rid - } - }) + rid, + }, + }); } // 收藏歌手 1为收藏,其他取消订阅 -export function subArtist ({ t, id }) { - return request.get('/artist/sub', { +export function subArtist({ t, id }) { + return request.get("/artist/sub", { params: { t, - id - } - }) + id, + }, + }); } -export function getHotTopic ({ limit = 30, offset = 0 }) { - return request.get('/hot/topic', { +export function getHotTopic({ limit = 30, offset = 0 }) { + return request.get("/hot/topic", { params: { limit, - offset - } - }) + offset, + }, + }); } diff --git a/src/renderer/api/video.js b/src/renderer/api/video.js index 5d071a0..f7f06e8 100644 --- a/src/renderer/api/video.js +++ b/src/renderer/api/video.js @@ -1,34 +1,34 @@ -import request from '@/utils/request.js' +import request from "@/utils/request.js"; -export function getVideo (groupId) { - let id = groupId || 5100 - return request.get(`/video/group?id=${id}&_=${new Date().getTime()}`) +export function getVideo(groupId) { + let id = groupId || 5100; + return request.get(`/video/group?id=${id}&_=${new Date().getTime()}`); } // /video/group/list -export function getVideoCates () { - return request.get('/video/group/list') +export function getVideoCates() { + return request.get("/video/group/list"); } -export function getVideoUrl (id) { - return request.get(`/video/url?id=${id}`) +export function getVideoUrl(id) { + return request.get(`/video/url?id=${id}`); } -export function getVideoDetail (id) { - return request.get(`/video/detail?id=${id}`) +export function getVideoDetail(id) { + return request.get(`/video/detail?id=${id}`); } // 相关视频 -export function getRelatedVideo (id) { - return request.get(`/related/allvideo?id=${id}`) +export function getRelatedVideo(id) { + return request.get(`/related/allvideo?id=${id}`); } // 收藏视频 t : 1 为收藏,其他为取消收藏 -export function subVideo (id, t) { - return request.get('/video/sub', { +export function subVideo(id, t) { + return request.get("/video/sub", { params: { id, - t - } - }) + t, + }, + }); } diff --git a/src/renderer/components/BasicHeader/Controls.vue b/src/renderer/components/BasicHeader/Controls.vue index 13cc9a6..c532a33 100644 --- a/src/renderer/components/BasicHeader/Controls.vue +++ b/src/renderer/components/BasicHeader/Controls.vue @@ -13,20 +13,20 @@ diff --git a/src/renderer/components/BasicSider/Created.vue b/src/renderer/components/BasicSider/Created.vue index 0d45c6e..f5e927d 100644 --- a/src/renderer/components/BasicSider/Created.vue +++ b/src/renderer/components/BasicSider/Created.vue @@ -85,88 +85,88 @@ diff --git a/src/renderer/components/BasicSider/MiniCard.vue b/src/renderer/components/BasicSider/MiniCard.vue index 7955435..dfa715c 100644 --- a/src/renderer/components/BasicSider/MiniCard.vue +++ b/src/renderer/components/BasicSider/MiniCard.vue @@ -24,7 +24,7 @@ :isLiked="likedsongIds.includes(current_song.id)" @heartClick=" (isLike) => { - handleLikeSong({ songId: current_song.id, isLike }) + handleLikeSong({ songId: current_song.id, isLike }); } " /> @@ -48,45 +48,46 @@ diff --git a/src/renderer/components/Common/dj-item.vue b/src/renderer/components/Common/dj-item.vue index 4154ea4..5552f70 100644 --- a/src/renderer/components/Common/dj-item.vue +++ b/src/renderer/components/Common/dj-item.vue @@ -19,17 +19,17 @@ diff --git a/src/renderer/components/Common/track-list/base/contextMenu.vue b/src/renderer/components/Common/track-list/base/contextMenu.vue index 5799234..b0d25f8 100644 --- a/src/renderer/components/Common/track-list/base/contextMenu.vue +++ b/src/renderer/components/Common/track-list/base/contextMenu.vue @@ -38,21 +38,21 @@ diff --git a/src/renderer/components/Common/track-list/base/default.vue b/src/renderer/components/Common/track-list/base/default.vue index bc0693e..34593a2 100644 --- a/src/renderer/components/Common/track-list/base/default.vue +++ b/src/renderer/components/Common/track-list/base/default.vue @@ -9,11 +9,11 @@ export default { props: { row: { - type: Object + type: Object, }, col: { - type: Object - } - } -} + type: Object, + }, + }, +}; diff --git a/src/renderer/components/Common/track-list/base/duration.vue b/src/renderer/components/Common/track-list/base/duration.vue index 93e6ade..ac1dc32 100644 --- a/src/renderer/components/Common/track-list/base/duration.vue +++ b/src/renderer/components/Common/track-list/base/duration.vue @@ -4,18 +4,18 @@ diff --git a/src/renderer/components/Common/track-list/base/songName.vue b/src/renderer/components/Common/track-list/base/songName.vue index ecfc79d..1735c3c 100644 --- a/src/renderer/components/Common/track-list/base/songName.vue +++ b/src/renderer/components/Common/track-list/base/songName.vue @@ -16,31 +16,31 @@ diff --git a/src/renderer/components/Player/index.vue b/src/renderer/components/Player/index.vue index a2c96e7..258ba1b 100644 --- a/src/renderer/components/Player/index.vue +++ b/src/renderer/components/Player/index.vue @@ -192,24 +192,24 @@ diff --git a/src/renderer/views/Dj/index.vue b/src/renderer/views/Dj/index.vue index 5427a8f..3bcab3a 100644 --- a/src/renderer/views/Dj/index.vue +++ b/src/renderer/views/Dj/index.vue @@ -93,8 +93,8 @@ diff --git a/src/renderer/views/Search/components/user.vue b/src/renderer/views/Search/components/user.vue index 4d5dbc2..b1e7748 100644 --- a/src/renderer/views/Search/components/user.vue +++ b/src/renderer/views/Search/components/user.vue @@ -21,25 +21,25 @@ diff --git a/src/renderer/views/Tray.vue b/src/renderer/views/Tray.vue index ed4a503..d52e377 100644 --- a/src/renderer/views/Tray.vue +++ b/src/renderer/views/Tray.vue @@ -85,104 +85,104 @@ diff --git a/src/renderer/views/User/Collect/components/Album.vue b/src/renderer/views/User/Collect/components/Album.vue index 5494b40..310bce7 100644 --- a/src/renderer/views/User/Collect/components/Album.vue +++ b/src/renderer/views/User/Collect/components/Album.vue @@ -10,40 +10,40 @@ diff --git a/src/renderer/views/User/index.vue b/src/renderer/views/User/index.vue index 60fae56..7cb0cd1 100644 --- a/src/renderer/views/User/index.vue +++ b/src/renderer/views/User/index.vue @@ -106,71 +106,71 @@