feat: migreate get user profile to trpc

This commit is contained in:
Justin Lin committed 2025-04-16 16:40:03 +08:00
1 parent ac92950177
commit 423548804a
11 files changed
+54 -62

No files matched your search

+2 -2
View File
@@ -1,5 +1,5 @@
import { defineStore } from 'pinia'
import { getUserProfile } from '../utils/api'
import { trpc } from '../utils/trpc'
interface IProgress {
quest: string
@@ -23,7 +23,7 @@ const useUserProfile = defineStore('userProfile', {
}),
actions: {
async loadUserProfile() {
const res = await getUserProfile()
const res = await trpc.users.getMyProfile.query()
this.$patch(res)
},
async resetUserProfile() {
-6
View File
@@ -1,7 +1,6 @@
import axios from 'axios'
import { GetSessionsRequest } from '@linux-odyssey/constants'
import { Session } from '../types'
import { UserProfile } from '../store/userProfile'
const api = axios.create({
baseURL: '/api/v1',
@@ -12,11 +11,6 @@ const api = axios.create({
})
export default api
export async function getUserProfile(): Promise<UserProfile> {
const res = await api.get<UserProfile>('/users/me')
return res.data
}
export async function createSession(questId: string): Promise<Session> {
const res = await api.post<Session>('/sessions', { questId })
return res.data