-
Notifications
You must be signed in to change notification settings - Fork 43
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
1 parent
6dda967
commit 303195a
Showing
8 changed files
with
86 additions
and
47 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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { PropType, Ref, Transition, TransitionProps, VNode } from 'vue'; | ||
import { MeKeepAliveProps, default as MeKeepAlive } from './meKeepAlive'; | ||
import { useLoadMessages } from '@/locales/i18n'; | ||
import { done } from '@/utils/nProgress'; | ||
import { localeConfig } from '@/config'; | ||
export default defineComponent({ | ||
props: { | ||
is: { | ||
type: [String, Object], | ||
}, | ||
keepAlive: Object as PropType<MeKeepAliveProps>, | ||
componentKey: [Number, String, Symbol], | ||
doneProgress: Boolean, | ||
transition: Object as PropType<TransitionProps>, | ||
}, | ||
setup(props, { attrs }) { | ||
const loadMessages = useLoadMessages(); | ||
const componentIs: Ref<any> = ref(undefined); | ||
const key = ref(props.componentKey); | ||
const _attrs = ref(attrs); | ||
watch( | ||
() => props.is, | ||
async (is) => { | ||
if (is) { | ||
localeConfig.loadMessageConfig.componentLoad && (await Promise.allSettled(loadMessages(is as any, false))); // 自动加载语言包 | ||
componentIs.value = is; | ||
key.value = props.componentKey; | ||
_attrs.value = attrs; | ||
if (props.doneProgress) { | ||
done(); | ||
} | ||
} | ||
}, | ||
{ immediate: true }, | ||
); | ||
|
||
return () => { | ||
const components = [] as VNode[]; | ||
components.push( | ||
h(componentIs.value || 'div', { | ||
key: key.value, | ||
..._attrs.value, | ||
}), | ||
); | ||
if (props.keepAlive) { | ||
const index = components.length - 1; | ||
components.push(h(MeKeepAlive, props.keepAlive, [components[index]])); | ||
} | ||
if (props.transition) { | ||
const index = components.length - 1; | ||
components.push(h(Transition, props.transition, { default: () => components[index] })); | ||
} | ||
return components[components.length - 1]; | ||
}; | ||
}, | ||
}); |
This file was deleted.
Oops, something went wrong.
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