Skip to content

Commit

Permalink
🔥 fix: hmr hot circular import (#263)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdsuwwz authored Jan 12, 2024
1 parent 6dcb7e2 commit e1188ab
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
9 changes: 9 additions & 0 deletions src/store/hooks/useOutsideRouter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineStore } from 'pinia'

export const useOutsideRouter = defineStore('outside-router', () => {
const router = useRouter()

return {
router
}
})
3 changes: 0 additions & 3 deletions src/store/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@
*/

import { getFilterResponse } from '@/store/utils/mixin'
import router from '@/router'

export const pluginPinia = ({ store }) => {
store.filterResponse = getFilterResponse
store.router = router
}

declare module 'pinia' {
export interface PiniaCustomProperties {

filterResponse: typeof getFilterResponse
router: typeof router
}
}
3 changes: 0 additions & 3 deletions src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import {
requiredRadioRules
} from '@/utils/formRules'

import router from '@/router'

// $ModalDialog
declare module 'vue' {
export interface VNode {
Expand Down Expand Up @@ -50,7 +48,6 @@ declare module 'pinia' {
*/
export interface PiniaCustomProperties {
filterResponse: typeof getFilterResponse
router: typeof router
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/utils/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import axios, { AxiosInstance } from 'axios'
import Cookie from 'js-cookie'

import { camelizeKeys, decamelizeKeys } from '@/utils/camelCase'
import Router from '@/router'
import { useOutsideRouter } from '@/store/hooks/useOutsideRouter'

// redirect error
function errorRedirect (url: string) {
Router.push(`/${url}`)
const { router } = useOutsideRouter()
router.push(url)
}

export interface RespData<T> {
Expand Down

0 comments on commit e1188ab

Please sign in to comment.