parent
8cc8ed9273
commit
72c23654c9
@ -1,50 +1,26 @@
|
|||||||
import pack from "../../package.json";
|
|
||||||
import initLocalStorage from "@/store/initLocalStorage.js";
|
import initLocalStorage from "@/store/initLocalStorage.js";
|
||||||
|
import pkg from "../../package.json";
|
||||||
|
|
||||||
// function exampleFunction() {
|
const updateSetting = () => {
|
||||||
// console.log("update to vx.x.x");
|
const parsedSettings = JSON.parse(localStorage.getItem("settings"));
|
||||||
// // 0.2.0 to 0.2.1
|
const setting = {
|
||||||
// localStorage.setItem("appVersion", "x.x.x");
|
playlistCategories: initLocalStorage?.settings?.playlistCategories,
|
||||||
// window.location.reload();
|
...parsedSettings,
|
||||||
// }
|
};
|
||||||
|
|
||||||
|
localStorage.setItem("setting", JSON.stringify(setting));
|
||||||
|
};
|
||||||
|
|
||||||
function updateTo_0_2_0() {
|
const updateData = () => {
|
||||||
// 0.1 to 0.2.0
|
const parsedData = JSON.parse(localStorage.getItem("data"));
|
||||||
// 移动 settings 内的 user 数据到 data
|
const data = {
|
||||||
let settings = JSON.parse(localStorage.getItem("settings"));
|
...parsedData,
|
||||||
let data = {
|
|
||||||
likedSongPlaylistID: settings.user.likedSongPlaylistID,
|
|
||||||
lastRefreshCookieDate: settings.lastRefreshCookieDate,
|
|
||||||
};
|
};
|
||||||
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("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 () {
|
export default function () {
|
||||||
while (localStorage.getItem("appVersion") !== pack.version) {
|
updateSetting();
|
||||||
let currentVersion = localStorage.getItem("appVersion");
|
updateData();
|
||||||
if (currentVersion === "0.1") {
|
localStorage.setItem("appVersion", JSON.stringify(pkg.version));
|
||||||
updateTo_0_2_0();
|
|
||||||
}
|
|
||||||
if (currentVersion === "0.2.0") {
|
|
||||||
updateTo_0_2_1();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in new issue