Skip to content

Commit d94f5fe

Browse files
committed
fix context menu
todo: add type support for responses.
1 parent bf225aa commit d94f5fe

File tree

4 files changed

+28
-15
lines changed

4 files changed

+28
-15
lines changed

src/App.vue

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,7 @@ onMounted(() => {
3535
</script>
3636

3737
<template>
38-
<div
39-
id="app-main"
40-
@contextmenu="
41-
(e) => {
42-
// e.preventDefault()
43-
}
44-
"
45-
>
38+
<div id="app-main" @contextmenu.prevent>
4639
<TitleBar :titleText="title" />
4740
<Dialog v-model:isOpen="isOpenModelDialog" />
4841
<TopLinks />

src/composables/useApi.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @ts-ignore
12
import { RocoRequest } from "./useHttp"
23
import NProgress from "nprogress"
34

@@ -48,6 +49,15 @@ interface FeatureObject {
4849
name: string
4950
}
5051

52+
interface AngelListItemObject {
53+
id: string
54+
group: string
55+
hash: string
56+
img?: string
57+
iconSrc: string
58+
features: string[]
59+
}
60+
5161
interface AngelListParma {
5262
search: string
5363
id: string
@@ -84,7 +94,10 @@ rocoApi.setInterceptors("response")(() => {
8494
export const useApi = () => {
8595
// Angel Feature Map
8696
async function getFeatures() {
87-
const response = await rocoApi.get("/feature/")
97+
const response = await rocoApi.get<{ list: FeatureObject[] }>(
98+
"/feature/",
99+
{}
100+
)
88101

89102
const obj: FeatureObject[] = response.data.list
90103
const map = new Map()
@@ -103,7 +116,11 @@ export const useApi = () => {
103116
page: 1,
104117
}
105118
) {
106-
const response = await rocoApi.post("/spiritList/", params)
119+
const response = await rocoApi.post<{ data: AngelListItemObject[] }>(
120+
"/spiritList/",
121+
params
122+
)
123+
107124
return response.data.data
108125
}
109126

src/composables/useHttp.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { fetch, Body } from "@tauri-apps/api/http"
1+
import { fetch, Body, ResponseType } from "@tauri-apps/api/http"
22
import type { FetchOptions } from "@tauri-apps/api/http"
33

44
interface RequestHeaders {
@@ -53,17 +53,18 @@ export class RocoRequest {
5353
this.$Option = { ...this.$Option, timeout }
5454
}
5555

56-
async get(path: string, params?: any) {
56+
async get<T>(path: string, params?: any) {
5757
let reqUrl = this.$uri + path
5858
// Request Interception
5959
this.$interceptors.request()
6060
console.log("HTTP ST GET - ", reqUrl)
6161
// Request
62-
const response = await fetch(reqUrl, {
62+
const response = await fetch<T>(reqUrl, {
6363
...this.$Option,
6464
method: "GET",
6565
headers: this.$headers,
6666
query: { ...params },
67+
responseType: ResponseType.JSON,
6768
})
6869
console.log("HTTP RC GET - ", response)
6970

@@ -73,17 +74,18 @@ export class RocoRequest {
7374
return response
7475
}
7576

76-
async post(path: string, params: {} = {}) {
77+
async post<T>(path: string, params = {}) {
7778
let reqUrl = this.$uri + path
7879
// Request Interception
7980
this.$interceptors.request()
8081
console.log("HTTP ST POST - ", reqUrl)
8182
// Request
82-
const response = await fetch(reqUrl, {
83+
const response = await fetch<T>(reqUrl, {
8384
...this.$Option,
8485
method: "POST",
8586
headers: this.$headers,
8687
body: Body.json({ ...params }),
88+
responseType: ResponseType.JSON,
8789
})
8890
console.log("HTTP RC POST - ", response)
8991

src/views/Skill.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script lang="ts" setup>
2+
// @ts-ignore
23
import GoBack from "../components/native/GoBack.vue"
34
// import { CubeTransparentIcon } from "@heroicons/vue/20/solid"
45

0 commit comments

Comments
 (0)