refactor: rewrite map page using user profile store

This commit is contained in:
wancat committed 2024-06-27 10:52:02 +08:00
1 parent 8a31a58c56
commit 78b9529699
1 file changed
+3 -12
+3 -12
View File
@@ -14,7 +14,9 @@ import {
import { DAG } from '@linux-odyssey/utils'
import api from '../utils/api'
import { NodeImage } from '../img/svg.js'
import useUserProfile from '../store/userProfile'
const store = useUserProfile()
const marginX = 500
const marginY = 300
const chartContainer = ref(null)
@@ -40,16 +42,6 @@ async function getQuests() {
}
}
async function getProgress() {
try {
const res = await api.get('/users/me')
return res.data.progress
} catch (err) {
console.error(err)
throw err
}
}
const genOption = (nodes: any, edges: any) => ({
renderer: 'svg',
tooltip: {},
@@ -163,8 +155,7 @@ function initChart(option: any) {
onMounted(async () => {
const quests = await getQuests()
const progress = await getProgress()
const option = getOption(quests, progress)
const option = getOption(quests, store.progress)
initChart(option)
})
</script>