From 78b9529699ca8bfa04e165f4aa76a7685da314c5 Mon Sep 17 00:00:00 2001 From: wancat Date: Thu, 27 Jun 2024 10:52:02 +0800 Subject: [PATCH] refactor: rewrite map page using user profile store --- app/src/components/QuestMap.vue | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/app/src/components/QuestMap.vue b/app/src/components/QuestMap.vue index 235edd0..bc75ed7 100644 --- a/app/src/components/QuestMap.vue +++ b/app/src/components/QuestMap.vue @@ -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) })