Skip to content

Commit 9a58b4e

Browse files
committed
fix api on return view more one request
cause case: using router params for computed value, which will trigger on page router change, so as in and return views.
1 parent b7541c6 commit 9a58b4e

File tree

4 files changed

+12
-17
lines changed

4 files changed

+12
-17
lines changed

src/composables/useApi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const headers = {
1919
authority: "api.rocotime.com",
2020
accept: "application/json, text/plain, */*",
2121
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
22-
// "content-type": "application/json",
22+
"content-type": "application/json",
2323
"Access-Control-Allow-Credentials": "true",
2424
dnt: "1",
2525
origin: "https://rocotime.com",

src/composables/useHttp.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class RocoRequest {
3939
// Request Interception
4040
this.$interceptors.request()
4141
console.log("HTTP ST GET - ", reqUrl)
42-
console.time("GET" + reqUrl)
42+
console.time(reqUrl)
4343
// Request
4444
const response = await fetch<T>(reqUrl, {
4545
...this.$Option,
@@ -48,7 +48,7 @@ export class RocoRequest {
4848
query: { ...params },
4949
responseType: ResponseType.JSON,
5050
})
51-
console.timeEnd("GET" + reqUrl)
51+
console.timeEnd(reqUrl)
5252
console.log("HTTP RC GET - ", response.status)
5353

5454
// Response Interception
@@ -62,7 +62,7 @@ export class RocoRequest {
6262
// Request Interception
6363
this.$interceptors.request()
6464
console.log("HTTP ST POST - ", reqUrl)
65-
console.time("POST" + reqUrl)
65+
console.time(reqUrl)
6666
// Request
6767
const response = await fetch<T>(reqUrl, {
6868
...this.$Option,
@@ -71,7 +71,7 @@ export class RocoRequest {
7171
body: Body.json({ ...params }),
7272
responseType: ResponseType.JSON,
7373
})
74-
console.timeEnd("POST" + reqUrl)
74+
console.timeEnd(reqUrl)
7575
console.log("HTTP RC POST - ", response.status)
7676

7777
// Response Interception

src/views/Angel.vue

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,10 @@ import { WindowCreator } from "../composables/useWindow"
1313
const $route = useRoute()
1414
const { getAngel, iconStaticURL, featureStaticURL, talentStaticURL } = useApi()
1515
16-
const angelData = computedAsync(async (onCancel) => {
17-
const abortController = new AbortController()
18-
19-
onCancel(() => abortController.abort())
20-
21-
return await getAngel({ hash: $route.params.hash as string })
16+
const routeHash = $route.params.hash as string
17+
const angelData = computedAsync(async () => {
18+
console.log(routeHash)
19+
return await getAngel({ hash: routeHash })
2220
})
2321
2422
function getIconSrc() {

src/views/Skill.vue

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,9 @@ const $route = useRoute()
1212
const { getSkill, damageTypeStaticMap, featureStaticURL, iconStaticURL } =
1313
useApi()
1414
15-
const skillData = computedAsync(async (onCancel) => {
16-
const abortController = new AbortController()
17-
18-
onCancel(() => abortController.abort())
19-
20-
return await getSkill({ hash: $route.params.hash as string })
15+
const routeHash = $route.params.hash as string
16+
const skillData = computedAsync(async () => {
17+
return await getSkill({ hash: routeHash })
2118
})
2219
2320
function getPropertyIconSrc(propertyIndex: string) {

0 commit comments

Comments
 (0)