diff --git a/package.json b/package.json index 2e5afbd..4186308 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "YesPlayMusic", - "version": "0.2.1", + "version": "0.2.2", "private": true, "description": "A third party music application for Netease Cloud Music", "author": "hawtim", diff --git a/src/store/actions.js b/src/store/actions.js index 0ee1b07..66a0930 100644 --- a/src/store/actions.js +++ b/src/store/actions.js @@ -6,8 +6,10 @@ import localforage from "localforage"; import store from "@/store"; import { cacheTrack } from "@/utils/db"; -const electron = window.require("electron"); -const ipcRenderer = electron.ipcRenderer; +const electron = + process.env.IS_ELECTRON === true ? window.require("electron") : null; +const ipcRenderer = + process.env.IS_ELECTRON === true ? electron.ipcRenderer : null; export default { switchTrack({ state, dispatch, commit }, basicTrack) { @@ -39,7 +41,10 @@ export default { document.title = `${track.name} · ${track.ar[0].name} - YesPlayMusic`; if (track.playable === false) { - const res = ipcRenderer.sendSync("unblock-music", track.id); + let res = undefined; + if (process.env.IS_ELECTRON === true) { + res = ipcRenderer.sendSync("unblock-music", track.id); + } if (res?.url) { commitMP3(res.url); } else { diff --git a/src/utils/updateApp.js b/src/utils/updateApp.js index 03e8453..9ce4946 100644 --- a/src/utils/updateApp.js +++ b/src/utils/updateApp.js @@ -1,50 +1,26 @@ -import pack from "../../package.json"; import initLocalStorage from "@/store/initLocalStorage.js"; +import pkg from "../../package.json"; -// function exampleFunction() { -// console.log("update to vx.x.x"); -// // 0.2.0 to 0.2.1 -// localStorage.setItem("appVersion", "x.x.x"); -// window.location.reload(); -// } +const updateSetting = () => { + const parsedSettings = JSON.parse(localStorage.getItem("settings")); + const setting = { + playlistCategories: initLocalStorage?.settings?.playlistCategories, + ...parsedSettings, + }; + + localStorage.setItem("setting", JSON.stringify(setting)); +}; -function updateTo_0_2_0() { - // 0.1 to 0.2.0 - // 移动 settings 内的 user 数据到 data - let settings = JSON.parse(localStorage.getItem("settings")); - let data = { - likedSongPlaylistID: settings.user.likedSongPlaylistID, - lastRefreshCookieDate: settings.lastRefreshCookieDate, +const updateData = () => { + const parsedData = JSON.parse(localStorage.getItem("data")); + const data = { + ...parsedData, }; - delete settings.user.likedSongPlaylistID; - delete settings.lastRefreshCookieDate; - data.user = settings.user; - delete settings.user; - localStorage.setItem("settings", JSON.stringify(settings)); localStorage.setItem("data", JSON.stringify(data)); - localStorage.setItem("appVersion", "0.2.0"); - window.location.reload(); -} - -function updateTo_0_2_1() { - console.log("update to v0.2.1"); - // 0.2.0 to 0.2.1 - // 初始化 playlistCategories - let settings = JSON.parse(localStorage.getItem("settings")); - settings.playlistCategories = initLocalStorage.settings.playlistCategories; - localStorage.setItem("settings", JSON.stringify(settings)); - localStorage.setItem("appVersion", "0.2.1"); - window.location.reload(); -} +}; export default function () { - while (localStorage.getItem("appVersion") !== pack.version) { - let currentVersion = localStorage.getItem("appVersion"); - if (currentVersion === "0.1") { - updateTo_0_2_0(); - } - if (currentVersion === "0.2.0") { - updateTo_0_2_1(); - } - } + updateSetting(); + updateData(); + localStorage.setItem("appVersion", JSON.stringify(pkg.version)); } diff --git a/src/views/album.vue b/src/views/album.vue index 55f13de..1b084d8 100644 --- a/src/views/album.vue +++ b/src/views/album.vue @@ -48,8 +48,11 @@ :iconClass="dynamicDetail.isSub ? 'heart-solid' : 'heart'" :iconButton="true" :horizontalPadding="0" - color="grey" + :color="dynamicDetail.isSub ? 'blue' : 'grey'" :textColor="dynamicDetail.isSub ? '#335eea' : ''" + :backgroundColor=" + dynamicDetail.isSub ? 'var(--color-secondary-bg)' : '' + " @click.native="likeAlbum" > diff --git a/src/views/playlist.vue b/src/views/playlist.vue index 0de3370..71b30bd 100644 --- a/src/views/playlist.vue +++ b/src/views/playlist.vue @@ -56,8 +56,11 @@ :iconClass="playlist.subscribed ? 'heart-solid' : 'heart'" :iconButton="true" :horizontalPadding="0" - color="grey" + :color="playlist.subscribed ? 'blue' : 'grey'" :textColor="playlist.subscribed ? '#335eea' : ''" + :backgroundColor=" + playlist.subscribed ? 'var(--color-secondary-bg)' : '' + " @click.native="likePlaylist" >