mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 03:20:12 +08:00
refactor: rewrite map page using user profile store
This commit is contained in:
1 parent
8a31a58c56
commit
78b9529699
1 file changed
+3
-12
@@ -14,7 +14,9 @@ import {
|
|||||||
import { DAG } from '@linux-odyssey/utils'
|
import { DAG } from '@linux-odyssey/utils'
|
||||||
import api from '../utils/api'
|
import api from '../utils/api'
|
||||||
import { NodeImage } from '../img/svg.js'
|
import { NodeImage } from '../img/svg.js'
|
||||||
|
import useUserProfile from '../store/userProfile'
|
||||||
|
|
||||||
|
const store = useUserProfile()
|
||||||
const marginX = 500
|
const marginX = 500
|
||||||
const marginY = 300
|
const marginY = 300
|
||||||
const chartContainer = ref(null)
|
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) => ({
|
const genOption = (nodes: any, edges: any) => ({
|
||||||
renderer: 'svg',
|
renderer: 'svg',
|
||||||
tooltip: {},
|
tooltip: {},
|
||||||
@@ -163,8 +155,7 @@ function initChart(option: any) {
|
|||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
const quests = await getQuests()
|
const quests = await getQuests()
|
||||||
const progress = await getProgress()
|
const option = getOption(quests, store.progress)
|
||||||
const option = getOption(quests, progress)
|
|
||||||
initChart(option)
|
initChart(option)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in new issue
Block a user