Skip to content

Commit

Permalink
fix: 🐛 修复访问过多导致卡loading
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaohuohumax committed Sep 30, 2024
1 parent 7e5e8ec commit 78a6374
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions app/web/src/api/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ class MetaAPI extends Meta {
const e = error as RequestError
if (e.status === 500 && error.message.includes('Failed to fetch')) {
this.printMessage(i18nt('api.error.network'))
return
}
if (e.response) {
else if (e.response) {
this.handleError(e.response as OctokitResponse<{ message: string }>)
}
throw error
})
}

Expand Down
2 changes: 1 addition & 1 deletion app/web/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async function run() {
app.use(i18n)

const appStore = useAppStore()
await appStore.initLoad()
appStore.initLoad()

app.use(router)
app.mount('#app')
Expand Down
8 changes: 5 additions & 3 deletions app/web/src/store/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import issueApi from '~/api/module/issue'
import type { Label } from '~/api/module/label'
import labelApi from '~/api/module/label'
import appConfig from '~/app.config'
import { lngList, useI18n } from '~/i18n'
import { i18nt, lngList } from '~/i18n'
import { IBrightnessDown, IMoonF } from '~/icons'
import { RouteName } from '~/router/routes'

Expand Down Expand Up @@ -149,7 +149,6 @@ export const useAppStore = defineStore('app', {
},
getters: {
menuOptions(state): MenuOption[] {
const { t } = useI18n()
return state.dMenus.filter((menu) => {
return menu.label
? state.labels.some(label => label.name === menu.label)
Expand All @@ -159,7 +158,7 @@ export const useAppStore = defineStore('app', {
label: () => h(
RouterLink,
{ to: { name: menu.routerName } },
{ default: () => t(menu.name) },
{ default: () => i18nt(menu.name) },
),
key: menu.routerName,
}
Expand All @@ -168,6 +167,9 @@ export const useAppStore = defineStore('app', {
theme(state) {
return state.themes[state.themeIndex]
},
loadLabelsFinished(state) {
return state.labels.length > 0
},
},
persist: {
key: `${appConfig.appName}-store-${appConfig.version}`,
Expand Down
2 changes: 1 addition & 1 deletion app/web/src/views/VNotFound.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const { t } = useI18n()
<template>
<div class="h-full flex justify-center items-center">
<NSpace :vertical="true" class="text-center">
<img src="/images/error_404.svg" class="max-w-64 md:max-w-96 mx-auto">
<img src="/images/error_404.svg?url" class="max-w-64 md:max-w-96 mx-auto">
<div class="">
{{ t('page.notFound.content') }}
</div>
Expand Down
5 changes: 4 additions & 1 deletion packages/api/src/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ export class Meta {
constructor(options: MetaOptions) {
this.octokit = new Octokit({
auth: options.token,
// retry: { enabled: false }
retry: {
doNotRetry: [400, 401, 404, 422, 451],
},
throttle: { enabled: false },
})

this.owner = options.owner
Expand Down

0 comments on commit 78a6374

Please sign in to comment.