-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
159 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { useChangeNotifyPlacement } from '@/provider/context' | ||
|
||
/** | ||
* 强制刷新 Layout View 路由 | ||
*/ | ||
export type ReloadRouterViewApiInjection = () => void | ||
export const reloadRouterViewInjectionKey: InjectionKey<ReloadRouterViewApiInjection> = Symbol() | ||
|
||
export const useRegisterForceReload = () => { | ||
const isRouterAlive = ref(true) | ||
|
||
const { changeNotifyPlacement } = useChangeNotifyPlacement() | ||
const reloadRouterView = () => { | ||
isRouterAlive.value = false | ||
nextTick(() => { | ||
changeNotifyPlacement('bottom-right') | ||
window.$ModalNotification.destroyAll() | ||
window.$ModalNotification.success({ | ||
title: '页面刷新成功', | ||
duration: 800, | ||
closable: true | ||
}) | ||
isRouterAlive.value = true | ||
}) | ||
} | ||
|
||
provide(reloadRouterViewInjectionKey, reloadRouterView) | ||
|
||
return { | ||
isRouterAlive, | ||
reloadRouterView | ||
} | ||
} | ||
|
||
export const useApplyForceReload = () => { | ||
const reloadRouterView = inject(reloadRouterViewInjectionKey)! | ||
|
||
return { | ||
reloadRouterView | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type { InjectionKey } from 'vue' | ||
|
||
type NotifyPlacementInjection = (placement: NotificationPlacement) => void | ||
|
||
export const notifyPlacementInjectionKey: InjectionKey<NotifyPlacementInjection> = Symbol() | ||
|
||
export const useNotifyPlacement = () => { | ||
const placement = ref<NotificationPlacement>('top-right') | ||
|
||
const emitChangeNotifyPlacement = (pt: NotificationPlacement) => { | ||
placement.value = pt | ||
} | ||
provide(notifyPlacementInjectionKey, emitChangeNotifyPlacement) | ||
|
||
return { | ||
notifyPlacement: placement | ||
} | ||
} | ||
|
||
export const useChangeNotifyPlacement = () => { | ||
const changeNotifyPlacement = inject(notifyPlacementInjectionKey)! | ||
return { | ||
changeNotifyPlacement | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.