mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
feat: migreate get user profile to trpc
This commit is contained in:
1 parent
ac92950177
commit
423548804a
11 files changed
+54
-62
No files matched your search
@@ -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() {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user