-
Notifications
You must be signed in to change notification settings - Fork 159
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
7 changed files
with
143 additions
and
115 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export { default as Page } from './views/page.vue'; | ||
export { useTabTitle } from './useTitle'; | ||
export * from './useLayout'; |
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 |
---|---|---|
@@ -1,12 +1,31 @@ | ||
import { createSharedComposable } from '@vueuse/core'; | ||
import { shallowReactive } from 'vue'; | ||
import { inject, ref } from 'vue'; | ||
|
||
function _useLayout() { | ||
const state = shallowReactive({ | ||
closeTab: () => {}, | ||
}); | ||
import { useRoute } from '@@/core/coreExports'; | ||
|
||
return state; | ||
export const PLUGIN_LAYOUT_TITLE_KEY = Symbol('PLUGIN_LAYOUT_TITLE_KEY'); | ||
|
||
export const PLUGIN_LAYOUT_KEY = Symbol('PLUGIN_LAYOUT_KEY'); | ||
|
||
export function useTabTitle(title) { | ||
const titleMap = inject(PLUGIN_LAYOUT_TITLE_KEY); | ||
if (!titleMap) { | ||
console.warn('[plugin-layout]: 未正确获取到titleMap'); | ||
return; | ||
} | ||
const route = useRoute(); | ||
const titleRef = ref(title); | ||
const path = route.path; | ||
|
||
titleMap.set(path, titleRef); | ||
|
||
return titleRef; | ||
} | ||
|
||
export const useLayout = createSharedComposable(_useLayout); | ||
export function useLayout(options) { | ||
const parent = inject(PLUGIN_LAYOUT_KEY, { reloadTab: () => void 0, closeTab: () => void 0 }); | ||
const titleRef = useTabTitle(options?.title); | ||
return { | ||
...parent, | ||
title: titleRef, | ||
}; | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.