This commit is contained in:
2025-03-12 09:36:26 +08:00
parent b98464d8b5
commit 6053fba1da
22 changed files with 286 additions and 228 deletions
+2 -8
View File
@@ -2,6 +2,7 @@ import type { AxiosInstance, AxiosResponse } from 'axios'
import axios from 'axios'
import { h } from 'vue'
import { gzip, ungzip } from 'pako'
import { useInfoStore } from '@/stores'
// import { useAppStore, useConfigStore } from '@/store'
// import { useDialog } from '@/components/hooks/dialog'
@@ -58,19 +59,12 @@ export function defineRequest<T>(fn: (ax: AxiosInstance) => T) {
// const token = configStore.token
// const uid = useAppStore().uid
const token = 'test'
const token = useInfoStore().token
if (token) {
request.headers['Access-Token'] = token
}
// 在网页端,会添加token
const accessToken = localStorage.getItem('dcalc/access_token')
if (accessToken) {
request.headers.Authorization = `Bearer ${accessToken}`
}
return request
},
(error) => {
+12 -3
View File
@@ -1,10 +1,19 @@
import { defineRequest } from '../common'
import type { IAdventureInfo } from './type'
import type { IAdventureInfo, ICharacterInfo } from './type'
export default defineRequest((request) => {
return {
adventures() {
return request.get<IAdventureInfo[]>('/adventure').then((res) => res.data)
async adventures() {
const res = await request.get<IAdventureInfo[]>('/adventure')
return res.data
},
async createToken(alter: string, equVersion?: string) {
const res = await request.get<string>(`/token/get/${alter}`, { params: { equVersion } })
return res.data
},
async characterInfo() {
const res = await request.get<ICharacterInfo>('/character')
return res.data
},
}
})
+23 -14
View File
@@ -3,20 +3,6 @@ export interface IAdventureInfo {
name: string
children: IAlterInfo[]
}
export interface ITools {
name: string
tooltips: string
link: string
end?: Date
target: '_blank' | '_self'
}
export interface IMonster {
id: number
name: string
}
export interface IAlterOption {
name: string
title: string
@@ -31,4 +17,27 @@ export interface IAlterInfo {
options?: IAlterOption[]
open?: boolean
comment?: string
class?:string
}
export interface ICharacterInfo {
alter: string
name: string
equVersion: string
equips: IEquipment[]
weapons: string[]
skills: ISkill[]
suits: ISuit[]
}
export interface IEquipment {}
export interface ISkill {
icon: string
name: string
id: number
learnLv:number
positon:number
}
export interface ISuit {}