Skip to content

Commit 8537152

Browse files
committed
last alpha release: finish type fix
1.0.0-alpha.4
1 parent d94f5fe commit 8537152

File tree

13 files changed

+249
-116
lines changed

13 files changed

+249
-116
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "rocox-codex",
33
"private": false,
4-
"version": "1.0.0-alpha.3",
4+
"version": "1.0.0-alpha.4",
55
"type": "module",
66
"scripts": {
77
"dev": "vite",

src-tauri/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rocox-codex"
3-
version = "1.0.0-alpha.3"
3+
version = "1.0.0-alpha.4"
44
description = "Rocox Codex"
55
authors = ["NeserCode"]
66
license = "MIT"
@@ -13,7 +13,7 @@ edition = "2021"
1313
tauri-build = { version = "1.4", features = [] }
1414

1515
[dependencies]
16-
tauri = { version = "1.4", features = [ "system-tray", "api-all"] }
16+
tauri = { version = "1.4", features = [ "system-tray", "api-all", "devtools"] }
1717
serde = { version = "1.0", features = ["derive"] }
1818
serde_json = "1.0"
1919

src-tauri/tauri.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"package": {
1010
"productName": "RoCoX Codex",
11-
"version": "1.0.0-alpha.3"
11+
"version": "1.0.0-alpha.4"
1212
},
1313
"tauri": {
1414
"allowlist": {

src/components/ChainItem.vue

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,8 @@
22
export default {
33
name: "chainItem",
44
}
5-
6-
interface ChainItemProp {
7-
hash: string
8-
id: string
9-
img: string
10-
name: string
11-
start?: boolean
12-
lv?: string
13-
to: ChainItemProp[] | "0"
14-
}
155
</script>
166
<script lang="ts" setup>
17-
// @ts-ignore
187
import { BoltIcon } from "@heroicons/vue/20/solid"
198
import { Ref, ref, toRefs } from "vue"
209
@@ -23,6 +12,8 @@ import { useRouter } from "vue-router"
2312
import { useStorage } from "@vueuse/core"
2413
import { WindowCreator } from "../composables/useWindow"
2514
15+
import type { ChainItemProp } from "../share"
16+
2617
const $props = defineProps<{
2718
chainTo: ChainItemProp | ChainItemProp[]
2819
}>()
@@ -71,12 +62,12 @@ function goAngelView(hash: string) {
7162
>
7263
<span
7364
class="angel-item"
74-
@click="setupWindowParams(chainTo.id, chainTo.name, chainTo.hash)"
65+
@click="setupWindowParams(chainTo.id!, chainTo.name!, chainTo.hash!)"
7566
>
7667
<img
7768
class="angel-img"
7869
v-if="chainTo.id"
79-
:src="iconSrc(chainTo.hash, chainTo.id)"
70+
:src="iconSrc(chainTo.hash!, chainTo.id!)"
8071
alt="Angel icon"
8172
draggable="false"
8273
loading="lazy"
@@ -90,19 +81,19 @@ function goAngelView(hash: string) {
9081
</span>
9182
<chainItem
9283
v-if="!(typeof chainTo.to === 'string')"
93-
:chainTo="chainTo.to"
84+
:chainTo="chainTo.to!"
9485
/>
9586
</template>
9687
<template v-if="Array.isArray(chainTo)">
9788
<span v-for="item of chainTo" class="chain-children">
9889
<span
9990
class="angel-item"
100-
@click="setupWindowParams(item.id, item.name, item.hash)"
91+
@click="setupWindowParams(item.id!, item.name!, item.hash!)"
10192
>
10293
<img
10394
class="angel-img"
10495
v-if="item.id"
105-
:src="iconSrc(item.hash, item.id)"
96+
:src="iconSrc(item.hash!, item.id!)"
10697
alt="Angel icon"
10798
draggable="false"
10899
loading="lazy"
@@ -114,7 +105,7 @@ function goAngelView(hash: string) {
114105
<span class="lv" v-else>Super</span>
115106
<BoltIcon class="icon" />
116107
</span>
117-
<chainItem v-if="!(typeof item.to === 'string')" :chainTo="item.to" />
108+
<chainItem v-if="!(typeof item.to === 'string')" :chainTo="item.to!" />
118109
</span>
119110
</template>
120111
</div>

src/components/ItemList.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,25 +62,25 @@ watch(listData, (val: any[]) => {
6262

6363
<template>
6464
<div class="item-list-main custom-scrollbar">
65-
<div class="item-card" v-for="item in listData" :key="item.hash">
65+
<div class="item-card" v-for="item in listData" :key="item.id!">
6666
<span class="name-text">
6767
<span class="id">#{{ item.id }}</span>
68-
<span class="font-bold inline-block mx-1"> · </span>
68+
<span class="inline-block mx-1 font-bold"> · </span>
6969
<span class="name">{{ item.name }}</span>
7070
</span>
7171
<span class="details">
7272
<img
7373
v-if="item.id && !loadErrorList.includes(item.id)"
7474
class="icon"
75-
@error="(e) => onerrorList(e, item.id)"
75+
@error="(e) => onerrorList(e, item.id!)"
7676
:src="getItemSrc(item.id)"
7777
alt="item image"
7878
draggable="false"
7979
/>
8080
<CubeTransparentIcon v-else class="icon placeholder" />
8181
<span class="text">
8282
<span class="unique"
83-
>持有 · {{ parseInt(item.Unique) ? "" : "不" }}唯一</span
83+
>持有 · {{ parseInt(item.Unique!) ? "" : "不" }}唯一</span
8484
>
8585
<span class="price">售价 · {{ item.Price }}</span>
8686
<span class="desc"

src/components/SkillList.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ function goSkillView(hash: string) {
8888
class="skill-card"
8989
v-for="skill in listData"
9090
:key="skill.hash"
91-
@click="setupWindowParams(skill.id, skill.name, skill.hash)"
91+
@click="setupWindowParams(skill.id!, skill.name!, skill.hash!)"
9292
>
9393
<span class="name-text">
9494
<span class="id">#{{ skill.id }}</span>
@@ -107,7 +107,7 @@ function goSkillView(hash: string) {
107107
v-if="skill.power !== '--'"
108108
draggable="false"
109109
class="icon damage"
110-
:src="damageTypeStaticMap.get(skill.damageType)"
110+
:src="damageTypeStaticMap.get(skill.damageType!)"
111111
:alt="skill.damageType === '1' ? '物理伤害' : '魔法伤害'"
112112
:title="skill.damageType === '1' ? '物理伤害' : '魔法伤害'"
113113
/>

src/components/SpiritList.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ watch(listData, (val: any[]) => {
5353
pageSize: pageSize.value,
5454
total: totalFromID.value,
5555
})
56+
// console.log(listData.value)
5657
})
5758
5859
function getFeatureIconSrc(featureIndex: string) {
@@ -92,7 +93,7 @@ function goAngelView(hash: string) {
9293
class="angel-card"
9394
v-for="angel in listData"
9495
:key="angel.hash"
95-
@click="setupWindowParams(angel.id, angel.name, angel.hash)"
96+
@click="setupWindowParams(angel.id!, angel.name!, angel.hash!)"
9697
>
9798
<span class="details">
9899
<span class="name-text">#{{ angel.id }} · {{ angel.name }}</span>
@@ -111,7 +112,7 @@ function goAngelView(hash: string) {
111112
draggable="false"
112113
class="angel-icon icon"
113114
v-show="angel.img"
114-
:src="getAngelIconSrc(angel.iconSrc)"
115+
:src="getAngelIconSrc(angel.iconSrc!)"
115116
alt="angel icon"
116117
referrerPolicy="no-referrer"
117118
loading="lazy"

src/composables/useApi.ts

Lines changed: 29 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1-
// @ts-ignore
21
import { RocoRequest } from "./useHttp"
32
import NProgress from "nprogress"
43

4+
import {
5+
AngelDetailObject,
6+
AngelListData,
7+
AngelListParma,
8+
FeatureListData,
9+
ItemListData,
10+
ItemListParma,
11+
SkillDetailObject,
12+
SkillListData,
13+
SkillListParma,
14+
} from "../share"
15+
516
const baseURL = "https://api.rocotime.com/api"
617
const timeout = 5000
718
const headers = {
@@ -44,40 +55,6 @@ const rocoApi = new RocoRequest({
4455
headers,
4556
})
4657

47-
interface FeatureObject {
48-
id: string
49-
name: string
50-
}
51-
52-
interface AngelListItemObject {
53-
id: string
54-
group: string
55-
hash: string
56-
img?: string
57-
iconSrc: string
58-
features: string[]
59-
}
60-
61-
interface AngelListParma {
62-
search: string
63-
id: string
64-
feature: string
65-
page: number
66-
}
67-
68-
interface SkillListParma {
69-
search: string
70-
id: string
71-
feature: string
72-
page: number
73-
}
74-
75-
interface ItemListParma {
76-
search: string
77-
id: string
78-
page: number
79-
}
80-
8158
// Request Interceptions
8259
rocoApi.setInterceptors("request")(() => {
8360
NProgress.start()
@@ -94,16 +71,14 @@ rocoApi.setInterceptors("response")(() => {
9471
export const useApi = () => {
9572
// Angel Feature Map
9673
async function getFeatures() {
97-
const response = await rocoApi.get<{ list: FeatureObject[] }>(
98-
"/feature/",
99-
{}
100-
)
74+
const response = await rocoApi.get<FeatureListData>("/feature/")
10175

102-
const obj: FeatureObject[] = response.data.list
103-
const map = new Map()
76+
const obj = response.data.list
77+
const map = new Map<string, string>()
10478
obj.forEach((pair) => {
105-
map.set(pair.id, pair.name)
79+
map.set(pair.id!, pair.name!)
10680
})
81+
10782
return map
10883
}
10984

@@ -116,17 +91,18 @@ export const useApi = () => {
11691
page: 1,
11792
}
11893
) {
119-
const response = await rocoApi.post<{ data: AngelListItemObject[] }>(
120-
"/spiritList/",
121-
params
122-
)
94+
const response = await rocoApi.post<AngelListData>("/spiritList/", params)
12395

12496
return response.data.data
12597
}
12698

12799
// Angel Detail
128100
async function getAngel(params: { hash: string }) {
129-
const response = await rocoApi.post("/detail/angel/", params)
101+
const response = await rocoApi.post<AngelDetailObject>(
102+
"/detail/angel/",
103+
params
104+
)
105+
130106
return response.data.data
131107
}
132108

@@ -138,7 +114,7 @@ export const useApi = () => {
138114
page: 1,
139115
}
140116
) {
141-
const response = await rocoApi.post("/Itemlist/", params)
117+
const response = await rocoApi.post<ItemListData>("/Itemlist/", params)
142118
return response.data.data
143119
}
144120

@@ -151,13 +127,16 @@ export const useApi = () => {
151127
page: 1,
152128
}
153129
) {
154-
const response = await rocoApi.post("/Skilllist/", params)
130+
const response = await rocoApi.post<SkillListData>("/Skilllist/", params)
155131
return response.data.data
156132
}
157133

158134
// Skill Detail
159135
async function getSkill(params: { hash: string }) {
160-
const response = await rocoApi.post("/detail/skill/", params)
136+
const response = await rocoApi.post<SkillDetailObject>(
137+
"/detail/skill/",
138+
params
139+
)
161140
return response.data
162141
}
163142

src/composables/useHttp.ts

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,6 @@
11
import { fetch, Body, ResponseType } from "@tauri-apps/api/http"
22
import type { FetchOptions } from "@tauri-apps/api/http"
3-
4-
interface RequestHeaders {
5-
authority: string
6-
accept: string
7-
"accept-language"?: string
8-
"content-type"?: string
9-
"Access-Control-Allow-Origin"?: string
10-
"Access-Control-Allow-Credentials"?: string
11-
dnt?: string
12-
origin?: string
13-
referrer?: string
14-
"sec-ch-ua"?: string
15-
"sec-ch-ua-mobile"?: string
16-
"sec-ch-ua-platform"?: string
17-
"sec-fetch-dest"?: string
18-
"sec-fetch-mode"?: string
19-
"sec-fetch-site"?: string
20-
"sec-gpc"?: string
21-
"user-agent"?: string
22-
}
3+
import type { RequestHeaders } from "../share"
234

245
// type Signal = AbortSignal
256

@@ -58,6 +39,7 @@ export class RocoRequest {
5839
// Request Interception
5940
this.$interceptors.request()
6041
console.log("HTTP ST GET - ", reqUrl)
42+
console.time("GET" + reqUrl)
6143
// Request
6244
const response = await fetch<T>(reqUrl, {
6345
...this.$Option,
@@ -66,7 +48,8 @@ export class RocoRequest {
6648
query: { ...params },
6749
responseType: ResponseType.JSON,
6850
})
69-
console.log("HTTP RC GET - ", response)
51+
console.timeEnd("GET" + reqUrl)
52+
console.log("HTTP RC GET - ", response.status)
7053

7154
// Response Interception
7255
this.$interceptors.response()
@@ -79,6 +62,7 @@ export class RocoRequest {
7962
// Request Interception
8063
this.$interceptors.request()
8164
console.log("HTTP ST POST - ", reqUrl)
65+
console.time("POST" + reqUrl)
8266
// Request
8367
const response = await fetch<T>(reqUrl, {
8468
...this.$Option,
@@ -87,7 +71,8 @@ export class RocoRequest {
8771
body: Body.json({ ...params }),
8872
responseType: ResponseType.JSON,
8973
})
90-
console.log("HTTP RC POST - ", response)
74+
console.timeEnd("POST" + reqUrl)
75+
console.log("HTTP RC POST - ", response.status)
9176

9277
// Response Interception
9378
this.$interceptors.response()

0 commit comments

Comments
 (0)