-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathApp.vue
88 lines (78 loc) · 3.1 KB
/
App.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<script lang="ts" setup name="App">
import { onMounted } from 'vue';
import { RouterView } from 'vue-router'
import { useGlobalStore } from './stores/global'
import { setGlobalLastModifiedTimestamp } from '@/utils/localStorage';
import Navbar from './components/navbar/Navbar.vue'
import LoadingScreen from './components/navbar/LoadingScreen.vue'
const globalStore = useGlobalStore()
function getLocalStorageDataByKey (key) {
return JSON.parse(localStorage.getItem(key) as string);
}
function setLocalStorageDataByKey (key, data) {
localStorage.setItem(key, JSON.stringify(data))
}
// PLEASE CAREFULLY MODIFY THE FUNCTION HERE
// otherwise, it may lead to data incompatibility and potentially break users' data
function clearLegacyData () {
const plannerSettingsStoreKey = 'plannerSettings'
const plannerSettingsStoreData = getLocalStorageDataByKey(plannerSettingsStoreKey)
if (plannerSettingsStoreData) { // only do this if there's data already stored in users' devices
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { settings: { enableGreedyMethod, enabledUnreleasedStages, ...restSettings } } = plannerSettingsStoreData
// remove the legacy data keys: enableGreedyMethod and enabledUnreleasedStages
const newPlannerSettingsStoreData = { ...plannerSettingsStoreData, settings: restSettings };
setLocalStorageDataByKey(plannerSettingsStoreKey, newPlannerSettingsStoreData)
}
const warehouseStoreKey = 'warehouse'
const warehouseStoreData = getLocalStorageDataByKey(warehouseStoreKey)
if (warehouseStoreData) { // only do this if there's data already stored in users' devices
const { data: warehouseData } = warehouseStoreData
const legacyMatlNameMapping = {
Caduceus: 'Serpent Scepter',
'Crimson Gold Compass': 'Golden Compass',
'Glimmering Mothwing Lamp': 'Glowing Mothwing',
'Curved Goose Neck': 'Goose Neck',
'Gold Dust Beetle': 'Golden Beetle',
'Winged Key': 'Winged Key',
'Ceaseless Wheel': 'Perpetual Cog',
'Dried Cicada Wing': 'Cicada Wings',
'Wheel and Axle Core': 'Watch Core'
}
const newWarehouseData = warehouseData.map((matlInfo) => {
const newMatlName = legacyMatlNameMapping[matlInfo.Material] || matlInfo.Material;
return {
...matlInfo,
Material: newMatlName
}
})
const newWarehouseStoreData = {
...warehouseStoreData,
data: newWarehouseData
}
setLocalStorageDataByKey(warehouseStoreKey, newWarehouseStoreData)
}
}
onMounted(() => {
clearLegacyData();
setGlobalLastModifiedTimestamp();
})
</script>
<template>
<div class="bg-gradient-to-r from-gray-900 to-blue-950">
<header>
<Navbar />
</header>
<main class="z-0 min-h-screen flex flex-col pt-14">
<LoadingScreen v-if="globalStore.isLoading"></LoadingScreen>
<RouterView v-else></RouterView>
</main>
</div>
</template>
<style scoped>
body,
html {
margin: 0;
padding: 0;
}
</style>